[PATCH v1 2/3] util/readline.c: add C-n, C-p shortcuts

Manos Pitsidianakis posted 3 patches 5 months, 2 weeks ago
[PATCH v1 2/3] util/readline.c: add C-n, C-p shortcuts
Posted by Manos Pitsidianakis 5 months, 2 weeks ago
C-n and C-p are the default bindings for readline's next-history and
previous-history respectively. They have the same functionality as the
Down and Up arrow keys.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
---
 util/readline.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/util/readline.c b/util/readline.c
index ded31b04b7..0b627d62ad 100644
--- a/util/readline.c
+++ b/util/readline.c
@@ -418,6 +418,14 @@ void readline_handle_byte(ReadLineState *rs, int ch)
             rs->last_cmd_buf_size = 0;
             rs->readline_func(rs->opaque, rs->cmd_buf, rs->readline_opaque);
             break;
+        case 14:
+            /* ^N Next line in history */
+            readline_down_char(rs);
+            break;
+        case 16:
+            /* ^P Prev line in history */
+            readline_up_char(rs);
+            break;
         case 23:
             /* ^W */
             readline_backword(rs);
-- 
γαῖα πυρί μιχθήτω