Print non-printable chars

This commit is contained in:
Saumya Bhatnagar 2018-06-03 09:26:13 +05:30
parent 0418c00ea4
commit f905abf55e
2 changed files with 11 additions and 1 deletions

BIN
editor

Binary file not shown.

View File

@ -761,7 +761,17 @@ void editorDrawRows(struct AppendBuffer* ab) {
unsigned char *hl = &E.erow[fileRow].hl[E.colOff];
int current_color = -1; // default color
for (int j = 0; j < len; j++) {
if (hl[j] == HL_NORMAL) {
if (iscntrl(c[j])) {
char sym = (c[j] <= 26) ? '@' + c[j] : '?';
abAppend(ab, "\x1b[7m", 4);
abAppend(ab, &sym, 1);
abAppend(ab, "\x1b[m", 3);
if (current_color != -1) {
char buf[16];
int clen = snprintf(buf, sizeof(buf), "\x1b[%dm", current_color);
abAppend(ab, buf, clen);
}
} else if (hl[j] == HL_NORMAL) {
if (current_color != -1) {
abAppend(ab, "\x1b[39m", 5);
current_color = -1;