Skip to content

SelectionPanelNode ​

Namespace: Hex1b.Nodes

Assembly: Hex1b.dll

Render node for . Implements a terminal-style copy mode over the wrapped child.

csharp
public sealed class SelectionPanelNode : Hex1bNode

Inheritance ​

Object → Hex1bNode → SelectionPanelNode

Properties ​

AnchorCol ​

Anchor column of the active selection, or null when no selection is active (only the cursor is shown).

Returns: Nullable<Int32>

csharp
public int? AnchorCol { get; }

AnchorRow ​

Anchor row of the active selection, or null when no selection is active (only the cursor is shown).

Returns: Nullable<Int32>

csharp
public int? AnchorRow { get; }

Child ​

The child node wrapped by this panel.

Returns: Hex1bNode

csharp
public Hex1bNode? Child { get; set; }

CopyHandler ​

Optional handler invoked with a describing the current selection when the user commits via (Y/Enter) or (right-click by default). When this is null, copy mode bindings are not registered (the panel behaves as a pure pass-through).

Returns: Func<SelectionPanelCopyEventArgs, Task>

csharp
public Func<SelectionPanelCopyEventArgs, Task>? CopyHandler { get; set; }

CursorCol ​

Cursor column in surface-local coordinates.

Returns: Int32

csharp
public int CursorCol { get; }

CursorRow ​

Cursor row in surface-local coordinates.

Returns: Int32

csharp
public int CursorRow { get; }

CursorSelectionMode ​

Geometry of the active selection. Has no effect when / are null.

Returns: SelectionMode

csharp
public SelectionMode CursorSelectionMode { get; }

HasSelection ​

true when both an anchor and cursor are set.

Returns: Boolean

csharp
public bool HasSelection { get; }

IsFocusable ​

Returns true if this node can receive focus.

Returns: Boolean

csharp
public override bool IsFocusable { get; }

IsFocused ​

Gets or sets whether this node is currently focused. Only meaningful for focusable nodes (where IsFocusable is true).

Returns: Boolean

csharp
public override bool IsFocused { get; set; }

IsInCopyMode ​

true while the user is in interactive copy mode.

Returns: Boolean

csharp
public bool IsInCopyMode { get; }

Methods ​

ArrangeCore(Rect) ​

Override this method to implement arranging logic for this node. The base implementation saves previous bounds, marks dirty on change, and sets bounds.

Parameters:

csharp
protected override void ArrangeCore(Rect rect)

BuildCopyEventArgs() ​

Builds the for the current selection: snapshots the text, computes the bounding box in panel-local and terminal-absolute coordinates, and walks the child node tree to produce per-node intersection records. Returns args with an empty text and empty node list when no selection is active (callers gate on before invoking).

Returns: SelectionPanelCopyEventArgs

csharp
public SelectionPanelCopyEventArgs BuildCopyEventArgs()

ConfigureDefaultBindings(InputBindingsBuilder) ​

Configures the default input bindings for this node type. Override in derived classes to add default key bindings. These bindings can be inspected and modified by the user's callback.

Parameters:

csharp
public override void ConfigureDefaultBindings(InputBindingsBuilder bindings)

EnterCopyMode() ​

Enters copy mode. The cursor is initialised at the bottom-left of the rendered surface (the natural starting point for chat-style content where the latest output sits at the bottom of an auto-scrolled viewport). Any existing selection is cleared. Note: this does not install input capture; the binding handler that calls EnterCopyMode also calls .

csharp
public void EnterCopyMode()

ExitCopyMode() ​

Exits copy mode and clears the cursor / selection state. Pair with at the caller.

csharp
public void ExitCopyMode()

GetChildren() ​

Gets the direct children of this node for structural tree traversal. Container nodes should override this to return their children.

Returns: IEnumerable<Hex1bNode>

csharp
public override IEnumerable<Hex1bNode> GetChildren()

GetFocusableNodes() ​

Gets all focusable nodes in this subtree (including this node if focusable).

Returns: IEnumerable<Hex1bNode>

csharp
public override IEnumerable<Hex1bNode> GetFocusableNodes()

MeasureCore(Constraints) ​

Override this method to implement measuring logic for this node.

Parameters:

Returns: Size

csharp
protected override Size MeasureCore(Constraints constraints)

MoveCursor(int, int) ​

Moves the cursor by rowDelta rows and colDelta columns. Clamps to surface bounds.

Parameters:

csharp
public void MoveCursor(int rowDelta, int colDelta)

Render(Hex1bRenderContext) ​

Renders the node to the given context.

Parameters:

csharp
public override void Render(Hex1bRenderContext context)

SetCursor(int, int) ​

Sets the cursor to the specified surface-local coordinates, clamped to 0..Width-1 and 0..Height-1.

Parameters:

csharp
public void SetCursor(int row, int col)

SnapshotText() ​

Reads back the plain text of the current selection. Returns an empty string when no selection is active or when bounds are zero.

Returns: String

csharp
public string SnapshotText()

StartOrToggleSelection(SelectionMode) ​

Starts a selection in mode if no selection is active, switches the mode (preserving the anchor) if a selection is active in a different mode, or clears the selection if the same mode is requested again. Mirrors 's vi-style toggle semantics.

Parameters:

csharp
public void StartOrToggleSelection(SelectionMode mode)

Remarks ​

Outside copy mode the node is a pure pass-through: layout, focus, and input flow to the child unchanged. While is true, the node:

Holds focus capture (set up by the binding handler via ) so that all subsequent input goes to its capture-override bindings rather than to whatever widget had keyboard focus.Renders an inverted-cell cursor (and, if a selection is active, an inverted selection region) over the child output by rendering the child to a viewport-sized temporary surface (the intersection of the panel Bounds with the parent's effective clip rect — so cost stays bounded by the visible region even when the panel sits inside a long-scrolling container), applying to the relevant cells, and compositing the modified surface back.

Cursor coordinates are surface-local: is in 0..Bounds.Height-1 and is in 0..Bounds.Width-1. initialises the cursor at the bottom-left of the surface to feel natural in chat-style auto-scrolling viewports (where the most recent content is at the bottom).

Released under the MIT License.