Buffer class

A 2D grid of cell data stored in parallel flat lists.

Implementers
Available extensions

Constructors

Buffer(int width, int height, {bool defaultBlend = true})
Creates a new buffer of width by height initialized with transparent empty cell data.
Buffer.blank(int width, int height, {bool defaultBlend = true})
Creates a new buffer of width by height initialized with solid blank cell data.

Properties

activeClip → Rect
Returns the current active clip rectangle, defaulting to full buffer bounds if stack is empty.
no setter
attributes ↔ Uint32List
Single unified data array for fg, bg, and modifiers. layout: fg, bg, mod, fg, bg, mod...
getter/setter pair
characters ↔ List<String>
Flat list of characters representing the grid.
getter/setter pair
defaultBlend → bool
Whether cell attribute writes alpha-blend colors over existing cells when a per-call blend argument is omitted.
final
effects → List<RegisteredEffect>
The list of terminal effects registered in this buffer.
final
hashCode → int
The hash code for this object.
no setterinherited
hasKittyImages → bool
Whether any Kitty image is registered in KittyImageRegistry.global or a scoped registry attached to this buffer.
no setter
hasUnderlineColors → bool
Whether any cell in this buffer has a non-zero custom underline color.
no setter
hasUris → bool
Whether any cell in this buffer has a non-null OSC 8 hyperlink URI.
no setter
height ↔ int
The height of the buffer in rows.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectableRegions → List<Rect>
Selectable sub-regions registered during the current paint pass.
final
width ↔ int
The width of the buffer in columns.
getter/setter pair

Methods

addEffect(RegisteredEffect effect) → void
Adds a terminal effect to this buffer.
cellsEqual(int x, int y, Buffer other, int ox, int oy) → bool
Whether all cell channels (char, fg, bg, modifiers, underlineColor, uri) at (x, y) match other at (ox, oy).
clear() → void
Resets all cells in the buffer to transparent empty cells.
clearCellAuxRange(int start, int end) → void
Clears SGR 58 underline colors and OSC 8 URIs across [start, end).
clearMetadata() → void
Clears overlay metadata lists (effects, selectable regions, and scoped Kitty image registries) without clearing cell character/attribute arrays.
copyCellAuxAt(Buffer source, int dstIdx, int srcIdx) → void
Copies SGR 58 underline color and OSC 8 URI from source at srcIdx to dstIdx.
copyCellAuxRangeFrom(Buffer source, int dstStart, int srcStart, int count) → void
Copies [srcStart, srcStart + count) auxiliary attributes from source to [dstStart, dstStart + count).
drawCautionTape(Rect rect, int offsetX, int offsetY) → void
Draws a patterned caution tape in the specified rectangular bounds.
fillAttributes({String? char, int? fg, int? bg, int? modifiers, int? underlineColor, String? uri, bool? blend}) → void
Fills the entire buffer with the specified attributes.
fillBackgroundStyle(Rect bounds, Style style, BlendOption blend) → void

Available on Buffer, provided by the EffectHelpers extension

Fills the background style of all cells in bounds using blend.
fillForegroundStyle(Rect bounds, Style style, BlendOption blend) → void

Available on Buffer, provided by the EffectHelpers extension

