diff options
author | nicm <nicm> | 2020-02-15 15:08:08 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-02-15 15:08:08 +0000 |
commit | a1f6bd55b652cd1658a005f96bbb667d637fe347 (patch) | |
tree | 94fb3b6943f1357749b7d1f15af52de2fb92caaf | |
parent | 58b47bf01b4136a7f90cb6852b0ecb1b414e4494 (diff) | |
download | rtmux-a1f6bd55b652cd1658a005f96bbb667d637fe347.tar.gz rtmux-a1f6bd55b652cd1658a005f96bbb667d637fe347.tar.bz2 rtmux-a1f6bd55b652cd1658a005f96bbb667d637fe347.zip |
Add -a to list-keys to also list keys without notes with -N, suggested
by Shehu Dikko.
-rw-r--r-- | cmd-list-keys.c | 17 | ||||
-rw-r--r-- | tmux.1 | 4 |
2 files changed, 14 insertions, 7 deletions
diff --git a/cmd-list-keys.c b/cmd-list-keys.c index e9e75a72..34ed43bf 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -36,8 +36,8 @@ const struct cmd_entry cmd_list_keys_entry = { .name = "list-keys", .alias = "lsk", - .args = { "1NP:T:", 0, 1 }, - .usage = "[-1N] [-P prefix-string] [-T key-table] [key]", + .args = { "1aNP:T:", 0, 1 }, + .usage = "[-1aN] [-P prefix-string] [-T key-table] [key]", .flags = CMD_STARTSERVER|CMD_AFTERHOOK, .exec = cmd_list_keys_exec @@ -89,7 +89,7 @@ cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args, struct key_table *table; struct key_binding *bd; const char *key; - char *tmp; + char *tmp, *note; int found = 0; table = key_bindings_get_table(tablename, 0); @@ -99,19 +99,24 @@ cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args, while (bd != NULL) { if ((only != KEYC_UNKNOWN && bd->key != only) || KEYC_IS_MOUSE(bd->key) || - bd->note == NULL) { + (bd->note == NULL && !args_has(args, 'a'))) { bd = key_bindings_next(table, bd); continue; } found = 1; key = key_string_lookup_key(bd->key); + if (bd->note == NULL) + note = cmd_list_print(bd->cmdlist, 1); + else + note = xstrdup(bd->note); tmp = utf8_padcstr(key, keywidth + 1); if (args_has(args, '1') && c != NULL) - status_message_set(c, "%s%s%s", prefix, tmp, bd->note); + status_message_set(c, "%s%s%s", prefix, tmp, note); else - cmdq_print(item, "%s%s%s", prefix, tmp, bd->note); + cmdq_print(item, "%s%s%s", prefix, tmp, note); free(tmp); + free(note); if (args_has(args, '1')) break; @@ -2686,7 +2686,7 @@ To view the default bindings and possible commands, see the .Ic list-keys command. .It Xo Ic list-keys -.Op Fl 1N +.Op Fl 1aN .Op Fl P Ar prefix-string Fl T Ar key-table .Op key .Xc @@ -2718,6 +2718,8 @@ also lists only keys in specifies a prefix to print before each key and .Fl 1 lists only the first matching key. +.Fl a +lists the command for keys that do have a note rather than skipping them. .It Xo Ic send-keys .Op Fl FHlMRX .Op Fl N Ar repeat-count |