2021-03-24 16:23:17 -04:00
|
|
|
package fn
|
2021-03-19 16:36:02 -04:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|