Skip to content

DiagnosticShellWorkloadAdapter

Namespace: Hex1b

Assembly: Hex1b.dll

A diagnostic shell workload that simulates a shell environment without PTY infrastructure. Useful for testing terminal control codes and debugging terminal behavior.

csharp
public sealed class DiagnosticShellWorkloadAdapter : IHex1bTerminalWorkloadAdapter, IAsyncDisposable

Inheritance

ObjectDiagnosticShellWorkloadAdapter

Implements

Constructors

DiagnosticShellWorkloadAdapter(int, int)

Creates a new diagnostic shell workload adapter.

Parameters:

  • width (Int32): Initial terminal width.
  • height (Int32): Initial terminal height.
csharp
public DiagnosticShellWorkloadAdapter(int width = 80, int height = 24)

Properties

HasExited

Gets whether the shell has exited.

Returns: Boolean

csharp
public bool HasExited { get; }

Methods

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

Returns: ValueTask

A task that represents the asynchronous dispose operation.

csharp
public ValueTask DisposeAsync()

ReadOutputAsync(CancellationToken)

Read output FROM the workload (ANSI sequences to display). The terminal calls this to get data to parse and send to presentation. Returns empty when workload has no more output (should be called in a loop).

Parameters:

Returns: ValueTask<Byte>>

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

ResizeAsync(int, int, CancellationToken)

Notify workload of terminal resize.

Parameters:

Returns: ValueTask

csharp
public ValueTask ResizeAsync(int width, int height, CancellationToken ct = default)

Start()

Starts the diagnostic shell and shows the initial prompt.

csharp
public void Start()

WriteInputAsync(ReadOnlyMemory<byte>, CancellationToken)

Write input TO the workload (raw bytes from keyboard/mouse). The terminal calls this when it receives input from the presentation layer.

Parameters:

Returns: ValueTask

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

Events

Disconnected

Raised when workload has disconnected/exited.

Returns: Action

csharp
public event Action? Disconnected

Remarks

The diagnostic shell provides a simulated shell environment with built-in commands for testing various terminal features including:

Control code output testing (colors, cursor movement, etc.)Input capture and hex dump functionalityCommand history with arrow key navigation

Commands: help - Show available commandsecho &lt;text&gt; - Echo text backcolors - Display color test patternscursor - Test cursor movement sequencesscroll - Test scroll regionclear - Clear screentitle &lt;text&gt; - Set window title via OSCcapture - Start capturing inputdump - Dump captured input as hex tableexit - Exit the shell

Released under the MIT License.