bjoterm: raw mode, key events and escape sequences

- (bjoterm terminal): terminal-open, with-raw-mode, terminal-size,
  terminal-suspend, read-event and read-event/timeout, and escape
  sequences for the cursor, clearing, the alternate screen, bracketed
  paste and styles. Linux only.
- glue/Tty.cs: termios, poll on fd 0, SIGWINCH, SIGCONT, SIGTSTP, and
  restoring the modes at SIGTERM, SIGHUP, SIGQUIT and process exit.
- glue/Keys.cs: the decoder of CSI and SS3 keys with modifiers, Alt,
  UTF-8 and bracketed paste.
- Tests: the decoder from bytes, and raw mode on a pseudo-terminal under
  script. plan.org has the decisions and the phases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-11-30 20:31:29 +01:00
commit fe42387a4c
12 changed files with 1830 additions and 0 deletions

26
AGENTS.md Normal file
View file

@ -0,0 +1,26 @@
## Comment Style
Write plain, direct engineering comments. Do **not** imitate the overly literary
or cryptic comment style found in some older files in this repo.
- **Use standard terms:** "returns" (not "answers"), "rejects/errors" (not "refuses"),
"resolves/looks up" (not "names/spells"), "traverses" (not "walks").
- **Name concepts directly:** Say "trait constraints" instead of "what the code around it asks".
- **Use normal sentences with verbs:** Start docstrings with a verb ("Checks whether...",
"Returns...", "Resolves...") rather than cryptic noun fragments.
- **Keep it short:** 1–2 sentences for most functions. Only add more to explain a
non-obvious invariant or edge case. Skip comments that just restate the code.
Examples:
- Bad: `/// Several answers as one: refused if any refuses, held if all hold, and otherwise not known yet.`
- Good: `/// Combines tri-state results: Some false if any failed, Some true if all passed, else None.`
- Bad: `/// What a file is called, worked out from where it is.`
- Good: `/// Module identity derived from a file's path on disk.`
## This package
- `bjo build` builds the library and the glue in `glue/`.
- `bjo test` runs `tests/keys.bjo` (the decoder, from bytes) and
`tests/terminal.bjo` (raw mode on a pseudo-terminal, under `script`).
- `plan.org` has the decisions and the phases.