refactor excapeExKey

This commit is contained in:
Cheney 2015-10-28 09:02:52 +08:00
parent 6ba1b6d3f5
commit d59da2cf77
1 changed files with 9 additions and 5 deletions

View File

@ -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
}