Skip to content

TerminalWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A widget that displays an embedded terminal session.

csharp
public sealed record TerminalWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<TerminalWidget>

Inheritance

ObjectHex1bWidgetTerminalWidget

Implements

Constructors

TerminalWidget(TerminalWidgetHandle)

A widget that displays an embedded terminal session.

Parameters:

csharp
public TerminalWidget(TerminalWidgetHandle Handle)

Properties

Handle

Returns: TerminalWidgetHandle

csharp
public TerminalWidgetHandle Handle { get; init; }

Remarks

The TerminalWidget binds to a which provides the screen buffer from a running terminal session. This allows embedding child terminals within a TUI application.

When the terminal is not running (not started or completed), you can optionally provide a fallback widget using . This enables post-exit interactivity such as showing the exit code or a "restart" button.

Example usage:

csharp
var terminal = Hex1bTerminal.CreateBuilder()
    .WithPtyProcess("bash")
    .WithTerminalWidget(out var bashHandle)
    .Build();

_ = terminal.RunAsync(appCt);

ctx.Terminal(bashHandle)
   .WhenNotRunning(args => ctx.Text($"Exited with code {args.ExitCode}"));

Released under the MIT License.