aboutsummaryrefslogtreecommitdiff
path: root/linenoise.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-04-08 12:42:29 +1000
committerSteve Bennett <steveb@workware.net.au>2011-04-08 12:54:33 +1000
commitcb67f7e065080f55a281d979c9de075db7ca1c84 (patch)
tree91b63e8663f8b201cbd9257f5df34c03e34ee7b4 /linenoise.c
parenta76b3913552b0204b02cbd64567c00a7b3aff8eb (diff)
downloadjimtcl-cb67f7e065080f55a281d979c9de075db7ca1c84.zip
jimtcl-cb67f7e065080f55a281d979c9de075db7ca1c84.tar.gz
jimtcl-cb67f7e065080f55a281d979c9de075db7ca1c84.tar.bz2
Add linenoise support for ^L
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'linenoise.c')
-rw-r--r--linenoise.c18
1 files changed, 18 insertions, 0 deletions
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;