gui/pkg/keybinding/platform.go
Claude a9b795f223
Some checks failed
Security Scan / security (push) Failing after 29s
Test / test (push) Successful in 2m9s
feat: Wails v3 stub bridge + feature expansion + display bridge + MCP events
Stubs (15 files, 479 exports):
- All managers: Dialog, Event, Browser, Clipboard, ContextMenu, Environment, Screen, KeyBinding
- Window interface (~50 methods), BrowserWindow, platform options (iOS/Android)
- MenuItem (42 roles), WebviewWindowOptions (full platform types)
- Wails v3 submodule pinned at alpha 74

New events package (17th package):
- Custom event system bridged to Core IPC
- TaskEmit, TaskOn, TaskOff, QueryListeners, ActionEventFired

Feature expansions:
- Window: zoom, content (SetURL/SetHTML/ExecJS), bounds, print, flash
- Screen: QueryCurrent, ScreenPlacement, Rect geometry
- Dialog: typed tasks, file options, Info/Question/Warning/Error
- Keybinding: TaskProcess, ErrorNotRegistered
- Notification: RevokePermission, RegisterCategory, action broadcasts
- Dock: SetProgressBar, Bounce/StopBounce
- Environment: HasFocusFollowsMouse
- ContextMenu: QueryGetAll, TaskUpdate, TaskDestroy

Display bridge: 5 new event types wired to WebSocket
MCP: 4 event tools (emit, on, off, list)

17 packages build and test clean (1 flaky test ordering issue in window).

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

23 lines
960 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 programmatically triggers the shortcut as if the user pressed it.
// Returns an error if the platform cannot trigger the shortcut.
// p.Process("Ctrl+S")
Process(accelerator string) error
// GetAll returns all currently registered accelerator strings.
// Used for adapter-level reconciliation only — not read by QueryList.
GetAll() []string
}