TermUI.Clipboard.Selection (TermUI v0.2.0)
View SourceSelection state management for clipboard operations.
Tracks text selection with start and end positions, supporting selection expansion with Shift+arrow keys and clearing on navigation without Shift.
Usage
# Create selection
selection = Selection.new()
# Start selection at cursor
selection = Selection.start(selection, 5)
# Extend selection
selection = Selection.extend(selection, 10)
# Get selected range
{start, finish} = Selection.range(selection)
# Extract content
selected_text = Selection.extract(selection, "Hello World")
Summary
Functions
Checks if there is an active selection.
Clears the selection.
Checks if a position is within the selection.
Checks if the selection is empty (start equals end).
Expands the selection in a direction.
Extends the selection to a new position.
Extracts selected content from a string.
Returns the length of the selection.
Moves the selection by a delta.
Creates a new empty selection.
Returns the selection range as {start, end}.
Selects all text.
Selects a word at the given position.
Starts a new selection at the given position.
Types
Functions
Checks if there is an active selection.
Clears the selection.
Checks if a position is within the selection.
Checks if the selection is empty (start equals end).
Expands the selection in a direction.
Direction can be :left, :right, :word_left, :word_right,
:line_start, :line_end, :all.
Extends the selection to a new position.
The selection extends from the anchor to the new position.
Extracts selected content from a string.
Returns empty string if no selection is active.
Returns the length of the selection.
Moves the selection by a delta.
Both start and end positions are adjusted.
@spec new() :: t()
Creates a new empty selection.
Returns the selection range as {start, end}.
Returns nil if no selection is active.
Selects all text.
Selects a word at the given position.
Starts a new selection at the given position.
This sets the anchor point for the selection.