gilo/internal/key/key.go

37 lines
653 B
Go

package key
// ----------------------------------------------------------------------------
// !Terminal Input Escape Code Sequences
// ----------------------------------------------------------------------------
const (
Backspace = 0x7f
Esc = 0x1b
Enter = '\r'
)
// Is this an ASCII character?
func IsAscii(char rune) bool {
return char < 0x80
}
// Is this an ASCII ctrl character?
func IsCtrl(char rune) bool {
if !IsAscii(char) {
return false
}
return char == 0x7f || char < 0x20
}
// Return the input code of a Ctrl-key chord.
func Ctrl(char rune) rune {
if !IsAscii(char) {
return 0
}
ch := char & 0x1f
return ch
}