util/readline: Add C-n, C-p shortcuts
authorManos Pitsidianakis <manos.pitsidianakis@linaro.org>
Thu, 13 Jun 2024 08:06:12 +0000 (11:06 +0300)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Wed, 19 Jun 2024 10:42:03 +0000 (12:42 +0200)
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>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <9876594132d1f2e7210ab3f7ca01a82f95206447.1718265822.git.manos.pitsidianakis@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
util/readline.c

index ded31b04b72aeee0d6cd2ba67df9962bc6201de6..0b627d62ad7bb8b244bcde643853e72185c772ae 100644 (file)
@@ -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);