From 476c8387539015904acbdfe864261f14a5a1c2d8 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 9 Jul 2020 20:55:37 +0200 Subject: [PATCH] bindings: allow typing digits on the numeric keypad by holding Shift Until now, on an xterm, Shift plus any keypad key would say "Unknown sequence", which is not useful. On other terminal emulators (urxvt, Pantheon, LXTerminal), Shift plus a keypad key already produces the relevant digit or symbol, so this change harmonizes the behavior of the different emulators. However, on a Linux console, Shift plus a keypad key moves the cursor and selects the text that is passed over. And holding Alt while pressing a keypad key does nothing at all. --- src/winio.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/winio.c b/src/winio.c index 40adc66b..ead5b018 100644 --- a/src/winio.c +++ b/src/winio.c @@ -368,12 +368,19 @@ int convert_sequence(const int *seq, size_t length, int *consumed) /* ->->->->->->-> */ } break; - case '2': - if (length > 2) + case '2': /* Shift */ + case '4': /* Shift+Alt */ + case '6': /* Shift+Ctrl */ + if (length > 2) { *consumed = 3; + /* Allow typing digits on the numeric keypad without + * engaging NumLock. Esc O 2 p == Shift-0, .... */ + return (seq[2] - 0x40); + } break; - case '3': - case '5': + case '3': /* Alt */ + case '5': /* Ctrl */ + case '7': /* Alt+Ctrl */ if (length > 2) { *consumed = 3; switch (seq[2]) {