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.master
parent
620553b795
commit
196e913681
|
@ -443,10 +443,7 @@ size_t shown_entries_for(int menu)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the shortcut that corresponds to the values of kbinput (the
|
/* Return the first shortcut in the current menu that matches the given input. */
|
||||||
* 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. */
|
|
||||||
const keystruct *get_shortcut(int *kbinput)
|
const keystruct *get_shortcut(int *kbinput)
|
||||||
{
|
{
|
||||||
/* Plain characters and upper control codes cannot be shortcuts. */
|
/* Plain characters and upper control codes cannot be shortcuts. */
|
||||||
|
@ -462,8 +459,7 @@ const keystruct *get_shortcut(int *kbinput)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (keystruct *s = sclist; s != NULL; s = s->next) {
|
for (keystruct *s = sclist; s != NULL; s = s->next) {
|
||||||
if ((s->menus & currmenu) && *kbinput == s->keycode &&
|
if ((s->menus & currmenu) && *kbinput == s->keycode)
|
||||||
meta_key == s->meta)
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -823,8 +823,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||||
assign_keyinfo(newsc, keycopy, keycode);
|
assign_keyinfo(newsc, keycopy, keycode);
|
||||||
|
|
||||||
/* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */
|
/* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */
|
||||||
if ((!newsc->meta && newsc->keycode == ESC_CODE) ||
|
if (newsc->keycode == ESC_CODE || newsc->keycode == '[') {
|
||||||
(newsc->meta && newsc->keycode == '[')) {
|
|
||||||
jot_error(N_("Keystroke %s may not be rebound"), keycopy);
|
jot_error(N_("Keystroke %s may not be rebound"), keycopy);
|
||||||
free_things:
|
free_things:
|
||||||
free(keycopy);
|
free(keycopy);
|
||||||
|
|
Loading…
Reference in New Issue