pub struct Picker {
pub kind: Kind,
pub prompt: String,
pub cursor: usize,
/* private fields */
}Fields§
§kind: Kind§prompt: StringWhat has been typed, verbatim.
cursor: usizePosition within hits, not within items.
Implementations§
Source§impl Picker
impl Picker
pub fn new(kind: Kind, items: Vec<Item>) -> Self
pub fn is_empty(&self) -> bool
pub fn total(&self) -> usize
pub fn shown(&self) -> usize
Sourcepub fn rows(&self) -> impl Iterator<Item = (&Item, &Match)>
pub fn rows(&self) -> impl Iterator<Item = (&Item, &Match)>
The visible entries, best first, each with the match positions that produced it so the renderer can underline the characters that were actually typed.
pub fn selected(&self) -> Option<&Item>
Sourcepub fn accept(&self) -> Option<&Target>
pub fn accept(&self) -> Option<&Target>
The target of the entry under the cursor, if there is one.
pub fn push(&mut self, c: char)
Sourcepub fn backspace(&mut self) -> bool
pub fn backspace(&mut self) -> bool
Delete a character. false when there was nothing to delete, which the caller turns
into closing the picker, the way backspace on an empty prompt does everywhere else.
Sourcepub fn move_cursor(&mut self, delta: isize)
pub fn move_cursor(&mut self, delta: isize)
Move the cursor, clamping rather than wrapping.
Clamping, unlike /, because a picker’s list is right there: running off the bottom
and reappearing at the top in a list you can see in full is disorienting, where in a
thousand-row table a wrap is the only way to keep going.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Picker
impl RefUnwindSafe for Picker
impl Send for Picker
impl Sync for Picker
impl Unpin for Picker
impl UnsafeUnpin for Picker
impl UnwindSafe for Picker
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
Mutably borrows from an owned value. Read more