fix(tui): xterm default cursor style #41050

Problem:
xterm doesn't reset to user configured default with the sequence `\x1b[0 q`.

Solution:
Restore old behavior: if the reset cursor style terminfo entry is
absent, xterm's sequence should set the cursor to steady block, which is
the xterm default. In the near future, they may support another option
(`\x1b[7 q`) to reset to the user configured default.
This commit is contained in:
Kyle
2026-07-30 02:34:26 -05:00
committed by GitHub
parent a85cce90e3
commit a3eff66e31

View File

@@ -2363,9 +2363,7 @@ static void patch_terminfo_bugs(TUIData *tui, const char *term, const char *colo
// DECSCUSR (cursor shape) is widely supported.
// https://github.com/gnachman/iTerm2/pull/92
if (!bsdvt
&& (xterm // anything claiming xterm compat
// per MinTTY 0.4.3-1 release notes from 2009
|| putty
&& (putty // per MinTTY 0.4.3-1 release notes from 2009
// per https://chromium.googlesource.com/apps/libapps/+/a5fb83c190aa9d74f4a9bca233dac6be2664e9e9/hterm/doc/ControlSequences.md
|| hterm
// per https://bugzilla.gnome.org/show_bug.cgi?id=720821
@@ -2411,6 +2409,11 @@ static void patch_terminfo_bugs(TUIData *tui, const char *term, const char *colo
"%e%{0}" // anything else
"%;" "%dc");
terminfo_set_str(tui, kTerm_reset_cursor_style, "\x1b[?c");
} else if (!bsdvt && xterm) {
terminfo_set_if_empty(tui, kTerm_set_cursor_style, "\x1b[%p1%d q");
// xterm has a configurable cursor, but the default is 2, and 0 doesn't
// reset to default. #41047
terminfo_set_if_empty(tui, kTerm_reset_cursor_style, "\x1b[2 q");
}
xfree(xterm_version);