Commit f2150d3f authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

input: treat Ctrl+Alt+key different from Esc followed by Ctrl+key

When the user changes her mind after having pressed Esc, she cannot
unpress Esc, so do that for her by ignoring the escape code when
the subsequent keycode is outside of the normal printable range.

This restores the behavior from before nano-2.3.5 -- except that
Ctrl+Alt+key continues to report an unbound key.

This fixes https://savannah.gnu.org/bugs/?48459.
No related merge requests found
Showing with 10 additions and 1 deletion
+10 -1
......@@ -2523,6 +2523,11 @@ int main(int argc, char **argv)
controlright = key_defined(keyvalue);
#endif
#ifndef USE_SLANG
/* Tell ncurses to pass the Esc key quickly. */
set_escdelay(50);
#endif
#ifdef DEBUG
fprintf(stderr, "Main: open file\n");
#endif
......
......@@ -40,6 +40,8 @@ static int *key_buffer = NULL;
* haven't handled yet at a given point. */
static size_t key_buffer_len = 0;
/* The length of the keystroke buffer. */
static bool solitary = FALSE;
/* Whether an Esc arrived by itself -- not as leader of a sequence. */
static int statusblank = 0;
/* The number of keystrokes left before we blank the statusbar. */
static bool suppress_cursorpos = FALSE;
......@@ -362,6 +364,7 @@ int parse_kbinput(WINDOW *win)
/* If there are four consecutive escapes, discard three of them. */
if (escapes > 3)
escapes = 1;
solitary = (escapes == 1 && get_key_buffer_len() == 0);
/* Wait for more input. */
break;
default:
......@@ -377,7 +380,8 @@ int parse_kbinput(WINDOW *win)
get_key_buffer_len() == 0 || *key_buffer == 0x1B) {
/* One escape followed by a single non-escape:
* meta key sequence mode. */
meta_key = TRUE;
if (!solitary || (*kbinput >= 0x20 && *kbinput < 0x7F))
meta_key = TRUE;
retval = tolower(*kbinput);
} else
/* One escape followed by a non-escape, and there
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment