summaryrefslogtreecommitdiff
path: root/src/gui/gui-color.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui-color.c')
-rw-r--r--src/gui/gui-color.c109
1 files changed, 67 insertions, 42 deletions
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
index 99c8bc065..326e3f542 100644
--- a/src/gui/gui-color.c
+++ b/src/gui/gui-color.c
@@ -88,13 +88,13 @@ gui_color_search_config (const char *color_name)
const char *
gui_color_get_custom (const char *color_name)
{
- int fg, bg;
- static char color[20][16];
+ int fg, bg, pair;
+ static char color[32][16];
static int index_color = 0;
- char *pos_comma, *str_fg, *pos_bg;
+ char *pos_comma, *str_fg, *pos_bg, *error;
/* attribute or other color name (GUI dependent) */
- index_color = (index_color + 1) % 20;
+ index_color = (index_color + 1) % 32;
color[index_color][0] = '\0';
if (!color_name || !color_name[0])
@@ -189,55 +189,74 @@ gui_color_get_custom (const char *color_name)
else
{
/* custom color name (GUI dependent) */
- pos_comma = strchr (color_name, ',');
- if (pos_comma)
+ error = NULL;
+ pair = (int)strtol (color_name, &error, 10);
+ if (error && !error[0])
{
- if (pos_comma == color_name)
- str_fg = NULL;
- else
- str_fg = string_strndup (color_name, pos_comma - color_name);
- pos_bg = pos_comma + 1;
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s%s%05d",
+ GUI_COLOR_COLOR_STR,
+ GUI_COLOR_PAIR_STR,
+ pair);
}
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);
- if ((fg >= 0) && (bg >= 0))
+ pos_comma = strchr (color_name, ',');
+ if (pos_comma)
{
- snprintf (color[index_color], sizeof (color[index_color]),
- "%s*%02d,%02d",
- GUI_COLOR_COLOR_STR, fg, bg);
+ 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 if (str_fg && !pos_bg)
- {
- fg = gui_color_search (str_fg);
- if (fg >= 0)
+ else
{
- snprintf (color[index_color], sizeof (color[index_color]),
- "%sF%02d",
- GUI_COLOR_COLOR_STR, fg);
+ str_fg = strdup (color_name);
+ pos_bg = NULL;
}
- }
- else if (!str_fg && pos_bg)
- {
- bg = gui_color_search (pos_bg);
- if (bg >= 0)
+
+ if (str_fg && pos_bg)
{
- snprintf (color[index_color], sizeof (color[index_color]),
- "%sB%02d",
- GUI_COLOR_COLOR_STR, bg);
+ fg = gui_color_search (str_fg);
+ bg = gui_color_search (pos_bg);
+ if ((fg >= 0) && (bg >= 0))
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s%s%02d,%02d",
+ GUI_COLOR_COLOR_STR,
+ GUI_COLOR_FG_BG_STR,
+ fg, bg);
+ }
}
+ else if (str_fg && !pos_bg)
+ {
+ fg = gui_color_search (str_fg);
+ if (fg >= 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s%s%02d",
+ GUI_COLOR_COLOR_STR,
+ GUI_COLOR_FG_STR,
+ fg);
+ }
+ }
+ else if (!str_fg && pos_bg)
+ {
+ bg = gui_color_search (pos_bg);
+ if (bg >= 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s%s%02d",
+ GUI_COLOR_COLOR_STR,
+ GUI_COLOR_BG_STR,
+ bg);
+ }
+ }
+
+ if (str_fg)
+ free (str_fg);
}
-
- if (str_fg)
- free (str_fg);
}
return color[index_color];
@@ -288,6 +307,12 @@ gui_color_decode (const char *string, const char *replacement)
&& ptr_string[4] && ptr_string[5])
ptr_string += 6;
break;
+ case GUI_COLOR_PAIR_CHAR:
+ if ((isdigit (string[1])) && (isdigit (string[2]))
+ && (isdigit (string[3])) && (isdigit (string[4]))
+ && (isdigit (string[5])))
+ ptr_string += 6;
+ break;
case GUI_COLOR_BAR_CHAR:
ptr_string++;
switch (ptr_string[0])