commit 34b8d58871e3af5ef24d49c97e2d8d1c0e3b4599
parent fb4ce71cfc77d50709653a92bc225f0e2b5ab80b
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 30 Dec 2018 19:28:17 +0100
rcfile: reject an attempt to bind ^[
Also, for <Esc> <Esc> [, report that it is unbindable.
This fixes https://savannah.gnu.org/bugs/?55336.
Diffstat:
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -1568,7 +1568,9 @@ void unbound_key(int code)
statusline(ALERT, _("Unbindable key: M-["));
else
statusline(ALERT, _("Unbound key: M-%c"), toupper(code));
- } else if (code < 0x20)
+ } else if (code == ESC_CODE)
+ statusline(ALERT, _("Unbindable key: ^["));
+ else if (code < 0x20)
statusline(ALERT, _("Unbound key: ^%c"), code + 0x40);
else
statusline(ALERT, _("Unbound key: %c"), code);
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -464,9 +464,10 @@ void parse_binding(char *ptr, bool dobind)
newsc->menus = menu;
assign_keyinfo(newsc, keycopy, 0);
- /* Do not allow rebinding a frequent escape-sequence starter: Esc [. */
- if (newsc->meta && newsc->keycode == 91) {
- rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
+ /* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */
+ if ((!newsc->meta && newsc->keycode == ESC_CODE) ||
+ (newsc->meta && newsc->keycode == '[')) {
+ rcfile_error(N_("Keystroke %s may not be rebound"), keycopy);
free_things:
free(keycopy);
free(newsc);