diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-07-25 08:52:04 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-07-25 08:52:04 +0000 |
commit | 28cf7dc39ed54a49567204c951ada1681af44734 (patch) | |
tree | 2c259016303d7dd0b82089ed64de7f89cd78f8f2 /cmd-list-keys.c | |
parent | 744ccb7cc933c6e433a3b4a4c889364540689829 (diff) |
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.
Diffstat (limited to 'cmd-list-keys.c')
-rw-r--r-- | cmd-list-keys.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/cmd-list-keys.c b/cmd-list-keys.c index d72b6b0e..126cf3a5 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-keys.c,v 1.16 2009-07-22 17:53:27 tcunha Exp $ */ +/* $Id: cmd-list-keys.c,v 1.17 2009-07-25 08:52:04 tcunha 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); } |