Expand description
facett-console (§8 TYPE-3, interactive) — a themed terminal/shell
component: a fixed monospace cell grid, a block/beam cursor, optional
ANSI colour mapped to the palette, scrollback on the CygnusEd
smooth-scroll engine (§11), plus the real terminal gestures — command
entry, history recall, scrolling, and per-line selection. A [Facet]:
themeable · resizable · scalable · copyable · pasteable · searchable ·
selectable.
§FC contract (the canonical Elm split, FC-2 / FC-9)
ConsoleModel— the complete observable, serializable, round-trippable state: the scrollback (each line carrying a stable id, FC-5), the prompt + in-progress input, the smooth-scroll offset, the command history, and the selected line.Console::statehands back a&ConsoleModel.Msg+Console::update— the single mutation path (FC-2): every gesture (type / backspace / submit / history / scroll / select / filter) and every host push flow through it, so a headless driver (facett_core::harness) reaches the identical transitions the canvas does.Console::view— a pure paint (FC-9): it reads&self, paints the scrollback + prompt, and returns theMsgs the interactions produced; theimpl_facet_via_elm!bridge applies them.Effect::RunCommand— side work as data (FC-8): submitting a line echoes it and asks the host to run the command. The console performs no I/O itself; it hands the command back and the host feeds output viaMsg::PushLine.- Rich
state_json— the observablelinesis published as a count (not the raw span array) and the scroll offset/extent as flat keys, so the macro is invoked in form 3 (custom_state_json) to preserve those exact keys.
Structs§
- Console
- The console / shell component.
- Console
Model - The complete observable state (FC-1 / FC-3) of a
Console, in one serializable, round-trippable struct. - Line
- One scrollback line: its stable id (FC-5) plus the ANSI-parsed coloured runs.
- Span
- A coloured run of text within a console line, with a palette-role colour.
Enums§
- Ansi
Color - The 8 ANSI colours, mapped to palette roles (not raw RGB) so the terminal follows the theme.
- Cursor
- Cursor shape (TYPE-3).
- Effect
- Side work as data (FC-8). The console does one thing it cannot do itself —
run a submitted command — so it hands it back as an
Effect::RunCommandfor the host to execute (the host then streams output back viaMsg::PushLine). No I/O is performed insideConsole::update. - Msg
- A robot-/CLI-addressable control message (FC-2) — the named boundary a headless
driver (or the host, or a canvas gesture) drives the console through. Applied by
Console::update, which is the only legal way to mutate theConsoleModel.
Functions§
- parse_
ansi - Parse a line containing ANSI SGR colour escapes into coloured
Spans. Only the foreground-colour subset is handled (others are stripped); enough to make CLI output match the palette.
Type Aliases§
- LineId
- A stable, monotonic scrollback-line id (FC-5): assigned once when a line is appended, it survives ring eviction and is never an index — selection and per-line interaction key on this, so evicting the oldest line does not silently re-target a selection onto a different line.