Skip to content
Myr

Let's call sequences what they really are

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent 8df1395 · Browse files · 1 file+5 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−5 removed

  • other:+5 added−5 removed

1 file+5 added−5 removed

modified:key.go+5 added-5 removed
16 unmodified lines
17 keyESC = 2718 keyUS = 3119)2021var controlKeyNames = map[int]string{21var controlNames = map[int]string{22 keyETX: "ctrl+c",23 keyLF: "enter",24 keyCR: "enter",25 keyESC: "esc",26 keyUS: "us",27}2829var keyNames = map[string]string{29var sequenceNames = map[string]string{30 "\x1b[A": "up",31 "\x1b[B": "down",32 "\x1b[C": "right",33 "\x1b[D": "left",
17 unmodified lines
51 }5253 // Is it a control character?54 if n == 1 && c <= keyUS {55 if s, ok := controlKeyNames[int(c)]; ok {55 if s, ok := controlNames[int(c)]; ok {56 return s, nil57 }58 }5960 // Is it a special key, like an arrow key?61 if s, ok := keyNames[string(buf[:n])]; ok {60 // Is it a special sequence, like an arrow key?61 if s, ok := sequenceNames[string(buf[:n])]; ok {62 return s, nil63 }6465 // Nope, just a regular, ol' rune
2 unmodified lines