CellBuffer
ConsoleMonster.Canvas
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.
Returned or exposed by 19
- Property Region.Buffer
- Method ConsoleExporter.Render
- Property RecordedFrame.Frame
- Event HeadlessTerminal.FrameRendered
- Method HeadlessTerminal.Snapshot
- Method ScreenCapture.FindFrame
- Property ScreenCapture.Frames
- Property ScreenCapture.LastFrame
- Property LivePause.Backdrop
- Method LiveSession.Snapshot
- Method RecordingTarget.Transcript
- Method SessionRecording.ChapterFrame
- Method SessionRecording.FinalFrame
- Method SessionRecording.FrameAt
- Method SessionRecording.Transcript
- Method Terminal.Render
- Method Terminal.RenderChunks
- Method TestTerminal.Render
- Method GroupedStreamingTable<T1, T2>.RenderChunks
Accepted by parameters 28
- Extension method CellBuffer.Save
- Extension method CellBuffer.ToHtml
- Extension method CellBuffer.ToMarkdown
- Extension method CellBuffer.ToPng
- Extension method CellBuffer.ToRaster
- Extension method CellBuffer.ToSvg
- Extension method CellBuffer.ToText
- Method CellBuffer.Blit
- Method CellBuffer.CopyFrom
- Constructor Region.Region
- Method ConsoleExporter.MeasureContentColumns
- Method ConsoleExporter.MeasureContentRows
- Method ConsoleExporter.ToHtml
- Method ConsoleExporter.ToSvg
- Method ConsoleExporter.ToText
- Method FrameExporter.Render
- Method IFrameExportProvider.Render
- Constructor RecordedFrame.RecordedFrame
- Method ConsoleGraphicsExtensions.Save
- Method ConsoleGraphicsExtensions.ToPng
- Method ConsoleGraphicsExtensions.ToRaster
- Method PngFrameExportProvider.Render
- Method InlineArea.Draw
- Method LivePause.Present
- Method MarkdownExporter.ToMarkdown
- Method MarkdownFrameExportProvider.Render
- Method ITerminalOutput.RenderFrame
- Method ITerminalOutput.WriteBlock
Constructors
public CellBuffer(int width, int height) #Creates a blank buffer.
Parameters
- width int
- Width in cells (at least 0).
- height int
- 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
- The source buffer.
- sourceX int
- Source column.
- sourceY int
- Source row.
- width int
- Columns to copy.
- height int
- Rows to copy.
- targetX int
- Target column.
- targetY int
- Target row.
public void Clear(Style style = default) #Resets every cell to a blank with the given style.
Parameters
- style ConsoleMonster.Styling.Style = default
- The fill style.
public void CopyFrom(CellBuffer source) #Copies another buffer of the same size into this one.
Parameters
- source ConsoleMonster.Canvas.CellBuffer
- The source buffer.
public string GetRowText(int y) #Returns a row as plain text (continuation cells skipped, trailing spaces kept).
Parameters
- y int
- Row.
Returns
string The row text.public void Resize(int width, int height) #Resizes the buffer, clearing its content.
Parameters
- width int
- New width.
- height int
- 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
- Column.
- y int
- Row.
- glyph string
- The grapheme.
- style ConsoleMonster.Styling.Style
- The style.
- width int = 1
- 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
- Column.
- y int
- Row.
- style ConsoleMonster.Styling.Style
- 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
- Start column.
- y int
- Row.
- text string
- The text (single line).
- style ConsoleMonster.Styling.Style
- The style.
- maxX int = 2147483647
- Exclusive right clip edge; defaults to the buffer width.
Returns
int The column after the last written cell.Inherited Methods
Properties
public Cell this[int x, int y] { get; } #Gets the cell at a position (blank when out of range).
Parameters
- x int
- Column.
- y int
- Row.
Extension Methods
public static void Save(CellBuffer frame, string path, GraphicsExportOptions? options = null) #Saves a frame as PNG.
Parameters
- frame ConsoleMonster.Canvas.CellBuffer
- The frame.
- path string
- The file.
- options ConsoleMonster.Graphics.GraphicsExportOptions? = null
- 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
- The frame.
- options ConsoleMonster.Export.ExportOptions? = null
- 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
- 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
- options ConsoleMonster.Graphics.GraphicsExportOptions? = null
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
- options ConsoleMonster.Graphics.GraphicsExportOptions? = null
Returns
RgbaImagepublic static string ToSvg(CellBuffer frame, ExportOptions? options = null) #Exports a rendered frame as an SVG image.
Parameters
- frame ConsoleMonster.Canvas.CellBuffer
- The frame.
- options ConsoleMonster.Export.ExportOptions? = null
- 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
- The frame.
- options ConsoleMonster.Export.ExportOptions? = null
- Unused; for symmetry with the other formats.
Returns
string The text.