gui/pkg/keybinding/platform.go
Claude 0f6400052c
feat(keybinding): add TaskProcess, error sentinels, concurrency test
- Platform.Process(accelerator) for programmatic trigger
- TaskProcess IPC task with ActionTriggered broadcast
- ErrorNotRegistered sentinel for remove/process on unknown bindings
- 5 new tests: process good/bad/ugly, remove sentinel, concurrent adds

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 14:55:01 +01:00

24 lines
1,003 B
Go

// pkg/keybinding/platform.go
package keybinding
// Platform abstracts the keyboard shortcut backend (Wails v3).
type Platform interface {
// Add registers a global keyboard shortcut with the given accelerator string.
// The handler is called when the shortcut is triggered.
// Accelerator syntax is platform-aware: "Cmd+S" (macOS), "Ctrl+S" (Windows/Linux).
// Special keys: F1-F12, Escape, Enter, Space, Tab, Backspace, Delete, arrow keys.
Add(accelerator string, handler func()) error
// Remove unregisters a previously registered keyboard shortcut.
Remove(accelerator string) error
// Process triggers the registered handler for the given accelerator programmatically.
// Returns true if a handler was found and invoked, false if not registered.
//
// handled := platform.Process("Ctrl+S")
Process(accelerator string) bool
// GetAll returns all currently registered accelerator strings.
// Used for adapter-level reconciliation only — not read by QueryList.
GetAll() []string
}