From 900d6da7869c3e91af8dc2dcbc0e686782e1f1ca Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Mon, 22 Oct 2018 14:09:18 -0500 Subject: [PATCH 4/4] input: properly read Alt-Delete when using -K/--rebindkeypad This works on xterm, rxvt, Eterm, Konsole, and xfce4-terminal, which generate "Esc [ 3 ; 3 ~", and urxvt, which generates "Esc Esc [ 3 ~". --- src/winio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/winio.c b/src/winio.c index 707ec1dd..45d55361 100644 --- a/src/winio.c +++ b/src/winio.c @@ -494,6 +494,16 @@ int parse_kbinput(WINDOW *win) ('a' <= *key_buffer && *key_buffer <= 'd'))) { /* An iTerm2/Eterm/rxvt sequence: ^[ ^[ [ X. */ double_esc = TRUE; +#ifndef NANO_TINY + } else if (keycode == '[' && key_buffer_len > 1 && + key_buffer[0] == '3' && key_buffer[1] == '~') { + /* Or a urxvt sequence: ^[ ^[ [ 3 ~ is Alt-Delete. Consume + * the two waiting codes. */ + kbinput = get_input(win, 1); + kbinput = get_input(win, 1); + retval = ALT_DELETE; + escapes = 0; +#endif } else { /* Two escapes followed by a non-escape, and there are more * codes waiting: combined meta and escape sequence mode. */ @@ -1114,6 +1124,10 @@ int convert_sequence(const int *seq, size_t length, int *consumed) #ifndef NANO_TINY if (length > 4 && seq[2] == ';' && seq[4] == '~') { *consumed = 5; + if (seq[3] == '3') + /* Esc [ 3 ; 3 ~ == Alt-Delete on xterm/rxvt/Eterm/ + * Terminal. */ + return ALT_DELETE; if (seq[3] == '5') /* Esc [ 3 ; 5 ~ == Ctrl-Delete on xterm. */ return CONTROL_DELETE; -- 2.19.1