Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete home end support #12

Merged
merged 5 commits into from
Oct 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (t *Terminal) ioloop() {
r = escapeKey(r)
} else if isEscapeEx {
isEscapeEx = false
r = escapeExKey(r)
r = escapeExKey(r, buf)
}

expectNextChar = true
Expand Down
12 changes: 11 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package readline

import (
"bufio"
"strconv"
"syscall"

Expand Down Expand Up @@ -38,8 +39,13 @@ func IsPrintable(key rune) bool {
}

// translate Esc[X
func escapeExKey(r rune) rune {
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':
Expand All @@ -48,6 +54,10 @@ func escapeExKey(r rune) rune {
r = CharPrev
case 'B':
r = CharNext
case 'H':
r = CharLineStart
case 'F':
r = CharLineEnd
}
return r
}
Expand Down