Class TestBackend
- Namespace
- MiniTui
- Assembly
- MiniTui.dll
An in-memory terminal for testing apps. It applies each frame's changed cells to a grid, so Lines and CellAt(int, int) show what a real terminal would display.
public sealed class TestBackend : ITerminalBackend, IDisposable
- Inheritance
-
TestBackend
- Implements
- Inherited Members
Constructors
TestBackend(int, int)
Create a test terminal of the given size.
public TestBackend(int width = 80, int height = 24)
Parameters
Properties
CursorPosition
Where the cursor is shown, or null when it's hidden.
public (int X, int Y)? CursorPosition { get; }
Property Value
CursorVisible
True when the cursor is shown.
public bool CursorVisible { get; }
Property Value
DrawCount
The number of Draw(IReadOnlyList<CellUpdate>, (int X, int Y)?, bool) calls.
public int DrawCount { get; }
Property Value
EnterCount
The number of times Enter() actually entered (repeated calls don't count).
public int EnterCount { get; }
Property Value
FullRedrawCount
The number of Draw(IReadOnlyList<CellUpdate>, (int X, int Y)?, bool) calls with fullRedraw set.
public int FullRedrawCount { get; }
Property Value
Height
Height in cells.
public int Height { get; }
Property Value
IsEntered
public bool IsEntered { get; }
Property Value
LastUpdateCount
The number of cells in the most recent Draw(IReadOnlyList<CellUpdate>, (int X, int Y)?, bool).
public int LastUpdateCount { get; }
Property Value
LeaveCount
The number of times Leave() actually left.
public int LeaveCount { get; }
Property Value
Lines
The displayed symbols, one string per row, with continuation cells omitted.
public string[] Lines { get; }
Property Value
- string[]
Width
Width in cells.
public int Width { get; }
Property Value
Methods
CellAt(int, int)
The displayed cell at a position, or Empty when out of bounds.
public Cell CellAt(int x, int y)
Parameters
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Draw(IReadOnlyList<CellUpdate>, (int X, int Y)?, bool)
Draw changed cells. Continuation cells are never included: a wide cell covers the cell to its right.
public void Draw(IReadOnlyList<CellUpdate> updates, (int X, int Y)? cursor, bool fullRedraw)
Parameters
updatesIReadOnlyList<CellUpdate>The changed cells.
cursor(int X, int Y)?Where to show the cursor, or null to hide it.
fullRedrawboolClear the screen first;
updatesthen contains every cell.
Enter()
Put the terminal into TUI mode (alternate screen, hidden cursor, ...). Idempotent.
public void Enter()
GetSize()
The current terminal size in cells.
public (int Width, int Height) GetSize()
Returns
Leave()
Restore the terminal to how it was before Enter(). Idempotent and never throws.
public void Leave()
Resize(int, int)
Change the size. The grid is cleared, like a real terminal's next full redraw.
public void Resize(int width, int height)