From e7618f41c23ba4f8434e792c5d82f267d64cad22 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 22 Sep 2026 14:10:26 +0000 Subject: [PATCH] Some terminals have extended DECSCUSR to allow it to reset to the default style and put that as the Se capability in their terminfo entry. Change so that if Ss and Se exist, tmux does not overwrite them with its own. GitHub issue 5476. --- tmux.h | 5 +++-- tty-features.c | 8 ++++---- tty-term.c | 10 +++++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tmux.h b/tmux.h index f739014a2..ef161807d 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1446 2026/09/22 06:58:06 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1447 2026/09/22 14:10:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1708,6 +1708,7 @@ struct tty_term { #define TERM_VT100LIKE 0x20 #define TERM_SIXEL 0x40 #define TERM_INVALIDMS 0x80 +#define TERM_NOREPLACE 0x100 int flags; LIST_ENTRY(tty_term) entry; @@ -2942,7 +2943,7 @@ void tty_default_colours(struct grid_cell *, struct window_pane *, u_int *); /* tty-term.c */ extern struct tty_terms tty_terms; u_int tty_term_ncodes(void); -void tty_term_apply(struct tty_term *, const char *, int); +void tty_term_apply(struct tty_term *, const char *, int, int); void tty_term_apply_overrides(struct tty_term *); struct tty_term *tty_term_create(struct tty *, char *, char **, u_int, char **); void tty_term_free(struct tty_term *); diff --git a/tty-features.c b/tty-features.c index 04ec4269b..74559dcf1 100644 --- a/tty-features.c +++ b/tty-features.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-features.c,v 1.44 2026/09/22 06:58:06 nicm Exp $ */ +/* $OpenBSD: tty-features.c,v 1.45 2026/09/22 14:10:26 nicm Exp $ */ /* * Copyright (c) 2020 Nicholas Marriott @@ -200,7 +200,7 @@ static const char *const tty_feature_cstyle_capabilities[] = { static const struct tty_feature tty_feature_cstyle = { "cstyle", tty_feature_cstyle_capabilities, - 0 + TERM_NOREPLACE }; /* Terminal supports cursor colours. */ @@ -544,11 +544,11 @@ tty_apply_features(struct tty_term *term) capability = tf->capabilities; while (*capability != NULL) { log_debug("adding capability: %s", *capability); - tty_term_apply(term, *capability, 1); + tty_term_apply(term, *capability, 1, tf->flags); capability++; } } - term->flags |= tf->flags; + term->flags |= (tf->flags & ~TERM_NOREPLACE); if (tf == &tty_feature_utf8) c->flags |= CLIENT_UTF8; } diff --git a/tty-term.c b/tty-term.c index 95bc76189..f2d8b67b6 100644 --- a/tty-term.c +++ b/tty-term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-term.c,v 1.110 2026/09/22 06:58:06 nicm Exp $ */ +/* $OpenBSD: tty-term.c,v 1.111 2026/09/22 14:10:26 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -361,7 +361,8 @@ tty_term_override_next(const char *s, size_t *offset) } void -tty_term_apply(struct tty_term *term, const char *capabilities, int quiet) +tty_term_apply(struct tty_term *term, const char *capabilities, int quiet, + int flags) { const struct tty_term_code_entry *ent; struct tty_code *code; @@ -404,6 +405,9 @@ tty_term_apply(struct tty_term *term, const char *capabilities, int quiet) if (strcmp(s, ent->name) != 0) continue; code = &term->codes[i]; + if ((flags & TERM_NOREPLACE) && + code->type != TTYCODE_NONE) + continue; if (remove) { code->type = TTYCODE_NONE; @@ -456,7 +460,7 @@ tty_term_apply_overrides(struct tty_term *term) offset = 0; first = tty_term_override_next(s, &offset); if (first != NULL && fnmatch(first, term->name, 0) == 0) - tty_term_apply(term, s + offset, 0); + tty_term_apply(term, s + offset, 0, 0); a = options_array_next(a); }