From cb67f7e065080f55a281d979c9de075db7ca1c84 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Fri, 8 Apr 2011 12:42:29 +1000 Subject: Add linenoise support for ^L Signed-off-by: Steve Bennett --- linenoise.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/linenoise.c b/linenoise.c index cf3e3f7..6365636 100644 --- a/linenoise.c +++ b/linenoise.c @@ -65,6 +65,17 @@ * Sequence: ESC [ n C * Effect: moves cursor forward of n chars * + * The following are used to clear the screen: ESC [ H ESC [ 2 J + * This is actually composed of two sequences: + * + * cursorhome + * Sequence: ESC [ H + * Effect: moves the cursor to upper left corner + * + * ED2 (Clear entire screen) + * Sequence: ESC [ 2 J + * Effect: clear the whole screen + * * DSR/CPR (Report cursor position) * Sequence: ESC [ 6 n * Effect: reports current cursor position as ESC [ NNN ; MMM R @@ -822,6 +833,13 @@ process_char: current->pos = current->chars; refreshLine(prompt, current); break; + case ctrl('L'): /* Ctrl+L, clear screen */ + /* clear screen */ + fd_printf(current->fd, "\x1b[H\x1b[2J"); + /* Force recalc of window size for serial terminals */ + current->cols = 0; + refreshLine(prompt, current); + break; } } return current->len; -- cgit v1.1