Repository navigation
Tui: re-measure the terminal on SIGWINCH, not on a timer - #62
Merged
Merged
Conversation
The app loop spawned `stty size` (6-15 ms) every 500 ms while idle to notice window resizes. It now measures once at start and again only after a SIGWINCH. `ResizeWatch` sets up a repeating `Std.Async.Signal.Waiter`; each signal sets a flag, and the loop reads and clears it each turn, so a burst of signals is one re-measure. The waiter is armed before the first measure, so a resize in between is not lost. Nothing blocks a thread: each round registers a callback on the signal's task. If the handler cannot be set up, the loop polls every 500 ms as before; with a fixed size there is no watch at all. Raw mode still uses `stty`, twice per run: Lean has no termios API (requested in leanprover/lean4#16868), noted in a comment. tui_spec has a resize group that sends SIGWINCH to its own process: reported, cleared on take, reported again, and a burst is one re-measure. The headless Tui.Test harness is unchanged. Driven in a pty, tui_mouse repaints at the new size after TIOCSWINSZ and exits cleanly on Ctrl+C.
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 idle, the TUI loop spawned
stty sizeevery 500 ms to notice window resizes. Each spawn costs 6–15 ms. With this change it measures the terminal once at start, and again only after aSIGWINCH.Change
ResizeWatch(inLeanTea/Tui/App.lean) sets up a repeatingStd.Async.Signal.Waiterfor.sigwinch. Each signal sets a flag, and the loop reads and clears it each turn. A burst of signals therefore causes only one re-measure.width/heightthere's no watch at all.stty, twice per run, because Lean has no termios API. It is requested upstream in Terminal raw mode and window size for IO.FS.Handle / stdin leanprover/lean4#16868, and a comment says so.Tests
tui_spec(73 passed) has a new "following resizes" group. It sendsSIGWINCHto its own process and checks four things:takeclears it;Tui.Testharness is unchanged; its existingSession.resizetests still pass.tui_mousein a pty, changed the size withTIOCSWINSZfrom 60×20 to 120×30, and: