summaryrefslogtreecommitdiffstats
path: root/cmd-list-keys.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-07-24 14:52:47 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-07-24 14:52:47 +0000
commit5a1a1066371328f9d53a9bc5e5c4c53acb26c2b2 (patch)
treeb9b54a76352420ff03b31146ad0846e438332949 /cmd-list-keys.c
parentce4eb6559e1aabb67e08a367a7c5e049e800c7ed (diff)
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.
Diffstat (limited to 'cmd-list-keys.c')
-rw-r--r--cmd-list-keys.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index af3a0208..717812d9 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -46,27 +46,33 @@ cmd_list_keys_exec(unused struct cmd *self, struct cmd_ctx *ctx)
{
struct key_binding *bd;
const char *key;
- char tmp[BUFSIZ];
- int width, keywidth;
+ char tmp[BUFSIZ], keytmp[64];
+ int width, keywidth;
width = 0;
SPLAY_FOREACH(bd, key_bindings, &key_bindings) {
- if ((key = key_string_lookup_key(bd->key)) == NULL)
+ key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
+ if (key == NULL)
continue;
keywidth = strlen(key) + 1;
+ if (!(bd->key & KEYC_PREFIX))
+ keywidth += 2;
if (keywidth > width)
width = keywidth;
}
-
SPLAY_FOREACH(bd, key_bindings, &key_bindings) {
- if ((key = key_string_lookup_key(bd->key)) == NULL)
+ key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
+ if (key == NULL)
continue;
*tmp = '\0';
cmd_list_print(bd->cmdlist, tmp, sizeof tmp);
-
+ if (!(bd->key & KEYC_PREFIX)) {
+ xsnprintf(keytmp, sizeof keytmp, "[%s]", key);
+ key = keytmp;
+ }
ctx->print(ctx, "%*s: %s", width, key, tmp);
}