beamtea_keybind (beamtea v0.1.2)

View Source

A bubble: key bindings (the key package in charmbracelet/bubbles).

A binding groups the concrete keys that trigger an action with the help text describing it, so your update/2 matches against intent rather than raw keys, and beamtea_help can render the controls automatically.

     Up = beamtea_keybind:new([up, {char, $k}], {<<"↑/k">>, <<"up">>}),
     case beamtea_keybind:matches(Key, Up) of true -> ...; false -> ... end

Summary

Functions

The {KeyLabel, Description} help pair.

Does Key trigger this binding? (Always false when disabled.)

Does Key match any binding in the list?

A binding over Keys with {KeyLabel, Description} help.

Types

binding/0

-opaque binding()

Functions

enabled(_)

-spec enabled(binding()) -> boolean().

help(_)

-spec help(binding()) -> {iodata(), iodata()}.

The {KeyLabel, Description} help pair.

keys(_)

-spec keys(binding()) -> [beamtea_key:key()].

matches(Key, _)

-spec matches(beamtea_key:key(), binding()) -> boolean().

Does Key trigger this binding? (Always false when disabled.)

matches_any(Key, Bindings)

-spec matches_any(beamtea_key:key(), [binding()]) -> boolean().

Does Key match any binding in the list?

new(Keys, Help)

-spec new([beamtea_key:key()], {iodata(), iodata()}) -> binding().

A binding over Keys with {KeyLabel, Description} help.

new(Keys, Help, Enabled)

-spec new([beamtea_key:key()], {iodata(), iodata()}, boolean()) -> binding().

set_enabled(E, B)

-spec set_enabled(boolean(), binding()) -> binding().