Skip to main content

Module engine

Module engine 

Source
Expand description

§Page-mode dispatcher engine.

The engine wraps a Keymap with the runtime state every vim-ish dispatcher needs:

  • pending chord buffer — chords accumulate until the trie reports Match, an ambiguity timeout fires, or a NoMatch resets the buffer.
  • count prefix — leading digits 1-9 (and 0 if it’s not a binding by itself) accumulate into a u32 count attached to the next count-bearing action. 5jScrollDown(5).
  • register prefix"<char> selects a register and stashes it on the engine. Phase 2 only captures the state; yank-to- register wiring lands in Phase 5.
  • mode — current PageMode. Mode transitions arrive two ways: implicit (specific actions like OpenOmnibar / EnterHintMode / EnterInsertMode move the engine into the matching mode after dispatch) and explicit (PageAction::EnterMode). The user-config friendly catch-all EnterMode co-exists with the legacy specific actions because each carries a slightly different semantic for the host (the omnibar action also opens the omnibar UI; a plain EnterMode only changes mode). Both code paths converge on Engine::set_mode.

§Design choice (mode transitions)

Per the brief: “Pick whichever is cleaner; document the choice in a code comment at the top of the new file.” Choice: keep the specific actions, add EnterMode(PageMode) for raw transitions, and have the engine auto-transition for any of them. Rationale: the specific actions carry host-side meaning beyond mode change (open the omnibar UI, paint the hint overlay), so they shouldn’t collapse into EnterMode. The engine treats both as triggers.

§Insert-mode stub

When the trie returns EnterInsertMode, the engine sets mode = Insert and stops processing keys via the trie. Subsequent keys must go through Engine::feed_edit_mode_key which currently returns EditModeStep::PassThrough(chord). Real wiring lands when hjkl_engine::Host extraction ships upstream.

Structs§

Engine
Page-mode dispatcher.

Enums§

EditModeStep
What feed_edit_mode_key returns.
Step
Result of feeding one chord to the engine.

Constants§

DEFAULT_TIMEOUT
Default ambiguity timeout (vim’s &timeoutlen).