Documentation
¶
Overview ¶
Package keymap provides the global, user-mappable key-binding dictionary: stable action names ("window.close") mapped to key + modifier combinations, with JSON persistence so applications (and a future Settings UI) can override the defaults at startup.
Spec string format — modifier + key names joined by '+', order-insensitive, case-insensitive:
"Escape" plain key "Ctrl+W" modifier + key "Ctrl+Shift+F" multiple modifiers
Modifier names: Ctrl/Control, Shift, Alt/Option, Meta/Cmd/Super/Win. Key names cover the mobilegles Keycode set (see keyNames).
Index ¶
- Constants
- func FormatSpec(key platform.KeyCode, mods platform.Modifiers) string
- func LoadOverrides(m *Map)
- func ParseSpec(spec string) (platform.KeyCode, platform.Modifiers, error)
- type Binding
- type Map
- func (m *Map) ActionSpec(action string) (string, bool)
- func (m *Map) All() []Binding
- func (m *Map) Bind(action, spec string) error
- func (m *Map) Load(path string) (int, error)
- func (m *Map) Match(key platform.KeyCode, mods platform.Modifiers) (string, bool)
- func (m *Map) MatchAll(key platform.KeyCode, mods platform.Modifiers) []string
- func (m *Map) MustBind(action, spec string) *Map
- func (m *Map) Save(path string) error
- func (m *Map) Unbind(action string)
Constants ¶
const ( ActionExitFullscreen = "app.exit-fullscreen" ActionCloseWindow = "window.close" ActionCloseTab = "window.close-tab" ActionFocusSearch = "view.focus-search" )
Seed action names. Applications register additional actions with Default().MustBind / Bind.
Variables ¶
This section is empty.
Functions ¶
func FormatSpec ¶
FormatSpec renders key+mods back into canonical spec form ("Ctrl+Shift+Escape") — used for persistence and Settings display.
func LoadOverrides ¶
func LoadOverrides(m *Map)
LoadOverrides applies the first keymap file found (MEUI_KEYMAP=<path> or ./keymap.json) onto m. Missing files are not an error — the seed defaults simply stand. Load errors (bad JSON, bad specs) are logged, not fatal.
Types ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is an ordered set of bindings; the first binding matching a key event wins. Actions may share a key — MatchAll returns every match in order so handlers can skip contextual actions (exit-fullscreen only fires while fullscreen, then the next match, window.close, applies).
func Default ¶
func Default() *Map
Default returns the process-wide key map: the seed bindings with any overrides from the keymap file applied (MEUI_KEYMAP=<path>, or ./keymap.json when present).
func Defaults ¶
func Defaults() *Map
Defaults returns a Map with the framework seed bindings. Esc is bound to both exit-fullscreen and window.close: handlers try actions in order (MatchAll) and skip contextual ones that don't apply, so plain Esc closes a window while Esc in fullscreen only leaves fullscreen — matching the legacy hardcoded behavior.
func (*Map) ActionSpec ¶
ActionSpec returns the spec string currently bound to action ("Ctrl+W") — for Settings UI display.
func (*Map) Bind ¶
Bind parses spec ("Ctrl+Shift+Escape") and binds it to action, replacing any existing binding for the same action.
func (*Map) Load ¶
Load reads path and applies every entry onto m as an override (rebinding the action's key). Unknown actions are still bound — the file may define bindings for application-specific actions. Returns the number of bindings applied.
func (*Map) MatchAll ¶
MatchAll returns every matching action in binding order — handlers walk it when actions are contextual (exit-fullscreen fires only while fullscreen, then window.close applies to the same key).