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

Function IsReserved

internal/keys/parse.go:152–180  ·  view source on GitHub ↗

IsReserved reports whether the given key combination is reserved for navigation and should not be reassigned. Only unmodified keys are checked.

(key tcell.Key, r rune, mod tcell.ModMask)

Source from the content-addressed store, hash-verified

150// IsReserved reports whether the given key combination is reserved for
151// navigation and should not be reassigned. Only unmodified keys are checked.
152func IsReserved(key tcell.Key, r rune, mod tcell.ModMask) bool {
153 // Unmodified navigation keys cannot be remapped.
154 if mod == 0 {
155 switch key {
156 case tcell.KeyUp, tcell.KeyDown, tcell.KeyLeft, tcell.KeyRight,
157 tcell.KeyEsc, tcell.KeyEnter, tcell.KeyBackspace, tcell.KeyBackspace2,
158 tcell.KeyTab:
159 return true
160 case tcell.KeyRune:
161 switch unicode.ToLower(r) {
162 case 'h', 'j', 'k', 'l':
163 return true
164 }
165 }
166 }
167
168 // System-reserved combinations like Ctrl+C should not be reused.
169 if key == tcell.KeyRune && (mod&tcell.ModCtrl) != 0 {
170 other := mod &^ (tcell.ModCtrl | tcell.ModShift)
171 if other == 0 {
172 switch unicode.ToLower(r) {
173 case 'c', 'd':
174 return true
175 }
176 }
177 }
178
179 return false
180}
181
182// NormalizeEvent converts an EventKey into a canonical (key,rune,mod) triple.
183// Ctrl+A style events are normalized to KeyRune with the corresponding rune.

Callers 1

ValidateKeyBindingsFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected