From d59da2cf7796b699c7be135d4744daa098f98ba2 Mon Sep 17 00:00:00 2001 From: Cheney Date: Wed, 28 Oct 2015 09:02:52 +0800 Subject: [PATCH] refactor excapeExKey --- utils.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/utils.go b/utils.go index efadd41..18e659a 100644 --- a/utils.go +++ b/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 }