pub struct MultiSelect<T>(/* private fields */);Expand description
A fuzzy multiple choice: Tab marks items (Shift+Tab marks and moves up, Ctrl+A marks every match), Enter returns the marked items in list order, or the focused one when none is marked.
Implementations§
Source§impl<T> MultiSelect<T>
impl<T> MultiSelect<T>
pub fn new<I, V>(prompt: impl Into<String>, items: I) -> MultiSelect<T>
pub fn height(self, rows: usize) -> Self
pub fn preview(self, layout: PreviewLayout) -> Self
pub fn theme(self, theme: Theme) -> Self
pub fn query(self, query: impl Into<String>) -> Self
Sourcepub fn repaint_every(self, interval: Duration) -> Self
pub fn repaint_every(self, interval: Duration) -> Self
Sourcepub fn actions(self, actions: Actions) -> Self
pub fn actions(self, actions: Actions) -> Self
See Select::actions.
Sourcepub fn with_mouse(self, on: bool) -> Self
pub fn with_mouse(self, on: bool) -> Self
See Select::with_mouse.
Sourcepub fn reload_on(
self,
key: Key,
source: impl FnMut() -> Vec<Item<T>> + Send + 'static,
) -> Self
pub fn reload_on( self, key: Key, source: impl FnMut() -> Vec<Item<T>> + Send + 'static, ) -> Self
See Select::reload_on: marks stay with their items.
Sourcepub fn reload_from(self, feed: Receiver<Vec<Item<T>>>) -> Self
pub fn reload_from(self, feed: Receiver<Vec<Item<T>>>) -> Self
See Select::reload_from.
Sourcepub fn reload(&mut self, items: Vec<Item<T>>)
pub fn reload(&mut self, items: Vec<Item<T>>)
Replace the items, keeping the query, the focus and the marks: see
Select::reload.
Sourcepub fn marked(self, indices: impl IntoIterator<Item = usize>) -> Self
pub fn marked(self, indices: impl IntoIterator<Item = usize>) -> Self
Mark these items to begin with; they are also the default without a terminal.
pub fn action(&self) -> Option<&str>
pub fn items(&self) -> &[Item<T>]
Trait Implementations§
Source§impl<T: Clone> Component for MultiSelect<T>
impl<T: Clone> Component for MultiSelect<T>
type Output = Vec<T>
Source§fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<Vec<T>>
fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<Vec<T>>
Handle one event. Ctrl+C never arrives here: the event loop ends the
component with
Outcome::Interrupted.Source§fn keymap(&self) -> Keymap
fn keymap(&self) -> Keymap
The bindings this component has right now, for a help overlay, a
shortcut list or status-bar hints to read (see
keymap). A container’s include its focused
child’s, before its own. The default declares none.Source§fn tick(&self) -> Option<Duration>
fn tick(&self) -> Option<Duration>
How often the component wants
Event::Tick, for a spinner or a
countdown. None (the default): never.Source§fn mouse(&self) -> bool
fn mouse(&self) -> bool
Whether the component wants mouse events (#476): clicks, drags and
the wheel. Off by default, since reporting the mouse takes text
selection away from the terminal; a component turns it on when its
caller opts in, and
run then enables mouse reporting
for the session.Source§fn default_value(&self) -> Option<Vec<T>>
fn default_value(&self) -> Option<Vec<T>>
The value to return when the terminal is not interactive and the
policy asks for defaults.
None: there is none.Source§fn prompt(
&mut self,
io: &mut dyn LineIo,
) -> Result<Option<Vec<T>>, NotInteractive>
fn prompt( &mut self, io: &mut dyn LineIo, ) -> Result<Option<Vec<T>>, NotInteractive>
Ask for the value line by line, for when the terminal is not
interactive and the policy asks for a prompt. The default says the
component has no line-based form. Read more
Source§fn start(&mut self, context: &Context<'_>) -> Flow<Self::Output>
fn start(&mut self, context: &Context<'_>) -> Flow<Self::Output>
Called once, before the component is first painted, with the
terminal’s size: for work that needs it, such as rendering content
at the width. Returning
Done or Cancel finishes the component
without waiting for an event. The default does nothing.Source§fn focusable(&self) -> bool
fn focusable(&self) -> bool
Whether the component takes focus in a container: Tab stops on it
and keys go to it. The default: yes. A label, or a component that
has finished, says no.
Source§fn focus_step(&mut self, forward: bool) -> bool
fn focus_step(&mut self, forward: bool) -> bool
Move focus to the next (
forward) or previous focus stop inside
this component, for Tab and Shift+Tab. false when there is none
after the current one, so the container moves on to its next
child. The default, for a component that is one stop: false.Auto Trait Implementations§
impl<T> !Freeze for MultiSelect<T>
impl<T> !RefUnwindSafe for MultiSelect<T>
impl<T> !Sync for MultiSelect<T>
impl<T> !UnwindSafe for MultiSelect<T>
impl<T> Send for MultiSelect<T>
impl<T> Unpin for MultiSelect<T>
impl<T> UnsafeUnpin for MultiSelect<T>where
Select<T>: UnsafeUnpin,
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
Source§impl<C> ComponentExt for Cwhere
C: Component,
impl<C> ComponentExt for Cwhere
C: Component,
Source§fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
Turn this component’s answer into
M’s flow: Flow::Done(m) to
finish the whole composition with m, Flow::Continue to carry on
(the component stays, showing its answer, and focus moves past it).
Cancelling cancels the composition unless
on_cancel says otherwise.