Add feature and capabilities for focus reporting. Also document AX and XT even

though they aren't tmux's.
This commit is contained in:
Nicholas Marriott 2020-04-24 07:37:11 +01:00
parent 5d69b9c4a7
commit 61550ac2e0
5 changed files with 48 additions and 11 deletions

20
tmux.1
View File

@ -5556,6 +5556,10 @@ It is not normally necessary to set these manually, instead the
.Ic terminal-features .Ic terminal-features
option should be used. option should be used.
.Bl -tag -width Ds .Bl -tag -width Ds
.It Em \&AX
An existing extension that tells
.Nm
the terminal supports default colours.
.It Em \&Cs , Cr .It Em \&Cs , Cr
Set the cursor colour. Set the cursor colour.
The first takes a single string argument and is used to set the colour; The first takes a single string argument and is used to set the colour;
@ -5568,8 +5572,19 @@ $ printf '\e033]12;red\e033\e\e'
.Ed .Ed
.It Em \&Cmg, \&Clmg, \&Dsmg , \&Enmg .It Em \&Cmg, \&Clmg, \&Dsmg , \&Enmg
Set, clear, disable or enable DECSLRM margins. Set, clear, disable or enable DECSLRM margins.
These are set automatically if the terminal reports it is
.Em VT420
compatible.
.It Em \&Dsbp , \&Enbp .It Em \&Dsbp , \&Enbp
Disable and enable bracketed paste. Disable and enable bracketed paste.
These are set automatically if the
.Em XT
capability is present.
.It Em \&Dsfcs , \&Enfcs
Disable and enable focus reporting.
These are set automatically if the
.Em XT
capability is present.
.It Em \&Smol .It Em \&Smol
Enable the overline attribute. Enable the overline attribute.
.It Em \&Smulx .It Em \&Smulx
@ -5620,6 +5635,11 @@ See the
option above and the option above and the
.Xr xterm 1 .Xr xterm 1
man page. man page.
.It Em \&XT
This is an existing extension capability that tmux uses to mean that the
terminal supports the
.Xr xterm 1
title set sequences and to automatically set some of the capabilities above.
.El .El
.Sh CONTROL MODE .Sh CONTROL MODE
.Nm .Nm

2
tmux.h
View File

