Revamp extended keys support to more closely match xterm and support

mode 2 as well as mode 1. From Stanislav Kljuhhin (GitHub issue 4038).

This changes tmux to always request mode 2 from parent terminal, change
to an unambiguous internal representation of keys, and adds an option
(extended-keys-format) to control the format similar to the xterm(1)
formatOtherKeys resource.
This commit is contained in:
nicm
2024-08-21 04:17:09 +00:00
parent de6bce057a
commit c7e61a01e5
12 changed files with 238 additions and 136 deletions

43
tmux.h
View File

@ -138,8 +138,7 @@ struct winlink;
#define KEYC_IMPLIED_META 0x08000000000000ULL
#define KEYC_BUILD_MODIFIERS 0x10000000000000ULL
#define KEYC_VI 0x20000000000000ULL
#define KEYC_EXTENDED 0x40000000000000ULL
#define KEYC_SENT 0x80000000000000ULL
#define KEYC_SENT 0x40000000000000ULL
/* Masks for key bits. */
#define KEYC_MASK_MODIFIERS 0x00f00000000000ULL
@ -187,6 +186,42 @@ struct winlink;
*/
typedef unsigned long long key_code;
/* C0 control characters */
enum {
C0_NUL,
C0_SOH,
C0_STX,
C0_ETX,
C0_EOT,
C0_ENQ,
C0_ASC,
C0_BEL,
C0_BS,
C0_HT,
C0_LF,
C0_VT,
C0_FF,
C0_CR,
C0_SO,
C0_SI,
C0_DLE,
C0_DC1,
C0_DC2,
C0_DC3,
C0_DC4,
C0_NAK,
C0_SYN,
C0_ETB,
C0_CAN,
C0_EM,
C0_SUB,
C0_ESC,
C0_FS,
C0_GS,
C0_RS,
C0_US
};
/* Special key codes. */
enum {
/* Focus events. */
@ -582,14 +617,16 @@ enum tty_code_code {
#define MODE_MOUSE_ALL 0x1000
#define MODE_ORIGIN 0x2000
#define MODE_CRLF 0x4000
#define MODE_KEXTENDED 0x8000
#define MODE_KEYS_EXTENDED 0x8000
#define MODE_CURSOR_VERY_VISIBLE 0x10000
#define MODE_CURSOR_BLINKING_SET 0x20000
#define MODE_KEYS_EXTENDED_2 0x40000
#define ALL_MODES 0xffffff
#define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
#define MOTION_MOUSE_MODES (MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
#define CURSOR_MODES (MODE_CURSOR|MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE)
#define EXTENDED_KEY_MODES (MODE_KEYS_EXTENDED|MODE_KEYS_EXTENDED_2)
/* Mouse protocol constants. */
#define MOUSE_PARAM_MAX 0xff