Buffer class

Native OpenTUI cell grid borrowed from a Renderer.

Each cell stores a character, packed RGBA foreground and background, and a u32 attribute word. Widgets do not paint through this type; they record into a PaintingContext. Obtain a buffer from Renderer.nextBuffer only on the advanced package:noir/noir_low_level.dart path.

Lifecycle: the instance is valid until the next Renderer.render or until the owner is disposed. Later operations throw StateError. Coordinates and extents must fit unsigned 32-bit ABI values.

Example:

final buffer = renderer.nextBuffer;

buffer.clear(Color.rgb(0.1, 0.13, 0.17));
buffer.drawBox(5, 2, 30, 15,
    BoxOptions(title: 'Settings'),
    Color.cyan, Color.darkGray);
buffer.drawText('Welcome to OpenTUI!', 10, 5, Color.white);
buffer.fillRect(10, 8, 20, 1, Color.green);

Properties

hashCode int
The hash code for this object.
no setterinherited
height int
Height of the buffer in terminal rows.
no setter
isInvalidated bool
Whether this buffer has been invalidated.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
width int
Width of the buffer in terminal columns.
no setter

Methods

clear(Color bg) → void
Clears the entire buffer to a uniform background color.
clipped({required int clipX, required int clipY, required int clipWidth, required int clipHeight}) Buffer
Returns a Buffer view that silently drops draw calls outside the rectangle (clipX, clipY, clipWidth, clipHeight). The view shares the underlying FFI buffer and validity state; invalidating the parent also invalidates every clipped view. Used by scrolling/clipping containers (e.g. ScrollBox).
drawBox(int x, int y, int width, int height, BoxOptions options, Color borderColor, Color backgroundColor) → void
Draws a bordered rectangle with optional titles and fill.
drawFrameBuffer(Buffer sourceBuffer, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY) → void
Draw another buffer onto this buffer (compositing).
drawImage(TerminalImage image, {required int x, required int y, required int width, required int height, int pixelWidth = 0, int pixelHeight = 0, int sourceX = 0, int sourceY = 0, int? sourceWidth, int? sourceHeight, ImageProtocol protocol = ImageProtocol.auto, int? clipX, int? clipY, int? clipWidth, int? clipHeight}) bool
Draws image into a terminal-cell rectangle.
drawText(String text, int x, int y, Color fg, {Color? bg, int attributes = 0}) → void
Draws text at the specified position with styling options.
fillRect(int x, int y, int width, int height, Color color) → void
Fills a rectangular region with solid background color.
getDirectAccess() DirectBufferAccess
Get direct access to internal arrays for performance-critical operations.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resize(int newWidth, int newHeight) → void
Resizes the buffer to newWidth by newHeight terminal cells.
setCell(int x, int y, String char, Color fg, Color bg, int attributes) → void
Sets a single cell at (x, y) using alpha blending.
setCellWithAlphaBlending(int x, int y, String char, Color fg, Color bg, int attributes) → void
Sets a cell at (x, y) with full alpha-blending support.
toString() String
A string representation of this object.
inherited

Operators

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