A 2D grid of Tuix.Cells representing one terminal frame.
The grid is row-oriented and sparse: rows maps a row index to a map of
column index to cell, and rows or cells that were never written are blank.
Row orientation lets frame diffing skip unchanged rows with a single term
comparison, which is the common case for incremental updates.
Coordinates are 0-based with {0, 0} at the top-left.
Summary
Functions
Returns the cell at {x, y}, or a blank cell if unset.
Fills a {x, y, w, h} rectangle with a cell.
Returns the display width of a grapheme (1 or 2 columns).
Creates an empty buffer of the given size.
Puts a cell at {x, y}. Out-of-bounds writes are ignored.
Writes count copies of a single-width grapheme horizontally starting at
{x, y}, clipped to clip. Faster than put_text/6 with a duplicated
string: the cell is built once and stamped per column.
Writes a single-line string starting at {x, y}, clipped to clip
(a {cx, cy, cw, ch} rectangle). Handles wide graphemes: a 2-column
grapheme occupies its cell plus a :continuation cell.
Returns row y as a sparse column map, or nil if the row is blank.
Returns the display width of a full string.
Renders the buffer to a plain-text string (no styling), one line per row, with trailing whitespace trimmed. Useful for tests.
Types
@type row() :: %{required(non_neg_integer()) => Tuix.Cell.t()}
@type t() :: %Tuix.Buffer{ height: non_neg_integer(), rows: %{required(non_neg_integer()) => row()}, width: non_neg_integer() }
Functions
@spec at(t(), non_neg_integer(), non_neg_integer()) :: Tuix.Cell.t()
Returns the cell at {x, y}, or a blank cell if unset.
@spec fill(t(), tuple(), Tuix.Cell.t()) :: t()
Fills a {x, y, w, h} rectangle with a cell.
@spec grapheme_width(String.t()) :: 1 | 2
Returns the display width of a grapheme (1 or 2 columns).
@spec new(non_neg_integer(), non_neg_integer()) :: t()
Creates an empty buffer of the given size.
@spec put(t(), integer(), integer(), Tuix.Cell.t()) :: t()
Puts a cell at {x, y}. Out-of-bounds writes are ignored.
@spec put_repeat( t(), integer(), integer(), String.t(), non_neg_integer(), keyword(), tuple() | nil ) :: t()
Writes count copies of a single-width grapheme horizontally starting at
{x, y}, clipped to clip. Faster than put_text/6 with a duplicated
string: the cell is built once and stamped per column.
Writes a single-line string starting at {x, y}, clipped to clip
(a {cx, cy, cw, ch} rectangle). Handles wide graphemes: a 2-column
grapheme occupies its cell plus a :continuation cell.
@spec row(t(), non_neg_integer()) :: row() | nil
Returns row y as a sparse column map, or nil if the row is blank.
@spec text_width(String.t()) :: non_neg_integer()
Returns the display width of a full string.
Renders the buffer to a plain-text string (no styling), one line per row, with trailing whitespace trimmed. Useful for tests.