Raxol.Terminal.Buffer.Selection (Raxol v2.0.1)
View SourceManages text selection operations for the terminal. This module handles all selection-related operations including:
- Starting and updating selections
- Getting selected text
- Checking if positions are within selections
- Managing selection boundaries
- Extracting text from regions
Summary
Functions
Checks if there is an active selection.
Clears the current selection.
Checks if a position is within the current selection.
Gets the current selection boundaries.
Gets the buffer text for the current selection. This is an alias for get_text/1 for compatibility.
Gets the selection end position.
Gets a line from a list of strings at the specified index.
Gets the selection start position.
Gets the currently selected text.
Gets text from a specified region in the buffer.
Creates a new selection with start and end positions.
Starts a text selection at the specified position.
Updates the current text selection to the specified position.
Functions
@spec active?(Raxol.Terminal.ScreenBuffer.t()) :: boolean()
Checks if there is an active selection.
@spec clear(Raxol.Terminal.ScreenBuffer.t()) :: Raxol.Terminal.ScreenBuffer.t()
Clears the current selection.
@spec contains?(Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer()) :: boolean()
Checks if a position is within the current selection.
@spec get_boundaries(Raxol.Terminal.ScreenBuffer.t()) :: {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()} | nil
Gets the current selection boundaries.
@spec get_buffer_text(Raxol.Terminal.ScreenBuffer.t()) :: {:ok, String.t()} | {:error, term()}
Gets the buffer text for the current selection. This is an alias for get_text/1 for compatibility.
@spec get_end_position(Raxol.Terminal.ScreenBuffer.t()) :: {non_neg_integer(), non_neg_integer()} | nil
Gets the selection end position.
@spec get_line([String.t()], non_neg_integer()) :: String.t()
Gets a line from a list of strings at the specified index.
@spec get_start_position(Raxol.Terminal.ScreenBuffer.t()) :: {non_neg_integer(), non_neg_integer()} | nil
Gets the selection start position.
@spec get_text(Raxol.Terminal.ScreenBuffer.t()) :: String.t()
Gets the currently selected text.
@spec get_text_in_region( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer() ) :: String.t()
Gets text from a specified region in the buffer.
@spec new( {non_neg_integer(), non_neg_integer()}, {non_neg_integer(), non_neg_integer()} ) :: {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
Creates a new selection with start and end positions.
@spec start(Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer()) :: Raxol.Terminal.ScreenBuffer.t()
Starts a text selection at the specified position.
@spec update(Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer()) :: Raxol.Terminal.ScreenBuffer.t()
Updates the current text selection to the specified position.