Parses human-readable key sequence strings into trie key tuples.
Converts strings like "SPC g s" or "C-x C-s" into the
[{codepoint, modifiers}] format used by Minga.Keymap.Bindings.
Supported tokens
| Token | Meaning |
|---|---|
SPC | Space (codepoint 32) |
TAB | Tab (codepoint 9) |
RET | Return/Enter (codepoint 13) |
ESC | Escape (codepoint 27) |
DEL | Delete (codepoint 127) |
C-x | Ctrl + x |
M-x | Alt/Meta + x |
a | Single character |
Examples
iex> Minga.Keymap.KeyParser.parse("SPC g s")
{:ok, [{32, 0}, {103, 0}, {115, 0}]}
iex> Minga.Keymap.KeyParser.parse("C-s")
{:ok, [{115, 2}]}
iex> Minga.Keymap.KeyParser.parse("")
{:error, "empty key sequence"}
Summary
Functions
@spec parse(String.t()) :: {:ok, [Minga.Keymap.Bindings.key()]} | {:error, String.t()}
Parses a key sequence string into a list of {codepoint, modifiers} tuples.
Returns {:ok, keys} on success or {:error, reason} on failure.
@spec parse!(String.t()) :: [Minga.Keymap.Bindings.key()]
Like parse/1 but raises on error.