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

Function createNavigationInputCapture

internal/ui/components/keyboard.go:49–89  ·  view source on GitHub ↗

createNavigationInputCapture creates a common input capture handler for navigation between components.

(app *App, leftTarget, rightTarget tview.Primitive)

Source from the content-addressed store, hash-verified

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 {
50 return func(event *tcell.EventKey) *tcell.EventKey {
51 switch event.Key() {
52 case tcell.KeyLeft:
53 if app != nil && leftTarget != nil {
54 app.SetFocus(leftTarget)
55
56 return nil
57 }
58 case tcell.KeyRight:
59 if app != nil && rightTarget != nil {
60 app.SetFocus(rightTarget)
61
62 return nil
63 }
64 case tcell.KeyRune:
65 switch event.Rune() {
66 case 'h': // VI-like left navigation
67 if app != nil && leftTarget != nil {
68 app.SetFocus(leftTarget)
69
70 return nil
71 }
72 case 'l': // VI-like right navigation
73 if app != nil && rightTarget != nil {
74 app.SetFocus(rightTarget)
75
76 return nil
77 }
78 case 'j': // VI-like down navigation
79 // Let the component handle down navigation naturally
80 return tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone)
81 case 'k': // VI-like up navigation
82 // Let the component handle up navigation naturally
83 return tcell.NewEventKey(tcell.KeyUp, 0, tcell.ModNone)
84 }
85 }
86
87 return event
88 }
89}
90
91// SetHotkeyOverride installs a temporary handler that runs before global shortcuts.
92// Return nil from the handler to swallow the event; otherwise return the event

Callers 6

SetAppMethod · 0.85
SetAppMethod · 0.85
SetAppMethod · 0.85
SetAppMethod · 0.85
SetAppMethod · 0.85

Calls 1

SetFocusMethod · 0.65

Tested by

no test coverage detected