pub struct TableVec<'a, T, Selection = RowSelection> { /* private fields */ }Expand description
A table that holds a Vec of the data in its state.
TableVec::default()
.widths([
Constraint::Length(6),
Constraint::Length(20),
Constraint::Length(15),
Constraint::Length(15),
Constraint::Length(3),
])
.render_cell(0, |_v, area, buf, ctx| {
row_fmt.fmt_u(ctx.row).render(area, buf)
})
.render_cell(1, |v, area, buf, _ctx| v.text.render(area, buf))
.render_cell(2, |v, area, buf, _ctx| {
num1_fmt.fmt_u(v.num1).render(area, buf)
})
.render_cell(3, |v, area, buf, _ctx| {
num2_fmt.fmt_u(v.num2).render(area, buf)
})
.render_cell(4, |v, area, buf, _ctx| {
let cc = if v.check { "\u{2622}" } else { "\u{2623}" };
cc.render(area, buf);
})
.column_spacing(1)
.header(vec!["Nr", "Text", "Val1", "Val2", "State"])
.footer(vec!["a", "b", "c", "d", "e"])
.block(
Block::bordered()
.border_type(BorderType::Rounded)
.title("tabledata-iter (no row-count)"),
)
.vscroll(Scroll::new())
.styles(table(&ctx.theme))
.render(l0[0], buf, &mut state.table);Implementations§
Source§impl<'a, T, Selection> TableVec<'a, T, Selection>
impl<'a, T, Selection> TableVec<'a, T, Selection>
pub fn new() -> TableVec<'a, T, Selection>where
Selection: Default,
Sourcepub fn row_height(
self,
row_height_fn: fn(&T, &TableContext<'_>) -> u8,
) -> TableVec<'a, T, Selection>
pub fn row_height( self, row_height_fn: fn(&T, &TableContext<'_>) -> u8, ) -> TableVec<'a, T, Selection>
A closure that calculates the row-height for a given row-value.
Sourcepub fn render_row(
self,
render_row_fn: impl FnMut(&T, Rect, &mut Buffer, &TableContext<'_>) -> bool + 'a,
) -> TableVec<'a, T, Selection>
pub fn render_row( self, render_row_fn: impl FnMut(&T, Rect, &mut Buffer, &TableContext<'_>) -> bool + 'a, ) -> TableVec<'a, T, Selection>
A closure for row-level rendering. The area covers the full row.
Return
Returns true if the individual cells should be rendered too.
Sourcepub fn render_cell(
self,
column: usize,
render_cell_fn: impl FnMut(&T, Rect, &mut Buffer, &TableContext<'_>) + 'a,
) -> TableVec<'a, T, Selection>
pub fn render_cell( self, column: usize, render_cell_fn: impl FnMut(&T, Rect, &mut Buffer, &TableContext<'_>) + 'a, ) -> TableVec<'a, T, Selection>
A closure for rendering a single column.
The area covers the exact column. Extra information is available in the TableContext.
The given Buffer covers the full row so you could render something outside the cells bounds. Cells for a given row are always rendered in ascending order.
Set the table-footer.
Sourcepub fn widths<I>(self, widths: I) -> TableVec<'a, T, Selection>
pub fn widths<I>(self, widths: I) -> TableVec<'a, T, Selection>
Column widths as Constraints.
The constraints work in tandem with Table::layout_width.
Sourcepub fn varying_heights(self, varying: bool) -> TableVec<'a, T, Selection>
pub fn varying_heights(self, varying: bool) -> TableVec<'a, T, Selection>
If your table uses varying row-heights for each row all page calculations will fail (somewhat). If you enable this flag, the row-heights for each row will be stored in the state to allow accurate page-calculations.
Sourcepub fn column_spacing(self, spacing: u16) -> TableVec<'a, T, Selection>
pub fn column_spacing(self, spacing: u16) -> TableVec<'a, T, Selection>
Spacing between columns.
Sourcepub fn layout_width(self, width: LayoutWidth) -> TableVec<'a, T, Selection>
pub fn layout_width(self, width: LayoutWidth) -> TableVec<'a, T, Selection>
Set the display width of the table.
Default The width of the rendered area is used.
Sourcepub fn block(self, block: Block<'a>) -> TableVec<'a, T, Selection>
pub fn block(self, block: Block<'a>) -> TableVec<'a, T, Selection>
Draws a block around the table widget.
Sourcepub fn border_style(self, style: Style) -> TableVec<'a, T, Selection>
pub fn border_style(self, style: Style) -> TableVec<'a, T, Selection>
Sets the border-style for the Block, if any.
Sourcepub fn title_style(self, style: Style) -> TableVec<'a, T, Selection>
pub fn title_style(self, style: Style) -> TableVec<'a, T, Selection>
Sets the title-style for the Block, if any.
Sourcepub fn styles(self, styles: TableStyle) -> TableVec<'a, T, Selection>
pub fn styles(self, styles: TableStyle) -> TableVec<'a, T, Selection>
Set all styles as a bundle.
Sourcepub fn header_style(self, style: Option<Style>) -> TableVec<'a, T, Selection>
pub fn header_style(self, style: Option<Style>) -> TableVec<'a, T, Selection>
Base style for the table.
Base style for the table.
Sourcepub fn select_row_style(
self,
select_style: Option<Style>,
) -> TableVec<'a, T, Selection>
pub fn select_row_style( self, select_style: Option<Style>, ) -> TableVec<'a, T, Selection>
Style for a selected row. The chosen selection must support row-selection for this to take effect.
Sourcepub fn show_row_focus(self, show: bool) -> TableVec<'a, T, Selection>
pub fn show_row_focus(self, show: bool) -> TableVec<'a, T, Selection>
Add the focus-style to the row-style if the table is focused.
Sourcepub fn select_column_style(
self,
select_style: Option<Style>,
) -> TableVec<'a, T, Selection>
pub fn select_column_style( self, select_style: Option<Style>, ) -> TableVec<'a, T, Selection>
Style for a selected column. The chosen selection must support column-selection for this to take effect.
Sourcepub fn show_column_focus(self, show: bool) -> TableVec<'a, T, Selection>
pub fn show_column_focus(self, show: bool) -> TableVec<'a, T, Selection>
Add the focus-style to the column-style if the table is focused.
Sourcepub fn select_cell_style(
self,
select_style: Option<Style>,
) -> TableVec<'a, T, Selection>
pub fn select_cell_style( self, select_style: Option<Style>, ) -> TableVec<'a, T, Selection>
Style for a selected cell. The chosen selection must support cell-selection for this to take effect.
Sourcepub fn show_cell_focus(self, show: bool) -> TableVec<'a, T, Selection>
pub fn show_cell_focus(self, show: bool) -> TableVec<'a, T, Selection>
Add the focus-style to the cell-style if the table is focused.
Sourcepub fn select_header_style(
self,
select_style: Option<Style>,
) -> TableVec<'a, T, Selection>
pub fn select_header_style( self, select_style: Option<Style>, ) -> TableVec<'a, T, Selection>
Style for a selected header cell. The chosen selection must support column-selection for this to take effect.
Sourcepub fn show_header_focus(self, show: bool) -> TableVec<'a, T, Selection>
pub fn show_header_focus(self, show: bool) -> TableVec<'a, T, Selection>
Add the focus-style to the header-style if the table is focused.
Style for a selected footer cell. The chosen selection must support column-selection for this to take effect.
Add the footer-style to the table-style if the table is focused.
Sourcepub fn focus_style(
self,
focus_style: Option<Style>,
) -> TableVec<'a, T, Selection>
pub fn focus_style( self, focus_style: Option<Style>, ) -> TableVec<'a, T, Selection>
This style will be patched onto the selection to indicate that the widget has the input focus.
The selection must support some kind of selection for this to be effective.
Source§impl<'a, 'b, T, Selection> TableVec<'a, T, Selection>where
'b: 'a,
Selection: TableSelection + Default,
impl<'a, 'b, T, Selection> TableVec<'a, T, Selection>where
'b: 'a,
Selection: TableSelection + Default,
pub fn render( self, area: Rect, buf: &mut Buffer, state: &'b mut TableVecState<T, Selection>, )
Trait Implementations§
Auto Trait Implementations§
impl<'a, T, Selection = RowSelection> !RefUnwindSafe for TableVec<'a, T, Selection>
impl<'a, T, Selection = RowSelection> !Send for TableVec<'a, T, Selection>
impl<'a, T, Selection = RowSelection> !Sync for TableVec<'a, T, Selection>
impl<'a, T, Selection = RowSelection> !UnwindSafe for TableVec<'a, T, Selection>
impl<'a, T, Selection> Forget for TableVec<'a, T, Selection>
impl<'a, T, Selection> Freeze for TableVec<'a, T, Selection>
impl<'a, T, Selection> Unpin for TableVec<'a, T, Selection>
impl<'a, T, Selection> UnsafeUnpin for TableVec<'a, T, Selection>
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> 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