nano

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

commit 196e9136814e71f43d9ae17e4f16058d56dc1a35
parent 620553b79567595628357b4b87d62c78470d8f25
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 22 Jan 2020 13:12:52 +0100

tweaks: elide three checks of a shortcut's meta flag

A control code cannot be a Meta keystroke, and a plain printable
character as key code necessarily means it is a Meta keystroke.
So, comparing just the key code is enough.

Diffstat:
Msrc/global.c | 8++------
Msrc/rcfile.c | 3+--
2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -443,10 +443,7 @@ size_t shown_entries_for(int menu) return count; } -/* Return the shortcut that corresponds to the values of kbinput (the - * key itself) and meta_key (whether the key is a meta sequence). The - * returned shortcut will be the first in the list that corresponds to - * the given sequence. */ +/* Return the first shortcut in the current menu that matches the given input. */ const keystruct *get_shortcut(int *kbinput) { /* Plain characters and upper control codes cannot be shortcuts. */ @@ -462,8 +459,7 @@ const keystruct *get_shortcut(int *kbinput) return NULL; for (keystruct *s = sclist; s != NULL; s = s->next) { - if ((s->menus & currmenu) && *kbinput == s->keycode && - meta_key == s->meta) + if ((s->menus & currmenu) && *kbinput == s->keycode) return s; } diff --git a/src/rcfile.c b/src/rcfile.c @@ -823,8 +823,7 @@ void parse_binding(char *ptr, bool dobind) assign_keyinfo(newsc, keycopy, keycode); /* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */ - if ((!newsc->meta && newsc->keycode == ESC_CODE) || - (newsc->meta && newsc->keycode == '[')) { + if (newsc->keycode == ESC_CODE || newsc->keycode == '[') { jot_error(N_("Keystroke %s may not be rebound"), keycopy); free_things: free(keycopy);