Created
October 15, 2018 06:55
-
-
Save bobbicodes/b23cadef1350056b4f0e83e7dac39771 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; | |
char *c = &E.row[filerow].render[E.coloff]; | |
int j; | |
for (j = 0; j < len; j++) { | |
if (isdigit(c[j])) { | |
abAppend(ab, "\x1b[31m", 5); | |
abAppend(ab, &c[j], 1); | |
abAppend(ab, "\x1b[39m", 5); | |
} else { | |
abAppend(ab, &c[j], 1); | |
} | |
} | |
} | |
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