Process modifiers as bits rather than using a switch, from Koichi Murase.

This commit is contained in:
nicm 2022-07-19 06:51:31 +00:00
parent 3c65475561
commit 86dfbda0e4

View File

@ -934,34 +934,16 @@ tty_keys_extended_key(struct tty *tty, const char *buf, size_t len,
nkey = number; nkey = number;
/* Update the modifiers. */ /* Update the modifiers. */
switch (modifiers) { if (modifiers > 0) {
case 2: modifiers--;
nkey |= KEYC_SHIFT; if (modifiers & 1)
break; nkey |= KEYC_SHIFT;
case 3: if (modifiers & 2)
nkey |= (KEYC_META|KEYC_IMPLIED_META); nkey |= (KEYC_META|KEYC_IMPLIED_META); /* Alt */
break; if (modifiers & 4)
case 4: nkey |= KEYC_CTRL;
nkey |= (KEYC_SHIFT|KEYC_META|KEYC_IMPLIED_META); if (modifiers & 8)
break; nkey |= (KEYC_META|KEYC_IMPLIED_META); /* Meta */
case 5:
nkey |= KEYC_CTRL;
break;
case 6:
nkey |= (KEYC_SHIFT|KEYC_CTRL);
break;
case 7:
nkey |= (KEYC_META|KEYC_CTRL);
break;
case 8:
nkey |= (KEYC_SHIFT|KEYC_META|KEYC_IMPLIED_META|KEYC_CTRL);
break;
case 9:
nkey |= (KEYC_META|KEYC_IMPLIED_META);
break;
default:
*key = KEYC_NONE;
break;
} }
/* /*