1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 22:36:38 +02:00

Add delimiter color for bars, fix some bugs with bars

This commit is contained in:
Sebastien Helleu
2008-06-22 12:01:50 +02:00
parent 96a92eacbf
commit 6635c7d617
21 changed files with 596 additions and 309 deletions
+2 -88
View File
@@ -222,10 +222,7 @@ plugin_api_prefix (const char *prefix)
char *
plugin_api_color (const char *color_name)
{
int num_color, fg, bg;
static char color[20][16];
static int index_color = 0;
char *pos_comma, *str_fg, *pos_bg;
int num_color;
if (!color_name)
return GUI_NO_COLOR;
@@ -234,91 +231,8 @@ plugin_api_color (const char *color_name)
num_color = gui_color_search_config_int (color_name);
if (num_color >= 0)
return GUI_COLOR(num_color);
/* attribute or other color name (GUI dependent) */
index_color = (index_color + 1) % 20;
color[index_color][0] = '\0';
if (string_strcasecmp (color_name, "reset") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%s",
GUI_COLOR_RESET_STR);
}
else if (string_strcasecmp (color_name, "bold") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%s%s",
GUI_COLOR_SET_STR,
GUI_COLOR_ATTR_BOLD_STR);
}
else if (string_strcasecmp (color_name, "reverse") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%s%s",
GUI_COLOR_SET_STR,
GUI_COLOR_ATTR_REVERSE_STR);
}
else if (string_strcasecmp (color_name, "italic") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%s%s",
GUI_COLOR_SET_STR,
GUI_COLOR_ATTR_ITALIC_STR);
}
else if (string_strcasecmp (color_name, "underline") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%s%s",
GUI_COLOR_SET_STR,
GUI_COLOR_ATTR_UNDERLINE_STR);
}
else
{
/* custom color name (GUI dependent) */
pos_comma = strchr (color_name, ',');
if (pos_comma)
{
if (pos_comma == color_name)
str_fg = NULL;
else
str_fg = string_strndup (color_name, pos_comma - color_name);
pos_bg = pos_comma + 1;
}
else
{
str_fg = strdup (color_name);
pos_bg = NULL;
}
if (str_fg && pos_bg)
{
fg = gui_color_search (str_fg);
bg = gui_color_search (pos_bg);
snprintf (color[index_color], sizeof (color[index_color]),
"%s*%02d,%02d",
GUI_COLOR_COLOR_STR, fg, bg);
}
else if (str_fg && !pos_bg)
{
fg = gui_color_search (str_fg);
snprintf (color[index_color], sizeof (color[index_color]),
"%sF%02d",
GUI_COLOR_COLOR_STR, fg);
}
else if (!str_fg && pos_bg)
{
bg = gui_color_search (pos_bg);
snprintf (color[index_color], sizeof (color[index_color]),
"%sB%02d",
GUI_COLOR_COLOR_STR, bg);
}
if (str_fg)
free (str_fg);
}
return color[index_color];
return gui_color_get_custom (color_name);
}
/*