35 lines
613 B
Go
35 lines
613 B
Go
|
package key
|
||
|
|
||
|
// ----------------------------------------------------------------------------
|
||
|
// !Terminal Input Escape Code Sequences
|
||
|
// ----------------------------------------------------------------------------
|
||
|
|
||
|
const (
|
||
|
Esc = '\x1b'
|
||
|
)
|
||
|
|
||
|
// 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
|
||
|
}
|