pub struct Searcher { /* private fields */ }Expand description
A query compiled for searching.
Implementations§
Source§impl Searcher
impl Searcher
pub fn new(query: &SearchQuery) -> Result<Self, SearchError>
Sourcepub fn new_raw(query: &SearchQuery) -> Result<Self, SearchError>
pub fn new_raw(query: &SearchQuery) -> Result<Self, SearchError>
A searcher for text that keeps its CR LF and CR line endings (a file
read as it is on disk): ^, $ and . treat \r as part of the
line break, as they treat \n.
pub fn options(&self) -> &SearchOptions
Sourcepub fn find_next(
&self,
doc: &Document,
from: ByteOffset,
) -> Option<Range<ByteOffset>>
pub fn find_next( &self, doc: &Document, from: ByteOffset, ) -> Option<Range<ByteOffset>>
The first match starting at or after from.
Sourcepub fn find_prev(
&self,
doc: &Document,
before: ByteOffset,
) -> Option<Range<ByteOffset>>
pub fn find_prev( &self, doc: &Document, before: ByteOffset, ) -> Option<Range<ByteOffset>>
The last match starting before before. Searches backwards in
growing windows, so a match near the caret is found quickly.
Sourcepub fn matches<'a>(
&'a self,
doc: &'a Document,
range: Range<ByteOffset>,
) -> impl Iterator<Item = Range<ByteOffset>> + 'a
pub fn matches<'a>( &'a self, doc: &'a Document, range: Range<ByteOffset>, ) -> impl Iterator<Item = Range<ByteOffset>> + 'a
The matches inside range, found as the iterator is advanced (so a
caller can stop after enough of them).
Sourcepub fn find_all(
&self,
doc: &Document,
range: Range<ByteOffset>,
) -> Vec<Range<ByteOffset>>
pub fn find_all( &self, doc: &Document, range: Range<ByteOffset>, ) -> Vec<Range<ByteOffset>>
All matches inside range.
Sourcepub fn find_all_bytes(&self, hay: &[u8]) -> Vec<Range<usize>>
pub fn find_all_bytes(&self, hay: &[u8]) -> Vec<Range<usize>>
Every match in hay: text already in memory, such as a line on
screen.
Sourcepub fn matches_in<'a>(
&'a self,
src: &'a dyn ByteSource,
range: Range<u64>,
) -> impl Iterator<Item = Range<u64>> + 'a
pub fn matches_in<'a>( &'a self, src: &'a dyn ByteSource, range: Range<u64>, ) -> impl Iterator<Item = Range<u64>> + 'a
The matches inside range of src, found as the iterator is
advanced (reading src a chunk at a time).
Sourcepub fn find_next_in(
&self,
src: &dyn ByteSource,
from: u64,
) -> Option<Range<u64>>
pub fn find_next_in( &self, src: &dyn ByteSource, from: u64, ) -> Option<Range<u64>>
The first match in src starting at or after from.
Sourcepub fn find_prev_in(
&self,
src: &dyn ByteSource,
before: u64,
) -> Option<Range<u64>>
pub fn find_prev_in( &self, src: &dyn ByteSource, before: u64, ) -> Option<Range<u64>>
The last match in src starting before before, looked for in
growing windows before it. A match may run at most 64 KB past
before (the search stops there, so a document without matches
after the caret is not read to its end).
Sourcepub fn expand(
&self,
doc: &Document,
m: Range<ByteOffset>,
replacement: &str,
) -> String
pub fn expand( &self, doc: &Document, m: Range<ByteOffset>, replacement: &str, ) -> String
The replacement text for the match at m.
Sourcepub fn ranges(
&self,
doc: &Document,
sels: &SelectionSet,
) -> Vec<Range<ByteOffset>>
pub fn ranges( &self, doc: &Document, sels: &SelectionSet, ) -> Vec<Range<ByteOffset>>
The ranges to search: the non-empty selections with “in selection” on, otherwise the whole document.
Sourcepub fn find_in(
&self,
doc: &Document,
sels: &SelectionSet,
) -> Vec<Range<ByteOffset>>
pub fn find_in( &self, doc: &Document, sels: &SelectionSet, ) -> Vec<Range<ByteOffset>>
Matches in the ranges ranges selects.
Sourcepub fn next_from(
&self,
doc: &Document,
sels: &SelectionSet,
backward: bool,
) -> Option<Range<ByteOffset>>
pub fn next_from( &self, doc: &Document, sels: &SelectionSet, backward: bool, ) -> Option<Range<ByteOffset>>
The match to select for Find Next/Previous from the current primary selection, wrapping if enabled.
Sourcepub fn replacement_for_selection(
&self,
doc: &Document,
sels: &SelectionSet,
replacement: &str,
) -> Option<(Range<ByteOffset>, String)>
pub fn replacement_for_selection( &self, doc: &Document, sels: &SelectionSet, replacement: &str, ) -> Option<(Range<ByteOffset>, String)>
If the primary selection is exactly a match, the range and its replacement text (for Replace).