From de6912203445f6af963de6fc05c7e5b321fe25b1 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 048d6c43f..de254a9f4 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1445 2026/09/22 06:46:50 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1447 2026/09/22 14:10:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1738,6 +1738,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; @@ -3007,7 +3008,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 0b12745e2..284943caf 100644 --- a/tty-features.c +++ b/tty-features.c @@ -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.45 2026/09/22 14:10:26 nicm Exp $ */ /* * Copyright (c) 2020 Nicholas Marriott @@ -198,7 +198,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. */ @@ -541,11 +541,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 6b149fcee..35df5c778 100644 --- a/tty-term.c +++ b/tty-term.c @@ -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.111 2026/09/22 14:10:26 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -362,7 +362,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; @@ -405,6 +406,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; @@ -457,7 +461,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); }