mg
mg copied to clipboard
attempt to add basic syntax highlighting
https://github.com/hboetes/mg/blob/32efa2519d61f1402e8c4d6998b1db0a4408e41e/display.c#L330
so I tried to implement a basic syntax highlighting by first trying to color in digits. I tried to utilize ANSI escape codes as follows
} else if (isprint(c)){
if (isdigit(c)){
char buf[5];
int clen = snprintf(buf, sizeof(buf), "\x1b[35m");
for(uint32_t i = 0; i < 5; ++i){
vp->v_text[vtcol++] = buf[i];
}
vp->v_text[vtcol++] = c;
clen = snprintf(buf, sizeof(buf), "\x1b[39m");
for(uint32_t i = 0; i < 5; ++i){
vp->v_text[vtcol++] = buf[i];
}
}
else
vp->v_text[vtcol++] = c;
}
but this does not seem to work as it only hides the digits and shrinks the modeline.
Anyone any idea on how to proceed here?