mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
Handle unknown keys more gracefully, return a string instead of NULL.
This commit is contained in:
parent
a22fe33aa0
commit
b85be36d1c
@ -77,8 +77,6 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
continue;
|
continue;
|
||||||
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
||||||
key = key_string_lookup_key(bd->key);
|
key = key_string_lookup_key(bd->key);
|
||||||
if (key == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (bd->can_repeat)
|
if (bd->can_repeat)
|
||||||
repeat = 1;
|
repeat = 1;
|
||||||
@ -97,8 +95,6 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
continue;
|
continue;
|
||||||
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
|
||||||
key = key_string_lookup_key(bd->key);
|
key = key_string_lookup_key(bd->key);
|
||||||
if (key == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!repeat)
|
if (!repeat)
|
||||||
r = "";
|
r = "";
|
||||||
@ -140,8 +136,6 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
any_mode = 0;
|
any_mode = 0;
|
||||||
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||||
key = key_string_lookup_key(mbind->key);
|
key = key_string_lookup_key(mbind->key);
|
||||||
if (key == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mbind->mode != 0)
|
if (mbind->mode != 0)
|
||||||
any_mode = 1;
|
any_mode = 1;
|
||||||
@ -153,8 +147,6 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
|
|
||||||
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
|
||||||
key = key_string_lookup_key(mbind->key);
|
key = key_string_lookup_key(mbind->key);
|
||||||
if (key == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mode = "";
|
mode = "";
|
||||||
if (mbind->mode != 0)
|
if (mbind->mode != 0)
|
||||||
|
@ -238,8 +238,10 @@ key_string_lookup_key(int key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Invalid keys are errors. */
|
/* Invalid keys are errors. */
|
||||||
if (key == 127 || key > 255)
|
if (key == 127 || key > 255) {
|
||||||
return (NULL);
|
snprintf(out, sizeof out, "<INVALID#%04x>", key);
|
||||||
|
return (out);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for standard or control key. */
|
/* Check for standard or control key. */
|
||||||
if (key >= 0 && key <= 32) {
|
if (key >= 0 && key <= 32) {
|
||||||
|
Loading…
Reference in New Issue
Block a user