Raxol.Terminal.ScreenBuffer.Selection (Raxol v2.3.0)

View Source

Text selection operations for the screen buffer. Handles selection creation, updates, text extraction, and clipboard operations.

Summary

Functions

Clears the current selection.

Expands selection to word boundaries.

Extends the selection to the specified position. Starts a new selection if none exists.

Gets the selected text as lines.

Gets the selected text as a string.

Gets the current selection boundaries, normalized so start <= end.

Checks if there is an active selection.

Checks if a position is within the current selection. Delegates to selected?/3.

Selects all content in the buffer.

Selects an entire line.

Selects multiple lines.

Selects a word at the given position.

Checks if the specified position is within the current selection.

Starts a new selection at the specified position.

Updates the selection endpoint. Returns buffer unchanged if no selection exists. Unlike extend_selection/3, does not start a new selection on nil.

Types

selection()

@type selection() ::
  {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
  | nil

Functions

clear_selection(buffer)

Clears the current selection.

expand_selection_to_word(buffer)

Expands selection to word boundaries.

extend_selection(buffer, x, y)

Extends the selection to the specified position. Starts a new selection if none exists.

get_selected_lines(buffer)

@spec get_selected_lines(Raxol.Terminal.ScreenBuffer.Core.t()) :: [String.t()]

Gets the selected text as lines.

get_selected_text(buffer)

@spec get_selected_text(Raxol.Terminal.ScreenBuffer.Core.t()) :: String.t()

Gets the selected text as a string.

get_selection(buffer)

@spec get_selection(Raxol.Terminal.ScreenBuffer.Core.t()) :: selection()

Gets the current selection boundaries, normalized so start <= end.

get_selection_boundaries(buffer)

@spec get_selection_boundaries(Raxol.Terminal.ScreenBuffer.Core.t()) ::
  {{non_neg_integer(), non_neg_integer()},
   {non_neg_integer(), non_neg_integer()}}
  | nil

get_selection_end(buffer)

@spec get_selection_end(Raxol.Terminal.ScreenBuffer.Core.t()) ::
  {non_neg_integer(), non_neg_integer()} | nil

get_selection_start(buffer)

@spec get_selection_start(Raxol.Terminal.ScreenBuffer.Core.t()) ::
  {non_neg_integer(), non_neg_integer()} | nil

has_selection?(buffer)

@spec has_selection?(Raxol.Terminal.ScreenBuffer.Core.t()) :: boolean()

Checks if there is an active selection.

position_in_selection?(buffer, x, y)

@spec position_in_selection?(
  Raxol.Terminal.ScreenBuffer.Core.t(),
  integer(),
  integer()
) :: boolean()

Checks if a position is within the current selection. Delegates to selected?/3.

select_all(buffer)

Selects all content in the buffer.

select_line(buffer, y)

Selects an entire line.

select_lines(buffer, start_y, end_y)

Selects multiple lines.

select_word(buffer, x, y)

Selects a word at the given position.

selected?(buffer, x, y)

Checks if the specified position is within the current selection.

selection_active?(buffer)

@spec selection_active?(Raxol.Terminal.ScreenBuffer.Core.t()) :: boolean()

Delegates to has_selection?/1.

start_selection(buffer, x, y)

Starts a new selection at the specified position.

update_selection(buffer, x, y)

Updates the selection endpoint. Returns buffer unchanged if no selection exists. Unlike extend_selection/3, does not start a new selection on nil.