Skip to main content

Table

Struct Table 

Source
pub struct Table<'a, H, R> { /* private fields */ }
Expand description

A widget to display data in formatted columns

§Examples

let row_style = Style::default().fg(Color::White);
Table::new(
        ["Col1", "Col2", "Col3"].into_iter(),
        vec![
            Row::StyledData(["Row11", "Row12", "Row13"].into_iter(), row_style),
            Row::StyledData(["Row21", "Row22", "Row23"].into_iter(), row_style),
            Row::StyledData(["Row31", "Row32", "Row33"].into_iter(), row_style),
            Row::Data(["Row41", "Row42", "Row43"].into_iter())
        ].into_iter()
    )
    .block(Block::default().title("Table"))
    .header_style(Style::default().fg(Color::Yellow))
    .widths(&[Constraint::Length(5), Constraint::Length(5), Constraint::Length(10)])
    .style(Style::default().fg(Color::White))
    .column_spacing(1);

Implementations§

Source§

impl<'a, H, D, R> Table<'a, H, R>
where H: Iterator, D: Iterator, D::Item: Display, R: Iterator<Item = Row<D>>,

Source

pub fn new(header: H, rows: R) -> Table<'a, H, R>

Source

pub fn block(self, block: Block<'a>) -> Table<'a, H, R>

Source

pub fn header<II>(self, header: II) -> Table<'a, H, R>
where II: IntoIterator<Item = H::Item, IntoIter = H>,

Source

pub fn header_style(self, style: Style) -> Table<'a, H, R>

Source

pub fn widths(self, widths: &'a [Constraint]) -> Table<'a, H, R>

Source

pub fn rows<II>(self, rows: II) -> Table<'a, H, R>
where II: IntoIterator<Item = Row<D>, IntoIter = R>,

Source

pub fn style(self, style: Style) -> Table<'a, H, R>

Source

pub fn highlight_symbol(self, highlight_symbol: &'a str) -> Table<'a, H, R>

Source

pub fn highlight_style(self, highlight_style: Style) -> Table<'a, H, R>

Source

pub fn column_spacing(self, spacing: u16) -> Table<'a, H, R>

Source

pub fn header_gap(self, gap: u16) -> Table<'a, H, R>

Trait Implementations§

Source§

impl<'a, H, R> Default for Table<'a, H, R>
where H: Iterator + Default, R: Iterator + Default,

Source§

fn default() -> Table<'a, H, R>

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

impl<'a, H, D, R> StatefulWidget for Table<'a, H, R>
where H: Iterator, H::Item: Display, D: Iterator, D::Item: Display, R: Iterator<Item = Row<D>>,

Source§

type State = TableState

Source§

fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State)

Source§

impl<'a, H, D, R> Widget for Table<'a, H, R>
where H: Iterator, H::Item: Display, D: Iterator, D::Item: Display, R: Iterator<Item = Row<D>>,

Source§

fn render(self, area: Rect, buf: &mut Buffer)

Draws the current state of the widget in the given buffer. That the only method required to implement a custom widget.

Auto Trait Implementations§

§

impl<'a, H, R> Freeze for Table<'a, H, R>
where H: Freeze, R: Freeze,

§

impl<'a, H, R> RefUnwindSafe for Table<'a, H, R>

§

impl<'a, H, R> Send for Table<'a, H, R>
where H: Send, R: Send,

§

impl<'a, H, R> Sync for Table<'a, H, R>
where H: Sync, R: Sync,

§

impl<'a, H, R> Unpin for Table<'a, H, R>
where H: Unpin, R: Unpin,

§

impl<'a, H, R> UnsafeUnpin for Table<'a, H, R>
where H: UnsafeUnpin, R: UnsafeUnpin,

§

impl<'a, H, R> UnwindSafe for Table<'a, H, R>
where H: UnwindSafe, R: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.