SelectionPanelNode
Namespace: Hex1b.Nodes
Assembly: Hex1b.dll
Render node for . Implements a terminal-style copy mode over the wrapped child.
public sealed class SelectionPanelNode : Hex1bNodeInheritance
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>
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>
public int? AnchorRow { get; }Child
The child node wrapped by this panel.
Returns: Hex1bNode
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>
public Func<SelectionPanelCopyEventArgs, Task>? CopyHandler { get; set; }CursorCol
Cursor column in surface-local coordinates.
Returns: Int32
public int CursorCol { get; }CursorRow
Cursor row in surface-local coordinates.
Returns: Int32
public int CursorRow { get; }CursorSelectionMode
Geometry of the active selection. Has no effect when / are null.
Returns: SelectionMode
public SelectionMode CursorSelectionMode { get; }HasSelection
true when both an anchor and cursor are set.
Returns: Boolean
public bool HasSelection { get; }IsFocusable
Returns true if this node can receive focus.
Returns: Boolean
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
public override bool IsFocused { get; set; }IsInCopyMode
true while the user is in interactive copy mode.
Returns: Boolean
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:
rect(Rect):
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
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:
bindings(InputBindingsBuilder): The builder to add bindings to.
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 .
public void EnterCopyMode()ExitCopyMode()
Exits copy mode and clears the cursor / selection state. Pair with at the caller.
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>
public override IEnumerable<Hex1bNode> GetChildren()GetFocusableNodes()
Gets all focusable nodes in this subtree (including this node if focusable).
Returns: IEnumerable<Hex1bNode>
public override IEnumerable<Hex1bNode> GetFocusableNodes()MeasureCore(Constraints)
Override this method to implement measuring logic for this node.
Parameters:
constraints(Constraints):
Returns: Size
protected override Size MeasureCore(Constraints constraints)MoveCursor(int, int)
Moves the cursor by rowDelta rows and colDelta columns. Clamps to surface bounds.
Parameters:
public void MoveCursor(int rowDelta, int colDelta)Render(Hex1bRenderContext)
Renders the node to the given context.
Parameters:
context(Hex1bRenderContext):
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:
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
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:
mode(SelectionMode):
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).