fix(hotkey): split platform files by platform+cgo build matrix
The `!darwin` guard on the modifier helpers was too broad: golang.design/x/ hotkey only exposes its Mod*/Key* constants from the darwin&&cgo, linux&&cgo and windows backends, while the `!windows && !cgo` complement (e.g. Linux cross-builds with CGO_ENABLED=0) falls back to a stub with no constants. That made hk.ModCtrl/ModShift/KeyA... undefined and produced editor/vet warnings. Realign the build tags with the upstream matrix and confine every hk.* constant to a tagged file so the shared hotkey.go compiles everywhere. Also fix the Linux mapping (option -> hk.Mod1; hk.ModAlt does not exist on X11).
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
//go:build windows || cgo
|
||||
|
||||
package hotkey
|
||||
|
||||
import hk "golang.design/x/hotkey"
|
||||
|
||||
// lookupKey maps a token from the user-supplied hotkey spec to a hk.Key.
|
||||
//
|
||||
// The Key* constants only exist in the platform backends that ship them
|
||||
// (windows, or the cgo-backed darwin/linux implementations); the cgo-less stub
|
||||
// in hotkey_unsupported.go provides a fallback lookupKey for the complement.
|
||||
//
|
||||
// The map is intentionally exhaustive over the alphanumeric set so we never
|
||||
// rely on an assumption that hk.KeyA..hk.KeyZ are contiguous values — the
|
||||
// upstream package gives no such guarantee.
|
||||
|
||||
Reference in New Issue
Block a user