api: add support of full color option name in function color()
parent
ccc6cdace1
commit
0f333ee630
|
@ -32,6 +32,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
|||
* core: add option "-s" in command /eval to split expression before evaluating
|
||||
it (no more split by default) (closes #324)
|
||||
* core: add priority in plugins to initialize them in order
|
||||
* api: add support of full option name in function color()
|
||||
* api: add "_chat_line" (line pointer) in hashtable of hook_focus
|
||||
* irc: add support of SHA-256 and SHA-512 algorithms in server option
|
||||
"ssl_fingerprint" (closes #281)
|
||||
|
|
|
@ -6491,7 +6491,10 @@ const char *weechat_color (const char *color_name);
|
|||
Arguments:
|
||||
|
||||
* 'color_name': name of color, one of:
|
||||
** WeeChat option name (from weechat.color.xxx), for example 'chat_delimiters'
|
||||
** WeeChat color option name (from weechat.color.xxx), for example
|
||||
'chat_delimiters'
|
||||
** option name (format: file.section.option), for example
|
||||
'irc.color.message_quit' (_WeeChat ≥ 1.2_)
|
||||
** color with optional attributes/background (see below)
|
||||
** attribute:
|
||||
*** 'bold': set bold
|
||||
|
|
|
@ -6587,7 +6587,10 @@ const char *weechat_color (const char *color_name);
|
|||
Paramètres :
|
||||
|
||||
* 'color_name' : nom de la couleur, parmi :
|
||||
** une option WeeChat (de weechat.color.xxx), par exemple 'chat_delimiters'
|
||||
** le nom d'une option de couleur WeeChat (de weechat.color.xxx), par exemple
|
||||
'chat_delimiters'
|
||||
** le nom d'une option (format: fichier.section.option), par exemple
|
||||
'irc.color.message_quit' (_WeeChat ≥ 1.2_)
|
||||
** une couleur avec des attributs/fond optionnels (voir ci-dessous)
|
||||
** un attribut :
|
||||
*** 'bold' : activer le gras
|
||||
|
|
|
@ -6614,7 +6614,12 @@ const char *weechat_color (const char *color_name);
|
|||
Argomenti:
|
||||
|
||||
* 'color_name': nome del colore, uno di:
|
||||
** nome opzione di WeeChat (da weechat.color.xxx), ad esempio 'chat_delimiters'
|
||||
// TRANSLATION MISSING
|
||||
** WeeChat color option name (from weechat.color.xxx), for example
|
||||
'chat_delimiters'
|
||||
// TRANSLATION MISSING
|
||||
** option name (format: file.section.option), for example
|
||||
'irc.color.message_quit' (_WeeChat ≥ 1.2_)
|
||||
** colore con attributi/sfondo opzionali (vedi sotto)
|
||||
** attributo:
|
||||
*** 'bold': imposta grassetto
|
||||
|
|
|
@ -6492,7 +6492,12 @@ const char *weechat_color (const char *color_name);
|
|||
引数:
|
||||
|
||||
* 'color_name': 色の名前、以下の中から 1 つ:
|
||||
** WeeChat オプション名 (weechat.color.xxx の xxx)、例えば 'chat_delimiters'
|
||||
// TRANSLATION MISSING
|
||||
** WeeChat color option name (from weechat.color.xxx), for example
|
||||
'chat_delimiters'
|
||||
// TRANSLATION MISSING
|
||||
** option name (format: file.section.option), for example
|
||||
'irc.color.message_quit' (_WeeChat ≥ 1.2_)
|
||||
** 任意で属性や背景色を指定した色 (以下を参照)
|
||||
** 属性:
|
||||
*** 'bold': 太字を有効
|
||||
|
|
|
@ -112,6 +112,37 @@ char *gui_color_ansi[16] =
|
|||
};
|
||||
|
||||
|
||||
/*
|
||||
* Returns a color code from an option, which can be a color or a string.
|
||||
*
|
||||
* Returns NULL if the option has a wrong type.
|
||||
*/
|
||||
|
||||
const char *
|
||||
gui_color_from_option (struct t_config_option *option)
|
||||
{
|
||||
if (!option)
|
||||
return NULL;
|
||||
|
||||
switch (option->type)
|
||||
{
|
||||
case CONFIG_OPTION_TYPE_COLOR:
|
||||
if (option->min < 0)
|
||||
{
|
||||
return gui_color_get_custom (
|
||||
gui_color_get_name (CONFIG_COLOR(option)));
|
||||
}
|
||||
return GUI_COLOR(option->min);
|
||||
case CONFIG_OPTION_TYPE_STRING:
|
||||
return gui_color_get_custom (CONFIG_STRING(option));
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* never executed */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Searches for a color with configuration option name.
|
||||
*
|
||||
|
@ -123,21 +154,24 @@ gui_color_search_config (const char *color_name)
|
|||
{
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
if (color_name)
|
||||
if (!color_name)
|
||||
return NULL;
|
||||
|
||||
/* search in weechat.conf colors (example: "chat_delimiters") */
|
||||
for (ptr_option = weechat_config_section_color->options;
|
||||
ptr_option; ptr_option = ptr_option->next_option)
|
||||
{
|
||||
for (ptr_option = weechat_config_section_color->options;
|
||||
ptr_option; ptr_option = ptr_option->next_option)
|
||||
{
|
||||
if (string_strcasecmp (ptr_option->name, color_name) == 0)
|
||||
{
|
||||
if (ptr_option->min < 0)
|
||||
{
|
||||
return gui_color_get_custom (
|
||||
gui_color_get_name (CONFIG_COLOR(ptr_option)));
|
||||
}
|
||||
return GUI_COLOR(ptr_option->min);
|
||||
}
|
||||
}
|
||||
if (string_strcasecmp (ptr_option->name, color_name) == 0)
|
||||
return gui_color_from_option (ptr_option);
|
||||
}
|
||||
|
||||
/* search in any configuration file (example: "irc.color.message_quit") */
|
||||
if (strchr (color_name, '.'))
|
||||
{
|
||||
config_file_search_with_string (color_name, NULL, NULL, &ptr_option,
|
||||
NULL);
|
||||
if (ptr_option)
|
||||
return gui_color_from_option (ptr_option);
|
||||
}
|
||||
|
||||
/* color not found */
|
||||
|
|
Loading…
Reference in New Issue