Raxol.Search.Fuzzy (Raxol v2.0.1)
View SourceSearch system with fuzzy, exact, and regex matching.
Provides multiple search modes for finding text in terminal buffers:
- Fuzzy matching (like fzf)
- Exact string matching
- Regular expression matching
- Result highlighting
- Navigation with n/N
Example
buffer = Buffer.create_blank_buffer(80, 24)
# ... populate buffer ...
# Fuzzy search
results = Fuzzy.search(buffer, "hlo", :fuzzy)
# Matches "hello", "halo", etc.
# Exact search
results = Fuzzy.search(buffer, "hello", :exact)
# Regex search
results = Fuzzy.search(buffer, ~r/h.llo/, :regex)
Summary
Functions
Get all match positions.
Get current match position.
Get search statistics.
Highlight search results in buffer.
Create a new search state.
Navigate to next match.
Navigate to previous match.
Perform a search on the buffer.
Update search query and find new matches.
Types
@type match() :: %{ position: position(), text: String.t(), score: float(), highlight: [{non_neg_integer(), non_neg_integer()}] }
@type position() :: {non_neg_integer(), non_neg_integer()}
@type search_mode() :: :fuzzy | :exact | :regex
@type t() :: %Raxol.Search.Fuzzy{ buffer: Raxol.Core.Buffer.t(), case_sensitive: boolean(), current_index: non_neg_integer(), matches: [match()], mode: search_mode(), query: String.t() }
Functions
Get all match positions.
Get current match position.
Get search statistics.
@spec highlight_matches(Raxol.Core.Buffer.t(), [match()], map()) :: Raxol.Core.Buffer.t()
Highlight search results in buffer.
Returns a new buffer with highlighted matches.
@spec new(Raxol.Core.Buffer.t(), map()) :: t()
Create a new search state.
Navigate to next match.
Navigate to previous match.
@spec search(Raxol.Core.Buffer.t(), String.t(), search_mode(), map()) :: [match()]
Perform a search on the buffer.
Update search query and find new matches.