Key-event helper for the Harlock.Elements.tabs/1 widget.
The widget is a dumb renderer — the app holds the active tab id in
its model. When the tabs element has focus, route key events through
apply_key/3 to compute the next active id:
def update({:key, _, _} = event, %{tab: active} = model) do
case Harlock.Focus.current() do
:tabs ->
case Harlock.Tabs.apply_key(event, active, [{:a, "Alpha"}, {:b, "Beta"}]) do
{:select, id} -> %{model | tab: id}
:noop -> model
end
_ ->
model
end
endBindings:
Left/Right— cycle tabs (with wrap)Home/End— first / last- anything else —
:noop
Summary
Functions
Map a {:key, key, mods} event to a selection change.