Skip to content
docsv0.3.0

VirtualTerminalBufferInterface

An off-screen, fixed-size character grid that painted {@see TuiFrame}s are composited into, so a full retained-tree repaint can be diffed against the previously drawn buffer and only the changed rows written to the real terminal — the mechanism that makes retained-mode TUI rendering cheap enough to run every frame.

VirtualTerminalBufferInterface::width()

abstract public function width(): int

The buffer's fixed column count.

VirtualTerminalBufferInterface::height()

abstract public function height(): int

The buffer's fixed row count.

VirtualTerminalBufferInterface::writeFrame()

abstract public function writeFrame(Milpa\Live\ValueObjects\Tui\TuiBounds $bounds, Milpa\Live\ValueObjects\Tui\TuiFrame $frame): void

Composites `$frame` into this buffer at `$bounds`, overwriting the cells it covers. Implementations MUST clip silently: any part of `$frame` that falls outside this buffer's `[0, width) x [0, height)` extent is dropped rather than throwing.

Parameters

Parameters of writeFrame()
NameTypeDescription
$boundsMilpa\Live\ValueObjects\Tui\TuiBounds
$frameMilpa\Live\ValueObjects\Tui\TuiFrame

VirtualTerminalBufferInterface::lines()

abstract public function lines(): array

The buffer's current contents as one string per row.

VirtualTerminalBufferInterface::diff()

abstract public function diff(self $previous): Milpa\Live\ValueObjects\Tui\TuiBufferDiff

Compares this buffer's current contents against another buffer (typically the previous frame's buffer) and returns only the rows that differ, for a minimal-repaint terminal write. `self` here means "any implementation of this interface", not specifically the same concrete class — two different implementations MAY be diffed against each other as long as both answer {@see lines()}.

Parameters

Parameters of diff()
NameTypeDescription
$previousself