Interface ITerminal
Defines the traits needed to implement a terminal. The only existing implementation of this interface is Terminal class.
Namespace: Sharpie.Abstractions
Assembly: sharpie.dll
Syntax
[PublicAPI]
public interface ITerminal
Properties
BaudRate
Gets the terminal's baud rate.
Declaration
int BaudRate { get; }
Property Value
Type | Description |
---|---|
int |
Colors
Provides access to the terminal's color management.
Declaration
IColorManager Colors { get; }
Property Value
Type | Description |
---|---|
IColorManager |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The terminal has been disposed. |
CurrentEraseChar
Gets the currently defined erase character. null
is returned if none is defined.
Declaration
Rune? CurrentEraseChar { get; }
Property Value
Type | Description |
---|---|
Rune? |
CurrentKillChar
Gets the currently defined kill character. null
is returned if none is defined.
Declaration
Rune? CurrentKillChar { get; }
Property Value
Type | Description |
---|---|
Rune? |
Curses
The Curses backend.
Declaration
ICursesBackend Curses { get; }
Property Value
Type | Description |
---|---|
ICursesBackend |
CursesVersion
Returns the version of the Curses library in use.
Declaration
string? CursesVersion { get; }
Property Value
Type | Description |
---|---|
string |
Description
Returns the long description of the terminal.
Declaration
string? Description { get; }
Property Value
Type | Description |
---|---|
string |
Disposed
Checks whether the terminal has been disposed of and is no longer usable.
Declaration
bool Disposed { get; }
Property Value
Type | Description |
---|---|
bool |
Events
The event pump instance that can be used to read events from the terminal.
Declaration
IEventPump Events { get; }
Property Value
Type | Description |
---|---|
IEventPump |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The terminal has been disposed. |
Footer
The footer surface. Only initialized if AllocateFooter was set.
Declaration
ITerminalSurface? Footer { get; }
Property Value
Type | Description |
---|---|
ITerminalSurface |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The terminal has been disposed. |
Header
The header surface. Only initialized if AllocateHeader was set.
Declaration
ITerminalSurface? Header { get; }
Property Value
Type | Description |
---|---|
ITerminalSurface |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The terminal has been disposed. |
Name
Returns the name of the terminal.
Declaration
string? Name { get; }
Property Value
Type | Description |
---|---|
string |
Screen
The screen instance. Use this property to access the entire screen functionality.
Declaration
IScreen Screen { get; }
Property Value
Type | Description |
---|---|
IScreen |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The terminal has been disposed. |
SoftLabelKeys
Provides access to the terminal's color management.
Declaration
ISoftLabelKeyManager SoftLabelKeys { get; }
Property Value
Type | Description |
---|---|
ISoftLabelKeyManager |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The terminal has been disposed. |
SupportedAttributes
Gets the combination of supported terminal attributes.
Declaration
VideoAttribute SupportedAttributes { get; }
Property Value
Type | Description |
---|---|
VideoAttribute |
Methods
Alert(bool)
Attempts to notify the user with audio or flashing alert.
Declaration
void Alert(bool silent)
Parameters
Type | Name | Description |
---|---|---|
bool | silent | The alert mode. |
Remarks
The actual notification depends on terminal support.
Exceptions
Type | Condition |
---|---|
CursesSynchronizationException | Thrown if this operation was expected to run on the main thread/context but wasn't. |
AtomicRefresh()
Creates a batch update lock. All refreshes are batched together until the batch is disposed.
Declaration
IDisposable AtomicRefresh()
Returns
Type | Description |
---|---|
IDisposable | A disposable object that need to be disposed to release the batch update lock. |
Remarks
This operation is not thread safe.
Exceptions
Type | Condition |
---|---|
CursesSynchronizationException | Thrown if this operation was expected to run on the main thread/context but wasn't. |
Delay(Func<Terminal, Task>, int)
Sets up a delayed action that is to be executed after some time.
Declaration
IInterval Delay(Func<Terminal, Task> action, int delayMillis)
Parameters
Type | Name | Description |
---|---|---|
Func<Terminal, Task> | action | The action to be executed. |
int | delayMillis | The delay in milliseconds. |
Returns
Type | Description |
---|---|
IInterval | The interval object. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
Delay<TState>(Func<Terminal, TState?, Task>, int, TState?)
Sets up a delayed action that is to be executed after some time.
Declaration
IInterval Delay<TState>(Func<Terminal, TState?, Task> action, int delayMillis, TState? state)
Parameters
Type | Name | Description |
---|---|---|
Func<Terminal, TState, Task> | action | The action to be executed. |
int | delayMillis | The delay in milliseconds. |
TState | state | User-supplied state object. |
Returns
Type | Description |
---|---|
IInterval | The interval object. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
Delegate(Func<Task>)
Delegates an action to be executed on the main thread.
Declaration
void Delegate(Func<Task> action)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | action | The action to execute. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ObjectDisposedException | The terminal has been disposed. |
Repeat(Func<Terminal, Task>, int, bool)
Sets up a delayed action that is to be executed after some time.
Declaration
IInterval Repeat(Func<Terminal, Task> action, int intervalMillis, bool immediate = false)
Parameters
Type | Name | Description |
---|---|---|
Func<Terminal, Task> | action | The action to be executed. |
int | intervalMillis | The interval in milliseconds. |
bool | immediate | If |
Returns
Type | Description |
---|---|
IInterval | The interval object. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
Repeat<TState>(Func<Terminal, TState?, Task>, int, bool, TState?)
Sets up a delayed action that is to be executed after some time.
Declaration
IInterval Repeat<TState>(Func<Terminal, TState?, Task> action, int intervalMillis, bool immediate = false, TState? state = default)
Parameters
Type | Name | Description |
---|---|---|
Func<Terminal, TState, Task> | action | The action to be executed. |
int | intervalMillis | The interval in milliseconds. |
bool | immediate | If |
TState | state | User-supplied state object. |
Returns
Type | Description |
---|---|
IInterval | The interval object. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state object. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
Run(Func<ITerminal, Event, Task>, bool)
Runs the application main loop and dispatches each event to eventAction
.
Declaration
void Run(Func<ITerminal, Event, Task> eventAction, bool stopOnCtrlC = true)
Parameters
Type | Name | Description |
---|---|---|
Func<ITerminal, Event, Task> | eventAction | The method to accept the events. |
bool | stopOnCtrlC | Set to |
Remarks
This operation is not thread safe.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
InvalidOperationException | Thrown if another Run(Func<ITerminal, Event, Task>, bool) is already running. |
ObjectDisposedException | The terminal has been disposed. |
CursesSynchronizationException | Thrown if this operation was expected to run on the main thread/context but wasn't. |
SetTitle(string)
Sets the terminal title.
Declaration
void SetTitle(string title)
Parameters
Type | Name | Description |
---|---|---|
string | title | The title of the terminal. |
Remarks
This operation is not thread safe.
Exceptions
Type | Condition |
---|---|
CursesSynchronizationException | Thrown if this operation was expected to run on the main thread/context but wasn't. |
Stop(bool)
Enqueues a stop signal for the Run(Func<ITerminal, Event, Task>, bool) method.
Declaration
void Stop(bool wait = false)
Parameters
Type | Name | Description |
---|---|---|
bool | wait | If |