diff --git a/kilo.c b/kilo.c index 406eb7be..dfc948b0 100644 --- a/kilo.c +++ b/kilo.c @@ -997,6 +997,14 @@ void editorRefreshScreen(void) { abFree(&ab); } +/* This function clear the whole screen using VT100 escape characters */ +void editorClearScreen(void) { + struct abuf ab = ABUF_INIT; + abAppend(&ab,"\x1b[J", E.numrows); + write(STDOUT_FILENO,ab.b,ab.len); + abFree(&ab); +} + /* Set an editor status message for the second line of the status, at the * end of the screen. */ void editorSetStatusMessage(const char *fmt, ...) { @@ -1207,6 +1215,7 @@ void editorProcessKeypress(int fd) { quit_times--; return; } + editorClearScreen(); exit(0); break; case CTRL_S: /* Ctrl-s */