summaryrefslogtreecommitdiffstats
path: root/src/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/text.c')
-rw-r--r--src/text.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/text.c b/src/text.c
index cb777e4..1d888d8 100644
--- a/src/text.c
+++ b/src/text.c
@@ -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') {