forked from mirror/readline
delete redundancy char check moved to escapeExKey method
This commit is contained in:
parent
de44b28597
commit
391c225c0b
|
@ -107,13 +107,7 @@ func (t *Terminal) ioloop() {
|
||||||
r = escapeKey(r)
|
r = escapeKey(r)
|
||||||
} else if isEscapeEx {
|
} else if isEscapeEx {
|
||||||
isEscapeEx = false
|
isEscapeEx = false
|
||||||
r = escapeExKey(r)
|
r = escapeExKey(r, buf)
|
||||||
// if hw delete button is pressed it is specified as set ot 4 runes [27,91,51,126]. we are now at 51
|
|
||||||
if r == CharDelete {
|
|
||||||
if d, _, err := buf.ReadRune(); err != nil || d != 126 {
|
|
||||||
buf.UnreadRune()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expectNextChar = true
|
expectNextChar = true
|
||||||
|
|
6
utils.go
6
utils.go
|
@ -1,6 +1,7 @@
|
||||||
package readline
|
package readline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
@ -38,10 +39,13 @@ func IsPrintable(key rune) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// translate Esc[X
|
// translate Esc[X
|
||||||
func escapeExKey(r rune) rune {
|
func escapeExKey(r rune, reader *bufio.Reader) rune {
|
||||||
switch r {
|
switch r {
|
||||||
case 51:
|
case 51:
|
||||||
r = CharDelete
|
r = CharDelete
|
||||||
|
if d, _, err := reader.ReadRune(); err != nil || d != 126 {
|
||||||
|
reader.UnreadRune()
|
||||||
|
}
|
||||||
case 'D':
|
case 'D':
|
||||||
r = CharBackward
|
r = CharBackward
|
||||||
case 'C':
|
case 'C':
|
||||||
|
|
Loading…
Reference in New Issue