beamtea_table (beamtea v0.1.2)
View SourceA bubble: a scrollable, row-selectable data table, mirroring the table package in charmbracelet/bubbles.
Cols = [{<<"Name">>, 12}, {<<"Lang">>, 8}, {<<"Stars">>, 6}],
Rows = [[<<"beamtea">>, <<"Erlang">>, <<"1.2k">>], ...],
T = beamtea_table:new(Cols, Rows, #{height => 6}),
{T1, _} = beamtea_table:update({key, down}, T),
beamtea_table:selected_row(T1).
Summary
Functions
Equivalent to new(Columns, Rows, #{}).
Options: height (visible rows, default 10), header_color, select_color.
The currently selected row (or none if the table is empty).
Replace the rows; the cursor is clamped into range.
Move the selected row with the arrows (or j/k) and scroll to follow.
Render the header and the visible rows.
Types
-type column() :: {Title :: iodata(), Width :: pos_integer()}.
-opaque model()
Functions
-spec cursor(model()) -> non_neg_integer().
Equivalent to new(Columns, Rows, #{}).
Options: height (visible rows, default 10), header_color, select_color.
-spec selected_row(model()) -> {non_neg_integer(), [iodata()]} | none.
The currently selected row (or none if the table is empty).
Replace the rows; the cursor is clamped into range.
-spec update(term(), model()) -> {model(), beamtea:cmd()}.
Move the selected row with the arrows (or j/k) and scroll to follow.
Render the header and the visible rows.