ScreenGrid class
Namespace: Arlecchino.Testing · Assembly: Arlecchino.Testing
A terminal screen as the terminal itself would hold it: a grid of cells that output is applied to rather than collected in, obeying the escapes FrameText strips out.
public sealed class ScreenGrid
Constructors
| Member | Summary |
|---|---|
ScreenGrid(int, int) | Creates a blank screen at a fixed size. |
Properties
| Member | Summary |
|---|---|
CursorColumn | The column the cursor sits on, counted from the left. A symbol written into the last column leaves it one past the right edge while wrapping is on, and in that column while it is off, as tmux does. |
CursorRow | The row the cursor sits on, counted from the top. |
Height | Rows. |
IsCursorVisible | Whether the cursor was left visible. |
Width | Columns. |
Methods
| Member | Summary |
|---|---|
Apply(string) | Applies what was written to the terminal. Call it as often as there are frames — the screen carries over, which is what makes a run of diffed frames add up to a picture. |
CellAt(int, int) | The symbol standing on a cell, or an empty string for the second half of a wide one. |
Line(int) | One row as it reads, padded out to the full width. |
Lines() | Every row as it reads. |
Matches(ScreenGrid) | Whether another screen holds the same symbols in the same styles. Text alone is the readable half of a frame, so a screen that matches on ScreenGrid.ToString can still differ in color. |
Resize(int, int) | Resizes the screen, keeping what fits and dropping the rest, the way a terminal does. The cursor is pulled back inside. |
StyleAt(int, int) | The style sequence in force on a cell, empty where the style was reset. Compare it against TermColor.Ansi to assert that something was drawn in the color it should be. |
ToString() | The whole screen as text, rows separated by line feeds. |
Constructors in detail
ScreenGrid(int, int)
public ScreenGrid(int width, int height);
Creates a blank screen at a fixed size.
Parameters
| Name | Type | Description |
|---|---|---|
width | int | Columns. |
height | int | Rows. |
Properties in detail
CursorColumn
public int CursorColumn { get; }
The column the cursor sits on, counted from the left. A symbol written into the last column leaves it one past the right edge while wrapping is on, and in that column while it is off, as tmux does.
Type int
CursorRow
public int CursorRow { get; }
The row the cursor sits on, counted from the top.
Type int
Height
public int Height { get; }
Rows.
Type int
IsCursorVisible
public bool IsCursorVisible { get; }
Whether the cursor was left visible.
Type bool
Width
public int Width { get; }
Columns.
Type int
Methods in detail
Apply(string)
public void Apply(string output);
Applies what was written to the terminal. Call it as often as there are frames — the screen carries over, which is what makes a run of diffed frames add up to a picture.
Parameters
| Name | Type | Description |
|---|---|---|
output | string | The bytes written, escapes and all. |
CellAt(int, int)
public string CellAt(int row, int column);
The symbol standing on a cell, or an empty string for the second half of a wide one.
Parameters
| Name | Type | Description |
|---|---|---|
row | int | Row, counted from the top. |
column | int | Column, counted from the left. |
Returns string — The symbol.
Line(int)
public string Line(int row);
One row as it reads, padded out to the full width.
Parameters
| Name | Type | Description |
|---|---|---|
row | int | Row, counted from the top. |
Returns string — The row as text.
Lines()
public string[] Lines();
Every row as it reads.
Returns string[] — One string per row.
Matches(ScreenGrid)
public bool Matches(ScreenGrid other);
Whether another screen holds the same symbols in the same styles. Text alone is the readable half of a frame, so a screen that matches on ScreenGrid.ToString can still differ in color.
Parameters
| Name | Type | Description |
|---|---|---|
other | ScreenGrid | The screen to compare against. |
Returns bool — true when both the symbols and the styles agree.
Resize(int, int)
public void Resize(int width, int height);
Resizes the screen, keeping what fits and dropping the rest, the way a terminal does. The cursor is pulled back inside.
Parameters
| Name | Type | Description |
|---|---|---|
width | int | Columns. |
height | int | Rows. |
StyleAt(int, int)
public string StyleAt(int row, int column);
The style sequence in force on a cell, empty where the style was reset. Compare it against TermColor.Ansi to assert that something was drawn in the color it should be.
Parameters
| Name | Type | Description |
|---|---|---|
row | int | Row, counted from the top. |
column | int | Column, counted from the left. |
Returns string — The sequence.
ToString()
public override string ToString();
The whole screen as text, rows separated by line feeds.
Returns string — The screen as it reads.