From 031d4864a94cd7c042fe96a2d236bccde83655e7 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 15 May 2020 11:24:30 +0100 Subject: [PATCH] Rename KEYC_ESCAPE to KEYC_META. --- input-keys.c | 16 +++---- key-string.c | 4 +- mode-tree.c | 6 +-- server-client.c | 2 +- status.c | 8 ++-- tmux.h | 2 +- tty-keys.c | 110 ++++++++++++++++++++++++------------------------ 7 files changed, 74 insertions(+), 74 deletions(-) diff --git a/input-keys.c b/input-keys.c index 30141243..7f2bc7d8 100644 --- a/input-keys.c +++ b/input-keys.c @@ -335,12 +335,12 @@ static const key_code input_key_modifiers[] = { 0, 0, KEYC_SHIFT|KEYC_XTERM, - KEYC_ESCAPE|KEYC_XTERM, - KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM, + KEYC_META|KEYC_XTERM, + KEYC_SHIFT|KEYC_META|KEYC_XTERM, KEYC_CTRL|KEYC_XTERM, KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM, - KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM, - KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM + KEYC_META|KEYC_CTRL|KEYC_XTERM, + KEYC_SHIFT|KEYC_META|KEYC_CTRL|KEYC_XTERM }; /* Input key comparison function. */ @@ -448,9 +448,9 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key) * If this is a normal 7-bit key, just send it, with a leading escape * if necessary. If it is a UTF-8 key, split it and send it. */ - justkey = (key & ~(KEYC_XTERM|KEYC_ESCAPE)); + justkey = (key & ~(KEYC_XTERM|KEYC_META)); if (justkey <= 0x7f) { - if (key & KEYC_ESCAPE) + if (key & KEYC_META) bufferevent_write(bev, "\033", 1); ud.data[0] = justkey; bufferevent_write(bev, &ud.data[0], 1); @@ -459,7 +459,7 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key) if (justkey > 0x7f && justkey < KEYC_BASE) { if (utf8_split(justkey, &ud) != UTF8_DONE) return (-1); - if (key & KEYC_ESCAPE) + if (key & KEYC_META) bufferevent_write(bev, "\033", 1); bufferevent_write(bev, ud.data, ud.size); return (0); @@ -482,7 +482,7 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key) log_debug("found key 0x%llx: \"%s\"", key, ike->data); /* Prefix a \033 for escape. */ - if (key & KEYC_ESCAPE) + if (key & KEYC_META) bufferevent_write(bev, "\033", 1); bufferevent_write(bev, ike->data, datalen); return (0); diff --git a/key-string.c b/key-string.c index 2a0602b2..bd98ca69 100644 --- a/key-string.c +++ b/key-string.c @@ -143,7 +143,7 @@ key_string_get_modifiers(const char **string) break; case 'M': case 'm': - modifiers |= KEYC_ESCAPE; + modifiers |= KEYC_META; break; case 'S': case 's': @@ -265,7 +265,7 @@ key_string_lookup_key(key_code key) /* Fill in the modifiers. */ if (key & KEYC_CTRL) strlcat(out, "C-", sizeof out); - if (key & KEYC_ESCAPE) + if (key & KEYC_META) strlcat(out, "M-", sizeof out); if (key & KEYC_SHIFT) strlcat(out, "S-", sizeof out); diff --git a/mode-tree.c b/mode-tree.c index a523478e..03738d56 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -987,7 +987,7 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key, choice = -1; if (*key >= '0' && *key <= '9') choice = (*key) - '0'; - else if (((*key) & KEYC_MASK_MOD) == KEYC_ESCAPE) { + else if (((*key) & KEYC_MASK_MOD) == KEYC_META) { tmp = (*key) & KEYC_MASK_KEY; if (tmp >= 'a' && tmp <= 'z') choice = 10 + (tmp - 'a'); @@ -1111,12 +1111,12 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key, mode_tree_build(mtd); } break; - case '-'|KEYC_ESCAPE: + case '-'|KEYC_META: TAILQ_FOREACH(mti, &mtd->children, entry) mti->expanded = 0; mode_tree_build(mtd); break; - case '+'|KEYC_ESCAPE: + case '+'|KEYC_META: TAILQ_FOREACH(mti, &mtd->children, entry) mti->expanded = 1; mode_tree_build(mtd); diff --git a/server-client.c b/server-client.c index c7bec010..9631a7de 100644 --- a/server-client.c +++ b/server-client.c @@ -1033,7 +1033,7 @@ have_event: out: /* Apply modifiers if any. */ if (b & MOUSE_MASK_META) - key |= KEYC_ESCAPE; + key |= KEYC_META; if (b & MOUSE_MASK_CTRL) key |= KEYC_CTRL; if (b & MOUSE_MASK_SHIFT) diff --git a/status.c b/status.c index 56af02f5..9bee2e7b 100644 --- a/status.c +++ b/status.c @@ -827,7 +827,7 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key) return (1); case 'b': case 'B': - *new_key = 'b'|KEYC_ESCAPE; + *new_key = 'b'|KEYC_META; return (1); case 'd': *new_key = '\025'; @@ -836,7 +836,7 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key) case 'E': case 'w': case 'W': - *new_key = 'f'|KEYC_ESCAPE; + *new_key = 'f'|KEYC_META; return (1); case 'p': *new_key = '\031'; /* C-y */ @@ -1158,7 +1158,7 @@ process_key: c->prompt_index = idx; goto changed; - case 'f'|KEYC_ESCAPE: + case 'f'|KEYC_META: case KEYC_RIGHT|KEYC_CTRL: ws = options_get_string(oo, "word-separators"); @@ -1182,7 +1182,7 @@ process_key: c->prompt_index--; goto changed; - case 'b'|KEYC_ESCAPE: + case 'b'|KEYC_META: case KEYC_LEFT|KEYC_CTRL: ws = options_get_string(oo, "word-separators"); diff --git a/tmux.h b/tmux.h index 22baa560..9c27944b 100644 --- a/tmux.h +++ b/tmux.h @@ -120,7 +120,7 @@ struct winlink; #define KEYC_USER 0x0002000000000ULL /* Key modifier bits. */ -#define KEYC_ESCAPE 0x0100000000000ULL +#define KEYC_META 0x0100000000000ULL #define KEYC_CTRL 0x0200000000000ULL #define KEYC_SHIFT 0x0400000000000ULL #define KEYC_XTERM 0x0800000000000ULL diff --git a/tty-keys.c b/tty-keys.c index 19ac71ed..1c424c5d 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -226,12 +226,12 @@ static const key_code tty_default_xterm_modifiers[] = { 0, 0, KEYC_SHIFT|KEYC_XTERM, - KEYC_ESCAPE|KEYC_XTERM, - KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM, + KEYC_META|KEYC_XTERM, + KEYC_SHIFT|KEYC_META|KEYC_XTERM, KEYC_CTRL|KEYC_XTERM, KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM, - KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM, - KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM + KEYC_META|KEYC_CTRL|KEYC_XTERM, + KEYC_SHIFT|KEYC_META|KEYC_CTRL|KEYC_XTERM }; /* @@ -297,22 +297,22 @@ static const struct tty_default_key_code tty_default_code_keys[] = { { TTYC_KF47, KEYC_F11|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, { TTYC_KF48, KEYC_F12|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KF49, KEYC_F1|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF50, KEYC_F2|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF51, KEYC_F3|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF52, KEYC_F4|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF53, KEYC_F5|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF54, KEYC_F6|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF55, KEYC_F7|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF56, KEYC_F8|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF57, KEYC_F9|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF58, KEYC_F10|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF59, KEYC_F11|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KF60, KEYC_F12|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KF49, KEYC_F1|KEYC_META|KEYC_XTERM }, + { TTYC_KF50, KEYC_F2|KEYC_META|KEYC_XTERM }, + { TTYC_KF51, KEYC_F3|KEYC_META|KEYC_XTERM }, + { TTYC_KF52, KEYC_F4|KEYC_META|KEYC_XTERM }, + { TTYC_KF53, KEYC_F5|KEYC_META|KEYC_XTERM }, + { TTYC_KF54, KEYC_F6|KEYC_META|KEYC_XTERM }, + { TTYC_KF55, KEYC_F7|KEYC_META|KEYC_XTERM }, + { TTYC_KF56, KEYC_F8|KEYC_META|KEYC_XTERM }, + { TTYC_KF57, KEYC_F9|KEYC_META|KEYC_XTERM }, + { TTYC_KF58, KEYC_F10|KEYC_META|KEYC_XTERM }, + { TTYC_KF59, KEYC_F11|KEYC_META|KEYC_XTERM }, + { TTYC_KF60, KEYC_F12|KEYC_META|KEYC_XTERM }, - { TTYC_KF61, KEYC_F1|KEYC_ESCAPE|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KF62, KEYC_F2|KEYC_ESCAPE|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KF63, KEYC_F3|KEYC_ESCAPE|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF61, KEYC_F1|KEYC_META|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF62, KEYC_F2|KEYC_META|KEYC_SHIFT|KEYC_XTERM }, + { TTYC_KF63, KEYC_F3|KEYC_META|KEYC_SHIFT|KEYC_XTERM }, { TTYC_KICH1, KEYC_IC }, { TTYC_KDCH1, KEYC_DC }, @@ -330,67 +330,67 @@ static const struct tty_default_key_code tty_default_code_keys[] = { /* Key and modifier capabilities. */ { TTYC_KDC2, KEYC_DC|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KDC3, KEYC_DC|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KDC4, KEYC_DC|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KDC3, KEYC_DC|KEYC_META|KEYC_XTERM }, + { TTYC_KDC4, KEYC_DC|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KDC5, KEYC_DC|KEYC_CTRL|KEYC_XTERM }, { TTYC_KDC6, KEYC_DC|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KDC7, KEYC_DC|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KDC7, KEYC_DC|KEYC_META|KEYC_CTRL|KEYC_XTERM }, { TTYC_KIND, KEYC_DOWN|KEYC_SHIFT|KEYC_XTERM }, { TTYC_KDN2, KEYC_DOWN|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KDN3, KEYC_DOWN|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KDN4, KEYC_DOWN|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KDN3, KEYC_DOWN|KEYC_META|KEYC_XTERM }, + { TTYC_KDN4, KEYC_DOWN|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KDN5, KEYC_DOWN|KEYC_CTRL|KEYC_XTERM }, { TTYC_KDN6, KEYC_DOWN|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KDN7, KEYC_DOWN|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KDN7, KEYC_DOWN|KEYC_META|KEYC_CTRL|KEYC_XTERM }, { TTYC_KEND2, KEYC_END|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KEND3, KEYC_END|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KEND4, KEYC_END|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KEND3, KEYC_END|KEYC_META|KEYC_XTERM }, + { TTYC_KEND4, KEYC_END|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KEND5, KEYC_END|KEYC_CTRL|KEYC_XTERM }, { TTYC_KEND6, KEYC_END|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KEND7, KEYC_END|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KEND7, KEYC_END|KEYC_META|KEYC_CTRL|KEYC_XTERM }, { TTYC_KHOM2, KEYC_HOME|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KHOM3, KEYC_HOME|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KHOM4, KEYC_HOME|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KHOM3, KEYC_HOME|KEYC_META|KEYC_XTERM }, + { TTYC_KHOM4, KEYC_HOME|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KHOM5, KEYC_HOME|KEYC_CTRL|KEYC_XTERM }, { TTYC_KHOM6, KEYC_HOME|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KHOM7, KEYC_HOME|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KHOM7, KEYC_HOME|KEYC_META|KEYC_CTRL|KEYC_XTERM }, { TTYC_KIC2, KEYC_IC|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KIC3, KEYC_IC|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KIC4, KEYC_IC|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KIC3, KEYC_IC|KEYC_META|KEYC_XTERM }, + { TTYC_KIC4, KEYC_IC|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KIC5, KEYC_IC|KEYC_CTRL|KEYC_XTERM }, { TTYC_KIC6, KEYC_IC|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KIC7, KEYC_IC|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KIC7, KEYC_IC|KEYC_META|KEYC_CTRL|KEYC_XTERM }, { TTYC_KLFT2, KEYC_LEFT|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KLFT3, KEYC_LEFT|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KLFT4, KEYC_LEFT|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KLFT3, KEYC_LEFT|KEYC_META|KEYC_XTERM }, + { TTYC_KLFT4, KEYC_LEFT|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KLFT5, KEYC_LEFT|KEYC_CTRL|KEYC_XTERM }, { TTYC_KLFT6, KEYC_LEFT|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KLFT7, KEYC_LEFT|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KLFT7, KEYC_LEFT|KEYC_META|KEYC_CTRL|KEYC_XTERM }, { TTYC_KNXT2, KEYC_NPAGE|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KNXT3, KEYC_NPAGE|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KNXT4, KEYC_NPAGE|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KNXT3, KEYC_NPAGE|KEYC_META|KEYC_XTERM }, + { TTYC_KNXT4, KEYC_NPAGE|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KNXT5, KEYC_NPAGE|KEYC_CTRL|KEYC_XTERM }, { TTYC_KNXT6, KEYC_NPAGE|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KNXT7, KEYC_NPAGE|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KNXT7, KEYC_NPAGE|KEYC_META|KEYC_CTRL|KEYC_XTERM }, { TTYC_KPRV2, KEYC_PPAGE|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KPRV3, KEYC_PPAGE|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KPRV4, KEYC_PPAGE|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KPRV3, KEYC_PPAGE|KEYC_META|KEYC_XTERM }, + { TTYC_KPRV4, KEYC_PPAGE|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KPRV5, KEYC_PPAGE|KEYC_CTRL|KEYC_XTERM }, { TTYC_KPRV6, KEYC_PPAGE|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KPRV7, KEYC_PPAGE|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KPRV7, KEYC_PPAGE|KEYC_META|KEYC_CTRL|KEYC_XTERM }, { TTYC_KRIT2, KEYC_RIGHT|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KRIT3, KEYC_RIGHT|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KRIT4, KEYC_RIGHT|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KRIT3, KEYC_RIGHT|KEYC_META|KEYC_XTERM }, + { TTYC_KRIT4, KEYC_RIGHT|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KRIT5, KEYC_RIGHT|KEYC_CTRL|KEYC_XTERM }, { TTYC_KRIT6, KEYC_RIGHT|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KRIT7, KEYC_RIGHT|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KRIT7, KEYC_RIGHT|KEYC_META|KEYC_CTRL|KEYC_XTERM }, { TTYC_KRI, KEYC_UP|KEYC_SHIFT|KEYC_XTERM }, { TTYC_KUP2, KEYC_UP|KEYC_SHIFT|KEYC_XTERM }, - { TTYC_KUP3, KEYC_UP|KEYC_ESCAPE|KEYC_XTERM }, - { TTYC_KUP4, KEYC_UP|KEYC_SHIFT|KEYC_ESCAPE|KEYC_XTERM }, + { TTYC_KUP3, KEYC_UP|KEYC_META|KEYC_XTERM }, + { TTYC_KUP4, KEYC_UP|KEYC_SHIFT|KEYC_META|KEYC_XTERM }, { TTYC_KUP5, KEYC_UP|KEYC_CTRL|KEYC_XTERM }, { TTYC_KUP6, KEYC_UP|KEYC_SHIFT|KEYC_CTRL|KEYC_XTERM }, - { TTYC_KUP7, KEYC_UP|KEYC_ESCAPE|KEYC_CTRL|KEYC_XTERM }, + { TTYC_KUP7, KEYC_UP|KEYC_META|KEYC_CTRL|KEYC_XTERM }, }; /* Add key to tree. */ @@ -731,7 +731,7 @@ first_key: size = 1; goto complete_key; } - key |= KEYC_ESCAPE; + key |= KEYC_META; size++; goto complete_key; } @@ -744,7 +744,7 @@ first_key: * escape). So pass it through even if the timer has not expired. */ if (*buf == '\033' && len >= 2) { - key = (u_char)buf[1] | KEYC_ESCAPE; + key = (u_char)buf[1] | KEYC_META; size = 2; } else { key = (u_char)buf[0]; @@ -902,10 +902,10 @@ tty_keys_extended_key(struct tty *tty, const char *buf, size_t len, (*key) |= KEYC_SHIFT; break; case 3: - (*key) |= KEYC_ESCAPE; + (*key) |= KEYC_META; break; case 4: - (*key) |= (KEYC_SHIFT|KEYC_ESCAPE); + (*key) |= (KEYC_SHIFT|KEYC_META); break; case 5: (*key) |= KEYC_CTRL; @@ -914,10 +914,10 @@ tty_keys_extended_key(struct tty *tty, const char *buf, size_t len, (*key) |= (KEYC_SHIFT|KEYC_CTRL); break; case 7: - (*key) |= (KEYC_ESCAPE|KEYC_CTRL); + (*key) |= (KEYC_META|KEYC_CTRL); break; case 8: - (*key) |= (KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL); + (*key) |= (KEYC_SHIFT|KEYC_META|KEYC_CTRL); break; default: *key = KEYC_NONE;