Skip to content

terminal: support DECSTR - #14538

Merged
jcollie merged 2 commits into
ghostty-org:mainfrom
jcollie:decstr
Oct 9, 2026
Merged

jcollie merged 2 commits into
ghostty-org:mainfrom
jcollie:decstr

Conversation

@jcollie

@jcollie jcollie commented Oct 4, 2026

Copy link
Copy Markdown
Member

Programs and test suites use DECSTR (CSI ! p) to undo the modes, margins, and pen they may have left behind without clearing the screen. It was ignored, so that state leaked into whatever ran next.

@jcollie
jcollie requested a review from a team as a code owner October 4, 2026 20:24
@ghostty-bot ghostty-bot Bot added the vt Control sequence related label Oct 4, 2026
@jcollie jcollie added this to the 1.4.0 milestone Oct 5, 2026
Comment thread src/terminal/Terminal.zig
jcollie and others added 2 commits October 8, 2026 22:06
Programs and test suites use DECSTR (CSI ! p) to undo the modes, margins,
and pen they may have left behind without clearing the screen. It was
ignored, so that state leaked into whatever ran next.

@vancluever vancluever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good!

Tested by hiding cursor w/DECTCEM and then resetting w/DECSTR.

@jcollie
jcollie merged commit b115e45 into ghostty-org:main Oct 9, 2026
@jcollie
jcollie deleted the decstr branch October 9, 2026 04:00
trancong12102 added a commit to aislopware/ghostty that referenced this pull request Oct 9, 2026
Takes DECSTR (ghostty-org#14538), the single shift on exactly one printed character
(ghostty-org#14576) and origin-mode cursor positions in VT format (ghostty-org#14588).

Conflicts:
- Terminal.zig: keep the fork's default_prompt_redraw beside upstream's
  DECSTR wording. DECSTR leaves shell_redraws_prompt alone: it is shell
  integration state, not a mode a program set.
- formatter.zig: keep the fork's cursor emitter (pending wrap at the right
  margin, shape, saved cursor), and take upstream's rule for where CUP counts
  from: `cursor_origin` (now optional) is set only when the output restores
  both origin mode and the scrolling region. The saved cursor counts from the
  margins when DECSC saved it under origin mode, as before.
Dicklesworthstone pushed a commit to Dicklesworthstone/opentui that referenced this pull request Oct 26, 2026
A program in an embedded terminal that changed palette colors with OSC 4
kept those colors after RIS (`ESC c`, what `reset` sends), and the vendored
Ghostty ignored DECSTR (`CSI ! p`). xterm restores the palette on both and
keeps the OSC 10, 11, and 12 colors.

Update Ghostty from 727b8a02f to aeda37b30. DECSTR support landed in
b115e4567 (ghostty-org/ghostty#14538), the oldest commit whose fullReset
and softReset both reset the palette; aeda37b30 (#14643) adds that DECSTR
also turns off ISO character protection, as in xterm. Ghostty needs the
uucode 9d55524 code (BreakState.table_len), so the uucode-ghostty pin
moves too. That uucode ships Unicode 18 data, which would give the
embedded terminal other widths than OpenTUI text and most hosts (Unicode
17), so update-zig-deps.sh copies OpenTUI's Unicode 17 data files into
Ghostty's uucode; the next Ghostty update must revisit this. Rows pin the
agreement: U+1F6D9 (unassigned in 17) is one cell and U+1CF5 U+0915 two
cells in OpenTUI text, in the grid, and after a replay into Ghostty.

Other changes the embedded terminal needs:
- The write_pty effect now passes a slice without a sentinel.
- Kitty graphics now needs wuffs, which the archive does not carry, so
  Ghostty builds with -Dvt-features=-kitty-graphics. That compiles out the
  Kitty image storage and the replies the previous commit silenced, so the
  zero storage limit goes away; its test now checks that the storage type
  is empty.

The new Ghostty also changes other behavior: DECSTR resets the modes and
state xterm resets; a bare CSI g clears the tab stop at the cursor; it
answers ANSI-mode DECRQM, DECECM, Ghostty's terminfo through XTGETTCAP,
and Kitty clipboard requests (EPERM/ENOSYS); DECRQSS reports overline;
CAN and SUB cancel OSC; C0 0x10-0x1F and UTF-8 C1 controls no longer
draw cells; selection highlight at wide-character edges follows copying;
and it encodes F13-F25 and modifyOtherKeys 2 ctrl keys. The pull request
lists these. No existing test changes.

Source net +1: build.zig +3 (the vt-features option and two comment
lines with its reason), main.zig -2 (the storage limit and its comment).
Vendor script +6: the Unicode 17 data copy and its reason.

Issue: 192
Fixes anomalyco#1695
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vt Control sequence related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants