gilo/internal/rune/rune.go

30 lines
384 B
Go
Raw Normal View History

2021-03-19 16:36:02 -04:00
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)
}