From 15a79445762aa2b6934e4ef2a7894626f9e3cf2c Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 22 Sep 2026 06:58:05 +0000 Subject: [PATCH] Add a feature for mintty's application escape to avoid dodgy terminals whinging about not supporting it, GitHub issue 5626 from Pete Dietl. --- tmux.1 | 9 +++++++-- tmux.h | 2 ++ tty-features.c | 14 ++++++++++++++ tty-term.c | 2 ++ tty.c | 8 +++----- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tmux.1 b/tmux.1 index 0254f5de1..19b1000e8 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.1169 2026/09/10 11:02:18 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.1172 2026/09/22 06:58:05 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -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 10 2026 $ +.Dd $Mdocdate: September 22 2026 $ .Dt TMUX 1 .Os .Sh NAME @@ -5085,6 +5085,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 @@ -8968,6 +8971,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 diff --git a/tmux.h b/tmux.h index de254a9f4..4555fea2b 100644 --- a/tmux.h +++ b/tmux.h @@ -464,6 +464,7 @@ enum tty_code_code { TTYC_DL1, TTYC_DSBP, TTYC_DSEKS, + TTYC_DSESC, TTYC_DSFCS, TTYC_DSMG, TTYC_E3, @@ -474,6 +475,7 @@ enum tty_code_code { TTYC_ENACS, TTYC_ENBP, TTYC_ENEKS, + TTYC_ENESC, TTYC_ENFCS, TTYC_ENMG, TTYC_FSL, diff --git a/tty-features.c b/tty-features.c index 284943caf..0f3b64fa5 100644 --- a/tty-features.c +++ b/tty-features.c @@ -189,6 +189,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", @@ -378,6 +390,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, @@ -568,6 +581,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," diff --git a/tty-term.c b/tty-term.c index 35df5c778..1ac078cd4 100644 --- a/tty-term.c +++ b/tty-term.c @@ -90,6 +90,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" }, @@ -101,6 +102,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" }, diff --git a/tty.c b/tty.c index 9bac687eb..8cf9bb67e 100644 --- a/tty.c +++ b/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.480 2026/08/25 08:37:08 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.482 2026/09/22 06:58:06 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -503,8 +503,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)); @@ -563,8 +562,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