Fills the foreground style of all cells in bounds using blend.
fillRect(Rect rect, {String? char, int? fg, int? bg, int? modifiers, int? underlineColor, String? uri, bool? blend}) → void
Fills a rectangular region with the given character and attributes.
getBackground(int x, int y) → int
Gets the background color at (x, y). Returns 0 if coordinates are out of bounds.
getCharacter(int x, int y) → String
Gets the character at (x, y). Returns a space if coordinates are out of bounds.
getForeground(int x, int y) → int
Gets the foreground color at (x, y). Returns 0 if coordinates are out of bounds.
getModifiers(int x, int y) → int
Gets the modifiers at (x, y). Returns transparent if coordinates are out of bounds.
getUnderlineColor(int x, int y) → int
Gets the SGR 58 underline color at (x, y), or 0 when using the foreground color.
getUnderlineColorAt(int cellIdx) → int
Gets the SGR 58 underline color at flat index cellIdx (0 when unset).
getUri(int x, int y) → String?
Gets the OSC 8 hyperlink URI at (x, y), or null when no link is set.
getUriAt(int cellIdx) → String?
Gets the OSC 8 hyperlink URI at flat index cellIdx (null when unset).
isCellValid(int x, int y) → bool
Whether cell (x, y) is valid and inside the current active clip bounds.
lookupKittyImage(int x, int y, int imageId) → KittyImageData?
Looks up imageId using any scoped KittyImageRegistry covering (x, y), falling back to KittyImageRegistry.global only outside scoped regions.
lookupKittyRegistry(int x, int y) → KittyImageRegistry
Resolves the active KittyImageRegistry covering (x, y), falling back to KittyImageRegistry.global outside scoped regions.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
popClip() → void
Pops the most recently pushed clip rectangle from the stack.
propagateMetadataFrom(Buffer source, {int dx = 0, int dy = 0, Rect? clip, int? zIndex}) → void
Propagates region metadata (effects, selectableRegions, and scoped KittyImageRegistry bounds) from source translated by (dx, dy) and clipped to clip (or activeClip).
pushClip(Rect clipRect) → void
Pushes a new clip rectangle onto the stack, intersecting it with the current active clip.
registerKittyRegistry(Rect bounds, KittyImageRegistry registry) → void
Registers a pane-scoped KittyImageRegistry for cells within bounds.
registerSelectableRegion(Rect region, {int zIndex = 0}) → void
Registers a selectable rectangular region in buffer coordinates with optional zIndex.
resize(int newWidth, int newHeight) → void
Resizes the buffer to the new dimensions, preserving existing content where it fits.
rotateColumn(Rect bounds, int colIndex, int amount) → void

Available on Buffer, provided by the EffectHelpers extension

Rotates a specific column within the given bounds by amount downward.
rotateRow(Rect bounds, int rowIndex, int amount) → void

Available on Buffer, provided by the EffectHelpers extension

Rotates a specific row within the given bounds by amount rightward.
selectableRegionZIndexAt(int index) → int
Layer z-index recorded for selectableRegions[index] (0 by default).
setAttributes(int x, int y, {String? char, int? fg, int? bg, int? modifiers, int? underlineColor, String? uri, bool? blend}) → void
Sets the cell attributes at (x, y). Does nothing if coordinates are out of bounds.
setBackground(int x, int y, int bg) → void
Sets background color at coordinates.
setCell(int x, int y, String char, int fg, int bg, int mod, {bool? blend, int underlineColor = 0, String? uri}) → void
Sets character, colors, and modifiers at coordinates.
setCharacter(int x, int y, String char) → void
Sets character at coordinates.
setForeground(int x, int y, int fg) → void
Sets foreground color at coordinates.
setModifiers(int x, int y, int mod) → void
Sets modifiers at coordinates.
setUnderlineColor(int x, int y, int ulColor) → void
Sets the SGR 58 underline color at (x, y) (0 resets to default foreground).
setUnderlineColorAt(int cellIdx, int ulColor) → void
Sets the SGR 58 underline color at flat index cellIdx.
setUri(int x, int y, String? uri) → void
Sets the OSC 8 hyperlink URI at (x, y) (null clears the link).
setUriAt(int cellIdx, String? uri) → void
Sets the OSC 8 hyperlink URI at flat index cellIdx.
sliceUnderlineColors(int start, int end) → Uint32List?
Copies non-empty SGR 58 underline colors across [start, end), or null if all 0.
sliceUris(int start, int end) → List<String?>?
Copies non-empty OSC 8 URIs across [start, end), or null if all null.
toAnsiString({bool trimTrailingSpaces = true, bool resetLineEndings = false}) → String

Available on Buffer, provided by the BufferAnsiSerialization extension

Serializes this Buffer grid into an ANSI escape sequence string.
toString() → String
A string representation of this object.
inherited
writeCellAuxSlices(int dstStart, int count, {Uint32List? underlineColors, List<String?>? uris}) → void
Writes optional underlineColors and uris slices into [dstStart, dstStart + count).
writeString(int x, int y, String text, Style style) → void
Writes styled text to the buffer starting at (x, y).

Operators

operator ==(Object other) → bool
The equality operator.
inherited