summaryrefslogtreecommitdiffstats
path: root/input-keys.c
diff options
context:
space:
mode:
authornicm <nicm>2020-01-13 07:51:54 +0000
committernicm <nicm>2020-01-13 07:51:54 +0000
commit04eee2410df4a85005c9562db13a1fec93d7c2e4 (patch)
tree056d63f2e4f7d0b364fd69d3c3e821164dd2c6a8 /input-keys.c
parent381333c4a9fd521bee8a0287e648f0c6aeb96a0b (diff)
Treat plausible but invalid keys (like C-BSpace) as literal like any
other unrecognised string passed to send-keys. Reported by Anthony Sottile in GitHub issue 2049.
Diffstat (limited to 'input-keys.c')
-rw-r--r--input-keys.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/input-keys.c b/input-keys.c
index 01f9ad9d..5c7e8b1f 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -150,7 +150,7 @@ input_split2(u_int c, u_char *dst)
}
/* Translate a key code into an output key sequence. */
-void
+int
input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
{
const struct input_key_ent *ike;
@@ -167,14 +167,14 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
if (KEYC_IS_MOUSE(key)) {
if (m != NULL && m->wp != -1 && (u_int)m->wp == wp->id)
input_key_mouse(wp, m);
- return;
+ return (0);
}
/* Literal keys go as themselves (can't be more than eight bits). */
if (key & KEYC_LITERAL) {
ud.data[0] = (u_char)key;
bufferevent_write(wp->event, &ud.data[0], 1);
- return;
+ return (0);
}
/* Is this backspace? */
@@ -195,15 +195,15 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
bufferevent_write(wp->event, "\033", 1);
ud.data[0] = justkey;
bufferevent_write(wp->event, &ud.data[0], 1);
- return;
+ return (0);
}
if (justkey > 0x7f && justkey < KEYC_BASE) {
if (utf8_split(justkey, &ud) != UTF8_DONE)
- return;
+ return (-1);
if (key & KEYC_ESCAPE)
bufferevent_write(wp->event, "\033", 1);
bufferevent_write(wp->event, ud.data, ud.size);
- return;
+ return (0);
}
/*
@@ -214,7 +214,7 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
if ((out = xterm_keys_lookup(key)) != NULL) {
bufferevent_write(wp->event, out, strlen(out));
free(out);
- return;
+ return (0);
}
}
key &= ~KEYC_XTERM;
@@ -237,7 +237,7 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
}
if (i == nitems(input_keys)) {
log_debug("key 0x%llx missing", key);
- return;
+ return (-1);
}
dlen = strlen(ike->data);
log_debug("found key 0x%llx: \"%s\"", key, ike->data);
@@ -246,6 +246,7 @@ input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
if (key & KEYC_ESCAPE)
bufferevent_write(wp->event, "\033", 1);
bufferevent_write(wp->event, ike->data, dlen);
+ return (0);
}
/* Translate mouse and output. */