[Tui] Force full re-render on terminal resize#784
Open
ruttydm wants to merge 22 commits intofabpot:tuifrom
Open
[Tui] Force full re-render on terminal resize#784ruttydm wants to merge 22 commits intofabpot:tuifrom
ruttydm wants to merge 22 commits intofabpot:tuifrom
Conversation
Instead of adding a 'root' style class to the root widget (which could conflict with other widgets using the same class name), the root widget is now identified by the :root pseudo-class, matching CSS semantics. Changes: - AbstractWidget::getStateFlags() returns 'root' when the widget has no parent - StyleSheet::resolve() supports standalone :state selectors (e.g. :root) - Tui no longer adds the 'root' style class to the root container - Users should use ':root' instead of '.root' in their stylesheets
When the terminal is resized (SIGWINCH), the ScreenWriter's cached previousLines contain lines rendered at the old terminal width. A non-forced requestRender() performs differential rendering against these stale lines, producing visual glitches — misaligned borders, wrapped lines, and leftover characters. Pass force: true to requestRender() in the resize callback so the ScreenWriter resets its cache and performs a clean full render with the new terminal dimensions.
Author
|
Building a MIT coding agent using the TUI framework and came upon this resize issue. |
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.
When the terminal is resized (
SIGWINCH),requestRender()is called withoutforce: true. This means theScreenWriterperforms differential rendering against its cachedpreviousLines— but those lines were rendered at the old terminal width, so the diff is invalid.Symptoms:
Fix: Pass
force: truetorequestRender()in the resize callback, which callsscreenWriter->reset()and forces a clean full render with the new terminal dimensions.One-line change.