Table of Contents

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

block BlockBuilder

Returns

TableBuilder

ColumnSpacing(int)

Empty columns between columns. The default is 1.

public TableBuilder ColumnSpacing(int spacing)

Parameters

spacing int

Returns

TableBuilder

Columns(params Constraint[])

Column widths, solved like a horizontal Layout. By default each column is Fill(1).

public TableBuilder Columns(params Constraint[] widths)

Parameters

widths Constraint[]

Returns

TableBuilder

Draw(Buffer, Rect)

Draw the table.

public void Draw(Buffer buf, Rect area)

Parameters

buf Buffer
area Rect

Focused(bool)

Use the focused selection style.

public TableBuilder Focused(bool focused = true)

Parameters

focused bool

Returns

TableBuilder

Header(params Line[])

The header cells.

public TableBuilder Header(params Line[] cells)

Parameters

cells Line[]

Returns

TableBuilder

HeaderStyle(Style)

A style patched over the theme's header style.

public TableBuilder HeaderStyle(Style style)

Parameters

style Style

Returns

TableBuilder

HighlightStyle(Style)

A style patched over the theme's selection style.

public TableBuilder HighlightStyle(Style style)

Parameters

style Style

Returns

TableBuilder

HighlightSymbol(string)

A marker drawn before the selected row, such as "> ".

public TableBuilder HighlightSymbol(string symbol)

Parameters

symbol string

Returns

TableBuilder

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

position Vec2?

Returns

TableBuilder

Rows(IReadOnlyList<Row>)

The rows.

public TableBuilder Rows(IReadOnlyList<Row> rows)

Parameters

rows IReadOnlyList<Row>

Returns

TableBuilder

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

items IReadOnlyList<T>
format Func<T, Row>

Returns

TableBuilder

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

columns int[]

Returns

TableBuilder

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

state SelectionState

Returns

TableBuilder

Style(Style)

A style patched over the theme's text style.

public TableBuilder Style(Style style)

Parameters

style Style

Returns

TableBuilder