gilo/internal/key/key.go
Timothy J. Warren 910107428c
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
Buggy incremental search
2021-04-06 16:37:58 -04:00

37 lines
657 B
Go

package key
// ----------------------------------------------------------------------------
// !Terminal Input Escape Code Sequences
// ----------------------------------------------------------------------------
const (
Backspace = '\x7f'
Esc = '\x1b'
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
}