mirror of
https://github.com/golang/term.git
synced 2026-02-08 11:46:05 +03:00
ssh/terminal: support ^N and ^P
This makes it possible to navigate the history without leaving the home row on the keyboard. Change-Id: Id24c43f8eb6090520ab37bf8126264901b70c489 Reviewed-on: https://go-review.googlesource.com/c/33618 Run-TryBot: Matt Layher <mdlayher@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matt Layher <mdlayher@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
5c4920f7cd
commit
1fb3bd0768
@@ -159,6 +159,10 @@ func bytesToKey(b []byte, pasteActive bool) (rune, []byte) {
|
||||
return keyClearScreen, b[1:]
|
||||
case 23: // ^W
|
||||
return keyDeleteWord, b[1:]
|
||||
case 14: // ^N
|
||||
return keyDown, b[1:]
|
||||
case 16: // ^P
|
||||
return keyUp, b[1:]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,12 @@ var keyPressTests = []struct {
|
||||
{
|
||||
in: "\x1b[B\r", // down
|
||||
},
|
||||
{
|
||||
in: "\016\r", // ^P
|
||||
},
|
||||
{
|
||||
in: "\014\r", // ^N
|
||||
},
|
||||
{
|
||||
in: "line\x1b[A\x1b[B\r", // up then down
|
||||
line: "line",
|
||||
|
||||
Reference in New Issue
Block a user