forked from mirror/readline
refactor excapeExKey
This commit is contained in:
parent
6ba1b6d3f5
commit
d59da2cf77
14
utils.go
14
utils.go
|
@ -41,11 +41,6 @@ func IsPrintable(key rune) bool {
|
|||
// translate Esc[X
|
||||
func escapeExKey(r rune, reader *bufio.Reader) rune {
|
||||
switch r {
|
||||
case 51:
|
||||
r = CharDelete
|
||||
if d, _, err := reader.ReadRune(); reader != nil && (err != nil || d != 126) {
|
||||
reader.UnreadRune()
|
||||
}
|
||||
case 'D':
|
||||
r = CharBackward
|
||||
case 'C':
|
||||
|
@ -58,6 +53,15 @@ func escapeExKey(r rune, reader *bufio.Reader) rune {
|
|||
r = CharLineStart
|
||||
case 'F':
|
||||
r = CharLineEnd
|
||||
default:
|
||||
if r == '3' && reader != nil {
|
||||
d, _, _ := reader.ReadRune()
|
||||
if d == '~' {
|
||||
r = CharDelete
|
||||
} else {
|
||||
reader.UnreadRune()
|
||||
}
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue