bjoterm: the line editor, (bjoterm line)
- line-read with the keys of Emacs and readline: moving by character, word and line, a kill buffer, history with C-r search, Tab completion through #:completer, and input of several lines with #:input-done?. - Grapheme clusters and display widths in glue/Text.cs: the editor moves and deletes by cluster, and wraps lines by width. - Each key is a pure step, so tests/line.bjo runs the keys without a terminal through simulate-line. tests/line-terminal.bjo runs line-read on a pseudo-terminal. - History files, line-history-save and line-history-load!. - examples/repl.bjo: a small REPL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fe42387a4c
commit
6863503fa7
7 changed files with 1235 additions and 2 deletions
19
plan.org
19
plan.org
|
|
@ -23,6 +23,25 @@ is in raw mode, and gives it back as it found it.
|
|||
- Under ~script~, a child that stops makes ~script~ stop itself; the test
|
||||
of stop and continue sends SIGCONT to both.
|
||||
|
||||
*Phase 2 implemented (2026-11-30): (bjoterm line).*
|
||||
- ~line-read~ returns ~(LineText text)~, ~LineEof~ or ~LineCancelled~.
|
||||
Options of ~make-line-editor~: ~#:completer~, ~#:input-done?~,
|
||||
~#:history-size~; of ~line-read~: ~#:continuation~.
|
||||
- The keys are those of Emacs and readline, listed at ~line-read~. Up and
|
||||
Down move between the lines of the input, and reach the history only
|
||||
on its first and last line.
|
||||
- The buffer is a vector of grapheme clusters (glue/Text.cs). Widths
|
||||
follow ~wcwidth~ with a table of wide ranges; a C0 control shows as
|
||||
~^X~, a tab as spaces to the next multiple of 8.
|
||||
- The editor breaks lines itself: a line break where the next cluster does
|
||||
not fit, and after a line that ends at the edge. The whole input is
|
||||
drawn again after each key, from the prompt's row.
|
||||
- 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: an async ~line-read~ for a fiber (it is ~#:sync~), and
|
||||
redrawing after a terminal reflows lines when it narrows.
|
||||
|
||||
* Decisions
|
||||
|
||||
1. *Linux only, for now.* The termios layout, ~TIOCGWINSZ~ and the flag
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue