From d52f579fd5e7fd21d7dcf837780cbf98498b10ce Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 7 May 2017 21:25:59 +0000 Subject: 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. --- tmux.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tmux.h') diff --git a/tmux.h b/tmux.h index ac2991e8..378c937a 100644 --- a/tmux.h +++ b/tmux.h @@ -91,9 +91,10 @@ struct tmuxproc; #define KEYC_ESCAPE 0x200000000000ULL #define KEYC_CTRL 0x400000000000ULL #define KEYC_SHIFT 0x800000000000ULL +#define KEYC_XTERM 0x1000000000000ULL /* Mask to obtain key w/o modifiers. */ -#define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT) +#define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT|KEYC_XTERM) #define KEYC_MASK_KEY (~KEYC_MASK_MOD) /* Is this a mouse key? */ -- cgit From 5fee4638e08b1642a3b8882c5cf8825dd76b3a81 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 7 May 2017 22:27:57 +0000 Subject: Add a format for the name of the pane's mode, lets it be used as a conditional for key bindings. --- tmux.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'tmux.h') diff --git a/tmux.h b/tmux.h index 378c937a..1b1343b7 100644 --- a/tmux.h +++ b/tmux.h @@ -689,15 +689,18 @@ struct screen_write_ctx { * right function to handle input and output. */ struct window_mode { - struct screen *(*init)(struct window_pane *); - void (*free)(struct window_pane *); - void (*resize)(struct window_pane *, u_int, u_int); - void (*key)(struct window_pane *, struct client *, struct session *, - key_code, struct mouse_event *); - - const char *(*key_table)(struct window_pane *); - void (*command)(struct window_pane *, struct client *, - struct session *, struct args *, struct mouse_event *); + const char *name; + + struct screen *(*init)(struct window_pane *); + void (*free)(struct window_pane *); + void (*resize)(struct window_pane *, u_int, u_int); + void (*key)(struct window_pane *, struct client *, + struct session *, key_code, struct mouse_event *); + + const char *(*key_table)(struct window_pane *); + void (*command)(struct window_pane *, struct client *, + struct session *, struct args *, + struct mouse_event *); }; #define WINDOW_MODE_TIMEOUT 180 -- cgit