Skip to main content

List

Struct List 

Source
pub struct List<I: Item, D: ItemDelegate<I>> {
Show 16 fields pub title: String, 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 infinite_scrolling: bool, pub item_name_singular: String, pub item_name_plural: String, pub key_map: KeyMap, pub styles: Styles, pub status_message_lifetime: Duration, pub mouse_wheel_enabled: bool, pub mouse_wheel_delta: usize, pub mouse_click_enabled: bool, /* private fields */
}
Expand description

List model with filtering, pagination, and more.

Fields§

§title: String

Title of the list.

§show_title: bool

Whether to show the title.

§show_filter: bool

Whether to show the filter input.

§show_status_bar: bool

Whether to show the status bar.

§show_pagination: bool

Whether to show pagination.

§show_help: bool

Whether to show help.

§filtering_enabled: bool

Whether filtering is enabled.

§infinite_scrolling: bool

Whether infinite scrolling is enabled.

§item_name_singular: String

Singular name for items.

§item_name_plural: String

Plural name for items.

§key_map: KeyMap

Key bindings.

§styles: Styles

Styles.

§status_message_lifetime: Duration

Status message lifetime.

§mouse_wheel_enabled: bool

Whether mouse wheel scrolling is enabled.

§mouse_wheel_delta: usize

Number of items to scroll per mouse wheel tick.

§mouse_click_enabled: bool

Whether mouse click selection is enabled.

Implementations§

Source§

impl<I: Item, D: ItemDelegate<I>> List<I, D>

Source

pub fn new(items: Vec<I>, delegate: D, width: usize, height: usize) -> Self

Creates a new list with the given items and delegate.

Source

pub fn title(self, title: impl Into<String>) -> Self

Sets the title.

Source

pub fn mouse_wheel(self, enabled: bool) -> Self

Enables or disables mouse wheel scrolling (builder pattern).

Source

pub fn mouse_wheel_delta(self, delta: usize) -> Self

Sets the number of items to scroll per mouse wheel tick (builder pattern).

Source

pub fn mouse_click(self, enabled: bool) -> Self

Enables or disables mouse click item selection (builder pattern).

Source

pub fn set_items(&mut self, items: Vec<I>)

Sets the items.

Source

pub fn items(&self) -> &[I]

Returns the items.

Source

pub fn visible_items(&self) -> Vec<&I>

Returns visible items based on current filter.

Source

pub fn index(&self) -> usize

Returns the current cursor index in the filtered list.

Source

pub fn selected_item(&self) -> Option<&I>

Returns the currently selected item.

Source

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

Selects an item by index.

Source

pub fn cursor_up(&mut self)

Moves the cursor up.

Source

pub fn cursor_down(&mut self)

Moves the cursor down.

Source

pub fn filter_state(&self) -> FilterState

Returns the filter state.

Source

pub fn filter_value(&self) -> String

Returns the current filter value.

Source

pub fn set_filter_value(&mut self, value: &str)

Sets the filter value.

Source

pub fn reset_filter(&mut self)

Resets the filter.

Source

pub fn start_spinner(&mut self) -> Option<Message>

Starts the spinner. Returns a message that should be passed to update to start the animation.

Source

pub fn stop_spinner(&mut self)

Stops the spinner.

Source

pub fn spinner_visible(&self) -> bool

Returns whether the spinner is visible.

Source

pub fn new_status_message(&mut self, msg: impl Into<String>) -> Option<Cmd>

Sets a new status message.

Source

pub fn status_message(&self) -> Option<&str>

Returns the current status message.

Source

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

Sets the width.

Source

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

Sets the height.

Source

pub fn width(&self) -> usize

Returns the width.

Source

pub fn height(&self) -> usize

Returns the height.

Source

pub fn paginator(&self) -> &Paginator

Returns a reference to the paginator.

Source

pub fn update(&mut self, msg: Message) -> Option<Cmd>

Updates the list based on messages.

Source

pub fn view(&self) -> String

Renders the list.

Source

pub fn init(&self) -> Option<Cmd>

Initializes the list (called when used as a standalone Model).

Returns None by default since lists are typically initialized with items. Override or use start_spinner() if loading items asynchronously.

Trait Implementations§

Source§

impl<I: Clone + Item, D: Clone + ItemDelegate<I>> Clone for List<I, D>

Source§

fn clone(&self) -> List<I, D>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I: Item + Debug, D: ItemDelegate<I> + Debug> Debug for List<I, D>

Source§

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

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

impl<I: Item, D: ItemDelegate<I>> Model for List<I, D>

Implement the Model trait for standalone bubbletea usage.

Source§

fn init(&self) -> Option<Cmd>

Initialize the model and return an optional startup command. Read more
Source§

fn update(&mut self, msg: Message) -> Option<Cmd>

Process a message and return a new command. Read more
Source§

fn view(&self) -> String

Render the model as a string for display. Read more

Auto Trait Implementations§

§

impl<I, D> Freeze for List<I, D>
where D: Freeze,

§

impl<I, D> !RefUnwindSafe for List<I, D>

§

impl<I, D> Send for List<I, D>

§

impl<I, D> Sync for List<I, D>
where D: Sync, I: Sync,

§

impl<I, D> Unpin for List<I, D>
where D: Unpin, I: Unpin,

§

impl<I, D> !UnwindSafe for List<I, D>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more