AnsiRenderer class final
Emits the minimum ANSI byte sequence required to update the terminal
from previous state to next state.
Stateless: the caller owns the previous-frame buffer. Each frame:
- Walk cell by cell, left to right, top to bottom.
- Skip cells that are identical to the previous frame.
- Skip continuation cells (they're emitted by their leading cell's grapheme advancing the terminal cursor by 2 columns).
- On a dirty cell, emit:
- A cursor position update if the terminal's cursor isn't already at this cell.
- A style delta if the style differs from what was last emitted.
- The cell's grapheme (or a space for
CellRole.empty).
- After the last cell, if any style was emitted, reset back to
default with
\x1B[0m.
Trust contract: this renderer writes cell graphemes verbatim. The
CellBuffer is the safety boundary; widget code must pass strings
through sanitizeForDisplay before they reach the buffer. The
renderer never inspects grapheme bytes for ESC or control characters.
Constructors
- AnsiRenderer({ColorMode colorMode = ColorMode.truecolor, bool synchronizedOutput = false, bool ambiguousCharsAreWide = true, bool hyperlinks = false})
-
colorModeis the terminal's detected fidelity; colors that exceed it are downsampled per quantizeColor (truecolor → 256 → 16 → none). Defaults to ColorMode.truecolor (no downsampling).const
Properties
- ambiguousCharsAreWide → bool
-
final
- colorMode → ColorMode
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hyperlinks → bool
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- synchronizedOutput → bool
-
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
renderDiff(
CellBuffer previous, CellBuffer next, AnsiSink sink, {CellRect? dirtyBounds, int? scrollUpRows, bool hasChanges = true, void onDirtyCell(int col, int row)?, String trailer = '', AnsiRenderTarget target = const AnsiRenderTarget.fullScreen()}) → void -
Writes the diff between
previousandnexttosink. -
renderFull(
CellBuffer buffer, AnsiSink sink, {AnsiRenderTarget target = const AnsiRenderTarget.fullScreen()}) → void -
Renders
bufferas a full frame (no previous state). Equivalent to diffing against an all-empty buffer of the same size. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited