Class CellGrid
CPU-side grid manager for text mode cells. Stores a flat row-major array of Cell structs and tracks dirty regions for efficient partial GPU upload via CellBufferRenderer.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public class CellGrid
Constructors
CellGrid(int, int, Color32, Color32)
Creates a new cell grid with the specified dimensions.
Declaration
public CellGrid(int rows, int columns, Color32 defaultFG, Color32 defaultBG)
Parameters
| Type | Name | Description |
|---|---|---|
| int | rows | Number of rows. |
| int | columns | Number of columns. |
| Color32 | defaultFG | Default foreground color for new cells. |
| Color32 | defaultBG | Default background color for new cells. |
Properties
CellCount
Gets the total number of cells in the grid.
Declaration
public int CellCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Cells
Gets the underlying cell array for direct GPU upload.
Declaration
public Cell[] Cells { get; }
Property Value
| Type | Description |
|---|---|
| Cell[] |
Columns
Gets the number of columns in the grid.
Declaration
public int Columns { get; }
Property Value
| Type | Description |
|---|---|
| int |
DefaultBG
Gets the default background color for new cells.
Declaration
public Color32 DefaultBG { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
DefaultFG
Gets the default foreground color for new cells.
Declaration
public Color32 DefaultFG { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
DirtyRangeMax
Gets the maximum flat index of the dirty range (inclusive).
Declaration
public int DirtyRangeMax { get; }
Property Value
| Type | Description |
|---|---|
| int |
DirtyRangeMin
Gets the minimum flat index of the dirty range (inclusive).
Declaration
public int DirtyRangeMin { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsDirty
Gets whether any cells have been modified since the last upload.
Declaration
public bool IsDirty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Rows
Gets the number of rows in the grid.
Declaration
public int Rows { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Clear()
Clears all cells to the default foreground/background colors with space characters.
Declaration
public void Clear()
ClearDirty()
Resets the dirty state after a GPU upload.
Declaration
public void ClearDirty()
ClearRegion(int, int, int, int)
Clears a rectangular region of the grid.
Declaration
public void ClearRegion(int startRow, int startCol, int regionRows, int regionCols)
Parameters
| Type | Name | Description |
|---|---|---|
| int | startRow | Starting row (inclusive). |
| int | startCol | Starting column (inclusive). |
| int | regionRows | Number of rows to clear. |
| int | regionCols | Number of columns to clear. |
DeleteChars(int, int, int)
Deletes characters at the specified position, shifting subsequent characters left. Blank characters appear at the right edge.
Declaration
public void DeleteChars(int row, int col, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row index. |
| int | col | Column from which to delete. |
| int | count | Number of characters to delete. |
DeleteLines(int, int, int, int)
Deletes lines starting at the specified row, shifting subsequent rows up. New blank lines appear at the scroll bottom.
Declaration
public void DeleteLines(int row, int count, int scrollTop, int scrollBottom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row from which to delete. |
| int | count | Number of lines to delete. |
| int | scrollTop | Top of scroll region. |
| int | scrollBottom | Bottom of scroll region. |
EraseDisplay(int, int, int)
Erases cells in the display according to the erase mode.
Declaration
public void EraseDisplay(int cursorRow, int cursorCol, int mode)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cursorRow | Current cursor row. |
| int | cursorCol | Current cursor column. |
| int | mode | Erase mode: 0=cursor to end, 1=start to cursor, 2=entire display. |
EraseLine(int, int, int)
Erases cells in the specified row according to the erase mode.
Declaration
public void EraseLine(int row, int col, int mode)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row index. |
| int | col | Current cursor column. |
| int | mode | Erase mode: 0=cursor to end, 1=start to cursor, 2=entire line. |
Fill(int, int, int, int, uint, Color32, Color32, CellAttributes)
Fills a rectangular region with the specified character and colors.
Declaration
public void Fill(int startRow, int startCol, int regionRows, int regionCols, uint codepoint, Color32 fg, Color32 bg, CellAttributes attributes = CellAttributes.None)
Parameters
| Type | Name | Description |
|---|---|---|
| int | startRow | Starting row (inclusive). |
| int | startCol | Starting column (inclusive). |
| int | regionRows | Number of rows to fill. |
| int | regionCols | Number of columns to fill. |
| uint | codepoint | Unicode codepoint to fill with. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
| CellAttributes | attributes | Cell attributes. |
GetCell(int, int)
Gets a reference to the cell at the specified position.
Declaration
public Cell GetCell(int row, int col)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row index. |
| int | col | Column index. |
Returns
| Type | Description |
|---|---|
| Cell | The cell at the specified position, or a default cell if out of bounds. |
GetCellRef(int)
Gets a reference to the cell at the specified flat index.
Declaration
public ref Cell GetCellRef(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Flat array index. |
Returns
| Type | Description |
|---|---|
| Cell | Reference to the cell. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when index is outside the valid range. |
GetDirtyRange()
Gets the dirty range as a tuple of (startIndex, count) suitable for partial buffer upload.
Declaration
public (int Start, int Count) GetDirtyRange()
Returns
| Type | Description |
|---|---|
| (int Start, int Count) | Tuple of start index and element count, or (0, 0) if not dirty. |
InsertChars(int, int, int)
Inserts blank characters at the specified position, shifting existing characters right. Characters pushed past the right edge are discarded.
Declaration
public void InsertChars(int row, int col, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row index. |
| int | col | Column at which to insert. |
| int | count | Number of characters to insert. |
InsertLines(int, int, int, int)
Inserts blank lines at the specified row, shifting subsequent rows down. Rows that fall below the scroll bottom are discarded.
Declaration
public void InsertLines(int row, int count, int scrollTop, int scrollBottom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row at which to insert. |
| int | count | Number of lines to insert. |
| int | scrollTop | Top of scroll region. |
| int | scrollBottom | Bottom of scroll region. |
IsRowDirty(int)
Checks whether a specific row is dirty.
Declaration
public bool IsRowDirty(int row)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row index. |
Returns
| Type | Description |
|---|---|
| bool | True if the row has been modified. |
MarkAllDirty()
Marks all rows as dirty, forcing a full GPU upload.
Declaration
public void MarkAllDirty()
MarkRowDirty(int)
Marks a specific row as dirty.
Declaration
public void MarkRowDirty(int row)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row index to mark dirty. |
Resize(int, int)
Resizes the grid to new dimensions, preserving as much content as possible.
Declaration
public void Resize(int newRows, int newColumns)
Parameters
| Type | Name | Description |
|---|---|---|
| int | newRows | New number of rows. |
| int | newColumns | New number of columns. |
ScrollDown(int, int)
Scrolls the grid content down by one line within the scroll region, clearing the top row.
Declaration
public void ScrollDown(int scrollTop, int scrollBottom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | scrollTop | Top row of the scroll region (inclusive). |
| int | scrollBottom | Bottom row of the scroll region (inclusive). |
ScrollUp(int, int)
Scrolls the grid content up by one line, clearing the bottom row. Returns the scrolled-off top row for scrollback buffer storage.
Declaration
public Cell[] ScrollUp(int scrollTop, int scrollBottom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | scrollTop | Top row of the scroll region (inclusive). |
| int | scrollBottom | Bottom row of the scroll region (inclusive). |
Returns
| Type | Description |
|---|---|
| Cell[] | Copy of the scrolled-off top row cells. |
SetCell(int, int, uint, Color32, Color32, CellAttributes)
Sets the cell at the specified grid position.
Declaration
public void SetCell(int row, int col, uint codepoint, Color32 fg, Color32 bg, CellAttributes attributes = CellAttributes.None)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row index (0-based, top to bottom). |
| int | col | Column index (0-based, left to right). |
| uint | codepoint | Unicode codepoint to display. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
| CellAttributes | attributes | Cell style attributes. |
SetCellStamped(int, int, uint, uint, uint, uint, uint, Color32, Color32, CellAttributes)
Sets a cell with pre-stamped atlas data (used internally by GlyphAtlasCache).
Declaration
public void SetCellStamped(int row, int col, uint codepoint, uint atlasUV, uint metrics, uint atlasRect, uint metricsWH, Color32 fg, Color32 bg, CellAttributes attributes = CellAttributes.None)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row index. |
| int | col | Column index. |
| uint | codepoint | Unicode codepoint. |
| uint | atlasUV | Pre-packed atlas UV origin. |
| uint | metrics | Pre-packed glyph bearings (2x half16). |
| uint | atlasRect | Pre-packed atlas rect UV size (2x half16). |
| uint | metricsWH | Pre-packed glyph metrics width/height (2x half16). |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
| CellAttributes | attributes | Cell style attributes. |
SetDefaultColors(Color32, Color32)
Sets the default colors used when clearing cells.
Declaration
public void SetDefaultColors(Color32 fg, Color32 bg)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | fg | Default foreground color. |
| Color32 | bg | Default background color. |