Class Buffer
- Namespace
- MiniTui
- Assembly
- MiniTui.dll
Off-screen buffer for rendering. This is your canvas.
public class Buffer
- Inheritance
-
Buffer
- Inherited Members
Remarks
No drawing method throws for any coordinates or Rect: out-of-bounds writes are ignored. Wide characters always occupy two cells, a head and a continuation, and are never split.
Constructors
Buffer(int, int)
Create a new buffer with the specified dimensions. Negative sizes are treated as zero.
public Buffer(int width, int height)
Parameters
Properties
Area
The full buffer area as a Rect.
public Rect Area { get; }
Property Value
CursorRequest
Where the visible terminal cursor should be shown this frame, or null to hide it. Set with SetCursor(int, int); reset by Clear().
public (int X, int Y)? CursorRequest { get; }
Property Value
Height
Buffer height in cells.
public int Height { get; }
Property Value
Width
Buffer width in cells.
public int Width { get; }
Property Value
Methods
Clear()
Clear the buffer to empty cells and drop any cursor request.
public void Clear()
DrawHLine(int, int, int, char, Style)
Draw a horizontal line of c, patching each cell with style.
public void DrawHLine(int x, int y, int length, char c = '─', Style style = default)
Parameters
DrawVLine(int, int, int, char, Style)
Draw a vertical line of c, patching each cell with style.
public void DrawVLine(int x, int y, int length, char c = '│', Style style = default)
Parameters
Fill(Cell)
Fill the entire buffer with a cell.
public void Fill(Cell cell)
Parameters
cellCell
FillRect(Rect, Cell)
Fill a rectangular area with a cell.
public void FillRect(Rect rect, Cell cell)
Parameters
Get(int, int)
Get a cell at the given position. Returns empty cell for out-of-bounds.
public Cell Get(int x, int y)
Parameters
Returns
Set(int, int, Cell)
Set a cell at the given position. Ignores out-of-bounds coordinates. The symbol is sanitized (a zero-width symbol becomes a space), and wide characters overwrite the cell to their right. A wide character that would start in the last column is written as a space.
public void Set(int x, int y, Cell cell)
Parameters
SetCursor(int, int)
Request that the visible terminal cursor be shown at this position for this frame. Out-of-bounds positions are ignored.
public void SetCursor(int x, int y)
Parameters
SetLine(int, int, Line, int)
Write a line of styled spans, up to maxWidth columns.
Like Ratatui's set_line, this ignores Alignment.
public int SetLine(int x, int y, Line line, int maxWidth)
Parameters
Returns
- int
The number of columns advanced.
SetString(int, int, ReadOnlySpan<char>, Style, int)
Write a single line of text, patching each cell with style.
Control characters are sanitized; tabs and line breaks become spaces.
Stops at maxWidth columns or the buffer edge, and never writes half of a wide character.
public int SetString(int x, int y, ReadOnlySpan<char> text, Style style, int maxWidth = 2147483647)
Parameters
Returns
- int
The number of columns advanced.
SetStyle(Rect, Style)
Patch the style of every cell in area, keeping the symbols.
public void SetStyle(Rect area, Style style)
Parameters
ToLines()
The buffer's symbols, one string per row, with continuation cells omitted. Intended for tests.
public string[] ToLines()
Returns
- string[]