line-read: redraw correctly after a terminal reflows
- Each row of the input ends with a line break, so only a narrowing terminal that reflows moves the cursor. The layout keeps the widths of the items on each row, and cursor-row-after-reflow computes the cursor's row after the terminal wraps each row again. - terminal-reflows? guesses from the environment. An unknown terminal counts as not reflowing. #:reflow? of make-line-editor overrides it. - New tests: the model in tests/line.bjo, and tests/reflow.bjo, which narrows the terminal with stty under script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ce778f9b1e
commit
95d747cf70
6 changed files with 226 additions and 13 deletions
17
plan.org
17
plan.org
|
|
@ -39,7 +39,22 @@ is in raw mode, and gives it back as it found it.
|
|||
- Each key is a pure step from one state to the next (~line-step~), so
|
||||
~simulate-line~ tests the keys without a terminal.
|
||||
- History files have one entry per line, with "\n" and "\\" escaped.
|
||||
- Not done: redrawing after a terminal reflows lines when it narrows.
|
||||
- Reflow (2026-11-30): each row of the input ends with a line break, so
|
||||
widening changes nothing, and a terminal that does not reflow (xterm)
|
||||
keeps the rows as drawn. A terminal that reflows wraps each row again
|
||||
when it narrows. The editor keeps the widths of the items on each row,
|
||||
and when the width is less than at the last drawing it computes the
|
||||
cursor's row after the wrap (~cursor-row-after-reflow~).
|
||||
- Whether the terminal reflows is a guess from the environment
|
||||
(~terminal-reflows?~); ~#:reflow?~ of ~make-line-editor~ overrides it.
|
||||
An unknown terminal counts as not reflowing: a wrong #f leaves a copy
|
||||
of the input, a wrong #t erases output above it.
|
||||
- Several resizes before one redraw give the same result as one, as
|
||||
the terminal joins its own wraps again.
|
||||
- Not done: input taller than the screen after a reflow. The rows above
|
||||
the top are in the scrollback, and the cursor cannot go up to them.
|
||||
- Tested with ~script~, which does not reflow: the test checks the
|
||||
escape sequences. Not yet tried on a terminal that reflows.
|
||||
|
||||
*Async, and less C# (2026-11-30).*
|
||||
- ~read-event~ and everything above it work in both colours. The one leaf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue