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.
This commit is contained in:
Benno Schulenberg 2020-01-22 13:12:52 +01:00
parent 620553b795
commit 196e913681
2 changed files with 3 additions and 8 deletions

View File

@ -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;
}

View File

@ -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);