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:
Linus Björnstam 2026-11-30 21:24:16 +01:00
parent ce778f9b1e
commit 95d747cf70
6 changed files with 226 additions and 13 deletions

View file

@ -33,6 +33,8 @@ Examples:
- `tests/terminal.bjo` and `tests/line-terminal.bjo`: raw mode and
`line-read` on a pseudo-terminal, under `script`.
- `tests/text.bjo`: clusters and widths.
- `tests/reflow.bjo`: the redraw after the terminal narrows, with and
without reflow, under `script`.
- `tests/async.bjo`: `line-read` in a bjoroutine, and cancelled by a
deadline.
- `examples/keys.bjo` prints events; `examples/repl.bjo` is a small REPL.