mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 21:36:37 +02:00
Fix color string returned by API function color() for some WeeChat color options
This commit is contained in:
+13
-6
@@ -43,12 +43,12 @@ struct t_gui_color *gui_color[GUI_COLOR_NUM_COLORS]; /* GUI colors */
|
||||
|
||||
|
||||
/*
|
||||
* gui_color_search_config_int: search a color with configuration option name
|
||||
* return color found (number >= 0), -1 if not found
|
||||
* gui_color_search_config: search a color with configuration option name
|
||||
* return color string, NULL if not found
|
||||
*/
|
||||
|
||||
int
|
||||
gui_color_search_config_int (const char *color_name)
|
||||
const char *
|
||||
gui_color_search_config (const char *color_name)
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
struct t_config_option *ptr_option;
|
||||
@@ -63,13 +63,20 @@ gui_color_search_config_int (const char *color_name)
|
||||
ptr_option = ptr_option->next_option)
|
||||
{
|
||||
if (string_strcasecmp (ptr_option->name, color_name) == 0)
|
||||
return ptr_option->min;
|
||||
{
|
||||
if (ptr_option->min < 0)
|
||||
{
|
||||
return gui_color_get_custom (
|
||||
gui_color_get_name (CONFIG_COLOR(ptr_option)));
|
||||
}
|
||||
return GUI_COLOR(ptr_option->min);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* color not found */
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ extern struct t_gui_color *gui_color[];
|
||||
|
||||
/* color functions */
|
||||
|
||||
extern int gui_color_search_config_int (const char *color_name);
|
||||
extern const char *gui_color_search_config (const char *color_name);
|
||||
extern const char *gui_color_get_custom (const char *color_name);
|
||||
extern char *gui_color_decode (const char *string, const char *replacement);
|
||||
extern void gui_color_free (struct t_gui_color *color);
|
||||
|
||||
@@ -215,16 +215,16 @@ plugin_api_prefix (const char *prefix)
|
||||
const char *
|
||||
plugin_api_color (const char *color_name)
|
||||
{
|
||||
int num_color;
|
||||
const char *str_color;
|
||||
|
||||
if (!color_name)
|
||||
return GUI_NO_COLOR;
|
||||
|
||||
/* name is a weechat color option ? => then return this color */
|
||||
num_color = gui_color_search_config_int (color_name);
|
||||
if (num_color >= 0)
|
||||
return GUI_COLOR(num_color);
|
||||
|
||||
str_color = gui_color_search_config (color_name);
|
||||
if (str_color)
|
||||
return str_color;
|
||||
|
||||
return gui_color_get_custom (color_name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user