Fix #59 , support HOME/END for <Esc>OH/F

This commit is contained in:
chzyer 2016-06-21 17:53:12 +08:00
parent 3717d7c383
commit 683bf8ff7c
2 changed files with 12 additions and 2 deletions

View File

@ -129,7 +129,7 @@ func (t *Terminal) ioloop() {
isEscapeEx = true
continue
}
r = escapeKey(r)
r = escapeKey(r, buf)
} else if isEscapeEx {
isEscapeEx = false
r = escapeExKey(r, buf)

View File

@ -93,7 +93,7 @@ func escapeExKey(r rune, reader *bufio.Reader) rune {
}
// translate EscX to Meta+X
func escapeKey(r rune) rune {
func escapeKey(r rune, reader *bufio.Reader) rune {
switch r {
case 'b':
r = MetaBackward
@ -105,6 +105,16 @@ func escapeKey(r rune) rune {
r = MetaTranspose
case CharBackspace:
r = MetaBackspace
case 'O':
d, _, _ := reader.ReadRune()
switch d {
case 'H':
r = CharLineStart
case 'F':
r = CharLineEnd
default:
reader.UnreadRune()
}
case CharEsc:
}