pub struct TableSelect<T> { /* private fields */ }Expand description
Pick a row of a table: columns aligned under their headings, rows filtered by any cell. Returns the row’s value.
Ctrl+Y copies the focused row, and Alt+Y its focused cell, to the
terminal’s clipboard (#434): as text (cells
separated by tabs), CSV or JSON (an object keyed by the headings),
cycled with Alt+F or set with copy_format.
Ctrl+Right and Ctrl+Left move the focused column, which the headings
underline.
With scroll_x, a table wider than its list scrolls
across (#717): Left and Right move a column at a time, Shift+Home and
Shift+End go to the ends, Shift with the wheel scrolls, and the view
follows the focused column. ‹ and › at the ends of the headings say
that columns are out of view on that side.
freeze_columns keeps leading columns in place.
Implementations§
Source§impl<T> TableSelect<T>
impl<T> TableSelect<T>
Sourcepub fn new<H, S, R, V>(
prompt: impl Into<String>,
headers: H,
rows: R,
) -> TableSelect<T>where
H: IntoIterator<Item = S>,
S: Into<String>,
R: IntoIterator<Item = (V, Vec<String>)>,
V: Into<Item<T>>,
pub fn new<H, S, R, V>(
prompt: impl Into<String>,
headers: H,
rows: R,
) -> TableSelect<T>where
H: IntoIterator<Item = S>,
S: Into<String>,
R: IntoIterator<Item = (V, Vec<String>)>,
V: Into<Item<T>>,
A table of rows, each an item (its value, actions, preview) and
its cells, under headers.
pub fn preview(self, layout: PreviewLayout) -> Self
pub fn theme(self, theme: Theme) -> Self
Sourcepub fn default(self, index: usize) -> Self
pub fn default(self, index: usize) -> Self
The row returned without a terminal, and focused first.
Sourcepub fn actions(self, actions: Actions) -> Self
pub fn actions(self, actions: Actions) -> Self
Actions offered on every row, beside each row’s own.
The key that opens the action menu (default Ctrl+K).
Sourcepub fn with_mouse(self, on: bool) -> Self
pub fn with_mouse(self, on: bool) -> Self
Report the mouse: see Select::with_mouse.
pub fn items(&self) -> &[Item<T>]
Sourcepub fn set_icons(&mut self, icons: Vec<Option<Text>>)
pub fn set_icons(&mut self, icons: Vec<Option<Text>>)
An icon before each row’s label, by item index: see
Select::set_icons.
Sourcepub fn copy_format(self, format: CopyFormat) -> Self
pub fn copy_format(self, format: CopyFormat) -> Self
How Ctrl+Y and Alt+Y copy (default: text).
Sourcepub fn scroll_x(self, on: bool) -> Self
pub fn scroll_x(self, on: bool) -> Self
Scroll across when the table is wider than its list (#717), rather than cutting it at the right edge: see the type’s keys.
Sourcepub fn freeze_columns(self, columns: usize) -> Self
pub fn freeze_columns(self, columns: usize) -> Self
Keep the first columns columns in place while the rest scroll
across; turns scroll_x on.
Sourcepub fn first_column(&self) -> usize
pub fn first_column(&self) -> usize
The first column in view after the frozen ones, as of the last render.
Sourcepub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
pub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
Make keys do action (see table_keymap) on this table only.
Trait Implementations§
Source§impl<T: Clone> Component for TableSelect<T>
impl<T: Clone> Component for TableSelect<T>
type Output = T
Source§fn keymap(&self) -> Keymap
fn keymap(&self) -> Keymap
keymap). A container’s include its focused
child’s, before its own. The default declares none.Source§fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<T>
fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<T>
Outcome::Interrupted.Source§fn tick(&self) -> Option<Duration>
fn tick(&self) -> Option<Duration>
Event::Tick, for a spinner or a
countdown. None (the default): never.Source§fn mouse(&self) -> bool
fn mouse(&self) -> bool
run then enables mouse reporting
for the session.Source§fn default_value(&self) -> Option<T>
fn default_value(&self) -> Option<T>
None: there is none.Source§fn prompt(&mut self, io: &mut dyn LineIo) -> Result<Option<T>, NotInteractive>
fn prompt(&mut self, io: &mut dyn LineIo) -> Result<Option<T>, NotInteractive>
Source§fn start(&mut self, context: &Context<'_>) -> Flow<Self::Output>
fn start(&mut self, context: &Context<'_>) -> Flow<Self::Output>
Done or Cancel finishes the component
without waiting for an event. The default does nothing.Source§fn focusable(&self) -> bool
fn focusable(&self) -> bool
Source§fn focus_step(&mut self, forward: bool) -> bool
fn focus_step(&mut self, forward: bool) -> bool
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 TableSelect<T>
impl<T> !RefUnwindSafe for TableSelect<T>
impl<T> !Sync for TableSelect<T>
impl<T> !UnwindSafe for TableSelect<T>
impl<T> Send for TableSelect<T>
impl<T> Unpin for TableSelect<T>
impl<T> UnsafeUnpin for TableSelect<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
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,
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.