nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit f2150d3f98d95f485b01cb69475c98c6f6797467
parent 033376aec086a8931229f1999fdfb0c911be332a
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Mon, 11 Jul 2016 14:21:38 +0200

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.

Diffstat:
Msrc/nano.c | 5+++++
Msrc/winio.c | 6+++++-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/nano.c b/src/nano.c @@ -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 diff --git a/src/winio.c b/src/winio.c @@ -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