nano

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

commit c5b0e1958ab458e3c297431db8314b154668143c
parent da43cc095940eb4e08452fa7ce29322b2d110e95
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed,  3 Jun 2020 16:45:15 +0200

feedback: beep also at a prompt when receiving an unknown escape sequence

Nano would beep (and report "Unknown sequence") only when in the main
edit window, in the help viewer, or in the file browser.  But the same
keystroke at a prompt would be enigmatically silent.

Also, in the file browser, nano would leave the cursor at the end of
the "Unknown sequence" message when --showcursor was used.

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

Bug existed (in this form) since around version 2.7.4,
and in a worse form since around version 2.3.5.

Diffstat:
Msrc/nano.c | 6+++++-
Msrc/nano.h | 3+++
Msrc/winio.c | 13+------------
3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -1261,7 +1261,11 @@ void confirm_margin(void) /* Say that an unbound key was struck, and if possible which one. */ void unbound_key(int code) { - if (code > 0x7F) + if (code == FOREIGN_SEQUENCE) + /* TRANSLATORS: This refers to a sequence of escape codes + * (from the keyboard) that nano does not recognize. */ + statusline(ALERT, _("Unknown sequence")); + else if (code > 0x7F) statusline(ALERT, _("Unbound key")); else if (meta_key) { if (code == '[') diff --git a/src/nano.h b/src/nano.h @@ -615,6 +615,9 @@ enum /* A special keycode to signal the beginning and end of a bracketed paste. */ #define BRACKETED_PASTE_MARKER 0x4FB +/* A special keycode for when a key produces an unknown escape sequence. */ +#define FOREIGN_SEQUENCE 0x4FC + #ifdef USE_SLANG #ifdef ENABLE_UTF8 #define KEY_BAD 0xFF /* Clipped error code. */ diff --git a/src/winio.c b/src/winio.c @@ -805,7 +805,7 @@ int convert_sequence(const int *seq, size_t length, int *consumed) } } - return ERR; + return FOREIGN_SEQUENCE; } /* Interpret the escape sequence in the keystroke buffer, the first @@ -829,17 +829,6 @@ int parse_escape_sequence(WINDOW *win, int kbinput) free(sequence); - /* If we got an unrecognized escape sequence, notify the user. */ - if (retval == ERR && win == edit) { - /* TRANSLATORS: This refers to a sequence of escape codes - * (from the keyboard) that nano does not recognize. */ - statusline(ALERT, _("Unknown sequence")); - suppress_cursorpos = FALSE; - lastmessage = HUSH; - if (currmenu == MMAIN || currmenu == MHELP) - place_the_cursor(); - } - return retval; }