ElementHost
The DSL's render-and-dispatch engine, with no loop and no key policy of its own.
TuiApp is this class plus opinions: Tab and Shift+Tab move focus, Ctrl+P opens the command palette, Ctrl+C quits, screens stack, toasts expire, a splash plays first. A host that already owns a loop — an application built around its own TerminalRunner, or one embedding a glyphora panel in a loop it did not write — constructs an ElementHost instead: it calls render once per frame and a dispatch* method per event, and decides for itself what the keys none of them consumed should mean.
What it does own is the part that would otherwise have to be rewritten: resolving the responsive view for the size actually being painted, reconciling focus across frames (so the highlight follows the element and not the screen position), decorating the tree with the focus cue, and routing keys, mouse events and pastes to the element that is on screen rather than to a freshly evaluated tree. The same session also owns hook identity and drains portals after ordinary painting. A portal escapes its containers, but never the host's render area intersected with the destination buffer. Hooks survive until they are unvisited in a frame, the host is discarded, or reset is called. Scheduling, reactive scope disposal and caller-owned resources remain the embedding loop's responsibility.
'''Ownership and threads.''' One instance belongs to one loop. Every method must be called on that loop's render thread: the instance holds the focus bookkeeping and the decorated tree of the last frame, and neither is synchronised. Nothing here schedules a frame — a host that changes something redraws when it decides to.
'''Focus changes take effect on the next frame.''' Events are routed against the tree the last render painted, which is the tree the person at the terminal is actually looking at. So focusNext, focusToKey and clearFocus change where focus will be, and the next render is what makes the following key go somewhere else. In a loop that redraws after handling an event — which is every loop — that is invisible; it is written down because a test that dispatches twice with no frame in between would otherwise be puzzling.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
How the element declared with .key(key) is announced on the last frame: its Element.accessibleName followed by the interaction states that hold — button Save, disabled, input, focused. This is the text a status line, an announcement region or a test reads to tell a screen-reader user what the cursor is on; colour alone (the dimmed disabled style, the reversed focus cue) announces nothing. None when no node on the last frame carried the key. Render-thread only.
How the element declared with .key(key) is announced on the last frame: its Element.accessibleName followed by the interaction states that hold — button Save, disabled, input, focused. This is the text a status line, an announcement region or a test reads to tell a screen-reader user what the cursor is on; colour alone (the dimmed disabled style, the reversed focus cue) announces nothing. None when no node on the last frame carried the key. Render-thread only.
Attributes
The rect the element declared with .key(key) was painted into on the last render, in the coordinates of the buffer that frame was drawn into and mapped out of any scroll view it sits in — so a test can click its centre without knowing the layout. None when no node on the last frame carried the key, when it was scrolled entirely out of view, or when recording was off for that frame.
The rect the element declared with .key(key) was painted into on the last render, in the coordinates of the buffer that frame was drawn into and mapped out of any scroll view it sits in — so a test can click its centre without knowing the layout. None when no node on the last frame carried the key, when it was scrolled entirely out of view, or when recording was off for that frame.
Asking is the opt-in: a call on a host that was not recording switches recordBounds on, so the next frame answers. Safe to call from another thread once that thread has observed the frame as drawn — the answer is a read of the last published frame, not of the paint in progress.
Attributes
Abandons pointer gestures and capture after terminal focus loss. Embedding loops call this on focus loss too. Returns whether a gesture or interaction cue was visible. Render-thread only.
Abandons pointer gestures and capture after terminal focus loss. Embedding loops call this on focus loss too. Returns whether a gesture or interaction cue was visible. Render-thread only.
Attributes
Takes focus off everything. Until focus moves again no element renders focused and every key comes straight back out of dispatchKey as unconsumed.
Takes focus off everything. Until focus moves again no element renders focused and every key comes straight back out of dispatchKey as unconsumed.
Attributes
Drops the mouse selection; true when one was showing, so a frame is owed.
Drops the mouse selection; true when one was showing, so a frame is owed.
Attributes
Copies the current mouse selection into the app clipboard — what Ctrl+Shift+C does in a TuiApp. false when nothing is selected. Outside an app's dispatch the clipboard is the in-memory one of this thread.
Copies the current mouse selection into the app clipboard — what Ctrl+Shift+C does in a TuiApp. false when nothing is selected. Outside an app's dispatch the clipboard is the in-memory one of this thread.
Attributes
Delivers a key to the focused element and the ancestors it bubbles through — after the capture phase, which offers it to the few nodes that take keys whatever holds focus (see Element.captureKeyHandler).
Delivers a key to the focused element and the ancestors it bubbles through — after the capture phase, which offers it to the few nodes that take keys whatever holds focus (see Element.captureKeyHandler).
false means nothing on screen consumed it and the decision is the host's. Unclaimed arrows rove within a focus group and Shift+arrows select text. It does not traverse Tab stops or quit: those belong to the loop — call focusNext or focusPrevious from your own key handling if you want the usual meaning.
Attributes
Offers a key release to the focused element and its ancestors — see EventRouter.dispatchKeyRelease.
Offers a key release to the focused element and its ancestors — see EventRouter.dispatchKeyRelease.
Attributes
Hit-tests the pointer, moves focus if a press landed inside a different focusable, then routes the event to the element under it. true when focus moved, an element consumed the event, or the hovered or pressed target changed while the frame draws a .hoverStyle/.pressedStyle cue (so the next frame looks different).
Hit-tests the pointer, moves focus if a press landed inside a different focusable, then routes the event to the element under it. true when focus moved, an element consumed the event, or the hovered or pressed target changed while the frame draws a .hoverStyle/.pressedStyle cue (so the next frame looks different).
On the way it synthesises the event's clickCount and applies pointer capture — see PointerCapture: while a consumed press holds the pointer, drags and the release go to the pressed target wherever they land. A pointer gesture runs over the routing — see PointerGestures: a press no element consumed on selectable text starts a selection, and while one is being dragged out its drags and release go to it, not to the elements.
Attributes
Delivers a bracketed-paste payload to the focused element. false when nothing took it.
Delivers a bracketed-paste payload to the focused element. false when nothing took it.
Attributes
Records painted rects from the next frame on, for boundsOf and the gestures that hit-test against them: of every keyed node, container, input target and node with a pointer role, and of every node under a click-outside backdrop — not of unkeyed leaves, which nothing but the element-tree snapshot and the inspector asks about (see enableFullBoundsRecording). Stays on for the life of the host; a call to boundsOf does the same.
Records painted rects from the next frame on, for boundsOf and the gestures that hit-test against them: of every keyed node, container, input target and node with a pointer role, and of every node under a click-outside backdrop — not of unkeyed leaves, which nothing but the element-tree snapshot and the inspector asks about (see enableFullBoundsRecording). Stays on for the life of the host; a call to boundsOf does the same.
Attributes
Records the painted rect of every node from the next frame on — what ElementTreeSnapshot and the inspector read for an unkeyed leaf. Costs a wrapper per node per frame, where enableBoundsRecording costs one only for the nodes a reader can ask about.
Records the painted rect of every node from the next frame on — what ElementTreeSnapshot and the inspector read for an unkeyed leaf. Costs a wrapper per node per frame, where enableBoundsRecording costs one only for the nodes a reader can ask about.
Attributes
Moves focus to the nearest focusable painted in direction from the focused one — spatial navigation, which TuiApp binds to Alt+arrows when spatialNavigation is on. true when focus moved; takes effect next frame.
Moves focus to the nearest focusable painted in direction from the focused one — spatial navigation, which TuiApp binds to Alt+arrows when spatialNavigation is on. true when focus moved; takes effect next frame.
Attributes
Moves focus to the next focusable in tab order, wrapping at the end. true when it moved.
Moves focus to the next focusable in tab order, wrapping at the end. true when it moved.
Attributes
Moves focus to the previous focusable in tab order, wrapping at the start. true when it moved.
Moves focus to the previous focusable in tab order, wrapping at the start. true when it moved.
Attributes
Moves focus to the element carrying key — the string an element was given by .key("email"). false when no element on the last frame had it, in which case focus stays where it was.
Moves focus to the element carrying key — the string an element was given by .key("email"). false when no element on the last frame had it, in which case focus stays where it was.
Attributes
The focusKey of the focused element as of the last render: None when that element has no key, when nothing is focused, or before the first frame.
The focusKey of the focused element as of the last render: None when that element has no key, when nothing is focused, or before the first frame.
Attributes
The image protocol the terminal draws pictures with, or None for the half-block fallback. While it is set, a pixelImage has its picture encoded for it on a worker (Async) and shows the fallback until the payload is ready, so no frame pays for an encode. TuiApp sets it from what the terminal answered at start-up; a host that owns its loop sets it from ImageProtocol.select(backend.capabilities). Render-thread only.
The image protocol the terminal draws pictures with, or None for the half-block fallback. While it is set, a pixelImage has its picture encoded for it on a worker (Async) and shows the fallback until the payload is ready, so no frame pays for an encode. TuiApp sets it from what the terminal answered at start-up; a host that owns its loop sets it from ImageProtocol.select(backend.capabilities). Render-thread only.
Attributes
The mouse pointer the last frame wants shown at position — see EventRouter.pointerShapeAt. A host that owns its own loop hands the answer to Backend.setPointerShape when it changes; TuiApp does so on every mouse event.
The mouse pointer the last frame wants shown at position — see EventRouter.pointerShapeAt. A host that owns its own loop hands the answer to Backend.setPointerShape when it changes; TuiApp does so on every mouse event.
Attributes
Whether a widget state painted on the last frame — a TextInputState, a ListState, any io.worxbend.tui.core.Versioned state a node was handed — has been mutated since that frame. When one has, the view the last render evaluated is invalidated through its ReactiveScope, exactly as a Signal write would invalidate it, and this answers true.
Whether a widget state painted on the last frame — a TextInputState, a ListState, any io.worxbend.tui.core.Versioned state a node was handed — has been mutated since that frame. When one has, the view the last render evaluated is invalidated through its ReactiveScope, exactly as a Signal write would invalidate it, and this answers true.
TuiApp asks once per loop iteration, which is why a background result written into a state on the render thread shows without a requestRedraw(). A host that owns its loop asks the same way, after running queued work and before deciding whether to draw. Render-thread-only.
Attributes
Whether this host records painted rects — see enableBoundsRecording.
Resolves view for an area of this size, reconciles focus, decorates the tree with theme's focus cue and paints it into buffer.
Resolves view for an area of this size, reconciles focus, decorates the tree with theme's focus cue and paints it into buffer.
The decorated tree is kept, because the dispatch* methods below route against what is actually on screen. Call this before dispatching anything: with no frame rendered yet there is no tree, and every dispatch answers false.
Attributes
Retires this mount's hooks, focus history and dispatch tree. The next render starts a fresh mount. Call only between frames on the owning thread. Caller-owned state, subscriptions and resources are not closed: the embedding loop owns its ReactiveScope and must dispose it separately.
Retires this mount's hooks, focus history and dispatch tree. The next render starts a fresh mount. Call only between frames on the owning thread. Caller-owned state, subscriptions and resources are not closed: the embedding loop owns its ReactiveScope and must dispose it separately.
Attributes
Whether a mouse drag over text, markdown, log and the tables selects their text, highlighted in the theme's focus cue and copied through the app clipboard on release — see TextSelection. Off by default: without mouse capture the terminal selects natively. TuiApp turns it on exactly when it runs with RunnerConfig.mouseCapture; a host that owns its loop and captures the mouse turns it on itself. Render-thread only.
Whether a mouse drag over text, markdown, log and the tables selects their text, highlighted in the theme's focus cue and copied through the app clipboard on release — see TextSelection. Off by default: without mouse capture the terminal selects natively. TuiApp turns it on exactly when it runs with RunnerConfig.mouseCapture; a host that owns its loop and captures the mouse turns it on itself. Render-thread only.
Attributes
Whether the last frame contained a node that only shows under all-motion tracking — a .hoverStyle, or an explicit .pointer(shape). A host that owns its loop and sees this turn true asks its backend for MouseCaptureMode.AllMotion; TuiApp does so by itself when it runs with mouse capture on.
Whether the last frame contained a node that only shows under all-motion tracking — a .hoverStyle, or an explicit .pointer(shape). A host that owns its loop and sees this turn true asks its backend for MouseCaptureMode.AllMotion; TuiApp does so by itself when it runs with mouse capture on.