Skip to content

SelectionPanelWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A container that wraps a child widget and adds a TerminalWidget-style copy mode for selecting and copying regions of the rendered content.

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

Inheritance

ObjectHex1bWidgetSelectionPanelWidget

Implements

Constructors

SelectionPanelWidget(Hex1bWidget)

A container that wraps a child widget and adds a TerminalWidget-style copy mode for selecting and copying regions of the rendered content.

Parameters:

csharp
public SelectionPanelWidget(Hex1bWidget Child)

Properties

Child

The child widget to wrap.

Returns: Hex1bWidget

csharp
public Hex1bWidget Child { get; init; }

Methods

OnCopy(Action<SelectionPanelCopyEventArgs>)

Sets a synchronous copy handler that receives the full — text plus geometry (panel-local and terminal-absolute bounds) and the per-node breakdown (). Invoked when the user commits via or (right-click by default).

Parameters:

Returns: SelectionPanelWidget

csharp
public SelectionPanelWidget OnCopy(Action<SelectionPanelCopyEventArgs> handler)

OnCopy(Action<string>)

Sets a synchronous copy handler that receives only the copied text. Invoked when the user commits via or (right-click by default). Equivalent to using .

Parameters:

Returns: SelectionPanelWidget

csharp
public SelectionPanelWidget OnCopy(Action<string> handler)

OnCopy(Func<SelectionPanelCopyEventArgs, Task>)

Sets an asynchronous copy handler that receives the full — text plus geometry (panel-local and terminal-absolute bounds) and the per-node breakdown (). Invoked when the user commits via or (right-click by default).

Parameters:

Returns: SelectionPanelWidget

csharp
public SelectionPanelWidget OnCopy(Func<SelectionPanelCopyEventArgs, Task> handler)

OnCopy(Func<string, Task>)

Sets an asynchronous copy handler that receives only the copied text. Invoked when the user commits via or (right-click by default). Equivalent to using .

Parameters:

Returns: SelectionPanelWidget

csharp
public SelectionPanelWidget OnCopy(Func<string, Task> handler)

Fields

CopyModeBufferBottom

Rebindable action: move the cursor to the bottom of the buffer. Default: Shift+G.

Returns: ActionId

csharp
public static readonly ActionId CopyModeBufferBottom

CopyModeBufferTop

Rebindable action: move the cursor to the top of the buffer. Default: G.

Returns: ActionId

csharp
public static readonly ActionId CopyModeBufferTop

CopyModeCancel

Rebindable action: cancel copy mode without copying. Default: Escape, Q.

Returns: ActionId

csharp
public static readonly ActionId CopyModeCancel

CopyModeCopy

Rebindable action: copy the current selection and exit copy mode. Default: Y, Enter.

Returns: ActionId

csharp
public static readonly ActionId CopyModeCopy

CopyModeDown

Rebindable action: move the copy mode cursor down one row. Default: DownArrow, J.

Returns: ActionId

csharp
public static readonly ActionId CopyModeDown

CopyModeLeft

Rebindable action: move the copy mode cursor left one column. Default: LeftArrow, H.

Returns: ActionId

csharp
public static readonly ActionId CopyModeLeft

CopyModeLineEnd

Rebindable action: move the cursor to the end of the current row. Default: End.

Returns: ActionId

csharp
public static readonly ActionId CopyModeLineEnd

CopyModeLineStart

Rebindable action: move the cursor to the start of the current row. Default: Home, D0.

Returns: ActionId

csharp
public static readonly ActionId CopyModeLineStart

CopyModeMouseCommit

Rebindable action: commit the current selection via mouse and exit copy mode. Default: right-click.

Returns: ActionId

csharp
public static readonly ActionId CopyModeMouseCommit

CopyModePageDown

Rebindable action: move the cursor down one page. Default: PageDown.

Returns: ActionId

csharp
public static readonly ActionId CopyModePageDown

CopyModePageUp

Rebindable action: move the cursor up one page. Default: PageUp.

Returns: ActionId

csharp
public static readonly ActionId CopyModePageUp

CopyModeRight

Rebindable action: move the copy mode cursor right one column. Default: RightArrow, L.

Returns: ActionId

csharp
public static readonly ActionId CopyModeRight

CopyModeStartSelection

Rebindable action: start or toggle a character (cell-stream) selection. Default: V, Spacebar.

Returns: ActionId

csharp
public static readonly ActionId CopyModeStartSelection

CopyModeToggleBlockMode

Rebindable action: start or toggle a block (rectangular) selection. Default: Alt+V.

Returns: ActionId

csharp
public static readonly ActionId CopyModeToggleBlockMode

CopyModeToggleLineMode

Rebindable action: start or toggle a line selection. Default: Shift+V.

Returns: ActionId

csharp
public static readonly ActionId CopyModeToggleLineMode

CopyModeUp

Rebindable action: move the copy mode cursor up one row. Default: UpArrow, K.

Returns: ActionId

csharp
public static readonly ActionId CopyModeUp

CopyModeWordBackward

Rebindable action: move the cursor backward one word. Default: B.

Returns: ActionId

csharp
public static readonly ActionId CopyModeWordBackward

CopyModeWordForward

Rebindable action: move the cursor forward one word. Default: W.

Returns: ActionId

csharp
public static readonly ActionId CopyModeWordForward

EnterCopyMode

Rebindable action: enter copy mode. Default: F12.

Returns: ActionId

csharp
public static readonly ActionId EnterCopyMode

Remarks

SelectionPanel is otherwise transparent: layout, focus, and input flow through to the child unchanged. Copy mode is a modal interaction triggered by (default F12). While active, the panel:

Captures all subsequent input (focus on outer widgets is preserved but their bindings are bypassed).Renders an inverted-cell cursor over the wrapped content.Listens for movement keys (arrows/hjkl, w/b, PageUp/PageDown, Home/End, g/G) and selection-mode toggles (v character, V line, Alt+v block).Copies the selection on y/Enter via and exits. Right-click also commits (matching 's

  default).Cancels with `Esc` or `q` without copying.

Cursor coordinates are in surface-local space — the column/row of the cell as it appears in the rendered child. The cursor starts at the bottom-left when copy mode is entered, which matches chat-style interfaces where the most recent content sits at the bottom of an auto-scrolling viewport. Selection geometry mirrors 's three modes:

— terminal-style cell stream from anchor to cursor, wrapping across rows. — full rows from anchor row to cursor row. — rectangle defined by the anchor and cursor positions.

All key bindings are rebindable via WithInputBindings using the published ActionId constants on this widget. The default keys mirror 's defaults so users familiar with vi-style terminal copy mode get the same muscle memory. The entry key is F12 (rather than F6) to avoid colliding with 's default in apps that contain both widgets, and to dodge Windows Terminal's F11 full-screen toggle.

Mouse drag also enters copy mode and starts a selection. Plain drag is character mode, Ctrl+drag is line mode (matching 's default), Alt+drag is block mode. Shift+drag is also accepted as a fallback for line mode but most terminals (Windows Terminal, GNOME Terminal, iTerm2) consume Shift+mouse for OS-level native selection, so prefer Ctrl+drag for cross-platform consistency.

is overloaded to accept either a string or a payload (sync and async variants of each). Because both Action&lt;string&gt; and Action&lt;SelectionPanelCopyEventArgs&gt; are valid targets, untyped lambda parameters such as OnCopy(_ =&gt; { }) are ambiguous to the C# overload resolver: type the parameter explicitly (OnCopy((string s) =&gt; { }) or OnCopy((SelectionPanelCopyEventArgs args) =&gt; { })). Method group conversions (OnCopy(MyHandlerMethod)) work without disambiguation because the method's parameter type fixes the overload.

Released under the MIT License.