mirror of https://github.com/chzyer/readline.git
Fix #59 , support HOME/END for <Esc>OH/F
This commit is contained in:
parent
3717d7c383
commit
683bf8ff7c
|
@ -129,7 +129,7 @@ func (t *Terminal) ioloop() {
|
||||||
isEscapeEx = true
|
isEscapeEx = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
r = escapeKey(r)
|
r = escapeKey(r, buf)
|
||||||
} else if isEscapeEx {
|
} else if isEscapeEx {
|
||||||
isEscapeEx = false
|
isEscapeEx = false
|
||||||
r = escapeExKey(r, buf)
|
r = escapeExKey(r, buf)
|
||||||
|
|
12
utils.go
12
utils.go
|
@ -93,7 +93,7 @@ func escapeExKey(r rune, reader *bufio.Reader) rune {
|
||||||
}
|
}
|
||||||
|
|
||||||
// translate EscX to Meta+X
|
// translate EscX to Meta+X
|
||||||
func escapeKey(r rune) rune {
|
func escapeKey(r rune, reader *bufio.Reader) rune {
|
||||||
switch r {
|
switch r {
|
||||||
case 'b':
|
case 'b':
|
||||||
r = MetaBackward
|
r = MetaBackward
|
||||||
|
@ -105,6 +105,16 @@ func escapeKey(r rune) rune {
|
||||||
r = MetaTranspose
|
r = MetaTranspose
|
||||||
case CharBackspace:
|
case CharBackspace:
|
||||||
r = MetaBackspace
|
r = MetaBackspace
|
||||||
|
case 'O':
|
||||||
|
d, _, _ := reader.ReadRune()
|
||||||
|
switch d {
|
||||||
|
case 'H':
|
||||||
|
r = CharLineStart
|
||||||
|
case 'F':
|
||||||
|
r = CharLineEnd
|
||||||
|
default:
|
||||||
|
reader.UnreadRune()
|
||||||
|
}
|
||||||
case CharEsc:
|
case CharEsc:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue