diff --git a/color/parse_ansi.c b/color/parse_ansi.c index f4f71676244..b05ce00d22b 100644 --- a/color/parse_ansi.c +++ b/color/parse_ansi.c @@ -153,6 +153,31 @@ int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool dry_ru ansi->attrs |= A_BOLD; pos += 2; } + else if ((buf[pos] == '2') && isdigit(buf[pos + 1]) && ansi_is_end_char(buf[pos + 2])) + { + char digit = buf[pos + 1]; + pos += 3; + if (digit == '2') + { + ansi->attrs &= ~A_BOLD; // Clear the flag + } + else if (digit == '3') + { + ansi->attrs &= ~A_ITALIC; // Clear the flag + } + else if (digit == '4') + { + ansi->attrs &= ~A_UNDERLINE; // Clear the flag + } + else if (digit == '5') + { + ansi->attrs &= ~A_BLINK; // Clear the flag + } + else if (digit == '7') + { + ansi->attrs &= ~A_REVERSE; // Clear the flag + } + } else if ((buf[pos] == '3') && ansi_is_end_char(buf[pos + 1])) { ansi->attrs |= A_ITALIC; @@ -190,9 +215,39 @@ int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool dry_ru else if (mutt_str_startswith(buf + pos, "38;2;") && isdigit(buf[pos + 5])) { // 38;2;R;G;B true colour foreground - pos += ansi_skip_sequence(buf + pos + 5); - pos += ansi_skip_sequence(buf + pos); - pos += ansi_skip_sequence(buf + pos); + long r = -1; + long g = -1; + long b = -1; + char *end = NULL; + unsigned long value = 0; + pos += 5; // Skip 38;2; + + value = strtoul(buf + pos, &end, 10); + if ((value < 0) || (value > 255) || !end || (end[0] != ';')) + { + return 0; + } + r = value; + pos += end - &buf[pos] + 1; + + value = strtoul(buf + pos, &end, 10); + if ((value < 0) || (value > 255) || !end || (end[0] != ';')) + { + return 0; + } + g = value; + pos += end - &buf[pos] + 1; + + value = strtoul(buf + pos, &end, 10); + if ((value < 0) || (value > 255) || !end || (end[0] != 'm')) + { + return 0; + } + b = value; + pos += end - &buf[pos] + 1; + + elem->color = (r << 16) + (g << 8) + (b << 0); + elem->type = CT_RGB; } else { @@ -248,9 +303,39 @@ int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool dry_ru else if (mutt_str_startswith(buf + pos, "48;2;") && isdigit(buf[pos + 5])) { // 48;2;R;G;B true colour background - pos += ansi_skip_sequence(buf + pos + 5); - pos += ansi_skip_sequence(buf + pos); - pos += ansi_skip_sequence(buf + pos); + long r = -1; + long g = -1; + long b = -1; + char *end = NULL; + unsigned long value = 0; + pos += 5; // Skip 48;2; + + value = strtoul(buf + pos, &end, 10); + if ((value < 0) || (value > 255) || !end || (end[0] != ';')) + { + return 0; + } + r = value; + pos += end - &buf[pos] + 1; + + value = strtoul(buf + pos, &end, 10); + if ((value < 0) || (value > 255) || !end || (end[0] != ';')) + { + return 0; + } + g = value; + pos += end - &buf[pos] + 1; + + value = strtoul(buf + pos, &end, 10); + if ((value < 0) || (value > 255) || !end || (end[0] != 'm')) + { + return 0; + } + b = value; + pos += end - &buf[pos] + 1; + + elem->color = (r << 16) + (g << 8) + (b << 0); + elem->type = CT_RGB; } else { diff --git a/color/simple.c b/color/simple.c index aa0e90000dc..f84931d739c 100644 --- a/color/simple.c +++ b/color/simple.c @@ -54,7 +54,9 @@ void simple_colors_init(void) // Set some defaults color_debug(LL_DEBUG5, "init indicator, markers, etc\n"); + SimpleColors[MT_COLOR_BOLD].attrs = A_BOLD; SimpleColors[MT_COLOR_INDICATOR].attrs = A_REVERSE; + SimpleColors[MT_COLOR_ITALIC].attrs = A_ITALIC; SimpleColors[MT_COLOR_MARKERS].attrs = A_REVERSE; SimpleColors[MT_COLOR_SEARCH].attrs = A_REVERSE; #ifdef USE_SIDEBAR @@ -62,6 +64,7 @@ void simple_colors_init(void) #endif SimpleColors[MT_COLOR_STATUS].attrs = A_REVERSE; SimpleColors[MT_COLOR_STRIPE_EVEN].attrs = A_BOLD; + SimpleColors[MT_COLOR_UNDERLINE].attrs = A_UNDERLINE; } /** @@ -74,6 +77,7 @@ void simple_colors_cleanup(void) { attr_color_clear(&SimpleColors[i]); } + simple_colors_init(); } /**