Skip to main content

Model

Struct Model 

Source
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: String

The title of the list.

§styles: Styles

The styles for the list.

§infinite_scrolling: bool

Whether scrolling is infinite.

§key_map: KeyMap

Key mappings for navigating the list.

§filter: FilterFunc

Filter 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: Model

The paginator of the list.

§help: Model

The help view of the list.

§filter_input: Model

The filter input of the list.

§filter_state: FilterState§status_message_lifetime: Duration

How 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

Source

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.

Source

pub fn filtering_enabled(&self) -> bool

FilteringEnabled returns whether or not filtering is enabled.

Source

pub fn set_show_title(&mut self, v: bool)

SetShowTitle shows or hides the title bar.

Source

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.

Source

pub fn set_filter_state(&mut self, state: FilterState)

SetFilterState allows setting the filtering state manually.

Source

pub fn show_title(&self) -> bool

ShowTitle returns whether or not the title bar is set to be rendered.

Source

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.

Source

pub fn show_filter(&self) -> bool

ShowFilter returns whether or not the filter is set to be rendered.

Source

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.

Source

pub fn show_status_bar(&self) -> bool

ShowStatusBar returns whether or not the status bar is set to be rendered.

Source

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.

Source

pub fn status_bar_item_name(&self) -> (String, String)

StatusBarItemName returns singular and plural status bar item names.

Source

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.

Source

pub fn show_pagination(&mut self) -> bool

ShowPagination returns whether the pagination is visible.

Source

pub fn set_show_help(&mut self, v: bool)

SetShowHelp shows or hides the help view.

Source

pub fn show_help(&self) -> bool

ShowHelp returns whether or not the help is set to be rendered.

Source

pub fn items(&self) -> &[Box<dyn Item + Send + Sync>]

Items returns the items in the list.

Source

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.

Source

pub fn select(&mut self, index: usize)

Select selects the given index of the list and goes to its respective page.

Source

pub fn reset_selected(&mut self)

ResetSelected resets the selected item to the first item in the first page of the list.

Source

pub fn reset_filter(&mut self)

ResetFilter resets the current filtering state.

Source

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.

Source

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.

Source

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.

Source

pub fn set_delegate(&mut self, d: Box<dyn ItemDelegate + Send + Sync>)

SetDelegate sets the item delegate.

Source

pub fn visible_items(&self) -> Vec<&dyn Item>

VisibleItems returns the total items available to be shown.

Source

pub fn selected_item(&self) -> Option<&dyn Item>

SelectedItem returns the current selected item in the list.

Source

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.

Source

pub fn index(&self) -> usize

Index returns the index of the currently selected item as it is stored in the filtered list of items.

Source

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.

Source

pub fn cursor(&self) -> usize

Cursor returns the index of the cursor on the current page.

Source

pub fn cursor_up(&mut self)

CursorUp moves the cursor up. This can also move the state to the previous page.

Source

pub fn cursor_down(&mut self)

CursorDown moves the cursor down. This can also advance the state to the next page.

Source

pub fn go_to_start(&mut self)

GoToStart moves to the first page, and first item on the first page.

Source

pub fn go_to_end(&mut self)

GoToEnd moves to the last page, and last item on the last page.

Source

pub fn prev_page(&mut self)

PrevPage moves to the previous page, if available.

Source

pub fn next_page(&mut self)

NextPage moves to the next page, if available.

Source

pub fn filter_state(&self) -> FilterState

FilterState returns the current filter state.

Source

pub fn filter_value(&self) -> String

FilterValue returns the current value of the filter.

Source

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() == Filtering
Source

pub fn is_filtered(&self) -> bool

IsFiltered returns whether or not the list is currently filtered.

Source

pub fn width(&self) -> usize

Width returns the current width setting.

Source

pub fn height(&self) -> usize

Height returns the current height setting.

Source

pub fn set_spinner(&mut self, spinner: Spinner)

SetSpinner allows to set the spinner style.

Source

pub fn toggle_spinner(&mut self) -> Cmd

ToggleSpinner toggles the spinner. Note that this also returns a command.

Source

pub fn start_spinner(&mut self) -> Cmd

StartSpinner starts the spinner. Note that this returns a command.

Source

pub fn stop_spinner(&mut self)

StopSpinner stops the spinner.

Source

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.

Source

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.

Source

pub fn set_width(&mut self, v: usize)

SetWidth sets the width of this component.

Source

pub fn set_height(&mut self, v: usize)

SetHeight sets the height of this component.

Source

pub fn set_size(&mut self, width: usize, height: usize)

SetSize sets the width and height of this component.

Source

pub fn update_keybindings(&mut self)

Set keybindings according to the filter state.

Source

pub fn update_pagination(&mut self)

Update pagination according to the amount of items for the current state.

Source

pub fn update(&mut self, msg: &dyn Msg) -> Cmd

Update is the Bubble Tea update loop.

Source

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.

Source

pub fn full_help(&self) -> Vec<Vec<Binding>>

FullHelp returns bindings to show the full help view. It’s part of the help.KeyMap interface.

Source

pub fn view(&self) -> String

View renders the component.

Trait Implementations§

Source§

impl Debug for Model

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl KeyMap for Model

Source§

fn short_help(&self) -> Vec<Binding>

ShortHelp returns a slice of bindings to be displayed in the short version of the help. The help bubble will render help in the order in which the help items are returned here.
Source§

fn full_help(&self) -> Vec<Vec<Binding>>

FullHelp returns an extended group of help items, grouped by columns. The help bubble will render the help in the order in which the help items are returned here.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Model

§

impl !UnwindSafe for Model

§

impl Freeze for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

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> Msg for T
where T: Any + Send + Sync + Debug,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Helper to downcast to Any.
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Consumes the boxed message and returns it as a Box<dyn Any>, so the program can move the concrete message out of the trait object (used to dispatch the commands carried by BatchMsg/SequenceMsg).
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.