etui/keymap
Types
A single key binding: key → action + description.
pub type Binding(action) {
Binding(key: String, action: action, description: String)
}
Constructors
-
Binding(key: String, action: action, description: String)
Values
pub fn all_bindings(
km: Keymap(action),
) -> List(#(String, action))
All bindings as #(key, action) pairs.
pub fn bind(
km: Keymap(action),
key: String,
action: action,
description: String,
) -> Keymap(action)
Add a binding to the end of the keymap.
The first matching binding wins on lookup.
pub fn filter(
km: Keymap(action),
query: String,
) -> Keymap(action)
Keep only bindings whose description contains query (case-insensitive).
Useful for a live-filter command palette.
pub fn help_lines(km: Keymap(action)) -> List(#(String, String))
All bindings as #(key, description) pairs, in registration order.
pub fn lookup(
km: Keymap(action),
key: String,
) -> Result(action, Nil)
Find the action bound to key. Returns Error(Nil) if not found.
pub fn merge(km: Keymap(a), other: Keymap(a)) -> Keymap(a)
Merge other into km. Bindings from other are appended.
pub fn render_help(
buf: buffer.Buffer,
area: geometry.Rect,
km: Keymap(action),
st: style.Style,
) -> buffer.Buffer
Render a help table into area.
Each row shows key_col description. key_col_width is the
minimum column width for keys (auto-computed if 0).
Returns the buffer with the help overlay drawn.