Interface ITextScreen
Interface for an object that can plot text in a 2D grid.
Namespace: SociallyDistant.Core.UI.Console
Assembly: SociallyDistant.Framework.dll
Syntax
public interface ITextScreen
Properties
Columns
Gets the width of the screen, in characters.
Declaration
int Columns { get; }
Property Value
Type | Description |
---|---|
int |
CursorLeft
Gets the horizontal position of the cursor, in characters.
Declaration
int CursorLeft { get; }
Property Value
Type | Description |
---|---|
int |
CursorTop
Gets the vertical position of the cursor, in characters.
Declaration
int CursorTop { get; }
Property Value
Type | Description |
---|---|
int |
Rows
Gets the height of the screen, in characters.
Declaration
int Rows { get; }
Property Value
Type | Description |
---|---|
int |
Title
Gets or sets the title of this text screen. Implementations or users of ITextScreen can display this text in other UI elements, such as a tab.
Declaration
string Title { get; set; }
Property Value
Type | Description |
---|---|
string |
Methods
ClearScreen()
Clear the screen.
Declaration
void ClearScreen()
Fill(Rune, int, int, int, int)
Fill a rectangular region of the screen with a specified Rune value.
Declaration
void Fill(Rune rune, int x, int y, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Rune | rune | The character to fill the rectangle with. |
int | x | The left column of the rectangle. |
int | y | The top row of the rectangle. |
int | width | The width, in columns, of the rectangle. |
int | height | The height, in rows, of the rectangle. |
Print(in ReadOnlySpan<Rune>)
Print the specified set of Rune values to the screen.
Declaration
void Print(in ReadOnlySpan<Rune> unicodeRunes)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Rune> | unicodeRunes | A set of Unicode characters to write. |
Print(string)
Print the specified text to the screen.
Declaration
void Print(string text)
Parameters
Type | Name | Description |
---|---|---|
string | text | A string of text to write. |
ReadLine(IHistoryCollection?, CancellationToken?)
Prompts the user to enter a line of text into the screen, creating a task that resolves with the entered text.
Declaration
Task<string?> ReadLine(IHistoryCollection? historyCollection = null, CancellationToken? cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IHistoryCollection | historyCollection | An optional IHistoryCollection containing command-line history, if applicable. |
CancellationToken? | cancellationToken | A cancellation token for interrupting the prompt. |
Returns
Type | Description |
---|---|
Task<string> | A task that resolves with the entered text. If a null string is returned, the screen doesn't support keyboard input. |
ResetBackgroundColor()
Reset the cursor's background color to its default.
Declaration
void ResetBackgroundColor()
ResetCursorPosition()
Move the cursor to the top-left.
Declaration
void ResetCursorPosition()
ResetFont()
Reset the cursor's font style to its default.
Declaration
void ResetFont()
ResetForegroundColor()
Reset the cursor's foreground color to its default.
Declaration
void ResetForegroundColor()
ResetTextEffects()
Reset the cursor's text effects to the default.
Declaration
void ResetTextEffects()
SetBackgroundColor(byte, byte, byte)
Set the background color of the cursor to the specified true color.
Declaration
void SetBackgroundColor(byte red, byte green, byte blue)
Parameters
Type | Name | Description |
---|---|---|
byte | red | Value for the red channel. |
byte | green | Value for the green channel. |
byte | blue | Value for the blue channel. |
SetBackgroundColor(ConsoleColor)
Set the background color of the cursor to the specified ConsoleColor value.
Declaration
void SetBackgroundColor(ConsoleColor paletteColor)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | paletteColor | One of the 16 colors available in the ConsoleColor palette. |
SetCursorPosition(int, int)
Move the cursor to a new position.
Declaration
void SetCursorPosition(int left, int top)
Parameters
Type | Name | Description |
---|---|---|
int | left | The new column for the cursor. |
int | top | The new row for the cursor. |
SetFont(bool, bool)
Change the cursor's font style.
Declaration
void SetFont(bool bold, bool italic)
Parameters
Type | Name | Description |
---|---|---|
bool | bold | Value indicating whether text should be bold. |
bool | italic | Value indicating whether text should be italic. |
SetForegroundColor(byte, byte, byte)
Set the foreground color of the cursor to the specified true color.
Declaration
void SetForegroundColor(byte red, byte green, byte blue)
Parameters
Type | Name | Description |
---|---|---|
byte | red | Value for the red channel. |
byte | green | Value for the green channel. |
byte | blue | Value for the blue channel. |
SetForegroundColor(ConsoleColor)
Set the foreground color of the cursor to the specified ConsoleColor value.
Declaration
void SetForegroundColor(ConsoleColor paletteColor)
Parameters
Type | Name | Description |
---|---|---|
ConsoleColor | paletteColor | One of the 16 colors available in the ConsoleColor palette. |
SetTextEffects(bool, bool)
Change the cursor's text effects.
Declaration
void SetTextEffects(bool underline, bool strikeThrough)
Parameters
Type | Name | Description |
---|---|---|
bool | underline | Value indicating whether text should be underlined. |
bool | strikeThrough | Value indicating whether text should be stricken out. |
WaitForKey(CancellationToken?)
Creates an awaitable task that resolves when a key is pressed.
Declaration
Task<ConsoleInputData?> WaitForKey(CancellationToken? cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken? | cancellationToken | A cancellation token for cancelling the task. |
Returns
Type | Description |
---|---|
Task<ConsoleInputData?> | A Task<TResult> that resolves when a key is pressed inside this screen. A null value returned at task completion means that this screen doessn't support input. |
Write(Rune)
Write the specified Rune value to the screen, and advance the cursor by one cell.
Declaration
void Write(Rune rune)
Parameters
Type | Name | Description |
---|---|---|
Rune | rune | The Unicode character to write to the screen. |