From 1fb3bd0768d0139e111842e96ac7ffe2571fe772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bohusl=C3=A1vek?= Date: Tue, 29 Nov 2016 22:27:05 +0000 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Matt Layher Reviewed-by: Brad Fitzpatrick --- terminal.go | 4 ++++ terminal_test.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/terminal.go b/terminal.go index 9a88759..9d666ff 100644 --- a/terminal.go +++ b/terminal.go @@ -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:] } } diff --git a/terminal_test.go b/terminal_test.go index 5e5d33b..3ae9116 100644 --- a/terminal_test.go +++ b/terminal_test.go @@ -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",