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

Function ToChar

internal/keys/parse.go:273–302  ·  view source on GitHub ↗

ToChar converts a tcell.Key to its rune representation if it's a Ctrl+ key.

(k tcell.Key)

Source from the content-addressed store, hash-verified

271
272// ToChar converts a tcell.Key to its rune representation if it's a Ctrl+<char> key.
273func ToChar(k tcell.Key) (rune, bool) {
274 switch k {
275 // These have special key codes and should not be treated as runes.
276 case tcell.KeyCtrlH: // Backspace
277 return 0, false
278 case tcell.KeyCtrlI: // Tab
279 return 0, false
280 case tcell.KeyCtrlM: // Enter
281 return 0, false
282 }
283
284 if k >= tcell.KeyCtrlA && k <= tcell.KeyCtrlZ {
285 return 'a' + rune(k-tcell.KeyCtrlA), true
286 }
287 // Handle other special Ctrl keys if necessary
288 switch k {
289 case tcell.KeyCtrlSpace:
290 return ' ', true
291 case tcell.KeyCtrlUnderscore:
292 return '_', true
293 case tcell.KeyCtrlRightSq:
294 return ']', true
295 case tcell.KeyCtrlBackslash:
296 return '\\', true
297 case tcell.KeyCtrlCarat:
298 return '^', true
299 }
300
301 return 0, false
302}

Callers 1

NormalizeEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected