Skip to main content

PickerState

Struct PickerState 

Source
pub struct PickerState {
    pub input_state: TextState<'static>,
    pub prompt_text: Cow<'static, str>,
    /* private fields */
}
Expand description

State of the picker component

Fields§

§input_state: TextState<'static>

Current input pattern

§prompt_text: Cow<'static, str>

Prompt text to display

Implementations§

Source§

impl PickerState

Source

pub fn new( prompt: impl Into<Cow<'static, str>>, items: Vec<PickerItem>, allow_custom_input: bool, ) -> Self

Create a new picker with items

Source

pub fn pattern(&self) -> &str

Get current input pattern

Source

pub fn update_filter(&mut self)

Update the filter based on current input pattern

Source

pub fn selected(&self) -> Option<&PickerItem>

Get the currently selected item, if any

Source

pub fn filtered_items(&self) -> impl Iterator<Item = (usize, &PickerItem)>

Get all filtered items with their original indices Custom input item (if present) is always last with index usize::MAX

Source

pub fn next(&mut self)

Move cursor to next item

Source

pub fn previous(&mut self)

Move cursor to previous item

Source

pub fn cursor(&self) -> usize

Get current cursor position

Source

pub fn total_items(&self) -> usize

Get total number of items

Source

pub fn filtered_count(&self) -> usize

Get number of filtered items

Source

pub fn match_indices(&self, item_index: usize) -> Option<Vec<usize>>

Get the fuzzy match positions for a given item (for highlighting)

Source

pub fn status(&self) -> &PickerStatus

Get current status

Source

pub fn done(&mut self)

Mark picker as done (user selected an item)

Source

pub fn cancel(&mut self)

Mark picker as cancelled (user cancelled)

Source

pub fn is_done(&self) -> bool

Check if picker is done

Source

pub fn is_cancelled(&self) -> bool

Check if picker is cancelled

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.