MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / keyMatch

Function keyMatch

internal/ui/components/keyboard.go:17–46  ·  view source on GitHub ↗

keyMatch checks if an event matches a key specification string.

(ev *tcell.EventKey, spec string)

Source from the content-addressed store, hash-verified

15
16// keyMatch checks if an event matches a key specification string.
17func keyMatch(ev *tcell.EventKey, spec string) bool {
18 if strings.TrimSpace(spec) == "" {
19 return false
20 }
21
22 key, r, mod, err := keys.Parse(spec)
23 if err != nil {
24 if config.DebugEnabled {
25 models.GetUILogger().Debug("invalid key spec %s: %v", spec, err)
26 }
27
28 return false
29 }
30
31 evKey, evRune, evMod := keys.NormalizeEvent(ev)
32
33 if evMod != mod {
34 return false
35 }
36
37 if key == tcell.KeyRune {
38 match := evKey == tcell.KeyRune && r != 0 && strings.EqualFold(string(evRune), string(r))
39
40 return match
41 }
42
43 match := evKey == key
44
45 return match
46}
47
48// createNavigationInputCapture creates a common input capture handler for navigation between components.
49func createNavigationInputCapture(app *App, leftTarget, rightTarget tview.Primitive) func(*tcell.EventKey) *tcell.EventKey {

Callers 3

setupKeyboardHandlersMethod · 0.85
setupKeyHandlersMethod · 0.85

Calls 4

ParseFunction · 0.92
GetUILoggerFunction · 0.92
NormalizeEventFunction · 0.92
DebugMethod · 0.65

Tested by 1