30 lines
384 B
Go
30 lines
384 B
Go
|
package rune
|
||
|
|
||
|
func isAscii(char rune) bool {
|
||
|
ord := int(char)
|
||
|
|
||
|
return ord < 0x80
|
||
|
}
|
||
|
|
||
|
func IsCtrl(char rune) bool {
|
||
|
if !isAscii(char) {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
ord := int(char)
|
||
|
|
||
|
return ord == 0x7f || ord < 0x20
|
||
|
}
|
||
|
|
||
|
// Return the input code of a Ctrl-key chord.
|
||
|
func Ctrl(char rune) rune {
|
||
|
ord := int(char)
|
||
|
raw := ord & 0x1f
|
||
|
|
||
|
if !IsCtrl(rune(raw)) {
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
return rune(raw)
|
||
|
}
|