Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear screen after pressing CTRL-Q #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions kilo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) {
Expand Down Expand Up @@ -1207,6 +1215,7 @@ void editorProcessKeypress(int fd) {
quit_times--;
return;
}
editorClearScreen();
exit(0);
break;
case CTRL_S: /* Ctrl-s */
Expand Down