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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ScreenBuffer(
width?,height?):ScreenBuffer
Defined in: src/render/buffer.ts:203
Parameters
Section titled “Parameters”width?
Section titled “width?”number = 0
Width in cells.
height?
Section titled “height?”number = 0
Height in cells.
Returns
Section titled “Returns”ScreenBuffer
Properties
Section titled “Properties”cells:
Cell[][] =[]
Defined in: src/render/buffer.ts:171
The grid, indexed cells[y][x].
containsGraphics
Section titled “containsGraphics”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
Section titled “currentClip”currentClip:
Region|null=null
Defined in: src/render/buffer.ts:174
Active clip rectangle; writes outside it are dropped (null = unclipped).
graphicSignature
Section titled “graphicSignature”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
Section titled “height”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.
Methods
Section titled “Methods”blendRegion()
Section titled “blendRegion()”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.
Parameters
Section titled “Parameters”region
Section titled “region”number
Returns
Section titled “Returns”void
clear()
Section titled “clear()”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).
Parameters
Section titled “Parameters”yStart?
Section titled “yStart?”number = 0
number = ...
Returns
Section titled “Returns”void
copyTo()
Section titled “copyTo()”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.
Parameters
Section titled “Parameters”ScreenBuffer
yStart?
Section titled “yStart?”number = 0
number = ...
Returns
Section titled “Returns”void
differsFrom()
Section titled “differsFrom()”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.
Parameters
Section titled “Parameters”ScreenBuffer
yStart?
Section titled “yStart?”number = 0
number = ...
Returns
Section titled “Returns”boolean
drawSegment()
Section titled “drawSegment()”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.
Parameters
Section titled “Parameters”startX
Section titled “startX”number
startY
Section titled “startY”number
segment
Section titled “segment”clipRegion?
Section titled “clipRegion?”Returns
Section titled “Returns”void
noteGraphic()
Section titled “noteGraphic()”noteGraphic(
x,y):void
Defined in: src/render/buffer.ts:197
Record an inline graphic at (x, y) for damage/orphan tracking.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
popClip()
Section titled “popClip()”popClip():
void
Defined in: src/render/buffer.ts:255
Restore the clip rectangle saved by the matching pushClip.
Returns
Section titled “Returns”void
pushClip()
Section titled “pushClip()”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.
Parameters
Section titled “Parameters”region
Section titled “region”Returns
Section titled “Returns”void
renderDiff()
Section titled “renderDiff()”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).
Parameters
Section titled “Parameters”oldBuffer
Section titled “oldBuffer”ScreenBuffer
formatChar?
Section titled “formatChar?”(cell, oldCell?) => string
clipW?
Section titled “clipW?”number
clipH?
Section titled “clipH?”number
yStart?
Section titled “yStart?”number = 0
allowScroll?
Section titled “allowScroll?”boolean = false
allowRepeat?
Section titled “allowRepeat?”boolean = false
Returns
Section titled “Returns”string
resize()
Section titled “resize()”resize(
width,height):void
Defined in: src/render/buffer.ts:213
Resize the grid, reallocating cells to blanks.
Parameters
Section titled “Parameters”number
height
Section titled “height”number
Returns
Section titled “Returns”void
setCell()
Section titled “setCell()”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.
Parameters
Section titled “Parameters”number
number
string
Returns
Section titled “Returns”void
shiftRowsForScroll()
Section titled “shiftRowsForScroll()”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.
Parameters
Section titled “Parameters”number
bottom
Section titled “bottom”number
number
Returns
Section titled “Returns”void