summaryrefslogtreecommitdiffstats
path: root/cmd-list-keys.c
diff options
context:
space:
mode:
authornicm <nicm>2019-05-23 14:03:44 +0000
committernicm <nicm>2019-05-23 14:03:44 +0000
commit27bfb56ad5e19afa686ed6a99bf8b205fac98aef (patch)
tree9d7eafe33dfe96c3194bbce93d43013e3565af39 /cmd-list-keys.c
parent3e3eb1dd0faa707fa6bdfd12d455ad711d775241 (diff)
Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.
Diffstat (limited to 'cmd-list-keys.c')
-rw-r--r--cmd-list-keys.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index 5efb0cd2..57f65c8e 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -60,8 +60,8 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = self->args;
struct key_table *table;
struct key_binding *bd;
- const char *key, *tablename, *r;
- char *cp, tmp[BUFSIZ];
+ const char *tablename, *r;
+ char *key, *cp, tmp[BUFSIZ];
int repeat, width, tablewidth, keywidth;
if (self->entry == &cmd_list_commands_entry)
@@ -83,7 +83,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
}
bd = key_bindings_first(table);
while (bd != NULL) {
- key = key_string_lookup_key(bd->key);
+ key = args_escape(key_string_lookup_key(bd->key));
if (bd->flags & KEY_BINDING_REPEAT)
repeat = 1;
@@ -95,6 +95,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
if (width > keywidth)
keywidth = width;
+ free(key);
bd = key_bindings_next(table, bd);
}
table = key_bindings_next_table(table);
@@ -108,7 +109,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
}
bd = key_bindings_first(table);
while (bd != NULL) {
- key = key_string_lookup_key(bd->key);
+ key = args_escape(key_string_lookup_key(bd->key));
if (!repeat)
r = "";
@@ -128,11 +129,13 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
strlcat(tmp, " ", sizeof tmp);
free(cp);
- cp = cmd_list_print(bd->cmdlist);
+ cp = cmd_list_print(bd->cmdlist, 1);
strlcat(tmp, cp, sizeof tmp);
free(cp);
cmdq_print(item, "bind-key %s", tmp);
+
+ free(key);
bd = key_bindings_next(table, bd);
}
table = key_bindings_next_table(table);