Commit graph

8 commits

Author SHA256 Message Date
3021b14aac line-read: suggestions, keys for the caller, initial input; 0.1.2
#:suggester shows a suggestion after the input, dimmed, as fish does. Right,
C-f, End and C-e at the end accept it; M-f, C-Right and M-Right one word.
#:command-key? hands keys to the caller as (LineKey key input), with the
input erased. line-read and simulate-line take #:initial.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 13:07:56 +01:00
dc8a3325b8 line-read: a prompt may contain line breaks
- A line break in the prompt ends its row, as one in the input does. Each
  drawing goes up to the prompt's first row and draws it again; before,
  each key wrote the prompt's first line once more.
- The default continuation prompt is as wide as the prompt's last line.
- tests/prompt.bjo, under script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 11:47:24 +01:00
5a8a441cbc line-read: #:notices writes lines above the input
line-read calls the function every 200 ms while it waits for a key. The
lines it returns are written above the input, which is drawn again below
them. For a shell's "[1] Done" lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 09:50:09 +01:00
566008e264 line-read: draw input taller than the screen in part
- input-window chooses the rows to draw: the window stays while the
  cursor is in it and moves the least it must. A marker row at each end
  with hidden rows gives their count.
- The cursor can always go up to the first row drawn, so redrawing no
  longer leaves copies of the input in the scrollback.
- The accepted input is drawn whole.
- layout returns the text of each row.
- New tests: input-window in tests/line.bjo, and tests/tall.bjo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 21:35:16 +01:00
95d747cf70 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>
2026-11-30 21:24:16 +01:00
ce778f9b1e 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>
2026-11-30 21:05:59 +01:00
6863503fa7 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>
2026-11-30 20:49:26 +01:00
fe42387a4c 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>
2026-11-30 20:31:29 +01:00