Sync OpenBSD patchset 175:

Permit commands to be bound to key presses without the prefix key first. The
new -n flag to bind-key and unbind-key sets or removes these bindings, and
list-key shows them in []s.
This commit is contained in:
Tiago Cunha
2009-07-25 08:52:04 +00:00
parent 744ccb7cc9
commit 28cf7dc39e
7 changed files with 83 additions and 31 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-unbind-key.c,v 1.17 2009-07-14 06:43:33 nicm Exp $ */
/* $Id: cmd-unbind-key.c,v 1.18 2009-07-25 08:52:04 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -36,7 +36,7 @@ struct cmd_unbind_key_data {
const struct cmd_entry cmd_unbind_key_entry = {
"unbind-key", "unbind",
"key",
"[-n] key",
0, 0,
NULL,
cmd_unbind_key_parse,
@ -51,12 +51,15 @@ int
cmd_unbind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
{
struct cmd_unbind_key_data *data;
int opt;
int opt, no_prefix = 0;
self->data = data = xmalloc(sizeof *data);
while ((opt = getopt(argc, argv, "")) != -1) {
while ((opt = getopt(argc, argv, "n")) != -1) {
switch (opt) {
case 'n':
no_prefix = 1;
break;
default:
goto usage;
}
@ -70,6 +73,8 @@ cmd_unbind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
xasprintf(cause, "unknown key: %s", argv[0]);
goto error;
}
if (!no_prefix)
data->key |= KEYC_PREFIX;
return (0);