diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-07-17 23:00:46 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-07-17 23:01:39 (EDT) |
commit | aaebf87cf60ce3c040eacf2403ff078b41e37331 (patch) | |
tree | df3439538a1496902a6de933aad803bd725cf660 /src/text.c | |
parent | 35cfcd0fd74ebce66cd7bf12309b600d37c34623 (diff) |
sgr(): New function (4-bit colors only)
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') { |