pub struct Model {Show 24 fields
pub show_title: bool,
pub show_filter: bool,
pub show_status_bar: bool,
pub show_pagination: bool,
pub show_help: bool,
pub filtering_enabled: bool,
pub title: String,
pub styles: Styles,
pub infinite_scrolling: bool,
pub key_map: KeyMap,
pub filter: FilterFunc,
pub disable_quit_keybindings: bool,
pub additional_short_help_keys: Option<Box<dyn Fn() -> Vec<Binding> + Send + Sync>>,
pub additional_full_help_keys: Option<Box<dyn Fn() -> Vec<Binding> + Send + Sync>>,
pub spinner: Model,
pub show_spinner: bool,
pub width: usize,
pub height: usize,
pub paginator: Model,
pub help: Model,
pub filter_input: Model,
pub filter_state: FilterState,
pub status_message_lifetime: Duration,
pub items: Vec<Box<dyn Item + Send + Sync>>,
/* private fields */
}Expand description
Model contains the state of this component.
Fields§
§show_title: bool§show_filter: bool§show_status_bar: bool§show_pagination: bool§show_help: bool§filtering_enabled: bool§title: StringThe title of the list.
styles: StylesThe styles for the list.
infinite_scrolling: boolWhether scrolling is infinite.
key_map: KeyMapKey mappings for navigating the list.
filter: FilterFuncFilter is used to filter the list.
disable_quit_keybindings: bool§additional_short_help_keys: Option<Box<dyn Fn() -> Vec<Binding> + Send + Sync>>Additional key mappings for the short and full help views.
additional_full_help_keys: Option<Box<dyn Fn() -> Vec<Binding> + Send + Sync>>Additional key mappings for the short and full help views.
spinner: Model§show_spinner: bool§width: usize§height: usize§paginator: ModelThe paginator of the list.
help: ModelThe help view of the list.
filter_input: ModelThe filter input of the list.
filter_state: FilterState§status_message_lifetime: DurationHow long status messages should stay visible. By default this is 1 second.
items: Vec<Box<dyn Item + Send + Sync>>The master set of items we’re working with.
Implementations§
Source§impl Model
impl Model
Sourcepub fn set_filtering_enabled(&mut self, v: bool)
pub fn set_filtering_enabled(&mut self, v: bool)
SetFilteringEnabled enables or disables filtering. Note that this is different from ShowFilter, which merely hides or shows the input view.
Sourcepub fn filtering_enabled(&self) -> bool
pub fn filtering_enabled(&self) -> bool
FilteringEnabled returns whether or not filtering is enabled.
Sourcepub fn set_show_title(&mut self, v: bool)
pub fn set_show_title(&mut self, v: bool)
SetShowTitle shows or hides the title bar.
Sourcepub fn set_filter_text(&mut self, filter: &str)
pub fn set_filter_text(&mut self, filter: &str)
SetFilterText explicitly sets the filter text without relying on user input. It also sets the filterState to a sane default of FilterApplied.
Sourcepub fn set_filter_state(&mut self, state: FilterState)
pub fn set_filter_state(&mut self, state: FilterState)
SetFilterState allows setting the filtering state manually.
Sourcepub fn show_title(&self) -> bool
pub fn show_title(&self) -> bool
ShowTitle returns whether or not the title bar is set to be rendered.
Sourcepub fn set_show_filter(&mut self, v: bool)
pub fn set_show_filter(&mut self, v: bool)
SetShowFilter shows or hides the filter bar. Note that this does not disable filtering, it simply hides the built-in filter view.
Sourcepub fn show_filter(&self) -> bool
pub fn show_filter(&self) -> bool
ShowFilter returns whether or not the filter is set to be rendered.
Sourcepub fn set_show_status_bar(&mut self, v: bool)
pub fn set_show_status_bar(&mut self, v: bool)
SetShowStatusBar shows or hides the view that displays metadata about the list, such as item counts.
Sourcepub fn show_status_bar(&self) -> bool
pub fn show_status_bar(&self) -> bool
ShowStatusBar returns whether or not the status bar is set to be rendered.
Sourcepub fn set_status_bar_item_name(&mut self, singular: &str, plural: &str)
pub fn set_status_bar_item_name(&mut self, singular: &str, plural: &str)
SetStatusBarItemName defines a replacement for the item’s identifier. Defaults to item/items.
Sourcepub fn status_bar_item_name(&self) -> (String, String)
pub fn status_bar_item_name(&self) -> (String, String)
StatusBarItemName returns singular and plural status bar item names.
Sourcepub fn set_show_pagination(&mut self, v: bool)
pub fn set_show_pagination(&mut self, v: bool)
SetShowPagination hides or shows the paginator. Note that pagination will still be active, it simply won’t be displayed.
Sourcepub fn show_pagination(&mut self) -> bool
pub fn show_pagination(&mut self) -> bool
ShowPagination returns whether the pagination is visible.
Sourcepub fn set_show_help(&mut self, v: bool)
pub fn set_show_help(&mut self, v: bool)
SetShowHelp shows or hides the help view.
Sourcepub fn show_help(&self) -> bool
pub fn show_help(&self) -> bool
ShowHelp returns whether or not the help is set to be rendered.
Sourcepub fn set_items(&mut self, items: Vec<Box<dyn Item + Send + Sync>>) -> Cmd
pub fn set_items(&mut self, items: Vec<Box<dyn Item + Send + Sync>>) -> Cmd
SetItems sets the items available in the list. This returns a command.
Sourcepub fn select(&mut self, index: usize)
pub fn select(&mut self, index: usize)
Select selects the given index of the list and goes to its respective page.
Sourcepub fn reset_selected(&mut self)
pub fn reset_selected(&mut self)
ResetSelected resets the selected item to the first item in the first page of the list.
Sourcepub fn reset_filter(&mut self)
pub fn reset_filter(&mut self)
ResetFilter resets the current filtering state.
Sourcepub fn set_item(
&mut self,
index: usize,
item: Box<dyn Item + Send + Sync>,
) -> Cmd
pub fn set_item( &mut self, index: usize, item: Box<dyn Item + Send + Sync>, ) -> Cmd
SetItem replaces an item at the given index. This returns a command.
Sourcepub fn insert_item(
&mut self,
index: usize,
item: Box<dyn Item + Send + Sync>,
) -> Cmd
pub fn insert_item( &mut self, index: usize, item: Box<dyn Item + Send + Sync>, ) -> Cmd
InsertItem inserts an item at the given index. If the index is out of the upper bound, the item will be appended. This returns a command.
Sourcepub fn remove_item(&mut self, index: usize)
pub fn remove_item(&mut self, index: usize)
RemoveItem removes an item at the given index. If the index is out of bounds this will be a no-op. O(n) complexity, which probably won’t matter in the case of a TUI.
Sourcepub fn set_delegate(&mut self, d: Box<dyn ItemDelegate + Send + Sync>)
pub fn set_delegate(&mut self, d: Box<dyn ItemDelegate + Send + Sync>)
SetDelegate sets the item delegate.
Sourcepub fn visible_items(&self) -> Vec<&dyn Item>
pub fn visible_items(&self) -> Vec<&dyn Item>
VisibleItems returns the total items available to be shown.
Sourcepub fn selected_item(&self) -> Option<&dyn Item>
pub fn selected_item(&self) -> Option<&dyn Item>
SelectedItem returns the current selected item in the list.
Sourcepub fn matches_for_item(&self, index: usize) -> Vec<usize>
pub fn matches_for_item(&self, index: usize) -> Vec<usize>
MatchesForItem returns rune positions matched by the current filter, if any. Use this to style runes matched by the active filter.
Sourcepub fn index(&self) -> usize
pub fn index(&self) -> usize
Index returns the index of the currently selected item as it is stored in the filtered list of items.
Sourcepub fn global_index(&self) -> usize
pub fn global_index(&self) -> usize
GlobalIndex returns the index of the currently selected item as it is stored in the unfiltered list of items. This value can be used with SetItem.
Sourcepub fn cursor_up(&mut self)
pub fn cursor_up(&mut self)
CursorUp moves the cursor up. This can also move the state to the previous page.
Sourcepub fn cursor_down(&mut self)
pub fn cursor_down(&mut self)
CursorDown moves the cursor down. This can also advance the state to the next page.
Sourcepub fn go_to_start(&mut self)
pub fn go_to_start(&mut self)
GoToStart moves to the first page, and first item on the first page.
Sourcepub fn filter_state(&self) -> FilterState
pub fn filter_state(&self) -> FilterState
FilterState returns the current filter state.
Sourcepub fn filter_value(&self) -> String
pub fn filter_value(&self) -> String
FilterValue returns the current value of the filter.
Sourcepub fn setting_filter(&self) -> bool
pub fn setting_filter(&self) -> bool
SettingFilter returns whether or not the user is currently editing the filter value. It’s purely a convenience method for the following:
m.FilterState() == FilteringSourcepub fn is_filtered(&self) -> bool
pub fn is_filtered(&self) -> bool
IsFiltered returns whether or not the list is currently filtered.
Sourcepub fn set_spinner(&mut self, spinner: Spinner)
pub fn set_spinner(&mut self, spinner: Spinner)
SetSpinner allows to set the spinner style.
Sourcepub fn toggle_spinner(&mut self) -> Cmd
pub fn toggle_spinner(&mut self) -> Cmd
ToggleSpinner toggles the spinner. Note that this also returns a command.
Sourcepub fn start_spinner(&mut self) -> Cmd
pub fn start_spinner(&mut self) -> Cmd
StartSpinner starts the spinner. Note that this returns a command.
Sourcepub fn stop_spinner(&mut self)
pub fn stop_spinner(&mut self)
StopSpinner stops the spinner.
Sourcepub fn disable_quit_keybindings(&mut self)
pub fn disable_quit_keybindings(&mut self)
DisableQuitKeybindings is a helper for disabling the keybindings used for quitting, in case you want to handle this elsewhere in your application.
Sourcepub fn new_status_message(&mut self, s: &str) -> Cmd
pub fn new_status_message(&mut self, s: &str) -> Cmd
NewStatusMessage sets a new status message, which will show for a limited amount of time. Note that this also returns a command.
Sourcepub fn set_height(&mut self, v: usize)
pub fn set_height(&mut self, v: usize)
SetHeight sets the height of this component.
Sourcepub fn set_size(&mut self, width: usize, height: usize)
pub fn set_size(&mut self, width: usize, height: usize)
SetSize sets the width and height of this component.
Sourcepub fn update_keybindings(&mut self)
pub fn update_keybindings(&mut self)
Set keybindings according to the filter state.
Sourcepub fn update_pagination(&mut self)
pub fn update_pagination(&mut self)
Update pagination according to the amount of items for the current state.
Sourcepub fn short_help(&self) -> Vec<Binding>
pub fn short_help(&self) -> Vec<Binding>
ShortHelp returns bindings to show in the abbreviated help view. It’s part of the help.KeyMap interface.