Async line-read, and the decoder and text handling in Bjolang

- read-event, line-read and the editor loop work in both colours. The
  leaf is read-bytes, a defbjouble: a bjoroutine awaits the glue's read,
  other code blocks. with-raw-mode takes a body of either colour.
- Cancelling the scope of a waiting line-read ends it and restores the
  terminal modes. The glue runs reads one at a time.
- The key decoder is (bjoterm keys), and widths, prompt escapes, search
  and common prefixes are (bjoterm text). Clusters and categories come
  from (std unicode grapheme) and (std unicode chars).
- Keys.cs and Text.cs are removed. The glue is termios, signals, poll
  and read.
- New tests: tests/async.bjo and tests/text.bjo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-11-30 21:05:59 +01:00
parent 6863503fa7
commit ce778f9b1e
11 changed files with 970 additions and 733 deletions

View file

@ -21,11 +21,19 @@ Examples:
## This package
- `bjo build` builds the library and the glue in `glue/`.
- Keep logic in Bjolang. The glue is for what Bjolang cannot call: termios,
signals and `poll`/`read`. For Unicode, use `(std unicode ...)`.
- Modules: `(bjoterm keys)` decodes input, `(bjoterm text)` measures text,
`(bjoterm terminal)` reads events and has the escape sequences,
`(bjoterm line)` is the line editor.
- `bjo test` runs the tests:
- `tests/keys.bjo`: the decoder, from bytes.
- `tests/line.bjo`: the line editor's keys, history and completion,
through `simulate-line`, without a terminal.
- `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/async.bjo`: `line-read` in a bjoroutine, and cancelled by a
deadline.
- `examples/keys.bjo` prints events; `examples/repl.bjo` is a small REPL.
- `plan.org` has the decisions and the phases.