Implements pkg/keybinding with three-layer pattern: IPC Bus -> Service -> Platform. Service maintains in-memory registry, ErrAlreadyRegistered on duplicates. QueryList reads from service registry, not platform.GetAll(). ActionTriggered broadcast on shortcut trigger via platform callback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
// pkg/keybinding/messages.go
|
|
package keybinding
|
|
|
|
import "errors"
|
|
|
|
// ErrAlreadyRegistered is returned when attempting to add a binding
|
|
// that already exists. Callers must TaskRemove first to rebind.
|
|
var ErrAlreadyRegistered = errors.New("keybinding: accelerator already registered")
|
|
|
|
// BindingInfo describes a registered keyboard shortcut.
|
|
type BindingInfo struct {
|
|
Accelerator string `json:"accelerator"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// --- Queries ---
|
|
|
|
// QueryList returns all registered bindings. Result: []BindingInfo
|
|
type QueryList struct{}
|
|
|
|
// --- Tasks ---
|
|
|
|
// TaskAdd registers a new keyboard shortcut. Result: nil
|
|
// Returns ErrAlreadyRegistered if the accelerator is already bound.
|
|
type TaskAdd struct {
|
|
Accelerator string `json:"accelerator"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// TaskRemove unregisters a keyboard shortcut. Result: nil
|
|
type TaskRemove struct {
|
|
Accelerator string `json:"accelerator"`
|
|
}
|
|
|
|
// --- Actions ---
|
|
|
|
// ActionTriggered is broadcast when a registered shortcut is activated.
|
|
type ActionTriggered struct {
|
|
Accelerator string `json:"accelerator"`
|
|
}
|