Skip to main content

Findable

Trait Findable 

pub trait Findable {
Show 15 methods // Required methods fn find(&mut self, query: &str, options: FindOptions) -> Vec<FindMatch>; fn reveal(&mut self, index: usize); // Provided methods fn mark_current(&mut self, _index: usize) { ... } fn set_find_cover(&mut self, _cover: Option<Rect>) { ... } fn clear_find(&mut self) { ... } fn supports_replace(&self) -> bool { ... } fn replace(&mut self, _index: usize, _with: &str) -> bool { ... } fn replace_all(&mut self, _with: &str) -> usize { ... } fn replaces_later(&self) -> bool { ... } fn supports_hex(&self) -> bool { ... } fn supports_regex(&self) -> bool { ... } fn step(&mut self, _forward: bool) -> bool { ... } fn content_revision(&self) -> u64 { ... } fn take_engine_results(&mut self) -> Option<(usize, Option<usize>)> { ... } fn take_own_find(&mut self) -> Option<OwnFind> { ... }
}
Expand description

A view whose content can be searched in place.

Required Methods§

fn find(&mut self, query: &str, options: FindOptions) -> Vec<FindMatch>

Every match of query under options, in reading order, and keep them to paint. An empty query clears the matches.

fn reveal(&mut self, index: usize)

Make match index the current one: scroll it into view and paint it emphasised (see paint_find_match).

Provided Methods§

fn mark_current(&mut self, _index: usize)

Paint match index emphasised without moving the view: the content changed under the find and the current match kept its place. A view that keeps its current match across Self::find needs nothing.

fn set_find_cover(&mut self, _cover: Option<Rect>)

What of the view the window’s search covers while its options stand open over it, in the view’s own coordinates (None: nothing). A view that scrolls reveals its current match clear of it, scrolling past its start where the match stands too near it; the search shows the current match again whenever the cover changes.

fn clear_find(&mut self)

The bar closed: stop painting matches.

fn supports_replace(&self) -> bool

Whether this view can replace text; the bar then offers a replace row.

fn replace(&mut self, _index: usize, _with: &str) -> bool

Replace match index with with. Returns whether it changed the content; an edit goes through the view’s own actions, so it is undoable.

fn replace_all(&mut self, _with: &str) -> usize

Replace every match; returns how many changed.

fn replaces_later(&self) -> bool

Whether a replacement this view took is written later, through its host’s edit path (on its next frame), rather than at once. The find then runs again once the content moved, to show the next match.

fn supports_hex(&self) -> bool

Whether this view shows bytes, so the bar offers a text/hex mode.

fn supports_regex(&self) -> bool

Whether this view can match a regular expression, so the bar offers the toggle for it (FindMode::Regex).

fn step(&mut self, _forward: bool) -> bool

Step to the next (or previous) match in a view whose engine owns the matches (a web page). Return true when the view stepped itself; it then reports the new position with FindBar::set_results. The default false lets the bar step through the matches find returned.

fn content_revision(&self) -> u64

A number that changes whenever the content under the bar changes (an edit, a page’s text arriving). The bar finds again on its next FindBar::drive when it moved, keeping the current match, so the counter never lags the content. The default never changes; such a view calls FindBar::refresh itself.

fn take_engine_results(&mut self) -> Option<(usize, Option<usize>)>

Where a view whose engine finds on its own (see Self::step) says its matches are, when it said so since the last call: (total, current), current 0-based. The bar’s counter follows on its next FindBar::drive.

fn take_own_find(&mut self) -> Option<OwnFind>

The find this view ran on its own since the last call (OwnFind), which the window’s search takes over: it shows the query and keeps the match the view went to.

Implementors§

§

impl Findable for BlockEditor

The window’s search finds in the document in place: every match is painted, and the current one is scrolled into view by the host (BlockEditor::take_find_reveal). The person’s caret, selection and the document stay as they are.