Add a feature for mintty's application escape to avoid dodgy terminals

whinging about not supporting it, GitHub issue 5626 from Pete Dietl.
This commit is contained in:
nicm
2026-09-22 06:58:05 +00:00
committed by tmux update bot
parent 19b7660778
commit 83f62d0acc
5 changed files with 31 additions and 10 deletions

9
tmux.1
View File

@@ -1,4 +1,4 @@
.\" $OpenBSD: tmux.1,v 1.1171 2026/09/21 10:22:31 nicm Exp $
.\" $OpenBSD: tmux.1,v 1.1172 2026/09/22 06:58:05 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: September 21 2026 $
.Dd $Mdocdate: September 22 2026 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -5083,6 +5083,9 @@ The available features are:
.Bl -tag -width Ds
.It 256
Supports 256 colours with the SGR escape sequences.
.It appesc
Supports application escape key mode, where the Escape key sends a sequence
that cannot be mistaken for the start of another key.
.It clipboard
Allows setting the system clipboard.
.It ccolour
@@ -8831,6 +8834,8 @@ These are set automatically if the
capability is present.
.It Em \&Dseks , \&Eneks
Disable and enable extended keys.
.It Em \&Dsesc , \&Enesc
Disable and enable application escape key mode.
.It Em \&Dsfcs , \&Enfcs
Disable and enable focus reporting.
These are set automatically if the

4
tmux.h
View File

@@ -1,4 +1,4 @@
/* $OpenBSD: tmux.h,v 1.1445 2026/09/22 06:46:50 nicm Exp $ */
/* $OpenBSD: tmux.h,v 1.1446 2026/09/22 06:58:06 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -455,6 +455,7 @@ enum tty_code_code {
TTYC_DL1,
TTYC_DSBP,
TTYC_DSEKS,
TTYC_DSESC,
TTYC_DSFCS,
TTYC_DSMG,
TTYC_E3,
@@ -465,6 +466,7 @@ enum tty_code_code {
TTYC_ENACS,
TTYC_ENBP,
TTYC_ENEKS,
TTYC_ENESC,
TTYC_ENFCS,
TTYC_ENMG,
TTYC_FSL,

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: tty-features.c,v 1.43 2026/08/31 12:41:03 kirill Exp $ */
/* $OpenBSD: tty-features.c,v 1.44 2026/09/22 06:58:06 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -179,6 +179,18 @@ static const struct tty_feature tty_feature_focus = {
0
};
/* Terminal supports application escape key mode. */
static const char *const tty_feature_appesc_capabilities[] = {
"Enesc=\\E[?7727h",
"Dsesc=\\E[?7727l",
NULL
};
static const struct tty_feature tty_feature_appesc = {
"appesc",
tty_feature_appesc_capabilities,
0
};
/* Terminal supports cursor styles. */
static const char *const tty_feature_cstyle_capabilities[] = {
"Ss=\\E[%p1%d q",
@@ -368,6 +380,7 @@ static const struct tty_feature tty_feature_utf8 = {
/* Available terminal features. */
static const struct tty_feature *const tty_features[] = {
&tty_feature_256,
&tty_feature_appesc,
&tty_feature_bpaste,
&tty_feature_ccolour,
&tty_feature_clipboard,
@@ -558,6 +571,7 @@ tty_default_features(struct client *c, const char *name, u_int version)
"256,RGB,bpaste,clipboard,mouse,strikethrough,title"
{ .name = "mintty",
.features = TTY_FEATURES_BASE_MODERN_XTERM ","
"appesc,"
"ccolour,"
"cstyle,"
"extkeys,"

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: tty-term.c,v 1.109 2026/08/25 08:37:08 nicm Exp $ */
/* $OpenBSD: tty-term.c,v 1.110 2026/09/22 06:58:06 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -87,6 +87,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_DL1] = { TTYCODE_STRING, "dl1" },
[TTYC_DL] = { TTYCODE_STRING, "dl" },
[TTYC_DSEKS] = { TTYCODE_STRING, "Dseks" },
[TTYC_DSESC] = { TTYCODE_STRING, "Dsesc" },
[TTYC_DSFCS] = { TTYCODE_STRING, "Dsfcs" },
[TTYC_DSBP] = { TTYCODE_STRING, "Dsbp" },
[TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" },
@@ -98,6 +99,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_ENACS] = { TTYCODE_STRING, "enacs" },
[TTYC_ENBP] = { TTYCODE_STRING, "Enbp" },
[TTYC_ENEKS] = { TTYCODE_STRING, "Eneks" },
[TTYC_ENESC] = { TTYCODE_STRING, "Enesc" },
[TTYC_ENFCS] = { TTYCODE_STRING, "Enfcs" },
[TTYC_ENMG] = { TTYCODE_STRING, "Enmg" },
[TTYC_FSL] = { TTYCODE_STRING, "fsl" },

8
tty.c
View File

@@ -1,4 +1,4 @@
/* $OpenBSD: tty.c,v 1.481 2026/09/21 10:22:31 nicm Exp $ */
/* $OpenBSD: tty.c,v 1.482 2026/09/22 06:58:06 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -497,8 +497,7 @@ tty_stop_tty(struct tty *tty)
if (tty_term_has(tty->term, TTYC_DSBP))
tty_raw(tty, tty_term_string(tty->term, TTYC_DSBP));
if (tty->term->flags & TERM_VT100LIKE)
tty_raw(tty, "\033[?7727l");
tty_raw(tty, tty_term_string(tty->term, TTYC_DSESC));
tty_raw(tty, tty_term_string(tty->term, TTYC_DSFCS));
tty_raw(tty, tty_term_string(tty->term, TTYC_DSEKS));
@@ -555,8 +554,7 @@ tty_update_features(struct tty *tty)
tty_puts(tty, tty_term_string(tty->term, TTYC_ENEKS));
if (options_get_number(global_options, "focus-events"))
tty_puts(tty, tty_term_string(tty->term, TTYC_ENFCS));
if (tty->term->flags & TERM_VT100LIKE)
tty_puts(tty, "\033[?7727h");
tty_puts(tty, tty_term_string(tty->term, TTYC_ENESC));
/*
* Features might have changed since the first draw during attach. For