Skip to main content

Model

Struct Model 

Source
pub struct Model {
    pub key_map: KeyMap,
    pub help: Model,
    /* private fields */
}
Expand description

Model defines a state for the table widget.

Fields§

§key_map: KeyMap

The key bindings for the table.

§help: Model

The help view for the table.

Implementations§

Source§

impl Model

Source

pub fn set_styles(&mut self, s: Styles)

SetStyles sets the table styles.

Source

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

Update is the Bubble Tea update loop.

Source

pub fn focused(&self) -> bool

Focused returns the focus state of the table.

Source

pub fn focus(&mut self)

Focus focuses the table, allowing the user to move around the rows and interact.

Source

pub fn blur(&mut self)

Blur blurs the table, preventing selection or movement.

Source

pub fn view(&self) -> String

View renders the component.

Source

pub fn help_view(&self) -> String

HelpView is a helper method for rendering the help menu from the keymap. Note that this view is not rendered by default and you must call it manually in your application, where applicable.

Source

pub fn update_viewport(&mut self)

UpdateViewport updates the list content based on the previously defined columns and rows.

Source

pub fn selected_row(&self) -> Option<Row>

SelectedRow returns the selected row.

Source

pub fn rows(&self) -> &[Row]

Rows returns the current rows.

Source

pub fn columns(&self) -> &[Column]

Columns returns the current columns.

Source

pub fn set_rows(&mut self, r: &[Row])

SetRows sets a new rows state.

Source

pub fn set_columns(&mut self, c: &[Column])

SetColumns sets a new columns state.

Source

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

SetWidth sets the width of the viewport of the table.

Source

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

SetHeight sets the height of the viewport of the table.

Source

pub fn height(&self) -> usize

Height returns the viewport height of the table.

Source

pub fn width(&self) -> usize

Width returns the viewport width of the table.

Source

pub fn cursor(&self) -> usize

Cursor returns the index of the selected row.

Source

pub fn set_cursor(&mut self, n: usize)

SetCursor sets the cursor position in the table.

Source

pub fn move_up(&mut self, n: usize)

MoveUp moves the selection up by any number of rows. It can not go above the first row.

Source

pub fn move_down(&mut self, n: usize)

MoveDown moves the selection down by any number of rows. It can not go below the last row.

Source

pub fn goto_top(&mut self)

GotoTop moves the selection to the first row.

Source

pub fn goto_bottom(&mut self)

GotoBottom moves the selection to the last row.

Source

pub fn from_values(&mut self, value: &str, separator: &str)

FromValues create the table rows from a simple string. It uses \n by default for getting all the rows and the given separator for the fields on each row.

Trait Implementations§

Source§

impl Debug for Model

Source§

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

Formats the value using the given formatter. Read more

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.