Raxol.Terminal.SearchBuffer (Raxol v2.0.1)

View Source

Manages search state, options, matches, and history for terminal search operations.

Summary

Functions

Adds a pattern to the search history.

Clears the current search.

Clears the search history.

Finds the next match in the search.

Finds the previous match in the search.

Gets all matches in the current search.

Gets the current match index.

Gets the total number of matches.

Gets the current search options.

Gets the current search pattern.

Gets the search history.

Highlights all matches in the current view (no-op placeholder).

Sets the search options.

Starts a new search with the given pattern.

Types

match()

@type match() :: %{
  line: integer(),
  start: integer(),
  length: integer(),
  text: String.t()
}

options()

@type options() :: %{case_sensitive: boolean(), regex: boolean()}

t()

@type t() :: %Raxol.Terminal.SearchBuffer{
  current_index: integer(),
  history: [String.t()],
  matches: [match()],
  options: options(),
  pattern: String.t() | nil
}

Functions

add_to_history(buffer, pattern)

@spec add_to_history(t(), String.t()) :: t()

Adds a pattern to the search history.

clear(buffer)

@spec clear(t()) :: t()

Clears the current search.

clear_history(buffer)

@spec clear_history(t()) :: t()

Clears the search history.

find_next(buffer)

@spec find_next(t()) :: {:ok, t(), match()} | {:error, term()}

Finds the next match in the search.

find_previous(buffer)

@spec find_previous(t()) :: {:ok, t(), match()} | {:error, term()}

Finds the previous match in the search.

get_all_matches(search_buffer)

@spec get_all_matches(t()) :: [match()]

Gets all matches in the current search.

get_current_index(search_buffer)

@spec get_current_index(t()) :: integer()

Gets the current match index.

get_match_count(search_buffer)

@spec get_match_count(t()) :: non_neg_integer()

Gets the total number of matches.

get_options(search_buffer)

@spec get_options(t()) :: map()

Gets the current search options.

get_pattern(search_buffer)

@spec get_pattern(t()) :: String.t() | nil

Gets the current search pattern.

get_search_history(search_buffer)

@spec get_search_history(t()) :: [String.t()]

Gets the search history.

highlight_matches(buffer)

@spec highlight_matches(t()) :: t()

Highlights all matches in the current view (no-op placeholder).

set_options(buffer, opts)

@spec set_options(t(), map()) :: t()

Sets the search options.

start_search(buffer, pattern)

@spec start_search(t(), String.t()) :: {:ok, t()} | {:error, term()}

Starts a new search with the given pattern.