diff options
Diffstat (limited to 'usr.bin/tmux/cmd-list-keys.c')
-rw-r--r-- | usr.bin/tmux/cmd-list-keys.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/usr.bin/tmux/cmd-list-keys.c b/usr.bin/tmux/cmd-list-keys.c index d0bd88be433..bdfcbacb61c 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.64 2021/08/20 17:50:42 nicm Exp $ */ +/* $OpenBSD: cmd-list-keys.c,v 1.65 2021/08/20 19:50:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -150,7 +150,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) struct args *args = cmd_get_args(self); struct key_table *table; struct key_binding *bd; - const char *tablename, *r; + const char *tablename, *r, *keystr; char *key, *cp, *tmp, *start, *empty; key_code prefix, only = KEYC_UNKNOWN; int repeat, width, tablewidth, keywidth, found = 0; @@ -159,10 +159,10 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) if (cmd_get_entry(self) == &cmd_list_commands_entry) return (cmd_list_keys_commands(self, item)); - if (args->argc != 0) { - only = key_string_lookup_string(args->argv[0]); + if ((keystr = args_string(args, 0)) != NULL) { + only = key_string_lookup_string(keystr); if (only == KEYC_UNKNOWN) { - cmdq_error(item, "invalid key: %s", args->argv[0]); + cmdq_error(item, "invalid key: %s", keystr); return (CMD_RETURN_ERROR); } only &= (KEYC_MASK_KEY|KEYC_MASK_MODIFIERS); @@ -243,6 +243,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) tmpsize = 256; tmp = xmalloc(tmpsize); + table = key_bindings_first_table(); while (table != NULL) { if (tablename != NULL && strcmp(table->name, tablename) != 0) { @@ -307,7 +308,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) out: if (only != KEYC_UNKNOWN && !found) { - cmdq_error(item, "unknown key: %s", args->argv[0]); + cmdq_error(item, "unknown key: %s", args_string(args, 0)); return (CMD_RETURN_ERROR); } return (CMD_RETURN_NORMAL); @@ -320,12 +321,9 @@ cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item) const struct cmd_entry **entryp; const struct cmd_entry *entry; struct format_tree *ft; - const char *template, *s, *command = NULL; + const char *template, *s, *command; char *line; - if (args->argc != 0) - command = args->argv[0]; - if ((template = args_get(args, 'F')) == NULL) { template = "#{command_list_name}" "#{?command_list_alias, (#{command_list_alias}),} " @@ -335,6 +333,7 @@ cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item) ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0); format_defaults(ft, NULL, NULL, NULL, NULL); + command = args_string(args, 0); for (entryp = cmd_table; *entryp != NULL; entryp++) { entry = *entryp; if (command != NULL && |