Skip to content
docsv0.3.0

RetainedTuiRenderer

Turns a node tree into a filled {@see VirtualTerminalBuffer}: lays the tree out, resolves a renderer per node, and composites each frame at its bounds.

RetainedTuiRenderer::__construct()

public function __construct(Milpa\Live\Contracts\Tui\TuiLayoutEngineInterface $layout, Milpa\Live\Contracts\Tui\TuiNodeRendererRegistryInterface $renderers):

Parameters

Parameters of __construct()
NameTypeDescription
$layoutMilpa\Live\Contracts\Tui\TuiLayoutEngineInterface
$renderersMilpa\Live\Contracts\Tui\TuiNodeRendererRegistryInterface

RetainedTuiRenderer::render()

public function render(Milpa\Live\ValueObjects\Tui\TuiNode $root, int $width, int $height, ?string $focusedId = null): Milpa\Live\Tui\VirtualTerminalBuffer

Lays out the tree and composites every node's frame into a buffer of the given size, marking the focused node as focused.

Parameters

Parameters of render()
NameTypeDescription
$rootMilpa\Live\ValueObjects\Tui\TuiNode
$widthint
$heightint
$focusedId?string

RetainedTuiRenderer::caretPosition()

public function caretPosition(Milpa\Live\ValueObjects\Tui\TuiNode $root, int $width, int $height, ?string $focusedId = null): ?array

Returns the absolute terminal cell of the text caret for the focused node, or `null` when the focused node's renderer does not implement {@see FocusableInterface} or has no caret to position. This walks the same layout frame {@see render()} produces, finds the focused node, resolves its renderer, and — when the renderer is `FocusableInterface` — re-renders the node's frame (cheap; one node) and asks the renderer where its caret sits inside that frame. The caret's `[row, col]` is then offset by the node's layout bounds to get the absolute terminal cell the hardware cursor should move to for IME candidate-window tracking. This is outside {@see render()} because the cell-addressed {@see VirtualTerminalBuffer} cannot represent the zero-width {@see FocusableInterface::CURSOR_MARKER} APC — the marker has to be read straight from the renderer's frame, not from the buffer.

Parameters

Parameters of caretPosition()
NameTypeDescription
$rootMilpa\Live\ValueObjects\Tui\TuiNode
$widthint
$heightint
$focusedId?string

Returns

`[row, col]` zero-indexed absolute terminal cell, or null.