pub struct SearchState { /* private fields */ }Expand description
A search and its results.
The cursor is an index into matches, so stepping is trivial and
wraps. None means “no match is current yet” — the state right
after a query changes, before the caller has picked a starting point.
Implementations§
Source§impl SearchState
impl SearchState
pub fn new() -> SearchState
pub fn needle(&self) -> &str
pub fn case_sensitive(&self) -> bool
pub fn is_active(&self) -> bool
pub fn matches(&self) -> &[Match]
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn ordinal(&self) -> Option<usize>
pub fn ordinal(&self) -> Option<usize>
1-based position of the current match, for a “3 of 17” readout.
pub fn current(&self) -> Option<Match>
pub fn current_index(&self) -> Option<usize>
Sourcepub fn is_current(&self, m: &Match) -> bool
pub fn is_current(&self, m: &Match) -> bool
Is this exact occurrence the current one?
Compared by value rather than by index so the renderer doesn’t need to know where in the list it is.
pub fn clear(&mut self)
Sourcepub fn set_results(
&mut self,
needle: &str,
case_sensitive: bool,
matches: Vec<Match>,
)
pub fn set_results( &mut self, needle: &str, case_sensitive: bool, matches: Vec<Match>, )
Install a fresh result set for needle.
Sourcepub fn seek_from(
&mut self,
order: impl Fn(MessageId) -> Option<usize>,
from_row: usize,
)
pub fn seek_from( &mut self, order: impl Fn(MessageId) -> Option<usize>, from_row: usize, )
Point the cursor at the first match at or after message, so
opening the find bar starts from what is on screen rather than
from the top of a long scrollback.
Falls back to the last match when everything is above the viewport, which is the useful direction: scrollback grows downward and the interesting end is the recent one.