input: ignore any <Escape>s before a valid command keystroke

Just like an <Esc> before a Ctrl+letter keystroke is ignored, an <Esc>
before an Alt+letter keystroke should be ignored too -- it should not
be interpreted as if the user had typed <Esc> <Esc> letter.

This fixes https://savannah.gnu.org/bugs/?54301.
master
Benno Schulenberg 2018-06-28 11:52:17 +02:00
parent ab0897072a
commit ecc9211afc
1 changed files with 12 additions and 9 deletions

View File

@ -385,7 +385,7 @@ int parse_kbinput(WINDOW *win)
if (escapes > 3) if (escapes > 3)
escapes = 1; escapes = 1;
/* Take note when an Esc arrived by itself. */ /* Take note when an Esc arrived by itself. */
solitary = (escapes == 1 && key_buffer_len == 0); solitary = (key_buffer_len == 0);
return ERR; return ERR;
} }
@ -476,11 +476,12 @@ int parse_kbinput(WINDOW *win)
} }
} else { } else {
if (digit_count == 0) if (digit_count == 0)
/* Two escapes followed by a non-decimal /* Two escapes followed by a non-digit: meta key
* digit (or a decimal digit that would * or control character sequence mode. */
* create a byte sequence greater than 2XX) if (!solitary) {
* and there aren't any other codes waiting: meta_key = TRUE;
* control character sequence mode. */ retval = keycode;
} else
retval = get_control_kbinput(keycode); retval = get_control_kbinput(keycode);
else { else {
/* An invalid digit in the middle of a byte /* An invalid digit in the middle of a byte
@ -505,11 +506,13 @@ int parse_kbinput(WINDOW *win)
} }
break; break;
case 3: case 3:
if (key_buffer_len == 0) if (key_buffer_len == 0) {
if (!solitary)
meta_key = TRUE;
/* Three escapes followed by a non-escape, and no /* Three escapes followed by a non-escape, and no
* other codes are waiting: normal input mode. */ * other codes are waiting: normal input mode. */
retval = keycode; retval = keycode;
else } else
/* Three escapes followed by a non-escape, and more /* Three escapes followed by a non-escape, and more
* codes are waiting: combined control character and * codes are waiting: combined control character and
* escape sequence mode. First interpret the escape * escape sequence mode. First interpret the escape