diff --git a/kilo.c b/kilo.c index 7bf97ff..fdfca31 100644 --- a/kilo.c +++ b/kilo.c @@ -997,7 +997,22 @@ void editorDrawRows(struct abuf *ab) int j; for (j = 0; j < len; j++) { - if (hl[j] == HL_NORMAL) + // Make control characters "readable" + 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); + // Restore the previous highlighting color + 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) {