@jsvision/ui / RenderRoot
Interface: RenderRoot
Defined in: ui/src/view/render-root.ts:36
Mounts a view tree and renders it to a screen buffer. This is the seam a host (or the higher-level app shell / event loop) wires the terminal to.
Methods
buffer()
buffer():
ScreenBuffer
Defined in: ui/src/view/render-root.ts:53
The live composed screen buffer — for host integration and tests.
Returns
ScreenBuffer
flush()
flush():
void
Defined in: ui/src/view/render-root.ts:49
Force a synchronous frame now, running any pending scheduled repaint immediately.
Returns
void
mount()
mount(
root):void
Defined in: ui/src/view/render-root.ts:38
Mount a view tree: wire its scopes, run the first layout, and compose the first frame.
Parameters
root
Returns
void
originOf()
originOf(
view):Point|null
Defined in: ui/src/view/render-root.ts:64
The view's absolute top-left cell as of the last time it was composed, or null if it was never composed (unmounted / not visible). The event loop uses this to translate a focused view's desiredCaret() into an absolute terminal cell. An origin survives partial repaints — a view unchanged this frame keeps its last origin — so the caret is never lost just because the focused view was outside the changed region.
Parameters
view
The view to locate (typically the focused leaf).
Returns
Point | null
The absolute origin { x, y }, or null if never composed.
resize()
resize(
size):void
Defined in: ui/src/view/render-root.ts:47
Resize the viewport, triggering a full re-layout and recompose.
Parameters
size
Returns
void
serialize()
serialize():
string
Defined in: ui/src/view/render-root.ts:51
The last frame's damage-diff output (the escape sequences to apply); forces a flush if one is pending.
Returns
string
setRevealAccelerators()
setRevealAccelerators(
on,scope?):void
Defined in: ui/src/view/render-root.ts:75
Reveal (or hide) the hotkey-accelerator overlay for the next frame. While on, every widget that draws a ~X~ hotkey underlines its hot glyph. scope limits the reveal to a subtree (e.g. the active modal dialog); null/omitted reveals the whole tree. A change forces one coalesced full recompose on the next frame so the underlines appear/disappear together. Underlining does not change any cell width, so geometry never shifts.
Parameters
on
boolean
Whether the overlay is revealed.
scope?
View | null
The subtree to limit the reveal to, or null for the whole tree.
Returns
void
setTheme()
setTheme(
theme):void
Defined in: ui/src/view/render-root.ts:94
Replace the active theme and force one coalesced full recompose, so every view repaints with the new colors on the next frame. A theme swap changes no geometry, so origins are preserved and the caret is not lost. Under the event loop's no-op schedule this only marks the frame dirty — call it through EventLoop.setTheme (or flush() directly) to actually push the frame.
Parameters
theme
Theme
The theme to switch to.
Returns
void
Example
import { Group, createRenderRoot } from '@jsvision/ui';
import { resolveCapabilities, nordTheme } from '@jsvision/core';
const caps = resolveCapabilities({ env: {}, platform: 'linux' }).profile;
const renderRoot = createRenderRoot({ width: 40, height: 10 }, { caps });
renderRoot.mount(new Group());
renderRoot.setTheme(nordTheme);
renderRoot.flush(); // push the repainted frameunmount()
unmount():
void
Defined in: ui/src/view/render-root.ts:45
Unmount the mounted tree: dispose its reactive scope — which recursively disposes every descendant scope and runs their onCleanup — then drop the tree. Idempotent, and safe to call with nothing mounted. A host that detaches a still-live tree (the browser mountApp teardown) calls this so views release timers and subscriptions instead of leaking across a re-mount.
Returns
void