summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tty-keys.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2022-07-19 06:51:32 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2022-07-19 06:51:32 +0000
commitea0be5ce9a7cd11cf99449d44cc6a9b64ac2fe3a (patch)
treef1e55ad641f003ec9faa487ebb5d1d9bf2781ef8 /usr.bin/tmux/tty-keys.c
parentf63a04d741ebc3932a16a561bc45355f50055f3e (diff)
Process modifiers as bits rather than using a switch, from Koichi Murase.
Diffstat (limited to 'usr.bin/tmux/tty-keys.c')
-rw-r--r--usr.bin/tmux/tty-keys.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c
index d520f61af2c..4d24010bcea 100644
--- a/usr.bin/tmux/tty-keys.c
+++ b/usr.bin/tmux/tty-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-keys.c,v 1.157 2022/06/14 07:29:00 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.158 2022/07/19 06:51:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -934,34 +934,16 @@ tty_keys_extended_key(struct tty *tty, const char *buf, size_t len,
nkey = number;
/* Update the modifiers. */
- switch (modifiers) {
- case 2:
- nkey |= KEYC_SHIFT;
- break;
- case 3:
- nkey |= (KEYC_META|KEYC_IMPLIED_META);
- break;
- case 4:
- nkey |= (KEYC_SHIFT|KEYC_META|KEYC_IMPLIED_META);
- break;
- 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;
+ if (modifiers > 0) {
+ modifiers--;
+ if (modifiers & 1)
+ nkey |= KEYC_SHIFT;
+ if (modifiers & 2)
+ nkey |= (KEYC_META|KEYC_IMPLIED_META); /* Alt */
+ if (modifiers & 4)
+ nkey |= KEYC_CTRL;
+ if (modifiers & 8)
+ nkey |= (KEYC_META|KEYC_IMPLIED_META); /* Meta */
}
/*