Skip to content
ConsoleMonster
Class

CellBuffer

ConsoleMonster.Canvas

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 47 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 28

Constructors

public CellBuffer(int width, int height) #

Creates a blank buffer.

Parameters

width int required
Width in cells (at least 0).
height int required
Height in cells (at least 0).

Methods

public void Blit(CellBuffer source, int sourceX, int sourceY, int width, int height, int targetX, int targetY) #

Copies a region of another buffer into this one.

Parameters

source ConsoleMonster.Canvas.CellBuffer required
The source buffer.
sourceX int required
Source column.
sourceY int required
Source row.
width int required
Columns to copy.
height int required
Rows to copy.
targetX int required
Target column.
targetY int required
Target row.
public void Clear(Style style = default) #

Resets every cell to a blank with the given style.

Parameters

style ConsoleMonster.Styling.Style = default optional
The fill style.
public void CopyFrom(CellBuffer source) #

Copies another buffer of the same size into this one.

Parameters

source ConsoleMonster.Canvas.CellBuffer required
The source buffer.
public string GetRowText(int y) #

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

Parameters

y int required
Row.

Returns

string The row text.
public void Resize(int width, int height) #

Resizes the buffer, clearing its content.

Parameters

width int required
New width.
height int required
New height.
public void Set(int x, int y, string glyph, Style style, int width = 1) #

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

Parameters

x int required
Column.
y int required
Row.
glyph string required
The grapheme.
style ConsoleMonster.Styling.Style required
The style.
width int = 1 optional
Grapheme width (1 or 2); 0 or less measures the glyph.
public void SetStyle(int x, int y, Style style) #

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

Parameters

x int required
Column.
y int required
Row.
style ConsoleMonster.Styling.Style required
The new style.
public string ToPlainText() #

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

Returns

string The text, rows separated by \n.
public int Write(int x, int y, string text, Style style, int maxX = 2147483647) #

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

Parameters

x int required
Start column.
y int required
Row.
text string required
The text (single line).
style ConsoleMonster.Styling.Style required
The style.
maxX int = 2147483647 optional
Exclusive right clip edge; defaults to the buffer width.

Returns

int The column after the last written cell.

Properties

public int Width { get; private set; } #

Width in cells.

public int Height { get; private set; } #

Height in cells.

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

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

Parameters

x int required
Column.
y int required
Row.

Extension Methods

public static void Save(CellBuffer frame, string path, GraphicsExportOptions? options = null) #

Saves a frame as PNG.

Parameters

frame ConsoleMonster.Canvas.CellBuffer required
The frame.
path string required
The file.
options ConsoleMonster.Graphics.GraphicsExportOptions? = null optional
Canvas, fonts and background.
public static string ToHtml(CellBuffer frame, ExportOptions? options = null) #

Exports a rendered frame as an HTML page. Theme Auto keeps the frame's colours and lets default text follow the viewer.

Parameters

frame ConsoleMonster.Canvas.CellBuffer required
The frame.
options ConsoleMonster.Export.ExportOptions? = null optional
Theme, font and window frame (the size is the frame's).

Returns

string The HTML.
public static string ToMarkdown(CellBuffer frame) #

Preserves an already rendered frame in a fenced text block.

Parameters

frame ConsoleMonster.Canvas.CellBuffer required
The frame; its dimensions are kept.

Returns

string The Markdown code block.
public static byte[] ToPng(CellBuffer frame, GraphicsExportOptions? options = null) #

Encodes a rendered frame as PNG.

Parameters

frame ConsoleMonster.Canvas.CellBuffer required
options ConsoleMonster.Graphics.GraphicsExportOptions? = null optional

Returns

byte[]
public static RgbaImage ToRaster(CellBuffer frame, GraphicsExportOptions? options = null) #

Rasterises a frame with the core's geometric glyphs and ChartForgeX typography.

Parameters

frame ConsoleMonster.Canvas.CellBuffer required
options ConsoleMonster.Graphics.GraphicsExportOptions? = null optional

Returns

RgbaImage
public static string ToSvg(CellBuffer frame, ExportOptions? options = null) #

Exports a rendered frame as an SVG image.

Parameters

frame ConsoleMonster.Canvas.CellBuffer required
The frame.
options ConsoleMonster.Export.ExportOptions? = null optional
Theme, font and window frame.

Returns

string The SVG.
public static string ToText(CellBuffer frame, ExportOptions? options = null) #

Exports a rendered frame as plain text.

Parameters

frame ConsoleMonster.Canvas.CellBuffer required
The frame.
options ConsoleMonster.Export.ExportOptions? = null optional
Unused; for symmetry with the other formats.

Returns

string The text.