Table of Contents

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

width int
height int

Properties

CursorPosition

Where the cursor is shown, or null when it's hidden.

public (int X, int Y)? CursorPosition { get; }

Property Value

(int X, int Y)?

CursorVisible

True when the cursor is shown.

public bool CursorVisible { get; }

Property Value

bool

DrawCount

public int DrawCount { get; }

Property Value

int

EnterCount

The number of times Enter() actually entered (repeated calls don't count).

public int EnterCount { get; }

Property Value

int

FullRedrawCount

The number of Draw(IReadOnlyList<CellUpdate>, (int X, int Y)?, bool) calls with fullRedraw set.

public int FullRedrawCount { get; }

Property Value

int

Height

Height in cells.

public int Height { get; }

Property Value

int

IsEntered

True between Enter() and Leave().

public bool IsEntered { get; }

Property Value

bool

LastUpdateCount

The number of cells in the most recent Draw(IReadOnlyList<CellUpdate>, (int X, int Y)?, bool).

public int LastUpdateCount { get; }

Property Value

int

LeaveCount

The number of times Leave() actually left.

public int LeaveCount { get; }

Property Value

int

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

int

Methods

CellAt(int, int)

The displayed cell at a position, or Empty when out of bounds.

public Cell CellAt(int x, int y)

Parameters

x int
y int

Returns

Cell

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

updates IReadOnlyList<CellUpdate>

The changed cells.

cursor (int X, int Y)?

Where to show the cursor, or null to hide it.

fullRedraw bool

Clear the screen first; updates then 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

(int Width, int Height)

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)

Parameters

width int
height int