From 046f17a81a26f07d6a24aff7d26e9afe9e45dba0 Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Tue, 28 May 2013 19:01:52 -0700 Subject: [PATCH] ^A and ^E in shell --- userspace/core/sh.c | 14 ++++++++++++++ userspace/lib/kbd.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/userspace/core/sh.c b/userspace/core/sh.c index 15819b95..fbbaa624 100644 --- a/userspace/core/sh.c +++ b/userspace/core/sh.c @@ -336,6 +336,20 @@ size_t rline(char * buffer, size_t buf_size, rline_callbacks_t * callbacks) { fflush(stdout); } continue; + case KEY_CTRL_A: + while (context.offset > 0) { + printf("\033[D"); + context.offset--; + } + fflush(stdout); + continue; + case KEY_CTRL_E: + while (context.offset < context.collected) { + printf("\033[C"); + context.offset++; + } + fflush(stdout); + continue; case KEY_CTRL_L: /* ^L: Clear Screen, redraw prompt and buffer */ printf("\033[H\033[2J"); if (callbacks->redraw_prompt) { diff --git a/userspace/lib/kbd.h b/userspace/lib/kbd.h index a8710144..dc901ba3 100644 --- a/userspace/lib/kbd.h +++ b/userspace/lib/kbd.h @@ -8,7 +8,9 @@ #define KEY_NONE 0 #define KEY_BACKSPACE 8 +#define KEY_CTRL_A 1 #define KEY_CTRL_C 3 +#define KEY_CTRL_E 5 #define KEY_CTRL_L 12 #define KEY_CTRL_R 18 #define KEY_ESCAPE 27