Skip to main content

Module leader

Module leader 

Source
Expand description

Vim-style leader key bar — generic, reusable across apps.

§Usage

  1. Define your menu tree as a &'static [LeaderNode].
  2. Create LeaderState::new(root).
  3. Call arm() when the leader key is pressed.
  4. On each key: call push(c)LeaderResult.
  5. Call tick() each event-loop iteration (handles timeout).
  6. Call render_leader_bar(f, &state, screen_area, &theme) in your draw fn.

§Label rendering

Each LeaderNode takes a full label string (e.g. "navigate", "find"). The key character is highlighted inline with [k] brackets if it appears in the label, otherwise it is displayed as a prefix:

[f]ind         ← 'f' found at position 0
e[x]ecute      ← 'x' found at position 1
[g] navigate   ← 'g' not in "navigate"

Structs§

LeaderNode
One entry in a leader menu level.
LeaderState

Enums§

LeaderResult
Outcome of pressing a key while the leader is active.

Constants§

POPUP_DELAY
Delay before the leader popup first appears after arming. Fast typists never see a flash; once the popup is shown, subsequent keystrokes don’t re-trigger the delay.

Functions§

render_leader_bar
Render the leader bar as a centered column popup. Does nothing when state.active is false.