Termisu::Testing::Screen
Inherits Reference / Object
A minimal terminal emulator: feed it the byte stream a Termisu program writes
and it maintains a 2D grid of Termisu::Cell plus a cursor, so tests can
assert on what's rendered (get_by_text, cursor, to_s snapshot).
Scope: it decodes the subset Termisu emits (absolute cursor positioning,
erase, SGR colors/attrs, printable text with wide-char placement) and
recognizes-and-skips the rest (DEC private modes, mouse, kitty, OSC). It is
NOT a full VT525 — it does not implement scroll regions, tab stops, or insert
mode, which Termisu never emits. The grapheme/width logic reuses
Termisu::UnicodeWidth so columns match the program's own cursor tracking.
#feed is incremental and keeps parser state across calls, so PTY reads that
split an escape sequence mid-stream are handled correctly.
Constructors
Instance methods
Feed a chunk of output bytes. Safe to call repeatedly with partial data.
True if pattern appears anywhere on screen (row-wise match).
First {x, y} where pattern starts, or nil. x is the cell column of the
match start. Crystal string offsets are character-based, but a row may hold
wide (2-column) glyphs, so we map the matched character index back to its
column via row_columns rather than returning the offset directly.
The visible text of row y (continuation cells contribute nothing).
Whole screen as text, one row per line (trailing blanks stripped per line).
A deterministic snapshot capturing the glyph grid AND per-cell style (fg/bg/attr), run-length compressed — richer than glyph-only snapshots, so color/attribute regressions are caught. mask blanks volatile regions (matched against each row's text) at the cell level, so animated screens snapshot deterministically.