@ -282,6 +282,7 @@ enum tty_code_code {
TTYC_DL, TTYC_DL,
TTYC_DL1, TTYC_DL1,
TTYC_DSBP, TTYC_DSBP,
TTYC_DSFCS,
TTYC_DSMG, TTYC_DSMG,
TTYC_E3, TTYC_E3,
TTYC_ECH, TTYC_ECH,
@ -290,6 +291,7 @@ enum tty_code_code {
TTYC_EL1, TTYC_EL1,
TTYC_ENACS, TTYC_ENACS,
TTYC_ENBP, TTYC_ENBP,
TTYC_ENFCS,
TTYC_ENMG, TTYC_ENMG,
TTYC_FSL, TTYC_FSL,
TTYC_HOME, TTYC_HOME,

View File

@ -26,7 +26,6 @@
/* /*
* Still hardcoded: * Still hardcoded:
* - mouse (under kmous capability); * - mouse (under kmous capability);
* - focus events (under XT and focus-events option);
* - default colours (under AX or op capabilities); * - default colours (under AX or op capabilities);
* - AIX colours (under colors >= 16); * - AIX colours (under colors >= 16);
* - alternate escape (under XT). * - alternate escape (under XT).
@ -122,9 +121,9 @@ static struct tty_feature tty_feature_usstyle = {
0 0
}; };
/* Terminal supports cursor bracketed paste. */ /* Terminal supports bracketed paste. */
static const char *tty_feature_bpaste_capabilities[] = { static const char *tty_feature_bpaste_capabilities[] = {
"Enbp=\E[?2004h", "Enbp=\\E[?2004h",
"Dsbp=\\E[?2004l", "Dsbp=\\E[?2004l",
NULL NULL
}; };
@ -134,6 +133,18 @@ static struct tty_feature tty_feature_bpaste = {
0 0
}; };
/* Terminal supports focus reporting. */
static const char *tty_feature_focus_capabilities[] = {
"Enfcs=\\E[?1004h",
"Dsfcs=\\E[?1004l",
NULL
};
static struct tty_feature tty_feature_focus = {
"focus",
tty_feature_focus_capabilities,
0
};
/* Terminal supports cursor styles. */ /* Terminal supports cursor styles. */
static const char *tty_feature_cstyle_capabilities[] = { static const char *tty_feature_cstyle_capabilities[] = {
"Ss=\\E[%p1%d q", "Ss=\\E[%p1%d q",
@ -205,9 +216,10 @@ static struct tty_feature tty_feature_rectfill = {
static const struct tty_feature *tty_features[] = { static const struct tty_feature *tty_features[] = {
&tty_feature_256, &tty_feature_256,
&tty_feature_bpaste, &tty_feature_bpaste,
&tty_feature_clipboard,
&tty_feature_ccolour, &tty_feature_ccolour,
&tty_feature_clipboard,
&tty_feature_cstyle, &tty_feature_cstyle,
&tty_feature_focus,
&tty_feature_margins, &tty_feature_margins,
&tty_feature_overline, &tty_feature_overline,
&tty_feature_rectfill, &tty_feature_rectfill,
@ -308,20 +320,21 @@ tty_default_features(int *feat, const char *name, u_int version)
u_int version; u_int version;
const char *features; const char *features;
} table[] = { } table[] = {
#define TTY_FEATURES_BASE_MODERN_XTERM "256,RGB,bpaste,clipboard,strikethrough,title"
{ .name = "mintty", { .name = "mintty",
.features = "256,RGB,bpaste,ccolour,clipboard,cstyle,margins,overline,strikethrough,title" .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,margins,overline"
}, },
{ .name = "tmux", { .name = "tmux",
.features = "256,RGB,bpaste,ccolour,clipboard,cstyle,overline,strikethough,title,usstyle" .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,focus,overline,usstyle"
}, },
{ .name = "rxvt-unicode", { .name = "rxvt-unicode",
.features = "256,title" .features = "256,title"
}, },
{ .name = "iTerm2", { .name = "iTerm2",
.features = "256,RGB,bpaste,clipboard,cstyle,margins,strikethrough,sync,title" .features = TTY_FEATURES_BASE_MODERN_XTERM ",cstyle,margins,sync"
}, },
{ .name = "XTerm", { .name = "XTerm",
.features = "256,RGB,bpaste,ccolour,clipboard,cstyle,margins,rectfill,strikethrough,title" .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,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_DSFCS] = { TTYCODE_STRING, "Dsfcs" },
[TTYC_DSBP] = { TTYCODE_STRING, "Dsbp" }, [TTYC_DSBP] = { TTYCODE_STRING, "Dsbp" },
[TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" }, [TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" },
[TTYC_E3] = { TTYCODE_STRING, "E3" }, [TTYC_E3] = { TTYCODE_STRING, "E3" },
@ -95,6 +96,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_ENFCS] = { TTYCODE_STRING, "Enfcs" },
[TTYC_ENMG] = { TTYCODE_STRING, "Enmg" }, [TTYC_ENMG] = { TTYCODE_STRING, "Enmg" },
[TTYC_FSL] = { TTYCODE_STRING, "fsl" }, [TTYC_FSL] = { TTYCODE_STRING, "fsl" },
[TTYC_HOME] = { TTYCODE_STRING, "home" }, [TTYC_HOME] = { TTYCODE_STRING, "home" },
@ -567,7 +569,7 @@ tty_term_create(struct tty *tty, char *name, int *feat, int fd, char **cause)
/* Add some features if terminal has XT. */ /* Add some features if terminal has XT. */
if (tty_term_flag(term, TTYC_XT)) if (tty_term_flag(term, TTYC_XT))
tty_add_features(feat, "bpaste,title", ","); tty_add_features(feat, "bpaste,focus,title", ",");
/* Apply the features and overrides again. */ /* Apply the features and overrides again. */
tty_apply_features(term, *feat); tty_apply_features(term, *feat);

4
tty.c
View File

@ -333,7 +333,7 @@ tty_start_tty(struct tty *tty)
if (tty_term_flag(tty->term, TTYC_XT)) { if (tty_term_flag(tty->term, TTYC_XT)) {
if (options_get_number(global_options, "focus-events")) { if (options_get_number(global_options, "focus-events")) {
tty->flags |= TTY_FOCUS; tty->flags |= TTY_FOCUS;
tty_puts(tty, "\033[?1004h"); tty_raw(tty, tty_term_string(tty->term, TTYC_ENFCS));
} }
tty_puts(tty, "\033[?7727h"); tty_puts(tty, "\033[?7727h");
} }
@ -420,7 +420,7 @@ tty_stop_tty(struct tty *tty)
if (tty_term_flag(tty->term, TTYC_XT)) { if (tty_term_flag(tty->term, TTYC_XT)) {
if (tty->flags & TTY_FOCUS) { if (tty->flags & TTY_FOCUS) {
tty->flags &= ~TTY_FOCUS; tty->flags &= ~TTY_FOCUS;
tty_raw(tty, "\033[?1004l"); tty_raw(tty, tty_term_string(tty->term, TTYC_DSFCS));
} }
tty_raw(tty, "\033[?7727l"); tty_raw(tty, "\033[?7727l");
} }