aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/degesch.c b/degesch.c
index e0497aa..7e16205 100644
--- a/degesch.c
+++ b/degesch.c
@@ -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;
}