Documentation
¶
Overview ¶
Package keymap manages centralized keyboard shortcut registration, multi-key sequence handling, context-aware binding resolution, and user-configurable key overrides.
Index ¶
- func ApplyConfig(r *Registry, cfg *Config)
- func RegisterDefaults(r *Registry)
- type Binding
- type Category
- type Command
- type Config
- type Registry
- func (r *Registry) AllContexts() []string
- func (r *Registry) BindingsForContext(context string) []Binding
- func (r *Registry) GetCommand(id string) (Command, bool)
- func (r *Registry) Handle(key tea.KeyMsg, activeContext string) tea.Cmd
- func (r *Registry) HasPending() bool
- func (r *Registry) RegisterBinding(b Binding)
- func (r *Registry) RegisterCommand(cmd Command)
- func (r *Registry) RegisterPluginBinding(key, command, context string)
- func (r *Registry) ResetPending()
- func (r *Registry) SetUserOverride(key, commandID string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyConfig ¶
ApplyConfig applies user configuration overrides to the registry.
func RegisterDefaults ¶
func RegisterDefaults(r *Registry)
RegisterDefaults registers all default bindings with the given registry.
Types ¶
type Binding ¶
type Binding struct {
Key string // e.g., "tab", "ctrl+s", "g g"
Command string // Command ID
Context string // "global", plugin ID, etc.
}
Binding maps a key or key sequence to a command.
type Config ¶
Config represents user key binding configuration.
func LoadConfig ¶
LoadConfig loads key binding overrides from a JSON file.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages key bindings and command dispatch.
func (*Registry) AllContexts ¶
AllContexts returns all contexts that have bindings.
func (*Registry) BindingsForContext ¶
BindingsForContext returns all bindings for a given context.
func (*Registry) GetCommand ¶
GetCommand retrieves a command by ID. Returns the command and true if found, or zero value and false otherwise.
func (*Registry) Handle ¶
Handle dispatches a key event to the appropriate command handler. Returns nil if no matching binding is found.
func (*Registry) HasPending ¶
HasPending returns true if there's a pending key sequence.
func (*Registry) RegisterBinding ¶
RegisterBinding adds a key binding.
func (*Registry) RegisterCommand ¶
RegisterCommand adds a command to the registry.
func (*Registry) RegisterPluginBinding ¶
RegisterPluginBinding satisfies plugin.BindingRegistrar interface. It converts plugin.Binding to keymap.Binding and registers it.
func (*Registry) ResetPending ¶
func (r *Registry) ResetPending()
ResetPending clears any pending key sequence.
func (*Registry) SetUserOverride ¶
SetUserOverride sets a user-configured key override.