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
|
|
@ -216,4 +216,16 @@
|
|||
(expect "a history file that does not exist is empty"
|
||||
(line-history-load! (make-line-editor) (path-combine (temp-dir) "bjoterm-no-such-history.txt"))
|
||||
(Ok unit))
|
||||
|
||||
;; Reflow: where the cursor is after a terminal that reflows narrows.
|
||||
(expect "rows that still fit move nothing" (cursor-row-after-reflow [[1 1 1] [1 1]] 1 2 10) 1)
|
||||
(expect "a row above that wraps moves the cursor down"
|
||||
(cursor-row-after-reflow [[1 1 1 1 1 1] [1 1]] 1 1 4) 2)
|
||||
(expect "every row above counts" (cursor-row-after-reflow [[1 1 1 1 1] [1 1 1 1 1] [1]] 2 0 2) 6)
|
||||
(expect "the cursor's own row wraps before it" (cursor-row-after-reflow [[1 1 1 1 1 1]] 0 5 4) 1)
|
||||
(expect "but not after it" (cursor-row-after-reflow [[1 1 1 1 1 1]] 0 2 4) 0)
|
||||
(expect "a cursor after a full row is on the next" (cursor-row-after-reflow [[1 1 1 1]] 0 4 4) 1)
|
||||
(expect "a wide item that does not fit goes to the next row"
|
||||
(cursor-row-after-reflow [[1 1 1 2] [1]] 1 0 4) 2)
|
||||
(expect "an empty row is one row" (cursor-row-after-reflow [[] [] [1]] 2 1 4) 2)
|
||||
(println "line ok"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue