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.
public sealed record SelectionPanelWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<SelectionPanelWidget>Inheritance
Object → Hex1bWidget → SelectionPanelWidget
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:
Child(Hex1bWidget): The child widget to wrap.
public SelectionPanelWidget(Hex1bWidget Child)Properties
Child
The child widget to wrap.
Returns: Hex1bWidget
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:
handler(Action<SelectionPanelCopyEventArgs>):
Returns: SelectionPanelWidget
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:
handler(Action<String>):
Returns: SelectionPanelWidget
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:
handler(Func<SelectionPanelCopyEventArgs, Task>):
Returns: SelectionPanelWidget
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:
handler(Func<String, Task>):
Returns: SelectionPanelWidget
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
public static readonly ActionId CopyModeBufferBottomCopyModeBufferTop
Rebindable action: move the cursor to the top of the buffer. Default: G.
Returns: ActionId
public static readonly ActionId CopyModeBufferTopCopyModeCancel
Rebindable action: cancel copy mode without copying. Default: Escape, Q.
Returns: ActionId
public static readonly ActionId CopyModeCancelCopyModeCopy
Rebindable action: copy the current selection and exit copy mode. Default: Y, Enter.
Returns: ActionId
public static readonly ActionId CopyModeCopyCopyModeDown
Rebindable action: move the copy mode cursor down one row. Default: DownArrow, J.
Returns: ActionId
public static readonly ActionId CopyModeDownCopyModeLeft
Rebindable action: move the copy mode cursor left one column. Default: LeftArrow, H.
Returns: ActionId
public static readonly ActionId CopyModeLeftCopyModeLineEnd
Rebindable action: move the cursor to the end of the current row. Default: End.
Returns: ActionId
public static readonly ActionId CopyModeLineEndCopyModeLineStart
Rebindable action: move the cursor to the start of the current row. Default: Home, D0.
Returns: ActionId
public static readonly ActionId CopyModeLineStartCopyModeMouseCommit
Rebindable action: commit the current selection via mouse and exit copy mode. Default: right-click.
Returns: ActionId
public static readonly ActionId CopyModeMouseCommitCopyModePageDown
Rebindable action: move the cursor down one page. Default: PageDown.
Returns: ActionId
public static readonly ActionId CopyModePageDownCopyModePageUp
Rebindable action: move the cursor up one page. Default: PageUp.
Returns: ActionId
public static readonly ActionId CopyModePageUpCopyModeRight
Rebindable action: move the copy mode cursor right one column. Default: RightArrow, L.
Returns: ActionId
public static readonly ActionId CopyModeRightCopyModeStartSelection
Rebindable action: start or toggle a character (cell-stream) selection. Default: V, Spacebar.
Returns: ActionId
public static readonly ActionId CopyModeStartSelectionCopyModeToggleBlockMode
Rebindable action: start or toggle a block (rectangular) selection. Default: Alt+V.
Returns: ActionId
public static readonly ActionId CopyModeToggleBlockModeCopyModeToggleLineMode
Rebindable action: start or toggle a line selection. Default: Shift+V.
Returns: ActionId
public static readonly ActionId CopyModeToggleLineModeCopyModeUp
Rebindable action: move the copy mode cursor up one row. Default: UpArrow, K.
Returns: ActionId
public static readonly ActionId CopyModeUpCopyModeWordBackward
Rebindable action: move the cursor backward one word. Default: B.
Returns: ActionId
public static readonly ActionId CopyModeWordBackwardCopyModeWordForward
Rebindable action: move the cursor forward one word. Default: W.
Returns: ActionId
public static readonly ActionId CopyModeWordForwardEnterCopyMode
Rebindable action: enter copy mode. Default: F12.
Returns: ActionId
public static readonly ActionId EnterCopyModeRemarks
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<string> and Action<SelectionPanelCopyEventArgs> are valid targets, untyped lambda parameters such as OnCopy(_ => { }) are ambiguous to the C# overload resolver: type the parameter explicitly (OnCopy((string s) => { }) or OnCopy((SelectionPanelCopyEventArgs args) => { })). Method group conversions (OnCopy(MyHandlerMethod)) work without disambiguation because the method's parameter type fixes the overload.