Surface class final

A Canvas draws on it; the Presenter compares its damaged spans with what the terminal shows, writes the difference, and clears the damage (clearDamage). Cells are indexed y * width + x.

final surface = Surface(10, 2);
final styles = StyleTable();
final pen = styles.pen(const Pen());
Canvas(surface, styles, GlyphTable()).text(0, 1, 'hi', pen);
print(surface.cells[1 * surface.width + 0] & kGlyphMask); // 104, 'h'
print(surface.dirtyHi[1]); // 10: every cell is damaged when made

Constructors

Surface(int width, int height)
A surface width x height cells, blank in style 0 and damaged whole.

Properties

cells → Uint32List
The glyph and flags of each cell, row after row: the glyph id (& kGlyphMask) with kWide, kCont, kUncertain or kSkip.
no setter
cells64 → Uint64List
cells seen two cells to a word, for fast scans.
no setter
dirtyHi → Int32List
The column after the last damaged one of each row (see dirtyLo).
no setter
dirtyLo → Int32List
The first damaged column of each row: the damage is [dirtyLo, dirtyHi), none when dirtyLo >= dirtyHi.
no setter
hashCode → int
The hash code for this object.
no setterinherited
height → int
How many rows tall the surface is; resize changes it.
no setter
images → List<ImagePlacement>
The images shown in reserved cells (Canvas.image), oldest first. They move with scrollRows and scrollRect (one the move cuts through is dropped), and go with resize and clear; the presenter drops one whose cells were drawn over.
final
pendingScrolls → List<int>
Moves recorded by scrollRows / scrollRect since the last present, as flat (top, bottom, n, x0, x1) tuples. The presenter replays them as hardware scrolls; if it can't, it re-diffs the moved rows instead.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
styles → Uint32List
The style id of each cell in a StyleTable, as cells is ordered.
no setter
styles64 → Uint64List
styles seen two cells to a word, for fast scans.
no setter
width → int
How many cells wide the surface is; resize changes it.
no setter

Methods

blit(Surface src, int sx, int sy, int w, int h, int dx, int dy) → void
Copies the rectangle of src at (sx, sy, w, h) to (dx, dy) of this surface (layer compositing). Wide glyphs cut by the rectangle edges are replaced by blanks. src may be this surface, rectangles overlapping: the source rectangle is then copied to a surface of its own first.
breakWideAt(int rowBase, int x) → int
Breaks the wide glyph that cell x (on the row starting at rowBase) is a half of, by blanking the other half. Returns the column of the modified partner, or -1.
clear([StyleId style = StyleId.base]) → void
Blank every cell with style and damage everything.
clearDamage() → void
Clears the damage of every row and forgets the recorded moves, as the presenter does once a frame is written.
keep(CellKeeper keeper) → void
Has a sweep mark what keeper keeps of the surface's cells, as it marks the surface's (Screen.sweepIfDue), until it is released.
markAllDirty() → void
Damages every cell, so the next present compares them all.
markCells(void glyph(int glyph), void style(StyleId style)) → void
Marks the glyph word and the style of every cell, its own and those its keepers keep (keep).
markDirty(int y, int x0, int x1) → void
Damages columns [x0, x1) of row y: the row's damage grows to span them and what it had.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
place(ImagePlacement p) → void
Adds p: one of images of the same image in the same cells takes in the cells p shows (an image painted piece by piece, as a scroll view paints the rows a scroll exposed), others it is drawn over go.
release(CellKeeper keeper) → void
Marks no more what keeper keeps (keep).
resize(int w, int h) → void
Makes the surface w x h cells, blank and damaged whole, with no moves or images; does nothing when that is its size.
scrollRect(int left, int right, int rowTop, int rowBottom, int n, [StyleId style = StyleId.base]) → void
Moves the content of the rectangle columns [left, right) x rows [rowTop, rowBottom) up by n rows (down when negative), like scrollRows but for a scroll view that doesn't span the whole width (a side panel, a list inside a border). Wide glyphs cut by the rectangle's left/right edges are broken (both halves blanked) first. The move is recorded; the presenter replays it with DECSLRM margins where the terminal has them.
scrollRows(int rowTop, int rowBottom, int n, [StyleId style = StyleId.base]) → void
Moves the content of rows [rowTop, rowBottom) up by n rows (down when negative); exposed rows become blank with style. This is how a scrolling view avoids repainting content that only moved: the damage moves with the rows, only the exposed rows are damaged, and the move is recorded so the presenter scrolls the terminal in hardware too.
toString() → String
A string representation of this object.
inherited

Operators

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