A terminal (TUI) rendering target for Fulcro.
Fulcro normally renders through React to the browser DOM. This namespace provides an alternative
rendering target that lays out a tree of terminal-native nodes (boxes, text, inputs, buttons) and
paints them into a character cell buffer for display via a JLine terminal (see
com.fulcrologic.fulcro.tui.terminal).
The UI is described as a tree of nodes. A node is a plain map of the form:
{:com.fulcrologic.fulcro.tui/tag :vbox ; one of `tags`
:com.fulcrologic.fulcro.tui/attrs {...} ; layout/style/event attributes
:com.fulcrologic.fulcro.tui/children [...]} ; child nodes, strings, and numbers
Use the element generators (vbox, hbox, box, text, input, button, line, viewport)
to build the tree rather than constructing the maps by hand.
A terminal (TUI) rendering target for Fulcro.
Fulcro normally renders through React to the browser DOM. This namespace provides an alternative
rendering target that lays out a tree of terminal-native nodes (boxes, text, inputs, buttons) and
paints them into a character cell buffer for display via a JLine terminal (see
`com.fulcrologic.fulcro.tui.terminal`).
The UI is described as a tree of *nodes*. A node is a plain map of the form:
```
{:com.fulcrologic.fulcro.tui/tag :vbox ; one of `tags`
:com.fulcrologic.fulcro.tui/attrs {...} ; layout/style/event attributes
:com.fulcrologic.fulcro.tui/children [...]} ; child nodes, strings, and numbers
```
Use the element generators (`vbox`, `hbox`, `box`, `text`, `input`, `button`, `line`, `viewport`)
to build the tree rather than constructing the maps by hand.The side-effecting driver for the TUI rendering target: it renders a Fulcro app to a terminal and runs the input loop.
This is the edge that ties together the pure TUI pipeline in com.fulcrologic.fulcro.tui (layout,
paint, diff, focus, input) with a concrete com.fulcrologic.fulcro.tui.terminal/Terminal. Use
application to build a synchronous raw Fulcro app whose renders repaint the terminal, mount!
(or run!) to attach a terminal and start the keyboard input loop, and step! to drive a single
deterministic iteration (used by tests).
State/runtime keys (single source of truth):
com.fulcrologic.fulcro.tui (see that ns).::terminal, ::prev-buffer, ::placed,
::last-size).This is JVM/babashka only (plain .clj).
Viewport scrolling: tui/place lays a viewport's single child out at its natural size into a
virtual rect, and tui/render-buffer blits only the window [scroll-x scroll-y w h] of that
virtual content into the viewport's ::rect. Scroll offsets are stored in the state-map under
:com.fulcrologic.fulcro.tui/scroll keyed by viewport id; render! injects them onto the placed
tree (inject-scroll), follow-focus! advances them after focus changes to keep the focused node
visible, and PageUp/PageDown page-scroll via viewport-scroll-key!. Up/Down arrows move focus
item-to-item (in tui/process-key!) and follow-focus! autoscrolls to track the focused item.
The side-effecting *driver* for the TUI rendering target: it renders a Fulcro app to a terminal
and runs the input loop.
This is the edge that ties together the pure TUI pipeline in `com.fulcrologic.fulcro.tui` (layout,
paint, diff, focus, input) with a concrete `com.fulcrologic.fulcro.tui.terminal/Terminal`. Use
`application` to build a synchronous raw Fulcro app whose renders repaint the terminal, `mount!`
(or `run!`) to attach a terminal and start the keyboard input loop, and `step!` to drive a single
deterministic iteration (used by tests).
State/runtime keys (single source of truth):
* Focus & carets & scroll are owned by `com.fulcrologic.fulcro.tui` (see that ns).
* The attached terminal and the bookkeeping for incremental painting live in the app
RUNTIME-ATOM under this namespace's keys (see `::terminal`, `::prev-buffer`, `::placed`,
`::last-size`).
This is JVM/babashka only (plain `.clj`).
Viewport scrolling: `tui/place` lays a viewport's single child out at its natural size into a
virtual rect, and `tui/render-buffer` blits only the window `[scroll-x scroll-y w h]` of that
virtual content into the viewport's `::rect`. Scroll offsets are stored in the state-map under
`:com.fulcrologic.fulcro.tui/scroll` keyed by viewport id; `render!` injects them onto the placed
tree (`inject-scroll`), `follow-focus!` advances them after focus changes to keep the focused node
visible, and PageUp/PageDown page-scroll via `viewport-scroll-key!`. Up/Down arrows move focus
item-to-item (in `tui/process-key!`) and `follow-focus!` autoscrolls to track the focused item.A self-contained terminal abstraction for a TUI rendering target.
This namespace OWNS the normalized key-event model that downstream TUI code consumes, a pure
(JLine-free) key decoder, a Terminal protocol, a real JLine-backed implementation, and an
atom-backed fake (string-terminal) used for tests.
This is JVM/babashka only (plain .clj).
A self-contained terminal abstraction for a TUI rendering target. This namespace OWNS the normalized key-event model that downstream TUI code consumes, a pure (JLine-free) key decoder, a `Terminal` protocol, a real JLine-backed implementation, and an atom-backed fake (`string-terminal`) used for tests. This is JVM/babashka only (plain `.clj`).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |