pub struct TableWidget<'a> { /* private fields */ }Expand description
Themed Ratatui table. Render with render_widget or pass a native
TableState to render_stateful_widget; while focused,
the native selected row paints as the cursor row.
use ratatui::{layout::Constraint, widgets::Row};
use ratcn::{TableWidget, Theme};
let theme = Theme::default_dark();
let _widget = TableWidget::new(
[Row::new(["Alice", "$42.00"])],
[Constraint::Fill(1), Constraint::Length(8)],
)
.header(Row::new(["Name", "Amount"]))
.themed(&theme)
.focused(true);Implementations§
Source§impl<'a> TableWidget<'a>
impl<'a> TableWidget<'a>
Sourcepub fn new(
rows: impl IntoIterator<Item = impl Into<Row<'a>>>,
widths: impl IntoIterator<Item = impl Into<Constraint>>,
) -> Self
pub fn new( rows: impl IntoIterator<Item = impl Into<Row<'a>>>, widths: impl IntoIterator<Item = impl Into<Constraint>>, ) -> Self
Accept native rows, cells, and width constraints, including borrowed text.
Sourcepub fn header(self, row: Row<'a>) -> Self
pub fn header(self, row: Row<'a>) -> Self
A fixed native header, including its height, margins and cell styles.
A fixed native footer.
Sourcepub const fn style(self, style: TableStyle) -> Self
pub const fn style(self, style: TableStyle) -> Self
Use an explicit set of colors.
Sourcepub const fn focused(self, focused: bool) -> Self
pub const fn focused(self, focused: bool) -> Self
Paint as the focused control: the focus backdrop and the cursor row. Unfocused, the selected row paints as an ordinary one, so two tables side by side cannot both look active.
Sourcepub const fn hovered(self, hovered: bool) -> Self
pub const fn hovered(self, hovered: bool) -> Self
Paint the hovered backdrop. Hover wins when the table is also focused.
Sourcepub const fn disabled(self, disabled: bool) -> Self
pub const fn disabled(self, disabled: bool) -> Self
Paint the whole table as disabled, with no cursor row. Colors set on native rows and cells are left to the caller.
Sourcepub fn into_inner(self) -> NativeTable<'a>
pub fn into_inner(self) -> NativeTable<'a>
Finish styling and use any native builder (block, flex, spacing, highlight symbol/spacing, or individual highlight styles). Only the row highlight is themed; column and cell highlights are left to the caller.
Trait Implementations§
Source§impl<'a> Clone for TableWidget<'a>
impl<'a> Clone for TableWidget<'a>
Source§impl<'a> Debug for TableWidget<'a>
impl<'a> Debug for TableWidget<'a>
impl<'a> Eq for TableWidget<'a>
Source§impl<'a> PartialEq for TableWidget<'a>
impl<'a> PartialEq for TableWidget<'a>
Source§impl StatefulWidget for TableWidget<'_>
impl StatefulWidget for TableWidget<'_>
impl<'a> StructuralPartialEq for TableWidget<'a>
Auto Trait Implementations§
impl<'a> Forget for TableWidget<'a>
impl<'a> Freeze for TableWidget<'a>where
*const u8 is !null: Freeze,
PhantomData<Row<'a>>: Freeze,
PhantomData<Cell<'a>>: Freeze,
InternalBitFlags: Freeze,
PhantomData<Constraint>: Freeze,
PhantomData<(Option<TitlePosition>, Line<'a>)>: Freeze,
InternalBitFlags: Freeze,
&'a str: Freeze,
&'static str: Freeze,
*const ArcInner<dyn CellEffect> is !null: Freeze,
PhantomData<ArcInner<dyn CellEffect>>: Freeze,
PhantomData<Line<'a>>: Freeze,
impl<'a> Move for TableWidget<'a>
impl<'a> RefUnwindSafe for TableWidget<'a>where
InternalBitFlags: RefUnwindSafe,
String: RefUnwindSafe,
InternalBitFlags: RefUnwindSafe,
Atomic<usize>: RefUnwindSafe,
impl<'a> Send for TableWidget<'a>
impl<'a> Sync for TableWidget<'a>
impl<'a> Unpin for TableWidget<'a>
impl<'a> UnsafeUnpin for TableWidget<'a>where
*const u8 is !null: UnsafeUnpin,
PhantomData<Row<'a>>: UnsafeUnpin,
PhantomData<Cell<'a>>: UnsafeUnpin,
InternalBitFlags: UnsafeUnpin,
PhantomData<Constraint>: UnsafeUnpin,
PhantomData<(Option<TitlePosition>, Line<'a>)>: UnsafeUnpin,
InternalBitFlags: UnsafeUnpin,
&'a str: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<dyn CellEffect> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn CellEffect>>: UnsafeUnpin,
PhantomData<Line<'a>>: UnsafeUnpin,
impl<'a> UnwindSafe for TableWidget<'a>where
RawVecInner: UnwindSafe,
InternalBitFlags: UnwindSafe,
&'a str: UnwindSafe,
String: UnwindSafe,
InternalBitFlags: UnwindSafe,
&'static str: UnwindSafe,
Arc<dyn CellEffect>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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