1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 17:53:13 +02:00

core: fix conversion of WeeChat "default" color to ANSI color

This commit is contained in:
Sébastien Helleu
2024-05-11 11:54:16 +02:00
parent a456c3db86
commit 32b01a606c
4 changed files with 44 additions and 32 deletions
+28 -32
View File
@@ -1351,14 +1351,13 @@ gui_color_encode_ansi (const char *string)
if (error && !error[0])
{
ansi_color = gui_color_weechat_to_ansi (color);
if (ansi_color >= 0)
{
snprintf (str_concat, sizeof (str_concat),
"\x1B[%dm",
(ansi_color < 8) ?
ansi_color + 30 : ansi_color - 8 + 90);
string_dyn_concat (out, str_concat, -1);
}
snprintf (str_concat, sizeof (str_concat),
"\x1B[%dm",
(ansi_color < 0) ?
GUI_COLOR_ANSI_DEFAULT_FG :
((ansi_color < 8) ?
ansi_color + 30 : ansi_color - 8 + 90));
string_dyn_concat (out, str_concat, -1);
}
ptr_string += 2;
}
@@ -1397,14 +1396,13 @@ gui_color_encode_ansi (const char *string)
if (error && !error[0])
{
ansi_color = gui_color_weechat_to_ansi (color);
if (ansi_color >= 0)
{
snprintf (str_concat, sizeof (str_concat),
"\x1B[%dm",
(ansi_color < 8) ?
ansi_color + 40 : ansi_color - 8 + 100);
string_dyn_concat (out, str_concat, -1);
}
snprintf (str_concat, sizeof (str_concat),
"\x1B[%dm",
(ansi_color < 0) ?
GUI_COLOR_ANSI_DEFAULT_BG :
((ansi_color < 8) ?
ansi_color + 40 : ansi_color - 8 + 100));
string_dyn_concat (out, str_concat, -1);
}
ptr_string += 2;
}
@@ -1453,14 +1451,13 @@ gui_color_encode_ansi (const char *string)
if (error && !error[0])
{
ansi_color = gui_color_weechat_to_ansi (color);
if (ansi_color >= 0)
{
snprintf (str_concat, sizeof (str_concat),
"\x1B[%dm",
(ansi_color < 8) ?
ansi_color + 30 : ansi_color - 8 + 90);
string_dyn_concat (out, str_concat, -1);
}
snprintf (str_concat, sizeof (str_concat),
"\x1B[%dm",
(ansi_color < 0) ?
GUI_COLOR_ANSI_DEFAULT_FG :
((ansi_color < 8) ?
ansi_color + 30 : ansi_color - 8 + 90));
string_dyn_concat (out, str_concat, -1);
}
ptr_string += 2;
}
@@ -1506,14 +1503,13 @@ gui_color_encode_ansi (const char *string)
if (error && !error[0])
{
ansi_color = gui_color_weechat_to_ansi (color);
if (ansi_color >= 0)
{
snprintf (str_concat, sizeof (str_concat),
"\x1B[%dm",
(ansi_color < 8) ?
ansi_color + 40 : ansi_color - 8 + 100);
string_dyn_concat (out, str_concat, -1);
}
snprintf (str_concat, sizeof (str_concat),
"\x1B[%dm",
(ansi_color < 0) ?
GUI_COLOR_ANSI_DEFAULT_BG :
((ansi_color < 8) ?
ansi_color + 40 : ansi_color - 8 + 100));
string_dyn_concat (out, str_concat, -1);
}
ptr_string += 2;
}
+3
View File
@@ -159,6 +159,9 @@ enum t_gui_color_enum
"([<>])|" \
"(\\[[0-9;?]*[A-Za-z]))"
#define GUI_COLOR_ANSI_DEFAULT_FG 39
#define GUI_COLOR_ANSI_DEFAULT_BG 49
#define GUI_COLOR_BUFFER_NAME "color"
/* color structure */