diff options
Diffstat (limited to 'usr.bin/tmux/xterm-keys.c')
-rw-r--r-- | usr.bin/tmux/xterm-keys.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/tmux/xterm-keys.c b/usr.bin/tmux/xterm-keys.c index 34962ecec58..36e7542ba46 100644 --- a/usr.bin/tmux/xterm-keys.c +++ b/usr.bin/tmux/xterm-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xterm-keys.c,v 1.21 2017/01/25 14:36:08 nicm Exp $ */ +/* $OpenBSD: xterm-keys.c,v 1.22 2017/05/07 21:25:59 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -197,7 +197,7 @@ xterm_keys_find(const char *buf, size_t len, size_t *size, key_code *key) if (matched == -1) continue; if (matched == 0) - *key = entry->key | modifiers; + *key = (entry->key|modifiers|KEYC_XTERM); return (matched); } return (-1); @@ -227,8 +227,16 @@ xterm_keys_lookup(key_code key) if (modifiers == 1) return (NULL); + /* + * If this has the escape modifier, but was not originally an xterm + * key, it may be a genuine escape + key. So don't pass it through as + * an xterm key or programs like vi may be confused. + */ + if ((key & (KEYC_ESCAPE|KEYC_XTERM)) == KEYC_ESCAPE) + return (NULL); + /* Otherwise, find the key in the table. */ - key &= ~(KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL); + key &= KEYC_MASK_KEY; for (i = 0; i < nitems(xterm_keys_table); i++) { entry = &xterm_keys_table[i]; if (key == entry->key) |