Skip to content

ScreenBuffer

Defined in: src/render/buffer.ts:169

The backend-neutral cell grid every widget paints into. A 2-D array of Cell (char + Style + optional icon/graphic). Drivers turn it into ANSI (terminal) or draw it (canvas). In a custom widget you mostly call setCell inside your region.

new ScreenBuffer(width?, height?): ScreenBuffer

Defined in: src/render/buffer.ts:203

number = 0

Width in cells.

number = 0

Height in cells.

ScreenBuffer

cells: Cell[][] = []

Defined in: src/render/buffer.ts:171

The grid, indexed cells[y][x].


containsGraphics: boolean = false

Defined in: src/render/buffer.ts:181

Set true by widgets that place an inline icon/graphic this frame. Terminal graphics are a separate, stateful layer (Kitty/iTerm/Sixel) that only the full-buffer diff clears/redraws correctly, so the app forces a full frame (not a damage-scoped partial repaint) whenever this is set.


currentClip: Region | null = null

Defined in: src/render/buffer.ts:174

Active clip rectangle; writes outside it are dropped (null = unclipped).


graphicSignature: number = 0

Defined in: src/render/buffer.ts:194

Order-independent hash of the cells that hold an inline graphic this frame. When it changes between full frames a graphic was added/moved/removed, so the app wipes all terminal graphics and re-emits — clearing any placement that was orphaned (scrolled, screen swapped) and that the per-cell diff alone can’t catch. Unchanged across frames → no wipe, so static graphics (and a breathing focus ring over them) never flicker.


height: number = 0

Defined in: src/render/buffer.ts:207

Height in cells.


width: number = 0

Defined in: src/render/buffer.ts:205

Width in cells.

blendRegion(region, src, alpha, base): void

Defined in: src/render/buffer.ts:325

Alpha-composite a translucent colour over every cell in region, in place. Each cell’s existing background and foreground are blended alpha of the way toward src, so the glyphs underneath stay visible but tinted — the basis for modal scrims, drop shadows, and translucent panels. Cells whose colour is default/unset blend against base (typically the theme bg/fg), since the real terminal default is unknowable. Glyphs are untouched.

Region

RGB

number

BlendBase

void


clear(yStart?, yEnd?): void

Defined in: src/render/buffer.ts:228

Reset cells in rows [yStart, yEnd) to a blank space with default style (whole grid by default).

number = 0

number = ...

void


copyTo(other, yStart?, yEnd?): void

Defined in: src/render/buffer.ts:841

Copy this buffer’s contents into other (resizing it to match). Restrict to rows [yStart, yEnd) for a partial-repaint frame — rows outside the damaged band are already identical in other, so copying them is wasted work.

ScreenBuffer

number = 0

number = ...

void


differsFrom(old, yStart?, yEnd?): boolean

Defined in: src/render/buffer.ts:650

Whether any cell in rows [yStart, yEnd) differs from old — a cheap change detector (early-exits, allocates nothing) for backends that re-present the cell grid rather than consuming the ANSI diff. The encoding-free half of the render path’s change detection.

ScreenBuffer

number = 0

number = ...

boolean


drawSegment(startX, startY, segment, clipRegion?): void

Defined in: src/render/buffer.ts:352

Draw a styled Segment starting at (startX, startY), advancing per grapheme width.

number

number

Segment

Region

void


noteGraphic(x, y): void

Defined in: src/render/buffer.ts:197

Record an inline graphic at (x, y) for damage/orphan tracking.

number

number

void


popClip(): void

Defined in: src/render/buffer.ts:255

Restore the clip rectangle saved by the matching pushClip.

void


pushClip(region): void

Defined in: src/render/buffer.ts:244

Push a clip rectangle (intersected with the current one); writes outside are ignored until popClip.

Region

void


renderDiff(oldBuffer, formatChar?, clipW?, clipH?, yStart?, allowScroll?, allowRepeat?): string

Defined in: src/render/buffer.ts:374

Diff against oldBuffer and return the ANSI to update only the changed cells (terminal backend).

ScreenBuffer

(cell, oldCell?) => string

number

number

number = 0

boolean = false

boolean = false

string


resize(width, height): void

Defined in: src/render/buffer.ts:213

Resize the grid, reallocating cells to blanks.

number

number

void


setCell(x, y, char, style): void

Defined in: src/render/buffer.ts:262

Write one styled character at (x, y). Out-of-bounds and clipped writes are ignored; wide glyphs occupy two cells.

number

number

string

Style

void


shiftRowsForScroll(top, bottom, delta): void

Defined in: src/render/buffer.ts:806

Mirror a terminal scroll on this buffer (used on the prev-frame buffer after emitting scrollRegionSeq): shift the band’s rows by delta and mark the revealed rows so the per-cell diff redraws exactly them. The revealed rows get a sentinel char (never equal to a real cell) rather than blanks, so the redraw is correct regardless of what fill colour SU/SD left behind.

number

number

number

void