From 683bf8ff7cd77265a852553c3c3e37a464339049 Mon Sep 17 00:00:00 2001 From: chzyer <0@0xdf.com> Date: Tue, 21 Jun 2016 17:53:12 +0800 Subject: [PATCH] Fix #59 , support HOME/END for OH/F --- terminal.go | 2 +- utils.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/terminal.go b/terminal.go index 486d9a3..0f1d393 100644 --- a/terminal.go +++ b/terminal.go @@ -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) diff --git a/utils.go b/utils.go index 932b10e..6a26447 100644 --- a/utils.go +++ b/utils.go @@ -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: }