Hex1bApp
Namespace: Hex1b
Assembly: Hex1b.dll
The main entry point for building terminal UI applications.
public class Hex1bApp : IDisposable, IAsyncDisposableInheritance
Object → Hex1bApp
Implements
Constructors
Hex1bApp(Func<RootContext, Hex1bWidget>, Hex1bAppOptions?)
Creates a Hex1bApp with a synchronous widget builder.
Parameters:
builder(Func<RootContext, Hex1bWidget>): A function that builds the widget tree.options(Hex1bAppOptions): Optional configuration options.
public Hex1bApp(Func<RootContext, Hex1bWidget> builder, Hex1bAppOptions? options = null)Hex1bApp(Func<RootContext, Task<Hex1bWidget>>, Hex1bAppOptions?)
Creates a Hex1bApp with an async widget builder.
Parameters:
builder(Func<RootContext, Hex1bWidget>>): A function that builds the widget tree.options(Hex1bAppOptions): Optional configuration options.
public Hex1bApp(Func<RootContext, Task<Hex1bWidget>> builder, Hex1bAppOptions? options = null)Properties
CapturedNode
Gets the node that has captured all input, or null if no capture is active.
Returns: Hex1bNode
public Hex1bNode? CapturedNode { get; }Focusables
Gets all focusable nodes in the current focus ring. Useful for testing and debugging focus navigation.
Returns: IReadOnlyList<Hex1bNode>
public IReadOnlyList<Hex1bNode> Focusables { get; }FocusedNode
Gets the currently focused node, or null if no node has focus. Useful for testing and debugging focus state.
Returns: Hex1bNode
public Hex1bNode? FocusedNode { get; }LastFocusChange
Gets the last focus change debug log from the focus ring. Useful for testing focus navigation.
Returns: String
public string? LastFocusChange { get; }LastFocusDebug
Gets the last Focus() call debug log.
Returns: String
public string? LastFocusDebug { get; }LastHitTestDebug
Gets the last hit test debug log from the focus ring. Useful for debugging mouse click focus issues.
Returns: String
public string? LastHitTestDebug { get; }LastPathDebug
Gets the last path debug info from input routing.
Returns: String
public string? LastPathDebug { get; }Methods
CaptureInput(Hex1bNode)
Captures all input to the specified node.
Parameters:
node(Hex1bNode): The node to capture input to.
public void CaptureInput(Hex1bNode node)CopyToClipboard(string)
Copies the specified text to the system clipboard using the OSC 52 escape sequence.
Parameters:
text(String): The text to copy to the clipboard.
public void CopyToClipboard(string text)Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
Returns: ValueTask
A task that represents the asynchronous dispose operation.
public ValueTask DisposeAsync()FocusWhere(Func<Hex1bNode, bool>)
Focuses the first node in the focus ring that matches the given predicate.
Parameters:
predicate(Func<Hex1bNode, Boolean>): A function that returns true for the node to focus.
Returns: Boolean
True if a matching node was found and focused, false otherwise.
public bool FocusWhere(Func<Hex1bNode, bool> predicate)Invalidate()
Signals that the UI should be re-rendered. Call this when external state changes (network events, timers, etc.). This method is thread-safe and can be called from any thread.
public void Invalidate()ReleaseCapture()
Releases input capture, returning to normal input routing.
public void ReleaseCapture()RequestFocus(Func<Hex1bNode, bool>)
Requests that focus be set to the first node matching the predicate after the next render.
Parameters:
predicate(Func<Hex1bNode, Boolean>): A function that returns true for the node to focus.
public void RequestFocus(Func<Hex1bNode, bool> predicate)RequestStop()
Requests the application to stop. The RunAsync call will exit gracefully after the current frame completes.
public void RequestStop()RunAsync(CancellationToken)
Runs the application until cancellation is requested.
Parameters:
cancellationToken(CancellationToken):
Returns: Task
public Task RunAsync(CancellationToken cancellationToken = default)Remarks
Hex1bApp manages the render loop, input handling, focus management, and reconciliation between widgets (immutable declarations) and nodes (mutable render state).
State management is handled via closures - simply capture your state variables in the widget builder callback.
Examples
Create a minimal Hex1b application:
using Hex1b;
var app = new Hex1bApp(ctx =>
ctx.VStack(v => [
v.Text("Hello, Hex1b!"),
v.Button("Quit", e => e.Context.RequestStop())
])
);
await app.RunAsync();