pub struct FuzzyFinder<String: Sync + Send + 'static> {
pub kind: FuzzyKind,
pub matcher: Nucleo<String>,
pub input: Input,
pub item_count: u32,
pub matched_item_count: u32,
pub index: u32,
/* private fields */
}Expand description
The fuzzy picker of file. it may be in one of 3 kinds:
- for file, it will match against paths from current folder,
- for lines, it will match against any text of a text files from current folder,
- for actions, it will match against any text from help, allowing to run an action when you forgot the keybind.
Internally, it’s just :
- a
Nucleomatcher, - a few
u32: index, top (first displayed index), height of the window, item count, matched item count - and the current selection as a string.
The matcher is used externally by display to get the displayed matches and internally to update the selection when the user type something or move around.
The interface shouldn’t change much, except to add more shortcut.
Fields§
§kind: FuzzyKindkind of fuzzy: Line (match lines into text file), File (match file against their name), Action (match an action)
matcher: Nucleo<String>The fuzzy matcher
input: Inputtyped input by the user
item_count: u32number of parsed item
matched_item_count: u32number of matched item
index: u32selected index. Should always been smaller than matched_item_count
Implementations§
Source§impl<String: Sync + Send + 'static> FuzzyFinder<String>
impl<String: Sync + Send + 'static> FuzzyFinder<String>
Sourcepub fn set_height(self, height: usize) -> Self
pub fn set_height(self, height: usize) -> Self
Set the terminal height of the fuzzy picker. It should always be called after new
Sourcepub fn should_preview(&self) -> bool
pub fn should_preview(&self) -> bool
True iff a preview should be built for this fuzzy finder. It only makes sense to preview files not lines nor actions.
Sourcepub fn update_input(&mut self, append: bool)
pub fn update_input(&mut self, append: bool)
if insert char: append = true, if delete char: append = false,
Sourcepub fn tick(&mut self, force: bool)
pub fn tick(&mut self, force: bool)
tick the matcher. refresh the selection if the status changed or if force = true.
Sourcepub fn top_bottom(&self) -> (u32, u32)
pub fn top_bottom(&self) -> (u32, u32)
Calculate the first & last matching index which should be stored in content.
It assumes the index can’t change by more than one at a time.
Returning both values (top & bottom) allows to avoid mutating self here.
This method can be called in crate::io::Display to know what matches should be drawn.
It should only be called after a refresh of the matcher to be sure the matched_item_count is correct.
Several cases :
- if there’s not enough element to fill the display, take everything.
- if the selection is in the top 4 rows, scroll up if possible.
- if the selection is in the last 4 rows, scroll down if possible.
- otherwise, don’t move.
Scrolling is done only at top or bottom, not in the middle of the screen. It feels more natural.
Source§impl FuzzyFinder<String>
impl FuzzyFinder<String>
pub fn find_files(&self, current_path: PathBuf)
pub fn find_action(&self, help: String)
pub fn find_line(&self, tokio_greper: TokioCommand)
Trait Implementations§
Auto Trait Implementations§
impl<String> Freeze for FuzzyFinder<String>
impl<String> !RefUnwindSafe for FuzzyFinder<String>
impl<String> Send for FuzzyFinder<String>
impl<String> Sync for FuzzyFinder<String>
impl<String> Unpin for FuzzyFinder<String>
impl<String> !UnwindSafe for FuzzyFinder<String>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more