Skip to content

ScreenBuffer ​

Category: Terminal

Source: screen_buffer.dart

Classes ​

Cell ​

A single cell in the virtual terminal grid.

Constructor ​

dart
Cell(this.char, {this.style})

Properties ​

PropertyTypeDescription
charString
styleAnsiStyle?
operatorbool
hashCodeint get
hashCodeint get

ScreenBuffer ​

Virtual terminal buffer with diff-based rendering.

Maintains a double-buffered grid of [Cell]s. On each [flush], only cells that differ from the previous frame are written to the real terminal, eliminating flicker.

Constructor ​

dart
ScreenBuffer(this._terminal)

Properties ​

PropertyTypeDescription
widthint getCurrent buffer width.
heightint getCurrent buffer height.
widthint getCurrent buffer width.
heightint getCurrent buffer height.

Methods ​

void writeAt(int row, int col, String text, {AnsiStyle? style}) ​

Write [text] into the buffer at ([row], [col]) without touching the real terminal. An optional [style] is applied to every character.

void fillRow(int row, String text, {AnsiStyle? style, int startCol = 0}) ​

Fill an entire [row] starting at [startCol] with [text], padding with spaces to the right edge.

void clear() ​

Clear the current buffer (fill with spaces).

void flush() ​

Flush only changed cells to the real terminal.

This is the key to flicker-free rendering: we compare each cell against the previous frame and only emit ANSI sequences for cells that differ.

void resize(int width, int height) ​

Handle a terminal resize.

Released under the MIT License.