Skip to content

@jsvision/ui / createRenderRoot

Function: createRenderRoot()

createRenderRoot(size, opts): RenderRoot

Defined in: ui/src/view/render-root.ts:473

Create a render root over a size-cell buffer, ready to mount and render a view tree.

Parameters

size

Size2D

The viewport size in cells.

opts

RenderRootOptions

Required caps (the terminal capability profile) plus optional theme, schedule, and logger — see RenderRootOptions.

Returns

RenderRoot

A RenderRoot; call mount(root) then read serialize()/buffer().

Example

ts
import { Group, View, createRenderRoot } from '@jsvision/ui';
import { resolveCapabilities } from '@jsvision/core';

const caps = resolveCapabilities({ env: {}, platform: 'linux' }).profile;
const root = new Group();
root.background = 'desktop';
// ...root.add(...) your widgets...

const render = createRenderRoot({ width: 80, height: 24 }, { caps });
render.mount(root);       // lays out + composes the first frame
const bytes = render.serialize(); // the escape sequences to write to the terminal