1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 13:56:37 +02:00

core: skip and ignore color attributes before special names like "reset" in gui_color_get_custom

This commit is contained in:
Sebastien Helleu
2014-03-25 15:36:21 +01:00
parent 28df18379f
commit 03f73b8cdc
+30 -29
View File
@@ -219,83 +219,96 @@ gui_color_get_custom (const char *color_name)
if (!color_name || !color_name[0])
return color[index_color];
if (string_strcasecmp (color_name, "reset") == 0)
/* read extra attributes (bold, ..) */
color_attr = NULL;
ptr_color_name = color_name;
while (gui_color_attr_get_flag (ptr_color_name[0]) > 0)
{
ptr_color_name++;
}
if (ptr_color_name != color_name)
{
color_attr = string_strndup (color_name,
ptr_color_name - color_name);
}
if (string_strcasecmp (ptr_color_name, "reset") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c",
GUI_COLOR_RESET_CHAR);
}
else if (string_strcasecmp (color_name, "resetcolor") == 0)
else if (string_strcasecmp (ptr_color_name, "resetcolor") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_RESET_CHAR);
}
else if (string_strcasecmp (color_name, "emphasis") == 0)
else if (string_strcasecmp (ptr_color_name, "emphasis") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_EMPHASIS_CHAR);
}
else if (string_strcasecmp (color_name, "bold") == 0)
else if (string_strcasecmp (ptr_color_name, "bold") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_SET_ATTR_CHAR,
GUI_COLOR_ATTR_BOLD_CHAR);
}
else if (string_strcasecmp (color_name, "-bold") == 0)
else if (string_strcasecmp (ptr_color_name, "-bold") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_REMOVE_ATTR_CHAR,
GUI_COLOR_ATTR_BOLD_CHAR);
}
else if (string_strcasecmp (color_name, "reverse") == 0)
else if (string_strcasecmp (ptr_color_name, "reverse") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_SET_ATTR_CHAR,
GUI_COLOR_ATTR_REVERSE_CHAR);
}
else if (string_strcasecmp (color_name, "-reverse") == 0)
else if (string_strcasecmp (ptr_color_name, "-reverse") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_REMOVE_ATTR_CHAR,
GUI_COLOR_ATTR_REVERSE_CHAR);
}
else if (string_strcasecmp (color_name, "italic") == 0)
else if (string_strcasecmp (ptr_color_name, "italic") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_SET_ATTR_CHAR,
GUI_COLOR_ATTR_ITALIC_CHAR);
}
else if (string_strcasecmp (color_name, "-italic") == 0)
else if (string_strcasecmp (ptr_color_name, "-italic") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_REMOVE_ATTR_CHAR,
GUI_COLOR_ATTR_ITALIC_CHAR);
}
else if (string_strcasecmp (color_name, "underline") == 0)
else if (string_strcasecmp (ptr_color_name, "underline") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_SET_ATTR_CHAR,
GUI_COLOR_ATTR_UNDERLINE_CHAR);
}
else if (string_strcasecmp (color_name, "-underline") == 0)
else if (string_strcasecmp (ptr_color_name, "-underline") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_REMOVE_ATTR_CHAR,
GUI_COLOR_ATTR_UNDERLINE_CHAR);
}
else if (string_strcasecmp (color_name, "bar_fg") == 0)
else if (string_strcasecmp (ptr_color_name, "bar_fg") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c%c",
@@ -303,7 +316,7 @@ gui_color_get_custom (const char *color_name)
GUI_COLOR_BAR_CHAR,
GUI_COLOR_BAR_FG_CHAR);
}
else if (string_strcasecmp (color_name, "bar_delim") == 0)
else if (string_strcasecmp (ptr_color_name, "bar_delim") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c%c",
@@ -311,7 +324,7 @@ gui_color_get_custom (const char *color_name)
GUI_COLOR_BAR_CHAR,
GUI_COLOR_BAR_DELIM_CHAR);
}
else if (string_strcasecmp (color_name, "bar_bg") == 0)
else if (string_strcasecmp (ptr_color_name, "bar_bg") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c%c",
@@ -326,22 +339,9 @@ gui_color_get_custom (const char *color_name)
bg_term = -1;
fg = -1;
bg = -1;
color_attr = NULL;
color_fg[0] = '\0';
color_bg[0] = '\0';
/* read extra attributes (bold, ..) */
ptr_color_name = color_name;
while (gui_color_attr_get_flag (ptr_color_name[0]) > 0)
{
ptr_color_name++;
}
if (ptr_color_name != color_name)
{
color_attr = string_strndup (color_name,
ptr_color_name - color_name);
}
pos_delim = strchr (ptr_color_name, ',');
if (!pos_delim)
pos_delim = strchr (ptr_color_name, ':');
@@ -451,12 +451,13 @@ gui_color_get_custom (const char *color_name)
color_bg);
}
if (color_attr)
free (color_attr);
if (str_fg)
free (str_fg);
}
if (color_attr)
free (color_attr);
return color[index_color];
}