nano

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

commit d96f296b8ed6f6297869b8c8dc9bb53ccbd38b95
parent 048ab0ee0be80bd5c0f3af21f9529d11cc6e6914
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri,  4 Dec 2020 16:35:28 +0100

input: interpret a keystroke as Meta only when an earlier escape was solo

This allows using <Esc> <Esc> <letter> in a macro as an alternative
for <Ctrl+letter>, but it does require that one does not type <Esc>
by accident when recording a macro as it might modify the subsequent
keystroke when the macro is replayed.

This fixes https://savannah.gnu.org/bugs/?58904.

Bug existed since version 3.0, commit ecc9211a.

Diffstat:
Msrc/winio.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/winio.c b/src/winio.c @@ -889,6 +889,7 @@ int convert_to_control(int kbinput) * the function keys (F1-F12), and the numeric keypad with NumLock off. */ int parse_kbinput(WINDOW *win) { + static bool first_escape_was_alone = FALSE; static bool solitary = FALSE; static int escapes = 0; int keycode; @@ -905,6 +906,7 @@ int parse_kbinput(WINDOW *win) /* Remember whether an Esc arrived by itself, and increment * its counter, rolling around on three escapes. */ if (keycode == ESC_CODE) { + first_escape_was_alone = solitary; solitary = (key_buffer_len == 0); if (digit_count > 0) { digit_count = 0; @@ -998,7 +1000,7 @@ int parse_kbinput(WINDOW *win) } else if (digit_count == 0) { /* If the second escape did not arrive alone, it is a Meta * keystroke; otherwise, it is an "Esc Esc control". */ - if (!solitary) { + if (first_escape_was_alone && !solitary) { if (!shifted_metas) keycode = tolower(keycode); meta_key = TRUE;