feat(terminal): add synchronized output (DEC mode ?2026)#70
Draft
roramirez wants to merge 1 commit into
Draft
Conversation
Track ?2026 on the grid and skip presenting frames while it is set, so a program writing a complex update (vim, lazygit) never shows a partial screen — the window keeps the last frame until the program resets the mode, eliminating tearing. Reset by RIS. Collapse the DECSET/DECRST arms of handle_dec_private_modes into `h | l` patterns while adding ?2026.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements synchronized output (DEC private mode
?2026). While a program holds?2026h, mmterm skips presenting frames, so a complex update (vim redraw, lazygit, fullscreen TUIs) is never shown half-drawn — the window keeps the last complete frame until the program sends?2026l, at which point the next frame renders normally. This eliminates tearing and is supported by WezTerm, Alacritty, and Ghostty.Changes
src/terminal/grid.rs: addGrid.synchronized_output(pattern ofbracketed_paste): declared, initializedfalse, and cleared by RIS.src/terminal/parser.rs:handle_dec_private_modessets/clears the flag on?2026h/?2026l. Also collapse the DECSET/DECRST (h/l) arms into('h' | 'l', …)patterns.src/renderer/render_ops.rs:redraw()returns early (before acquiring the surface buffer) when the active pane's grid hassynchronized_outputset, via a newactive_grid_synchronized()helper. The held frame is flushed by the redraw triggered when the?2026lreset byte arrives from the PTY.synchronized_output_modeinparser_test.rs.CHANGELOG.md: entry under[Unreleased] / Added.How to test
cargo test(seesynchronized_output_mode).printf '\033[?2026h'; sleep 1; printf 'partial'; printf '\033[?2026l'—partialdoes not appear until the reset; without the sequence it would appear immediately.Checks
.kimun.tomlfail_below = B); trend -0.02 at the Cognitive rounding floor from the render-gate early-return, partially offset by simplifying the DEC private-mode setter.Note / limitation
This implementation has no safety timeout: if a program sets
?2026hand never resets it, frames stay frozen until the next mode reset or RIS. Real applications reliably send?2026l; a timeout (e.g. ~150 ms) could be added as a follow-up if needed.