Skip to content

IHex1bTerminalPresentationAdapter

Namespace: Hex1b

Assembly: Hex1b.dll

Presentation-side interface: Where rendered output goes TO and user input comes FROM. This is the "user side" of the virtual terminal - the actual display device.

csharp
public interface IHex1bTerminalPresentationAdapter : IAsyncDisposable

Properties

Capabilities

Capability hints that inform optimization strategies.

Returns: TerminalCapabilities

csharp
TerminalCapabilities Capabilities { get; }

Height

Current terminal height in rows.

Returns: Int32

csharp
int Height { get; }

Width

Current terminal width in columns.

Returns: Int32

csharp
int Width { get; }

Methods

EnterRawModeAsync(CancellationToken)

Enter raw mode for proper input capture.

Parameters:

Returns: ValueTask

csharp
ValueTask EnterRawModeAsync(CancellationToken ct = default)

ExitRawModeAsync(CancellationToken)

Exit raw mode and restore normal terminal input handling.

Parameters:

Returns: ValueTask

csharp
ValueTask ExitRawModeAsync(CancellationToken ct = default)

FlushAsync(CancellationToken)

Flush any buffered output immediately.

Parameters:

Returns: ValueTask

csharp
ValueTask FlushAsync(CancellationToken ct = default)

GetCursorPosition()

Gets the current cursor position in the terminal. Returns (0, 0) if the position cannot be determined.

Returns: ValueTuple<Int32, Int32>

A tuple of (Row, Column), both 0-based.

csharp
(int Row, int Column) GetCursorPosition()

ReadInputAsync(CancellationToken)

Receive input (keystrokes, mouse events as ANSI sequences) FROM the user.

Parameters:

Returns: ValueTask<Byte>>

Raw input bytes from the user, or empty when disconnected.

csharp
ValueTask<ReadOnlyMemory<byte>> ReadInputAsync(CancellationToken ct = default)

WriteOutputAsync(ReadOnlyMemory<byte>, CancellationToken)

Write rendered output TO the presentation layer (display).

Parameters:

Returns: ValueTask

csharp
ValueTask WriteOutputAsync(ReadOnlyMemory<byte> data, CancellationToken ct = default)

Events

Disconnected

Raised when the presentation layer disconnects (e.g., terminal closed, WebSocket dropped).

Returns: Action

csharp
event Action? Disconnected

Resized

Raised when the presentation layer is resized by the user.

Returns: Action<Int32, Int32>

csharp
event Action<int, int>? Resized

Remarks

This interface mirrors but for the opposite side of the terminal. While the workload adapter connects to the application generating output, the presentation adapter connects to the device displaying that output.

Implementations include: ConsolePresentationAdapter - Real console I/OWebSocketPresentationAdapter - Browser-based terminalLegacyConsolePresentationAdapter - Wraps existing ConsoleHex1bTerminal

Released under the MIT License.