Created
October 15, 2018 06:54
-
-
Save bobbicodes/061ea557004a50da17bfe936e3731258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void editorDrawRows(struct abuf *ab) { | |
int y; | |
for (y = 0; y < E.screenrows; y++) { | |
int filerow = y + E.rowoff; | |
if (filerow >= E.numrows) { | |
if (E.numrows == 0 && y == E.screenrows / 3) { | |
char welcome[80]; | |
int welcomelen = snprintf(welcome, sizeof(welcome), | |
"Bob, the text editor"); | |
if (welcomelen > E.screencols) welcomelen = E.screencols; | |
int padding = (E.screencols - welcomelen) / 2; | |
if (padding) { | |
abAppend(ab, " ", 1); | |
padding--; | |
} | |
while (padding--) abAppend(ab, " ", 1); | |
abAppend(ab, welcome, welcomelen); | |
} else { | |
abAppend(ab, " ", 1); | |
} | |
} else { | |
int len = E.row[filerow].rsize - E.coloff; | |
if (len < 0) len = 0; | |
if (len > E.screencols) len = E.screencols; | |
abAppend(ab, &E.row[filerow].render[E.coloff], len); | |
} | |
abAppend(ab, "\x1b[K", 3); | |
abAppend(ab, "\r\n", 2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment