Skip to content
ConsoleMonster

API Reference

Class

CellBuffer

Namespace ConsoleMonster.Canvas
Assembly ConsoleMonster
Modifiers sealed
Attributes
DefaultMember("Item")

A grid of Cell values: the frame every widget renders into. Writing keeps wide graphemes consistent (a wide grapheme that would be split by the right edge or overwritten by half is replaced by blanks). Not thread-safe: a buffer belongs to one render pass.

Inheritance

  • Object
  • CellBuffer

Usage

Explore 32 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 20

Constructors

public CellBuffer(Int32 width, Int32 height) #

Creates a blank buffer.

Parameters

width System.Int32 requiredposition: 0
Width in cells (at least 0).
height System.Int32 requiredposition: 1
Height in cells (at least 0).

Methods

public Void Blit(CellBuffer source, Int32 sourceX, Int32 sourceY, Int32 width, Int32 height, Int32 targetX, Int32 targetY) #
Returns: Void

Copies a region of another buffer into this one.

Parameters

source ConsoleMonster.Canvas.CellBuffer requiredposition: 0
The source buffer.
sourceX System.Int32 requiredposition: 1
Source column.
sourceY System.Int32 requiredposition: 2
Source row.
width System.Int32 requiredposition: 3
Columns to copy.
height System.Int32 requiredposition: 4
Rows to copy.
targetX System.Int32 requiredposition: 5
Target column.
targetY System.Int32 requiredposition: 6
Target row.
public Void Clear(Style style = default) #
Returns: Void

Resets every cell to a blank with the given style.

Parameters

style ConsoleMonster.Styling.Style = default optionalposition: 0
The fill style.
public Void CopyFrom(CellBuffer source) #
Returns: Void

Copies another buffer of the same size into this one.

Parameters

source ConsoleMonster.Canvas.CellBuffer requiredposition: 0
The source buffer.
public String GetRowText(Int32 y) #
Returns: String

Returns a row as plain text (continuation cells skipped, trailing spaces kept).

Parameters

y System.Int32 requiredposition: 0
Row.

Returns

The row text.

public Void Resize(Int32 width, Int32 height) #
Returns: Void

Resizes the buffer, clearing its content.

Parameters

width System.Int32 requiredposition: 0
New width.
height System.Int32 requiredposition: 1
New height.
public Void Set(Int32 x, Int32 y, String glyph, Style style, Int32 width = 1) #
Returns: Void

Places one grapheme. Wide graphemes that do not fit at the right edge become a blank.

Parameters

x System.Int32 requiredposition: 0
Column.
y System.Int32 requiredposition: 1
Row.
glyph System.String requiredposition: 2
The grapheme.
style ConsoleMonster.Styling.Style requiredposition: 3
The style.
width System.Int32 = 1 optionalposition: 4
Grapheme width (1 or 2); 0 or less measures the glyph.
public Void SetStyle(Int32 x, Int32 y, Style style) #
Returns: Void

Changes only the style of a cell, keeping its glyph.

Parameters

x System.Int32 requiredposition: 0
Column.
y System.Int32 requiredposition: 1
Row.
style ConsoleMonster.Styling.Style requiredposition: 2
The new style.
public String ToPlainText() #
Returns: String

Returns the whole buffer as plain text lines with trailing spaces trimmed (used by snapshot tests).

Returns

The text, rows separated by \n.

public Int32 Write(Int32 x, Int32 y, String text, Style style, Int32 maxX = 2147483647) #
Returns: Int32

Writes text from a position, clipped at maxX (exclusive).

Parameters

x System.Int32 requiredposition: 0
Start column.
y System.Int32 requiredposition: 1
Row.
text System.String requiredposition: 2
The text (single line).
style ConsoleMonster.Styling.Style requiredposition: 3
The style.
maxX System.Int32 = 2147483647 optionalposition: 4
Exclusive right clip edge; defaults to the buffer width.

Returns

The column after the last written cell.

Properties

public Int32 Width { get; private set; } #

Width in cells.

public Int32 Height { get; private set; } #

Height in cells.

public Cell this[Int32 x, Int32 y] { get; } #

Gets the cell at a position (blank when out of range).

Parameters

x System.Int32 requiredposition: 0
Column.
y System.Int32 requiredposition: 1
Row.