diff options
| author | Franklin Wei <git@fwei.tk> | 2015-05-27 20:58:07 -0400 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2015-05-27 20:58:07 -0400 |
| commit | 34b11c33ff5b0df5466642b577bf32b529fc66fd (patch) | |
| tree | cd079ea23e7c46de1421f9b990abf96e70d41f0b /src/util.c | |
| parent | 8b61f947daa7b64a2dd8ee7d6340c64fa7787f07 (diff) | |
| download | market-sim-34b11c33ff5b0df5466642b577bf32b529fc66fd.zip market-sim-34b11c33ff5b0df5466642b577bf32b529fc66fd.tar.gz market-sim-34b11c33ff5b0df5466642b577bf32b529fc66fd.tar.bz2 market-sim-34b11c33ff5b0df5466642b577bf32b529fc66fd.tar.xz | |
add colorized html output
Diffstat (limited to 'src/util.c')
| -rw-r--r-- | src/util.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -319,6 +319,11 @@ uint parse_args(int argc, char *argv[], char **port_file) ret |= ARG_FAILURE; break; } + else if(strcmp(arg, "--html") == 0) + { + ret |= ARG_HTML; + ret |= ARG_NOCURSES; + } else if(strcmp(arg, "--nocurses") == 0) { ret |= ARG_NOCURSES; @@ -483,12 +488,35 @@ void (*heading)(const char*, ...) = heading_nocurses; bool have_color = false; +bool html_out = false; + void use_color(int col) { if(have_color) { attron(COLOR_PAIR(col)); } + else if(html_out) + { + uchar r, g, b; + switch(col) + { + case COL_NORM: + r = g = b = 0; + break; + case COL_RED: + r = 255; + g = b = 0; + break; + case COL_GREEN: + r = b = 0; + g = 255; + break; + default: + assert(0); + } + output("<font color=\"#%02x%02x%02x\">", r, g, b); + } } void stop_color(int col) @@ -497,6 +525,10 @@ void stop_color(int col) { attroff(COLOR_PAIR(col)); } + else if(html_out) + { + output("</font>"); + } } void curses_init(void) |