aboutsummaryrefslogtreecommitdiff
path: root/cmd-list-keys.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2021-08-20 22:01:46 +0100
committerThomas Adam <thomas@xteddy.org>2021-08-20 22:01:46 +0100
commitb0da0cee4d54aa64db0f49eee509a76fd89d6f68 (patch)
tree1e54ddb0b113708c46e80d342d10be74cdf7b176 /cmd-list-keys.c
parent944fde7c57c4f3caebb04cfc3943a81ee9729de8 (diff)
parentd589be6c65c7295880bb84cd875baab2f77d5067 (diff)
downloadrtmux-b0da0cee4d54aa64db0f49eee509a76fd89d6f68.tar.gz
rtmux-b0da0cee4d54aa64db0f49eee509a76fd89d6f68.tar.bz2
rtmux-b0da0cee4d54aa64db0f49eee509a76fd89d6f68.zip
Merge branch 'obsd-master' into master
Diffstat (limited to 'cmd-list-keys.c')
-rw-r--r--cmd-list-keys.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index dbb510fb..1484af6d 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -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 &&