Viewport class

A clipped view into a rectangular region of a parent Buffer.

Implemented types
Available extensions

Constructors

Viewport(Buffer parent, Rect bounds)
Creates a viewport wrapping parent constrained to bounds.

Properties

activeClip → Rect
Returns the current active clip rectangle, defaulting to full buffer bounds if stack is empty.
no setteroverride
attributes ↔ Uint32List
Single unified data array for fg, bg, and modifiers. layout: fg, bg, mod, fg, bg, mod...
getter/setter pairoverride
bounds → Rect
The rectangular bounds within the parent buffer.
final
characters ↔ List<String>
Flat list of characters representing the grid.
getter/setter pairoverride
defaultBlend → bool
Whether cell attribute writes alpha-blend colors over existing cells when a per-call blend argument is omitted.
no setteroverride
effects → List<RegisteredEffect>
The list of terminal effects registered in this buffer.
no setteroverride
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 setteroverride
hasUnderlineColors → bool
Whether any cell in this buffer has a non-zero custom underline color.
no setteroverride
hasUris → bool
Whether any cell in this buffer has a non-null OSC 8 hyperlink URI.
no setteroverride
height ↔ int
The height of the buffer in rows.
getter/setter pairoverride
parent → Buffer
The underlying parent buffer.
final
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.
no setteroverride
width ↔ int
The width of the buffer in columns.
getter/setter pairoverride

Methods

addEffect(RegisteredEffect effect) → void
Adds a terminal effect to this buffer.
override
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).
override
clear() → void
Resets all cells in the buffer to transparent empty cells.
override
clearCellAuxRange(int start, int end) → void
Clears SGR 58 underline colors and OSC 8 URIs across [start, end).
override
clearMetadata() → void
Clears overlay metadata lists (effects, selectable regions, and scoped Kitty image registries) without clearing cell character/attribute arrays.
override
copyCellAuxAt(Buffer source, int dstIdx, int srcIdx) → void
Copies SGR 58 underline color and OSC 8 URI from source at srcIdx to dstIdx.
override
copyCellAuxRangeFrom(Buffer source, int dstStart, int srcStart, int count) → void
Copies [srcStart, srcStart + count) auxiliary attributes from source to [dstStart, dstStart + count).
override
drawCautionTape(Rect rect, int offsetX, int offsetY) → void
Draws a patterned caution tape in the specified rectangular bounds.
override
fillAttributes({String? char, int? fg, int? bg, int? modifiers, int? underlineColor, String? uri, bool? blend}) → void
Fills the entire buffer with the specified attributes.
override
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.
override
getBackground(int x, int y) → int
Gets the background color at (x, y). Returns 0 if coordinates are out of bounds.
override
getCharacter(int x, int y) → String
Gets the character at (x, y). Returns a space if coordinates are out of bounds.
override
getForeground(int x, int y) → int
Gets the foreground color at (x, y). Returns 0 if coordinates are out of bounds.
override
getModifiers(int x, int y) → int
Gets the modifiers at (x, y). Returns transparent if coordinates are out of bounds.
override
getUnderlineColor(int x, int y) → int
Gets the SGR 58 underline color at (x, y), or 0 when using the foreground color.
override
getUnderlineColorAt(int cellIdx) → int
Gets the SGR 58 underline color at flat index cellIdx (0 when unset).
override
getUri(int x, int y) → String?
Gets the OSC 8 hyperlink URI at (x, y), or null when no link is set.
override
getUriAt(int cellIdx) → String?
Gets the OSC 8 hyperlink URI at flat index cellIdx (null when unset).
override
isCellValid(int x, int y) → bool
Whether cell (x, y) is valid and inside the current active clip bounds.
override
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.
override
lookupKittyRegistry(int x, int y) → KittyImageRegistry
Resolves the active KittyImageRegistry covering (x, y), falling back to KittyImageRegistry.global outside scoped regions.
override
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.
override
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).
override
pushClip(Rect clipRect) → void
Pushes a new clip rectangle onto the stack, intersecting it with the current active clip.
override
registerKittyRegistry(Rect rect, KittyImageRegistry registry) → void
Registers a pane-scoped KittyImageRegistry for cells within bounds.
override
registerSelectableRegion(Rect region, {int zIndex = 0}) → void
Registers a selectable rectangular region in buffer coordinates with optional zIndex.
override
resize(int newWidth, int newHeight) → void
Resizes the buffer to the new dimensions, preserving existing content where it fits.
override
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).
override
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.
override
setBackground(int x, int y, int bg) → void
Sets background color at coordinates.
override
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.
override
setCharacter(int x, int y, String char) → void
Sets character at coordinates.
override
setForeground(int x, int y, int fg) → void
Sets foreground color at coordinates.
override
setModifiers(int x, int y, int mod) → void
Sets modifiers at coordinates.
override
setUnderlineColor(int x, int y, int ulColor) → void
Sets the SGR 58 underline color at (x, y) (0 resets to default foreground).
override
setUnderlineColorAt(int cellIdx, int ulColor) → void
Sets the SGR 58 underline color at flat index cellIdx.
override
setUri(int x, int y, String? uri) → void
Sets the OSC 8 hyperlink URI at (x, y) (null clears the link).
override
setUriAt(int cellIdx, String? uri) → void
Sets the OSC 8 hyperlink URI at flat index cellIdx.
override
sliceUnderlineColors(int start, int end) → Uint32List?
Copies non-empty SGR 58 underline colors across [start, end), or null if all 0.
override
sliceUris(int start, int end) → List<String?>?
Copies non-empty OSC 8 URIs across [start, end), or null if all null.
override
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).
override
writeString(int x, int y, String text, Style style) → void
Writes styled text to the buffer starting at (x, y).
override

Operators

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