From 674ec410b7ecf14fa24e9c3987469a4d9da599c1 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 1 Jun 2020 16:09:35 +0000 Subject: [PATCH] Try without cursor/keypad flags if a key doesn't exist, and limit ctrl key translation to ASCII keys. Fixes send-keys, GitHub issue 2247. --- input-keys.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/input-keys.c b/input-keys.c index d1fbbfcf..938c530f 100644 --- a/input-keys.c +++ b/input-keys.c @@ -487,9 +487,13 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key) ike = input_key_get(key); if (ike == NULL && (key & KEYC_META) && (~key & KEYC_IMPLIED_META)) ike = input_key_get(key & ~KEYC_META); + if (ike == NULL && (key & KEYC_CURSOR)) + ike = input_key_get(key & ~KEYC_CURSOR); + if (ike == NULL && (key & KEYC_KEYPAD)) + ike = input_key_get(key & ~KEYC_KEYPAD); if (ike != NULL) { log_debug("found key 0x%llx: \"%s\"", key, ike->data); - if (key & KEYC_META && (~key & KEYC_IMPLIED_META)) + if ((key & KEYC_META) && (~key & KEYC_IMPLIED_META)) bufferevent_write(bev, "\033", 1); bufferevent_write(bev, ike->data, strlen(ike->data)); return (0); @@ -497,13 +501,13 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key) /* No builtin key sequence; construct an extended key sequence. */ if (~s->mode & MODE_KEXTENDED) { - justkey = (key & KEYC_MASK_KEY); if ((key & KEYC_MASK_MODIFIERS) != KEYC_CTRL) goto missing; + justkey = (key & KEYC_MASK_KEY); switch (justkey) { case ' ': case '2': - key = 0||(key & ~KEYC_MASK_KEY); + key = 0|(key & ~KEYC_MASK_KEY); break; case '|': key = 28|(key & ~KEYC_MASK_KEY); @@ -523,6 +527,8 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key) key = (justkey - 'A')|(key & ~KEYC_MASK_KEY); else if (justkey >= 'a' && justkey <= '~') key = (justkey - 96)|(key & ~KEYC_MASK_KEY); + else + return (0); break; } return (input_key(s, bev, key & ~KEYC_CTRL));