^A and ^E in shell

This commit is contained in:
Kevin Lange 2013-05-28 19:01:52 -07:00
parent c3995aaa55
commit 046f17a81a
2 changed files with 16 additions and 0 deletions

View File

@ -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) {

View File

@ -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