Skip to main content

Table

Struct Table 

Source
pub struct Table {
    pub key_map: KeyMap,
    pub styles: Styles,
    pub mouse_wheel_enabled: bool,
    pub mouse_wheel_delta: usize,
    pub mouse_click_enabled: bool,
    /* private fields */
}
Expand description

Table model for displaying tabular data with keyboard navigation.

Fields§

§key_map: KeyMap

Key bindings for navigation.

§styles: Styles

Styles for rendering.

§mouse_wheel_enabled: bool

Whether mouse wheel scrolling is enabled.

§mouse_wheel_delta: usize

Number of rows to scroll per mouse wheel tick.

§mouse_click_enabled: bool

Whether mouse click selection is enabled.

Implementations§

Source§

impl Table

Source

pub fn new() -> Self

Creates a new empty table.

Source

pub fn columns(self, columns: Vec<Column>) -> Self

Sets the columns (builder pattern).

Source

pub fn rows(self, rows: Vec<Row>) -> Self

Sets the rows (builder pattern).

Source

pub fn height(self, h: usize) -> Self

Sets the height (builder pattern).

Source

pub fn width(self, w: usize) -> Self

Sets the width (builder pattern).

Source

pub fn focused(self, f: bool) -> Self

Sets the focused state (builder pattern).

Source

pub fn with_styles(self, styles: Styles) -> Self

Sets the styles (builder pattern).

Source

pub fn with_key_map(self, key_map: KeyMap) -> Self

Sets the key map (builder pattern).

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 rows to scroll per mouse wheel tick (builder pattern).

Source

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

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

Source

pub fn is_focused(&self) -> bool

Returns whether the table is focused.

Source

pub fn focus(&mut self)

Focuses the table.

Source

pub fn blur(&mut self)

Blurs (unfocuses) the table.

Source

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

Returns the columns.

Source

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

Returns the rows.

Source

pub fn set_columns(&mut self, columns: Vec<Column>)

Sets the columns.

Source

pub fn set_rows(&mut self, rows: Vec<Row>)

Sets the rows.

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 get_height(&self) -> usize

Returns the viewport height.

Source

pub fn get_width(&self) -> usize

Returns the viewport width.

Source

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

Returns the currently selected row, if any.

Source

pub fn cursor(&self) -> usize

Returns the cursor position (selected row index).

Source

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

Sets the cursor position.

Source

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

Moves the selection up by n rows.

Source

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

Moves the selection down by n rows.

Source

pub fn goto_top(&mut self)

Moves to the first row.

Source

pub fn goto_bottom(&mut self)

Moves to the last row.

Source

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

Parses rows from a string value with the given separator.

Source

pub fn update(&mut self, msg: &Message)

Updates the table based on key/mouse input.

Source

pub fn view(&self) -> String

Renders the table.

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

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 Debug for Table

Source§

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

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

impl Default for Table

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Model for Table

Source§

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

Initialize the table.

Tables don’t require initialization commands.

Source§

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

Update the table state based on incoming messages.

Source§

fn view(&self) -> String

Render the table.

Auto Trait Implementations§

§

impl Freeze for Table

§

impl !RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl !UnwindSafe for Table

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