diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-05-07 21:26:00 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-05-07 21:26:00 +0000 |
commit | 484e32bc8e44e32e7b4b24db1f415cda28bc768b (patch) | |
tree | d35cbe02870f8bed06d656986dcfa9f21f41231c /usr.bin/tmux/key-bindings.c | |
parent | 53d720abb72ed08b4d724755b5f6bb09075183c4 (diff) |
Up to now, tmux sees \033\033[OA as M-Up and since we turned on
xterm-keys by default, generates \033[1;3A instead of
\033\033[OA. Unfortunately this confuses vi, which doesn't understand
xterm keys and now sees Escape+Up pressed within escape-time as Escape
followed by A.
The issue doesn't happen in xterm itself because it gets the keys from X
and can distinguish between a genuine M-Up and Escape+Up.
Because xterm can, tmux can too: xterm will give us \033[1;3A (that is,
kUP3) for a real M-Up and \033\033OA for Escape+Up - in fact, we can be
sure any \033 preceding an xterm key is a real Escape key press because
Meta would be part of the xterm key instead of a separate \033.
So change tmux to recognise both sequences as M-Up for its own purposes,
but generate the xterm version of M-Up only if it originally received
the xterm version from the terminal.
This means we will return to sending \033\033OA instead of the xterm key
for terminals that do not support xterm keys themselves, but there is no
practical way around this because they do not allow us to distinguish
between Escape+Up and M-Up. xterm style escape sequences are now the de
facto standard for these keys in any case.
Problem reported by jsing@ and subsequently by Cecile Tonglet in GitHub
issue 907.
Diffstat (limited to 'usr.bin/tmux/key-bindings.c')
-rw-r--r-- | usr.bin/tmux/key-bindings.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c index f0e0e1a950d..a54cbd11b4a 100644 --- a/usr.bin/tmux/key-bindings.c +++ b/usr.bin/tmux/key-bindings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-bindings.c,v 1.76 2017/04/21 19:33:07 nicm Exp $ */ +/* $OpenBSD: key-bindings.c,v 1.77 2017/05/07 21:25:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -92,7 +92,7 @@ key_bindings_add(const char *name, key_code key, int repeat, table = key_bindings_get_table(name, 1); - bd_find.key = key; + bd_find.key = (key & ~KEYC_XTERM); bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find); if (bd != NULL) { RB_REMOVE(key_bindings, &table->key_bindings, bd); @@ -119,7 +119,7 @@ key_bindings_remove(const char *name, key_code key) if (table == NULL) return; - bd_find.key = key; + bd_find.key = (key & ~KEYC_XTERM); bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find); if (bd == NULL) return; |