diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-04-07 15:46:13 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-04-07 15:46:13 +0000 |
commit | 269eaba4adbdde467be15aa2b636c3ebadc62408 (patch) | |
tree | 4e845097730e0b71fcf851016345882cb44271ce | |
parent | b2c1cbced91182493581960cd5440cc10b651c4a (diff) |
Restore previous behaviour so that C-X remains the same as C-x. Instead,
translate incoming extended keys so that they are consistent.
-rw-r--r-- | usr.bin/tmux/key-string.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/tty-keys.c | 36 |
2 files changed, 26 insertions, 17 deletions
diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c index eb72dc04665..6404504b096 100644 --- a/usr.bin/tmux/key-string.c +++ b/usr.bin/tmux/key-string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-string.c,v 1.64 2021/04/07 07:30:02 nicm Exp $ */ +/* $OpenBSD: key-string.c,v 1.65 2021/04/07 15:46:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -239,10 +239,11 @@ key_string_lookup_string(const char *string) /* Convert the standard control keys. */ if (key < KEYC_BASE && (modifiers & KEYC_CTRL) && - strchr(other, key) == NULL && - (key < 64 || key > 95)) { + strchr(other, key) == NULL) { if (key >= 97 && key <= 122) key -= 96; + else if (key >= 64 && key <= 95) + key -= 64; else if (key == 32) key = 0; else if (key == 63) diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index d3db07ecd98..78b8090bdbf 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.143 2021/04/07 07:30:02 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.144 2021/04/07 15:46:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -871,6 +871,7 @@ tty_keys_extended_key(struct tty *tty, const char *buf, size_t len, char tmp[64]; cc_t bspace; key_code nkey; + key_code onlykey; *size = 0; @@ -948,19 +949,26 @@ tty_keys_extended_key(struct tty *tty, const char *buf, size_t len, break; } - /* Don't allow both KEYC_CTRL and implied. */ - if ((nkey & KEYC_CTRL) && (nkey & KEYC_MASK_KEY) < 32) - nkey &= ~KEYC_CTRL; - if ((nkey & KEYC_MASK_MODIFIERS) == KEYC_CTRL) { - nkey &= KEYC_MASK_KEY; - if (nkey >= 97 && nkey <= 122) - nkey -= 96; - else if (nkey == 32) - nkey = 0; - else if (nkey == 63) - nkey = 127; - else - nkey |= KEYC_CTRL; + /* + * Don't allow both KEYC_CTRL and as an implied modifier. Also convert + * C-X into C-x and so on. + */ + if (nkey & KEYC_CTRL){ + onlykey = (nkey & KEYC_MASK_KEY); + if (onlykey < 32) + onlykey = (nkey & ~KEYC_CTRL); + else { + if (onlykey >= 97 && onlykey <= 122) + onlykey -= 96; + else if (onlykey >= 64 && onlykey <= 95) + onlykey -= 64; + else if (onlykey == 32) + onlykey = 0; + else if (onlykey == 63) + onlykey = 127; + onlykey |= ((nkey & KEYC_MASK_MODIFIERS) & ~KEYC_CTRL); + } + nkey = onlykey; } if (log_get_level() != 0) { |