Skip to content

Commit

Permalink
i
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurrium committed Dec 23, 2022
1 parent d32130e commit 1e1caba
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions kilo.c
Expand Up @@ -133,24 +133,29 @@ void editorProcessKeyPress() {

/*** output ***/

void editorDrawRows() {
void editorDrawRows(struct abuf *ab) {
int y;
for (y = 0; y < E.screenrows; y++) {
write(STDIN_FILENO, "~", 1);
abAppend(ab, "~", 1);

if (y < E.screenrows - 1) {
write(STDIN_FILENO, "\r\n", 2);
abAppend(ab, "\r\n", 2);
}
}
}

void editorRefreshScreen() {
write(STDOUT_FILENO, "\x1b[2J", 4);
write(STDOUT_FILENO, "\x1b[H", 3);
struct abuf ab = ABUF_INIT;

abAppend(&ab, "\x1b[2J", 4);
abAppend(&ab, "\x1b[H", 3);

editorDrawRows(&ab);

editorDrawRows();
abAppend(&ab, "\x1b[H", 3);

write(STDIN_FILENO, "\x1b[H", 3);
write(STDIN_FILENO, ab.b, ab.len);
abFree(&ab);
}

/*** init ***/
Expand Down

0 comments on commit 1e1caba

Please sign in to comment.