1
0
mirror of https://github.com/tmux/tmux.git synced 2025-04-01 21:41:44 +00:00

Add a terminal feature for enable/disable extended keys (supported by xterm and

mintty) and add an option to make tmux send it.
This commit is contained in:
Nicholas Marriott 2020-05-15 16:15:24 +01:00
parent e6b17e77db
commit 6d92b99dbc
6 changed files with 41 additions and 10 deletions

View File

@ -251,6 +251,14 @@ const struct options_table_entry options_table[] = {
"clients." "clients."
}, },
{ .name = "extended-keys",
.type = OPTIONS_TABLE_FLAG,
.scope = OPTIONS_TABLE_SERVER,
.default_num = 0,
.text = "Whether to request extended key sequences from terminals "
"that support it."
},
{ .name = "focus-events", { .name = "focus-events",
.type = OPTIONS_TABLE_FLAG, .type = OPTIONS_TABLE_FLAG,
.scope = OPTIONS_TABLE_SERVER, .scope = OPTIONS_TABLE_SERVER,

8
tmux.1
View File

@ -3225,6 +3225,12 @@ sessions.
.Op Ic on | off .Op Ic on | off
.Xc .Xc
If enabled, the server will exit when there are no attached clients. If enabled, the server will exit when there are no attached clients.
.It Xo Ic extended-keys
.Op Ic on | off
.Xc
When enabled, extended keys are requested from the terminal and if supported
are recognised by
.Nm .
.It Xo Ic focus-events .It Xo Ic focus-events
.Op Ic on | off .Op Ic on | off
.Xc .Xc
@ -5744,6 +5750,8 @@ Disable and enable bracketed paste.
These are set automatically if the These are set automatically if the
.Em XT .Em XT
capability is present. capability is present.
.It Em \&Dseks , \&Eneks
Disable and enable extended keys.
.It Em \&Dsfcs , \&Enfcs .It Em \&Dsfcs , \&Enfcs
Disable and enable focus reporting. Disable and enable focus reporting.
These are set automatically if the These are set automatically if the

4
tmux.h
View File

@ -292,6 +292,7 @@ enum tty_code_code {
TTYC_DL, TTYC_DL,
TTYC_DL1, TTYC_DL1,
TTYC_DSBP, TTYC_DSBP,
TTYC_DSEKS,
TTYC_DSFCS, TTYC_DSFCS,
TTYC_DSMG, TTYC_DSMG,
TTYC_E3, TTYC_E3,
@ -301,6 +302,7 @@ enum tty_code_code {
TTYC_EL1, TTYC_EL1,
TTYC_ENACS, TTYC_ENACS,
TTYC_ENBP, TTYC_ENBP,
TTYC_ENEKS,
TTYC_ENFCS, TTYC_ENFCS,
TTYC_ENMG, TTYC_ENMG,
TTYC_FSL, TTYC_FSL,
@ -1286,7 +1288,7 @@ struct tty {
/* 0x8 unused */ /* 0x8 unused */
#define TTY_STARTED 0x10 #define TTY_STARTED 0x10
#define TTY_OPENED 0x20 #define TTY_OPENED 0x20
#define TTY_FOCUS 0x40 /* 0x40 unused */
#define TTY_BLOCK 0x80 #define TTY_BLOCK 0x80
#define TTY_HAVEDA 0x100 #define TTY_HAVEDA 0x100
#define TTY_HAVEXDA 0x200 #define TTY_HAVEXDA 0x200

View File

@ -190,6 +190,18 @@ static const struct tty_feature tty_feature_sync = {
0 0
}; };
/* Terminal supports extended keys. */
static const char *tty_feature_extkeys_capabilities[] = {
"Eneks=\\E[>4;1m",
"Dseks=\\E[>4m",
NULL
};
static const struct tty_feature tty_feature_extkeys = {
"extkeys",
tty_feature_extkeys_capabilities,
0
};
/* Terminal supports DECSLRM margins. */ /* Terminal supports DECSLRM margins. */
static const char *tty_feature_margins_capabilities[] = { static const char *tty_feature_margins_capabilities[] = {
"Enmg=\\E[?69h", "Enmg=\\E[?69h",
@ -218,6 +230,7 @@ static const struct tty_feature *tty_features[] = {
&tty_feature_ccolour, &tty_feature_ccolour,
&tty_feature_clipboard, &tty_feature_clipboard,
&tty_feature_cstyle, &tty_feature_cstyle,
&tty_feature_extkeys,
&tty_feature_focus, &tty_feature_focus,
&tty_feature_margins, &tty_feature_margins,
&tty_feature_overline, &tty_feature_overline,
@ -321,7 +334,7 @@ tty_default_features(int *feat, const char *name, u_int version)
} table[] = { } table[] = {
#define TTY_FEATURES_BASE_MODERN_XTERM "256,RGB,bpaste,clipboard,strikethrough,title" #define TTY_FEATURES_BASE_MODERN_XTERM "256,RGB,bpaste,clipboard,strikethrough,title"
{ .name = "mintty", { .name = "mintty",
.features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,margins,overline" .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,extkeys,margins,overline"
}, },
{ .name = "tmux", { .name = "tmux",
.features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,focus,overline,usstyle" .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,focus,overline,usstyle"
@ -333,7 +346,7 @@ tty_default_features(int *feat, const char *name, u_int version)
.features = TTY_FEATURES_BASE_MODERN_XTERM ",cstyle,margins,sync" .features = TTY_FEATURES_BASE_MODERN_XTERM ",cstyle,margins,sync"
}, },
{ .name = "XTerm", { .name = "XTerm",
.features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,focus,margins,rectfill" .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,extkeys,focus,margins,rectfill"
} }
}; };
u_int i; u_int i;

View File

@ -86,6 +86,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_DIM] = { TTYCODE_STRING, "dim" }, [TTYC_DIM] = { TTYCODE_STRING, "dim" },
[TTYC_DL1] = { TTYCODE_STRING, "dl1" }, [TTYC_DL1] = { TTYCODE_STRING, "dl1" },
[TTYC_DL] = { TTYCODE_STRING, "dl" }, [TTYC_DL] = { TTYCODE_STRING, "dl" },
[TTYC_DSEKS] = { TTYCODE_STRING, "Dseks" },
[TTYC_DSFCS] = { TTYCODE_STRING, "Dsfcs" }, [TTYC_DSFCS] = { TTYCODE_STRING, "Dsfcs" },
[TTYC_DSBP] = { TTYCODE_STRING, "Dsbp" }, [TTYC_DSBP] = { TTYCODE_STRING, "Dsbp" },
[TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" }, [TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" },
@ -96,6 +97,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_EL] = { TTYCODE_STRING, "el" }, [TTYC_EL] = { TTYCODE_STRING, "el" },
[TTYC_ENACS] = { TTYCODE_STRING, "enacs" }, [TTYC_ENACS] = { TTYCODE_STRING, "enacs" },
[TTYC_ENBP] = { TTYCODE_STRING, "Enbp" }, [TTYC_ENBP] = { TTYCODE_STRING, "Enbp" },
[TTYC_ENEKS] = { TTYCODE_STRING, "Eneks" },
[TTYC_ENFCS] = { TTYCODE_STRING, "Enfcs" }, [TTYC_ENFCS] = { TTYCODE_STRING, "Enfcs" },
[TTYC_ENMG] = { TTYCODE_STRING, "Enmg" }, [TTYC_ENMG] = { TTYCODE_STRING, "Enmg" },
[TTYC_FSL] = { TTYCODE_STRING, "fsl" }, [TTYC_FSL] = { TTYCODE_STRING, "fsl" },

12
tty.c
View File

@ -329,10 +329,10 @@ tty_start_tty(struct tty *tty)
tty_puts(tty, "\033[?1006l\033[?1005l"); tty_puts(tty, "\033[?1006l\033[?1005l");
} }
if (options_get_number(global_options, "focus-events")) { if (options_get_number(global_options, "focus-events"))
tty->flags |= TTY_FOCUS;
tty_raw(tty, tty_term_string(tty->term, TTYC_ENFCS)); tty_raw(tty, tty_term_string(tty->term, TTYC_ENFCS));
} if (options_get_number(global_options, "extended-keys"))
tty_raw(tty, tty_term_string(tty->term, TTYC_ENEKS));
if (tty->term->flags & TERM_VT100LIKE) if (tty->term->flags & TERM_VT100LIKE)
tty_puts(tty, "\033[?7727h"); tty_puts(tty, "\033[?7727h");
@ -415,12 +415,10 @@ tty_stop_tty(struct tty *tty)
tty_raw(tty, "\033[?1006l\033[?1005l"); tty_raw(tty, "\033[?1006l\033[?1005l");
} }
if (tty->flags & TTY_FOCUS) {
tty->flags &= ~TTY_FOCUS;
tty_raw(tty, tty_term_string(tty->term, TTYC_DSFCS));
}
if (tty->term->flags & TERM_VT100LIKE) if (tty->term->flags & TERM_VT100LIKE)
tty_raw(tty, "\033[?7727l"); tty_raw(tty, "\033[?7727l");
tty_raw(tty, tty_term_string(tty->term, TTYC_DSFCS));
tty_raw(tty, tty_term_string(tty->term, TTYC_DSEKS));
if (tty_use_margin(tty)) if (tty_use_margin(tty))
tty_raw(tty, tty_term_string(tty->term, TTYC_DSMG)); tty_raw(tty, tty_term_string(tty->term, TTYC_DSMG));