pub struct PickerOptions { /* private fields */ }Expand description
Specify configuration options for a Picker.
Initialize with new or (equivalently) the
Default implementation, specify options, and then convert to a
Picker using the picker method.
§Example
use nucleo_picker::{render::StrRenderer, Picker, PickerOptions};
let picker: Picker<String, _> = PickerOptions::new()
.highlight(true)
.query("search")
.picker(StrRenderer);§Sort order settings
There are three settings which influence the order in which items appear on the screen.
The reversed setting only influences the layout: by default, the query is
placed at the bottom of the screen, with the match list rendered bottom-up. If this is set, the query will be placed at the top of the screen, with the match list rendered top-down.
The reverse_items and sort_results are used to
determine the order of the items inside the match list. The order is defined according to the
following table. Here, Index refers to the order in which the picker received the items
from the Injectors. If you use exactly one injector, this is guaranteed to be the same as
the insertion order.
sort_results | reverse_items | Sort priority |
|---|---|---|
true | false | Score (desc) → Length (asc) → Index (asc) |
true | true | Score (desc) → Length (asc) → Index (desc) |
false | false | Index (asc) |
false | true | Index (desc) |
Implementations§
Source§impl PickerOptions
impl PickerOptions
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Initialize with default configuration.
Equivalent to the Default implementation, but as a const fn.
Sourcepub fn picker<T: Send + Sync + 'static, R: Render<T>>(
self,
render: R,
) -> Picker<T, R>
pub fn picker<T: Send + Sync + 'static, R: Render<T>>( self, render: R, ) -> Picker<T, R>
Convert into a Picker.
Sourcepub const fn reversed(self, reversed: bool) -> Self
pub const fn reversed(self, reversed: bool) -> Self
Set ‘reversed’ layout.
Option false (default) will put the prompt at the bottom and render items in ascending
order. Option true will put the prompt at the top and render items in descending order.
Sourcepub const fn reverse_items(self, reversed: bool) -> Self
pub const fn reverse_items(self, reversed: bool) -> Self
Reverse the item insert order.
This changes the index tie-break method to prefer later indices rather than earlier
indices. This option is typically used with sort_results set
to false, in which case the newest items sent to the picker will be placed
first, rather than last.
The default is false.
Sourcepub const fn sort_results(self, sort: bool) -> Self
pub const fn sort_results(self, sort: bool) -> Self
Whether or not to sort matching items by score.
This option is useful when you just want to filter items, but preserve the original order.
By default, the oldest items will appear at the beginning and the newest items will appear at the end.
This can be swapped by setting reverse_items to true.
Sourcepub const fn frame_interval(self, interval: Duration) -> Self
pub const fn frame_interval(self, interval: Duration) -> Self
Set how long each frame should last.
This is the reciprocal of the refresh rate. The default value is
Duration::from_millis(15), which corresponds to a refresh rate of approximately 67 frames
per second. It is not recommended to set this to a value less than 8ms.
Sourcepub const fn threads(self, threads: Option<NonZero<usize>>) -> Self
pub const fn threads(self, threads: Option<NonZero<usize>>) -> Self
Set the number of threads used by the internal matching engine.
If None (default), use a heuristic choice based on the amount of available
parallelism along with other factors.
Sourcepub fn config(self, config: Config) -> Self
👎Deprecated since 0.10.0: Use native methods prefer_prefix and match_paths. The normalize and ignore_case settings are never used; use normalization and case_matching instead.
pub fn config(self, config: Config) -> Self
prefer_prefix and match_paths. The normalize and ignore_case settings are never used; use normalization and case_matching instead.Set the internal match engine configuration (default to nucleo::Config::DEFAULT).
Sourcepub const fn normalization(self, normalization: Normalization) -> Self
pub const fn normalization(self, normalization: Normalization) -> Self
How to perform Unicode normalization (defaults to Normalization::Smart).
Sourcepub const fn case_matching(self, case_matching: CaseMatching) -> Self
pub const fn case_matching(self, case_matching: CaseMatching) -> Self
How to treat case mismatch (defaults to CaseMatching::Smart).
Sourcepub const fn match_paths(self) -> Self
pub const fn match_paths(self) -> Self
Enable score bonuses appropriate for matching file paths.
Sourcepub const fn prefer_prefix(self, prefer_prefix: bool) -> Self
pub const fn prefer_prefix(self, prefer_prefix: bool) -> Self
Whether to provide a bonus to matches by their distance from the start of the item.
This is disabled by default and only recommended for autocompletion use-cases, where the expectation is that the user is typing the entire match.
Sourcepub const fn highlight(self, highlight: bool) -> Self
pub const fn highlight(self, highlight: bool) -> Self
Whether or not to highlight matches (default to true).
Sourcepub const fn highlight_padding(self, size: u16) -> Self
pub const fn highlight_padding(self, size: u16) -> Self
How much space to leave when rendering match highlighting (default to 3).
Sourcepub const fn scroll_padding(self, size: u16) -> Self
pub const fn scroll_padding(self, size: u16) -> Self
How much space to leave around the selection when scrolling (default to 3).
Sourcepub const fn prompt_padding(self, size: u16) -> Self
pub const fn prompt_padding(self, size: u16) -> Self
How much space to leave around the cursor (default to 2).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PickerOptions
impl RefUnwindSafe for PickerOptions
impl Send for PickerOptions
impl Sync for PickerOptions
impl Unpin for PickerOptions
impl UnwindSafe for PickerOptions
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> 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