diff options
Diffstat (limited to 'src/text.c')
-rw-r--r-- | src/text.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -27,6 +27,7 @@ #include <png.h> #include "font.h" +#include "sgr.h" #define MAX(a, b) (((a) > (b)) ? (a) : (b)) @@ -102,6 +103,7 @@ text_render(struct text *text, struct font *font, png_bytepp rows) char *string; size_t row; size_t col; + char *parameter; png_color fg = {255, 255, 255}; png_color bg = { 0, 0, 0}; @@ -117,9 +119,14 @@ text_render(struct text *text, struct font *font, png_bytepp rows) while (string && *string) { if (*string == 0x1B && *(string + 1) == '[') { /* CSI */ string += 2; + parameter = string; for (; *string >= 0x30 && *string <= 0x3F; ++string); for (; *string >= 0x20 && *string <= 0x2F; ++string); if (*string >= 0x40 && *string <= 0x7E) { + if (*string == 'm') { + *string = '\0'; + sgr(parameter, &fg, &bg); + } ++string; } } else if (*string == '\n') { |