TerminalSelection
Namespace: Hex1b
Assembly: Hex1b.dll
Tracks the current text selection state within a terminal buffer.
public sealed class TerminalSelectionInheritance
Object → TerminalSelection
Constructors
TerminalSelection(BufferPosition)
Creates a new selection with the cursor at the specified position. No text is selected until is called.
Parameters:
initialPosition(BufferPosition):
public TerminalSelection(BufferPosition initialPosition)Properties
Anchor
The position where the selection was started.
Returns: BufferPosition
public BufferPosition Anchor { get; }Cursor
The current cursor position (the moving end of the selection).
Returns: BufferPosition
public BufferPosition Cursor { get; }End
Gets the end (later) position of the selection.
Returns: BufferPosition
public BufferPosition End { get; }IsSelecting
Whether a selection range is active (anchor has been set and cursor is moving). When false, only the cursor is positioned but no text is selected.
Returns: Boolean
public bool IsSelecting { get; }Mode
The selection mode (character, line, or block).
Returns: SelectionMode
public SelectionMode Mode { get; }Start
Gets the start (earlier) position of the selection.
Returns: BufferPosition
public BufferPosition Start { get; }Methods
ClearSelection()
Clears the selection but keeps the cursor position.
public void ClearSelection()ExtractText(Func<int, int, TerminalCell?>, int)
Extracts the selected text from a virtual buffer.
Parameters:
getCell(Func<Int32, Int32, TerminalCell>>): Function to get a cell at (virtualRow, column). Returns null for out-of-bounds.bufferWidth(Int32): The width of the buffer (columns per row).
Returns: String
The selected text, or null if no selection is active.
public string? ExtractText(Func<int, int, TerminalCell?> getCell, int bufferWidth)IsCellSelected(int, int)
Determines whether the specified cell position is within the current selection.
Parameters:
Returns: Boolean
True if the cell is selected.
public bool IsCellSelected(int row, int column)MoveCursor(BufferPosition)
Moves the cursor to the specified position. If selecting, extends the selection.
Parameters:
position(BufferPosition):
public void MoveCursor(BufferPosition position)StartSelection(SelectionMode)
Begins a selection at the current cursor position.
Parameters:
mode(SelectionMode):
public void StartSelection(SelectionMode mode = SelectionMode.Character)ToggleMode(SelectionMode)
Toggles between selection modes. If the requested mode is already active, switches back to character mode.
Parameters:
mode(SelectionMode):
public void ToggleMode(SelectionMode mode)Remarks
The selection operates on a "virtual buffer" that unifies scrollback and screen rows. Scrollback rows are indexed 0..scrollbackCount-1, and screen rows are indexed scrollbackCount..scrollbackCount+screenHeight-1.