Class TableBuilder
- Namespace
- MiniTui
- Assembly
- MiniTui.dll
A table with a header, constraint-sized columns and a scrolling selection (§8.3). Only the visible rows are formatted, so the cost per frame doesn't depend on the row count.
public sealed class TableBuilder
- Inheritance
-
TableBuilder
- Inherited Members
Examples
Widget.Table()
.Header("Name", "Status")
.Columns(Constraint.Fill(), Constraint.Length(10))
.Rows(services, s => new Row(s.Name, s.Status))
.State(selection)
.Focused()
.Draw(buf, area);
Methods
Block(BlockBuilder)
Draw a block around the table.
public TableBuilder Block(BlockBuilder block)
Parameters
blockBlockBuilder
Returns
ColumnSpacing(int)
Empty columns between columns. The default is 1.
public TableBuilder ColumnSpacing(int spacing)
Parameters
spacingint
Returns
Columns(params Constraint[])
Column widths, solved like a horizontal Layout. By default each column is Fill(1).
public TableBuilder Columns(params Constraint[] widths)
Parameters
widthsConstraint[]
Returns
Draw(Buffer, Rect)
Draw the table.
public void Draw(Buffer buf, Rect area)
Parameters
Focused(bool)
Use the focused selection style.
public TableBuilder Focused(bool focused = true)
Parameters
focusedbool
Returns
Header(params Line[])
The header cells.
public TableBuilder Header(params Line[] cells)
Parameters
cellsLine[]
Returns
HeaderStyle(Style)
A style patched over the theme's header style.
public TableBuilder HeaderStyle(Style style)
Parameters
styleStyle
Returns
HighlightStyle(Style)
A style patched over the theme's selection style.
public TableBuilder HighlightStyle(Style style)
Parameters
styleStyle
Returns
HighlightSymbol(string)
A marker drawn before the selected row, such as "> ".
public TableBuilder HighlightSymbol(string symbol)
Parameters
symbolstring
Returns
Hover(Vec2?)
The pointer, usually Hover. Hover is patched over the row under it, unless it's the selected one (1.x spec §17.6).
public TableBuilder Hover(Vec2? position)
Parameters
positionVec2?
Returns
Rows(IReadOnlyList<Row>)
The rows.
public TableBuilder Rows(IReadOnlyList<Row> rows)
Parameters
rowsIReadOnlyList<Row>
Returns
Rows<T>(IReadOnlyList<T>, Func<T, Row>)
The rows, formatted by format. Only visible rows are formatted.
public TableBuilder Rows<T>(IReadOnlyList<T> items, Func<T, Row> format)
Parameters
itemsIReadOnlyList<T>formatFunc<T, Row>
Returns
Type Parameters
T
Sortable(params int[])
Let a click on the header cells of columns, or of every column when none are given, sort
by that column with ToggleSort(int) (1.x spec §14.5). Needs a State(SelectionState).
public TableBuilder Sortable(params int[] columns)
Parameters
columnsint[]
Returns
State(SelectionState)
The selection. The table clamps it and scrolls to keep it visible. Without one, no row is highlighted.
public TableBuilder State(SelectionState state)
Parameters
stateSelectionState
Returns
Style(Style)
A style patched over the theme's text style.
public TableBuilder Style(Style style)
Parameters
styleStyle