Raxol.Terminal.Buffer.Selection (Raxol v2.0.1)

View Source

Manages 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

active?(buffer)

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

Checks if there is an active selection.

clear(buffer)

Clears the current selection.

contains?(buffer, x, y)

Checks if a position is within the current selection.

get_boundaries(buffer)

Gets the current selection boundaries.

get_buffer_text(buffer)

@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.

get_end_position(buffer)

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

Gets the selection end position.

get_line(lines_list, row)

@spec get_line([String.t()], non_neg_integer()) :: String.t()

Gets a line from a list of strings at the specified index.

get_start_position(buffer)

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

Gets the selection start position.

get_text(buffer)

@spec get_text(Raxol.Terminal.ScreenBuffer.t()) :: String.t()

Gets the currently selected text.

get_text_in_region(buffer, start_x, start_y, end_x, end_y)

Gets text from a specified region in the buffer.

new(arg1, arg2)

Creates a new selection with start and end positions.

start(buffer, x, y)

Starts a text selection at the specified position.

update(buffer, x, y)

Updates the current text selection to the specified position.