TerminalSelectionController class
A controller that manages terminal cell selection state, supporting character/stream,
word, line, and rectangular block/box selection modes, pane region clamping,
virtual-scrollback coordinate offsets, wide-grapheme boundary snapping,
unified OSC 8 + plain-text link resolution, and clipboard text extraction.
- Implemented types
Constructors
- TerminalSelectionController()
- Creates a new TerminalSelectionController.
Properties
- anchor → SelectionPoint?
-
The selection starting anchor point.
no setter
- focus → SelectionPoint?
-
The current active selection focus point.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasSelection → bool
-
Whether there is currently an active selection with both anchor and focus.
no setter
- isSelecting → bool
-
Whether a selection gesture has been initiated.
no setter
- mode → SelectionMode
-
The active selection mode.
no setter
- region → SelectionRegion?
-
The bounding selectable region, if confined to a sub-pane.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
void listener()) → void -
Adds a listener to be notified when the state changes.
override
-
clearSelection(
) → void - Clears the current selection.
-
containsCell(
int col, int row, {int topVirtualRow = 0, int leftVirtualCol = 0}) → bool -
Returns whether the viewport cell at
(col, row)(offset bytopVirtualRowandleftVirtualCol) is currently selected. -
dispose(
) → void - Disposes the controller, removing all listeners.
-
extractSelectedText(
Buffer buffer, {bool includeHidden = true, int topVirtualRow = 0, int leftVirtualCol = 0}) → String -
Extracts the text contained in the current selection from
buffer. -
extractText(
Buffer buffer, {bool includeHidden = true, int topVirtualRow = 0, int leftVirtualCol = 0}) → String - Alias for extractSelectedText.
-
extractVirtualText(
VirtualLineLookup lookup, {required int cols}) → String -
Extracts selected text across
lookup, joining soft-wrapped rows (isWrapped == true) without\nunless mode is SelectionMode.block. -
isCellSelected(
int x, int y, {int topVirtualRow = 0, int leftVirtualCol = 0}) → bool -
Returns whether the viewport cell at
([x], [y])(offset bytopVirtualRowandleftVirtualCol) is currently selected. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void - Notifies all registered listeners of a change in selection state.
-
removeListener(
void listener()) → void -
Removes a previously registered listener.
override
-
selectWord(
Buffer buffer, int col, int row, {SelectionRegion? region}) → void -
Selects the contiguous word at
(col, row)inbuffer. -
startSelection(
int col, int row, {SelectionMode mode = SelectionMode.character, SelectionRegion? region}) → void -
Begins a new selection starting at
(col, row). -
toString(
) → String -
A string representation of this object.
inherited
-
updateSelection(
int col, int row, {SelectionMode? mode}) → void -
Updates the selection endpoint to
(col, row). -
updateWordSelection(
Buffer buffer, int col, int row) → void -
Extends a word-snapped selection from the initial
_wordAnchorto the word at(col, row)inbuffer, supporting forward, backward, and direction-reversed drags across wide graphemes. -
visibleRowSpans(
Buffer buffer, {int topVirtualRow = 0, int leftVirtualCol = 0}) → List< (int, int, int)> -
Intersects the active selection with
buffer's0..width-1by0..height-1viewport (starting attopVirtualRowandleftVirtualCol) and snaps wide-grapheme continuation ("") boundaries.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
resolveLinkSpanAt(
{required VirtualLineLookup lookup, required int col, required int virtualRow}) → ResolvedTerminalLink? -
Resolves a hyperlink span at
([col], [virtualRow])across soft-wrapped rows inlookup, preferring contiguousOSC 8urisspans first and falling back to plain-texthttp://,https://, andmailto:tokens. -
resolveRegionForCell(
Buffer buffer, int col, int row, {SelectionMode mode = SelectionMode.character}) → SelectionRegion? -
Resolves the confining SelectionRegion for a pointer gesture starting at
([col], [row])inbuffer, or returnsnullwhen selection should span the full buffer unconstrained. -
snapWideBounds(
List< String> chars, int rowOffset, int colStart, int colEnd, {int minCol = 0, required int maxCol}) → (int, int) -
Snaps
(colStart, colEnd)outward across wide-grapheme continuation ("") cells within[minCol, maxCol].