PUBLIC MODULE · lib/gtui/gtui.js

GTUI

GTUI public façade for synchronous terminal applications.

GTUI owns view geometry, rendering, terminal controls, selection, editing, and key decoding. Applications own semantic policy and conversation state; TUI turn lifecycle remains in lib/tui-app/. Hosts provide terminal I/O and receive rendered scenes and effects. Interactive input, including key events, is applied immediately; background frames are not used to delay input. GTUI is not a web-app abstraction.

view = freeze({…}) constant

Immutable constructors for renderable view nodes.

effect = freeze({…}) constant

Immutable constructors for host, task, timer, theme, and lifecycle effects.

event = freeze({…}) constant

Immutable constructors for messages delivered to an application update function.

memory({ width = 80, height = 24, scrollBar } = {…}) function

Create an in-memory host for application tests. It records rendered semantics and effects; it never emits terminal bytes.

Returns object — host implementing the GTUI host protocol

terminal(options = {…}) function

Construct a terminal host that owns input decoding and terminal rendering.

[options] object
terminal streams, mode, dimensions, and policies

Returns object — opaque GTUI host

class GTUI class

Run a synchronous application against a GTUI host. The application supplies init, update, view, and optional bindings/dispose; update transitions may return effects. GTUI applies messages, renders views, and manages host/task/timer cleanup.

constructor({ host, theme = {…} } = {…}) constructor

Create a runtime for a host.

dispatch(message) method

Deliver one message immediately to the running application.

stop(reason = "stop", code = 0) method

Stop the application, canceling tasks and timers and restoring the host.

run(app) method

Start an application and return its eventual completion result.

host = freeze({ memory, terminal }) constant

Host constructors for tests and terminal execution.

scrollGlyph(value, fallback) function

Return a one-cell grapheme or the supplied fallback.