beamtea_list (beamtea v0.1.2)
View SourceA bubble: a scrollable, selectable list.
Arrow keys (or j/k) move the selection; the visible window scrolls to keep the cursor in view. Forward key messages to update/2 and read the choice back with selected/1.
L = beamtea_list:new([<<"Tea">>, <<"Coffee">>, <<"Water">>], #{title => <<"Pick one">>}),
{L1, _} = beamtea_list:update({key, down}, L),
{1, <<"Coffee">>} = beamtea_list:selected(L1).
Summary
Functions
Equivalent to new(Items, #{}).
Options: title, height (visible rows, default 10), cursor_glyph (default "> "), color (selection accent).
{Index, Item} currently under the cursor (or none if empty).
Replace the items; the cursor is clamped into range.
Move the selection in response to a key; ignore everything else.
Render the (optional) title and the visible window of items.
Types
Functions
-spec cursor(model()) -> non_neg_integer().
Equivalent to new(Items, #{}).
Options: title, height (visible rows, default 10), cursor_glyph (default "> "), color (selection accent).
-spec selected(model()) -> {non_neg_integer(), iodata()} | none.
{Index, Item} currently under the cursor (or none if empty).
Replace the items; the cursor is clamped into range.
-spec update(term(), model()) -> {model(), beamtea:cmd()}.
Move the selection in response to a key; ignore everything else.
Render the (optional) title and the visible window of items.