diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2020-10-11 17:41:57 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2020-10-11 17:49:31 +0200 |
commit | f9ef1231716c1141391662476e93c9b19dbc3510 (patch) | |
tree | d7d71a0d070f255363ac0047885dba1b3f26a044 | |
parent | f51dd936f59088e92c8dfa43f110c4c4655a4bc6 (diff) | |
download | xK-f9ef1231716c1141391662476e93c9b19dbc3510.tar.gz xK-f9ef1231716c1141391662476e93c9b19dbc3510.tar.xz xK-f9ef1231716c1141391662476e93c9b19dbc3510.zip |
degesch: support more colours
-rw-r--r-- | degesch.c | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -3134,8 +3134,19 @@ static const int g_mirc_to_terminal[] = [MIRC_L_GRAY] = COLOR_256 (WHITE, 252), }; -// TODO: support more colors, see https://modern.ircdocs.horse/formatting.html -// + http://anti.teamidiot.de/static/nei/*/extended_mirc_color_proposal.html +// https://modern.ircdocs.horse/formatting.html +// http://anti.teamidiot.de/static/nei/*/extended_mirc_color_proposal.html +static const char g_extra_to_256[100 - 16] = +{ + 52, 94, 100, 58, 22, 29, 23, 24, 17, 54, 53, 89, + 88, 130, 142, 64, 28, 35, 30, 25, 18, 91, 90, 125, + 124, 166, 184, 106, 34, 49, 37, 33, 19, 129, 127, 161, + 196, 208, 226, 154, 46, 86 , 51, 75, 21, 171, 201, 198, + 203, 215, 227, 191, 83, 122, 87, 111, 63, 177, 207, 205, + 217, 223, 229, 193, 157, 158, 159, 153, 147, 183, 219, 212, + 16, 233, 235, 237, 239, 241, 244, 247, 250, 254, 231, -1 +}; + static const char * formatter_parse_mirc_color (struct formatter *self, const char *s) { @@ -3149,8 +3160,11 @@ formatter_parse_mirc_color (struct formatter *self, const char *s) int fg = *s++ - '0'; if (isdigit_ascii (*s)) fg = fg * 10 + (*s++ - '0'); - if (fg >= 0 && fg < 16) + if (fg < 16) FORMATTER_ADD_ITEM (self, FG_COLOR, .color = g_mirc_to_terminal[fg]); + else + FORMATTER_ADD_ITEM (self, FG_COLOR, + .color = COLOR_256 (DEFAULT, g_extra_to_256[fg])); if (*s != ',' || !isdigit_ascii (s[1])) return s; @@ -3159,8 +3173,11 @@ formatter_parse_mirc_color (struct formatter *self, const char *s) int bg = *s++ - '0'; if (isdigit_ascii (*s)) bg = bg * 10 + (*s++ - '0'); - if (bg >= 0 && bg < 16) + if (bg < 16) FORMATTER_ADD_ITEM (self, BG_COLOR, .color = g_mirc_to_terminal[bg]); + else + FORMATTER_ADD_ITEM (self, BG_COLOR, + .color = COLOR_256 (DEFAULT, g_extra_to_256[bg])); return s; } |