summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-list-keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/cmd-list-keys.c')
-rw-r--r--usr.bin/tmux/cmd-list-keys.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-list-keys.c b/usr.bin/tmux/cmd-list-keys.c
index dc4bc5d9d0b..5cfa7ae6818 100644
--- a/usr.bin/tmux/cmd-list-keys.c
+++ b/usr.bin/tmux/cmd-list-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-keys.c,v 1.3 2009/07/21 22:41:00 nicm Exp $ */
+/* $OpenBSD: cmd-list-keys.c,v 1.4 2009/07/24 14:52:47 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
}