mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 01:03:14 +02:00
core: add themable flag to configuration options
Add an "int themable" field on struct t_config_option. The flag is set
automatically for every CONFIG_OPTION_TYPE_COLOR option, and may be set
explicitly on any other type by suffixing the type argument with
"|themable" in the call to config_file_new_option (e.g. "string|themable"
for a string option whose value contains "${color:...}" references).
Opt in the relevant string options in core and in the buflist, fset, irc,
relay plugins.
The flag is exposed via hdata, infolist, and print_log so scripts and
/debug can read it. This is the foundation for an upcoming /theme
command that will only be allowed to modify themable options.
This commit is contained in:
@@ -17,6 +17,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
### Added
|
||||
|
||||
- core: add `themable` flag on configuration options
|
||||
- relay/api: add resource `GET /api/scripts`
|
||||
- relay: add option relay.network.unix_socket_permissions ([#2317](https://github.com/weechat/weechat/issues/2317))
|
||||
- script: add info "script_languages"
|
||||
|
||||
@@ -7367,7 +7367,7 @@ section = weechat.config_search_section(config_file, "section")
|
||||
|
||||
==== config_new_option
|
||||
|
||||
_Updated in 1.5, 4.1.0._
|
||||
_Updated in 1.5, 4.1.0, 4.10.0._
|
||||
|
||||
Create a new option in a section of a configuration file.
|
||||
|
||||
@@ -7413,7 +7413,9 @@ Arguments:
|
||||
option name (the value of parent option will be displayed in `/set` command
|
||||
output if this option is "null"), the syntax is then:
|
||||
"name << file.section.option"
|
||||
* _type_: type of option:
|
||||
* _type_: type of option; any type can be suffixed with `+|themable+` to mark
|
||||
the option as themable, so that it can be set by the `/theme` command
|
||||
(options of type _color_ are always themable) _(WeeChat ≥ 4.10.0)_:
|
||||
** _boolean_: boolean value (on/off)
|
||||
** _integer_: integer value
|
||||
** _string_: string value
|
||||
@@ -7499,7 +7501,7 @@ struct t_config_option *option_int =
|
||||
|
||||
/* string */
|
||||
struct t_config_option *option_str =
|
||||
weechat_config_new_option (config_file, section, "option_str", "string",
|
||||
weechat_config_new_option (config_file, section, "option_str", "string|themable",
|
||||
"My option, type string",
|
||||
NULL,
|
||||
0, 0,
|
||||
@@ -7575,7 +7577,7 @@ option_int = weechat.config_new_option(config_file, section, "option_int", "inte
|
||||
"", "",
|
||||
"", "")
|
||||
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string",
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string|themable",
|
||||
"My option, type string",
|
||||
"", 0, 0, "test", "test", 1,
|
||||
"option_str_check_value_cb", "",
|
||||
|
||||
@@ -7488,7 +7488,7 @@ section = weechat.config_search_section(config_file, "section")
|
||||
|
||||
==== config_new_option
|
||||
|
||||
_Mis à jour dans la 1.5, 4.1.0._
|
||||
_Mis à jour dans la 1.5, 4.1.0, 4.10.0._
|
||||
|
||||
Créer une nouvelle option dans une section d'un fichier de configuration.
|
||||
|
||||
@@ -7534,7 +7534,10 @@ Paramètres :
|
||||
d'une option parente (la valeur de l'option parente sera affichée dans la
|
||||
sortie de `/set` si cette option est "null"), la syntaxe est alors :
|
||||
"name << file.section.option"
|
||||
* _type_ : type de l'option :
|
||||
* _type_ : type de l'option ; n'importe quel type peut être suffixé par
|
||||
`+|themable+` pour rendre l'option modifiable par un thème, afin qu'elle
|
||||
puisse être définie par la commande `/theme` (les options de type _color_
|
||||
sont toujours modifiables par un thème) _(WeeChat ≥ 4.10.0)_ :
|
||||
** _boolean_ : valeur booléenne (on/off)
|
||||
** _integer_ : valeur entière
|
||||
** _string_ : une chaîne de caractères
|
||||
@@ -7625,7 +7628,7 @@ struct t_config_option *option_int =
|
||||
|
||||
/* chaîne */
|
||||
struct t_config_option *option_str =
|
||||
weechat_config_new_option (config_file, section, "option_str", "string",
|
||||
weechat_config_new_option (config_file, section, "option_str", "string|themable",
|
||||
"Mon option, type chaîne",
|
||||
NULL,
|
||||
0, 0,
|
||||
@@ -7701,7 +7704,7 @@ option_int = weechat.config_new_option(config_file, section, "option_int", "inte
|
||||
"", "",
|
||||
"", "")
|
||||
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string",
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string|themable",
|
||||
"Mon option, type chaîne",
|
||||
"", 0, 0, "test", "test", 1,
|
||||
"option_str_check_value_cb", "",
|
||||
|
||||
@@ -7661,7 +7661,7 @@ section = weechat.config_search_section(config_file, "section")
|
||||
==== config_new_option
|
||||
|
||||
// TRANSLATION MISSING
|
||||
_Updated in 1.5, 4.1.0._
|
||||
_Updated in 1.5, 4.1.0, 4.10.0._
|
||||
|
||||
Crea una nuova opzione nella sezione di un file di configurazione.
|
||||
|
||||
@@ -7708,7 +7708,10 @@ Argomenti:
|
||||
option name (the value of parent option will be displayed in `/set` command
|
||||
output if this option is "null"), the syntax is then:
|
||||
"name << file.section.option"
|
||||
* _type_: tipo dell'opzione:
|
||||
// TRANSLATION MISSING
|
||||
* _type_: type of option; any type can be suffixed with `+|themable+` to mark
|
||||
the option as themable, so that it can be set by the `/theme` command
|
||||
(options of type _color_ are always themable) _(WeeChat ≥ 4.10.0)_:
|
||||
** _boolean_: valore booleano (on/off)
|
||||
** _integer_: valore intero
|
||||
** _string_: valore stringa
|
||||
@@ -7799,7 +7802,7 @@ struct t_config_option *option_int =
|
||||
|
||||
/* stringa */
|
||||
struct t_config_option *option_str =
|
||||
weechat_config_new_option (config_file, section, "option_str", "string",
|
||||
weechat_config_new_option (config_file, section, "option_str", "string|themable",
|
||||
"My option, type string",
|
||||
NULL,
|
||||
0, 0,
|
||||
@@ -7875,7 +7878,7 @@ option_int = weechat.config_new_option(config_file, section, "option_int", "inte
|
||||
"", "",
|
||||
"", "")
|
||||
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string",
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string|themable",
|
||||
"My option, type string",
|
||||
"", 0, 0, "test", "test", 1,
|
||||
"option_str_check_value_cb", "",
|
||||
|
||||
@@ -7472,7 +7472,7 @@ section = weechat.config_search_section(config_file, "section")
|
||||
==== config_new_option
|
||||
|
||||
// TRANSLATION MISSING
|
||||
_Updated in 1.5, 4.1.0._
|
||||
_Updated in 1.5, 4.1.0, 4.10.0._
|
||||
|
||||
設定ファイルのあるセクションに新しいオプションを作成。
|
||||
|
||||
@@ -7518,7 +7518,10 @@ struct t_config_option *weechat_config_new_option (
|
||||
(このオプションが "null" の場合、親オプションの値が `/set`
|
||||
コマンドの出力に表示されます)。以下の構文を使ってください:
|
||||
"name << file.section.option"
|
||||
* _type_: オプションの型:
|
||||
// TRANSLATION MISSING
|
||||
* _type_: type of option; any type can be suffixed with `+|themable+` to mark
|
||||
the option as themable, so that it can be set by the `/theme` command
|
||||
(options of type _color_ are always themable) _(WeeChat ≥ 4.10.0)_:
|
||||
** _boolean_: ブール値 (on/off)
|
||||
** _integer_: 整数値
|
||||
** _string_: 文字列
|
||||
@@ -7606,7 +7609,7 @@ struct t_config_option *option_int =
|
||||
|
||||
/* string */
|
||||
struct t_config_option *option_str =
|
||||
weechat_config_new_option (config_file, section, "option_str", "string",
|
||||
weechat_config_new_option (config_file, section, "option_str", "string|themable",
|
||||
"My option, type string",
|
||||
NULL,
|
||||
0, 0,
|
||||
@@ -7682,7 +7685,7 @@ option_int = weechat.config_new_option(config_file, section, "option_int", "inte
|
||||
"", "",
|
||||
"", "")
|
||||
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string",
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string|themable",
|
||||
"My option, type string",
|
||||
"", 0, 0, "test", "test", 1,
|
||||
"option_str_check_value_cb", "",
|
||||
|
||||
@@ -7171,7 +7171,7 @@ section = weechat.config_search_section(config_file, "section")
|
||||
|
||||
==== config_new_option
|
||||
|
||||
_Ажурирано у верзији 1.5, 4.1.0._
|
||||
_Ажурирано у верзији 1.5, 4.1.0, 4.10.0._
|
||||
|
||||
Креира нову опцију у одељку конфигурационог фајла.
|
||||
|
||||
@@ -7214,7 +7214,10 @@ struct t_config_option *weechat_config_new_option (
|
||||
* _config_file_: показивач на конфигурациони фајл
|
||||
* _section_: показивач на одељак
|
||||
* _name_: име опције; у програм у WeeChat верзије ≥ 1.4, име може да укључи и име родитељске опције (у случају да је ова опција „null”, вредност родитељске опције ће се приказати у излазу команде `/set`), тада је синтакса: „име << фајл.одељак.опција”
|
||||
* _type_: тип опције:
|
||||
// TRANSLATION MISSING
|
||||
* _type_: type of option; any type can be suffixed with `+|themable+` to mark
|
||||
the option as themable, so that it can be set by the `/theme` command
|
||||
(options of type _color_ are always themable) _(WeeChat ≥ 4.10.0)_:
|
||||
** _boolean_: логичка вредност (on/off)
|
||||
** _integer_: целобројна вредност
|
||||
** _string_: стринг вредност
|
||||
@@ -7287,7 +7290,7 @@ struct t_config_option *option_int =
|
||||
|
||||
/* стринг */
|
||||
struct t_config_option *option_str =
|
||||
weechat_config_new_option (config_file, section, "option_str", "string",
|
||||
weechat_config_new_option (config_file, section, "option_str", "string|themable",
|
||||
"My option, type string",
|
||||
NULL,
|
||||
0, 0,
|
||||
@@ -7363,7 +7366,7 @@ option_int = weechat.config_new_option(config_file, section, "option_int", "inte
|
||||
"", "",
|
||||
"", "")
|
||||
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string",
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string|themable",
|
||||
"My option, type string",
|
||||
"", 0, 0, "test", "test", 1,
|
||||
"option_str_check_value_cb", "",
|
||||
|
||||
@@ -648,6 +648,7 @@ config_file_option_malloc (void)
|
||||
new_option->name = NULL;
|
||||
new_option->parent_name = NULL;
|
||||
new_option->type = 0;
|
||||
new_option->themable = 0;
|
||||
new_option->description = NULL;
|
||||
new_option->string_values = NULL;
|
||||
new_option->min = 0;
|
||||
@@ -704,17 +705,37 @@ config_file_new_option (struct t_config_file *config_file,
|
||||
void *callback_delete_data)
|
||||
{
|
||||
struct t_config_option *new_option;
|
||||
int var_type, int_value, argc, i, index_value, number;
|
||||
const char *pos;
|
||||
char *option_name, *parent_name;
|
||||
int var_type, int_value, argc, i, index_value, number, themable;
|
||||
const char *pos, *ptr_type;
|
||||
char *option_name, *parent_name, *type_name;
|
||||
|
||||
new_option = NULL;
|
||||
option_name = NULL;
|
||||
parent_name = NULL;
|
||||
type_name = NULL;
|
||||
themable = 0;
|
||||
|
||||
if (!name || !type)
|
||||
goto error;
|
||||
|
||||
/*
|
||||
* extract optional "|themable" suffix from type
|
||||
* (e.g.: "string|themable" for a string option that contains color names)
|
||||
*/
|
||||
pos = strchr (type, '|');
|
||||
if (pos && (strcmp (pos, "|themable") == 0))
|
||||
{
|
||||
type_name = string_strndup (type, pos - type);
|
||||
if (!type_name)
|
||||
goto error;
|
||||
ptr_type = type_name;
|
||||
themable = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_type = type;
|
||||
}
|
||||
|
||||
pos = strstr (name, " << ");
|
||||
if (pos)
|
||||
{
|
||||
@@ -735,7 +756,7 @@ config_file_new_option (struct t_config_file *config_file,
|
||||
var_type = -1;
|
||||
for (i = 0; i < CONFIG_NUM_OPTION_TYPES; i++)
|
||||
{
|
||||
if (strcmp (type, config_option_type_string[i]) == 0)
|
||||
if (strcmp (ptr_type, config_option_type_string[i]) == 0)
|
||||
{
|
||||
var_type = i;
|
||||
break;
|
||||
@@ -745,10 +766,14 @@ config_file_new_option (struct t_config_file *config_file,
|
||||
{
|
||||
gui_chat_printf (NULL, "%sUnknown option type \"%s\"",
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
type);
|
||||
ptr_type);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* color options are always themable */
|
||||
if (var_type == CONFIG_OPTION_TYPE_COLOR)
|
||||
themable = 1;
|
||||
|
||||
/*
|
||||
* compatibility with versions < 4.1.0: force enum type for an integer
|
||||
* with string values
|
||||
@@ -785,6 +810,7 @@ config_file_new_option (struct t_config_file *config_file,
|
||||
goto error;
|
||||
new_option->parent_name = (parent_name) ? strdup (parent_name) : NULL;
|
||||
new_option->type = var_type;
|
||||
new_option->themable = themable;
|
||||
if (description)
|
||||
{
|
||||
new_option->description = strdup (description);
|
||||
@@ -970,6 +996,7 @@ error:
|
||||
end:
|
||||
free (option_name);
|
||||
free (parent_name);
|
||||
free (type_name);
|
||||
return new_option;
|
||||
}
|
||||
|
||||
@@ -2440,6 +2467,8 @@ config_file_option_get_pointer (struct t_config_option *option,
|
||||
return option->parent_name;
|
||||
else if (strcmp (property, "type") == 0)
|
||||
return &option->type;
|
||||
else if (strcmp (property, "themable") == 0)
|
||||
return &option->themable;
|
||||
else if (strcmp (property, "description") == 0)
|
||||
return option->description;
|
||||
else if (strcmp (property, "string_values") == 0)
|
||||
@@ -4249,6 +4278,7 @@ config_file_hdata_config_option_cb (const void *pointer, void *data,
|
||||
HDATA_VAR(struct t_config_option, name, STRING, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_config_option, parent_name, STRING, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_config_option, type, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_config_option, themable, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_config_option, description, STRING, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_config_option, string_values, STRING, 0, "*,*", NULL);
|
||||
HDATA_VAR(struct t_config_option, min, INTEGER, 0, NULL, NULL);
|
||||
@@ -4361,6 +4391,8 @@ config_file_add_option_to_infolist (struct t_infolist *infolist,
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
if (!infolist_new_var_integer (ptr_item, "themable", option->themable))
|
||||
goto error;
|
||||
if (option->value)
|
||||
{
|
||||
value = config_file_option_value_to_string (option, 0, 0, 0);
|
||||
@@ -4525,6 +4557,7 @@ config_file_print_log (void)
|
||||
log_printf (" name . . . . . . . . . . . . : '%s'", ptr_option->name);
|
||||
log_printf (" parent_name. . . . . . . . . : '%s'", ptr_option->parent_name);
|
||||
log_printf (" type . . . . . . . . . . . . : %d", ptr_option->type);
|
||||
log_printf (" themable . . . . . . . . . . : %d", ptr_option->themable);
|
||||
log_printf (" description. . . . . . . . . : '%s'", ptr_option->description);
|
||||
log_printf (" string_values. . . . . . . . : %p", ptr_option->string_values);
|
||||
log_printf (" min. . . . . . . . . . . . . : %d", ptr_option->min);
|
||||
|
||||
@@ -154,6 +154,8 @@ struct t_config_option
|
||||
char *parent_name; /* parent name (to inherit the */
|
||||
/* value from another option) */
|
||||
enum t_config_option_type type; /* type */
|
||||
int themable; /* 1 if option is themable */
|
||||
/* (color, or string with color) */
|
||||
char *description; /* description */
|
||||
char **string_values; /* allowed string values */
|
||||
int min, max; /* min and max for value */
|
||||
|
||||
+13
-13
@@ -3450,7 +3450,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
config_look_buffer_time_format = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"buffer_time_format", "string",
|
||||
"buffer_time_format", "string|themable",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("time format for each line displayed in buffers (see man "
|
||||
"strftime for date/time specifiers, extra specifiers are "
|
||||
@@ -3474,7 +3474,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_look_buffer_time_same = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"buffer_time_same", "string",
|
||||
"buffer_time_same", "string|themable",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("time displayed for a message with same time as previous message: "
|
||||
"use a space \" \" to hide time, another string to display this "
|
||||
@@ -3641,7 +3641,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_look_day_change_message_1date = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"day_change_message_1date", "string",
|
||||
"day_change_message_1date", "string|themable",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("message displayed when the day has changed, with one date "
|
||||
"displayed (for example at beginning of buffer) (see man "
|
||||
@@ -3654,7 +3654,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_look_day_change_message_2dates = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"day_change_message_2dates", "string",
|
||||
"day_change_message_2dates", "string|themable",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("message displayed when the day has changed, with two dates "
|
||||
"displayed (between two messages); the second date specifiers "
|
||||
@@ -3971,7 +3971,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_look_item_time_format = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"item_time_format", "string",
|
||||
"item_time_format", "string|themable",
|
||||
N_("time format for \"time\" bar item (see man strftime for "
|
||||
"date/time specifiers) (note: content is evaluated, so you can "
|
||||
"use colors with format \"${color:xxx}\", see /help eval)"),
|
||||
@@ -4026,7 +4026,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_look_nick_color_force = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"nick_color_force", "string",
|
||||
"nick_color_force", "string|themable",
|
||||
N_("force color for some nicks: hash computed with nickname "
|
||||
"to find color will not be used for these nicks (format is: "
|
||||
"\"nick1:color1;nick2:color2\"); look up for nicks is with "
|
||||
@@ -4118,7 +4118,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
config_look_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"prefix_error", "string",
|
||||
"prefix_error", "string|themable",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("prefix for error messages (note: content is evaluated, so you "
|
||||
"can use colors with format \"${color:xxx}\", see /help eval)"),
|
||||
@@ -4128,7 +4128,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_look_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"prefix_network", "string",
|
||||
"prefix_network", "string|themable",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("prefix for network messages (note: content is evaluated, so you "
|
||||
"can use colors with format \"${color:xxx}\", see /help eval)"),
|
||||
@@ -4138,7 +4138,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_look_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"prefix_action", "string",
|
||||
"prefix_action", "string|themable",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("prefix for action messages (note: content is evaluated, so you "
|
||||
"can use colors with format \"${color:xxx}\", see /help eval)"),
|
||||
@@ -4148,7 +4148,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_look_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"prefix_join", "string",
|
||||
"prefix_join", "string|themable",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("prefix for join messages (note: content is evaluated, so you "
|
||||
"can use colors with format \"${color:xxx}\", see /help eval)"),
|
||||
@@ -4158,7 +4158,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_look_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"prefix_quit", "string",
|
||||
"prefix_quit", "string|themable",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("prefix for quit messages (note: content is evaluated, so you "
|
||||
"can use colors with format \"${color:xxx}\", see /help eval)"),
|
||||
@@ -4647,7 +4647,7 @@ config_weechat_init_options (void)
|
||||
NULL, NULL, NULL);
|
||||
config_color_chat_nick_colors = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_color,
|
||||
"chat_nick_colors", "string",
|
||||
"chat_nick_colors", "string|themable",
|
||||
/* TRANSLATORS: please do not translate "lightred:blue" */
|
||||
N_("text color for nicks (comma separated list of colors, "
|
||||
"background is allowed with format: \"fg:bg\", for example: "
|
||||
@@ -4918,7 +4918,7 @@ config_weechat_init_options (void)
|
||||
/* eval syntax highlighting colors (for "${raw_hl:xxx}" and "${hl:xxx}") */
|
||||
config_color_eval_syntax_colors = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_color,
|
||||
"eval_syntax_colors", "string",
|
||||
"eval_syntax_colors", "string|themable",
|
||||
/* TRANSLATORS: please do not translate "lightred:blue" */
|
||||
N_("text color for syntax highlighting in evaluated strings, "
|
||||
"with \"${raw_hl:...}\" and \"${hl:...}\" (comma separated "
|
||||
|
||||
@@ -645,7 +645,7 @@ buflist_config_init (void)
|
||||
{
|
||||
buflist_config_format_buffer = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"buffer", "string",
|
||||
"buffer", "string|themable",
|
||||
N_("format of each line with a buffer "
|
||||
"(note: content is evaluated, see /help buflist); "
|
||||
"example: standard format for bar item \"buflist\" and only the "
|
||||
@@ -663,7 +663,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_buffer_current = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"buffer_current", "string",
|
||||
"buffer_current", "string|themable",
|
||||
N_("format for the line with current buffer "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, "${color:,17}${format_buffer}", NULL, 0,
|
||||
@@ -672,7 +672,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_hotlist = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"hotlist", "string",
|
||||
"hotlist", "string|themable",
|
||||
N_("format for hotlist "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0,
|
||||
@@ -683,7 +683,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_hotlist_level[3] = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"hotlist_highlight", "string",
|
||||
"hotlist_highlight", "string|themable",
|
||||
N_("format for a buffer with hotlist level \"highlight\" "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, "${color:magenta}", NULL, 0,
|
||||
@@ -692,7 +692,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_hotlist_level[0] = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"hotlist_low", "string",
|
||||
"hotlist_low", "string|themable",
|
||||
N_("format for a buffer with hotlist level \"low\" "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, "${color:white}", NULL, 0,
|
||||
@@ -701,7 +701,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_hotlist_level[1] = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"hotlist_message", "string",
|
||||
"hotlist_message", "string|themable",
|
||||
N_("format for a buffer with hotlist level \"message\" "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, "${color:brown}", NULL, 0,
|
||||
@@ -710,7 +710,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_hotlist_level_none = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"hotlist_none", "string",
|
||||
"hotlist_none", "string|themable",
|
||||
N_("format for a buffer not in hotlist "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, "${color:default}", NULL, 0,
|
||||
@@ -719,7 +719,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_hotlist_level[2] = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"hotlist_private", "string",
|
||||
"hotlist_private", "string|themable",
|
||||
N_("format for a buffer with hotlist level \"private\" "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, "${color:green}", NULL, 0,
|
||||
@@ -728,7 +728,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_hotlist_separator = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"hotlist_separator", "string",
|
||||
"hotlist_separator", "string|themable",
|
||||
N_("separator for counts in hotlist "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, "${color:default},", NULL, 0,
|
||||
@@ -737,7 +737,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_indent = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"indent", "string",
|
||||
"indent", "string|themable",
|
||||
N_("string displayed to indent channel, private and list buffers "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, " ", NULL, 0,
|
||||
@@ -746,7 +746,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_lag = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"lag", "string",
|
||||
"lag", "string|themable",
|
||||
N_("format for lag on an IRC server buffer "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0,
|
||||
@@ -757,7 +757,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_name = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"name", "string",
|
||||
"name", "string|themable",
|
||||
N_("format for buffer name "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, "${name}", NULL, 0,
|
||||
@@ -766,7 +766,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_nick_prefix = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"nick_prefix", "string",
|
||||
"nick_prefix", "string|themable",
|
||||
N_("format for nick prefix on a channel "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0, "${color_nick_prefix}${nick_prefix}", NULL, 0,
|
||||
@@ -775,7 +775,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_number = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"number", "string",
|
||||
"number", "string|themable",
|
||||
N_("format for buffer number, ${number} is the indented number "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0,
|
||||
@@ -786,7 +786,7 @@ buflist_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
buflist_config_format_tls_version = weechat_config_new_option (
|
||||
buflist_config_file, buflist_config_section_format,
|
||||
"tls_version", "string",
|
||||
"tls_version", "string|themable",
|
||||
N_("format for TLS version on an IRC server buffer "
|
||||
"(note: content is evaluated, see /help buflist)"),
|
||||
NULL, 0, 0,
|
||||
|
||||
@@ -572,7 +572,7 @@ fset_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
fset_config_format_option[1] = weechat_config_new_option (
|
||||
fset_config_file, fset_config_section_format,
|
||||
"option2", "string",
|
||||
"option2", "string|themable",
|
||||
N_("second format of each line, used when option "
|
||||
"fset.look.format_number is set to 2 "
|
||||
"(note: content is evaluated, see /help fset); "
|
||||
|
||||
@@ -3957,7 +3957,7 @@ irc_config_init (void)
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_color_mirc_remap = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_color,
|
||||
"mirc_remap", "string",
|
||||
"mirc_remap", "string|themable",
|
||||
/* TRANSLATORS: please do not translate the list of WeeChat color names at the end of string */
|
||||
N_("remap mirc colors in messages using a hashtable (used only "
|
||||
"for standard colors, not RGB colors): keys are \"fg,bg\" as "
|
||||
@@ -3975,7 +3975,7 @@ irc_config_init (void)
|
||||
NULL, NULL, NULL);
|
||||
irc_config_color_nick_prefixes = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_color,
|
||||
"nick_prefixes", "string",
|
||||
"nick_prefixes", "string|themable",
|
||||
N_("color for nick prefixes using mode char (o=op, h=halfop, "
|
||||
"v=voice, ..), format is: \"o:color1;h:color2;v:color3\" (if a "
|
||||
"mode is not found, WeeChat will try with next modes received "
|
||||
@@ -4006,7 +4006,7 @@ irc_config_init (void)
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_color_term_remap = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_color,
|
||||
"term_remap", "string",
|
||||
"term_remap", "string|themable",
|
||||
N_("remap terminal color numbers in messages using a hashtable "
|
||||
"(used only for RGB colors as hexadecimal, which are first "
|
||||
"translated to terminal color numbers): keys are \"fg,bg\" as "
|
||||
|
||||
@@ -635,7 +635,7 @@ def config_new_option(config_file: str, section: str, name: str, type: str, desc
|
||||
"", "",
|
||||
"", "")
|
||||
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string",
|
||||
option_str = weechat.config_new_option(config_file, section, "option_str", "string|themable",
|
||||
"My option, type string",
|
||||
"", 0, 0, "test", "test", 1,
|
||||
"option_str_check_value_cb", "",
|
||||
|
||||
@@ -1934,7 +1934,7 @@ relay_config_init (void)
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
relay_config_api_remote_input_cmd_local = weechat_config_new_option (
|
||||
relay_config_file, relay_config_section_api,
|
||||
"remote_input_cmd_local", "string",
|
||||
"remote_input_cmd_local", "string|themable",
|
||||
N_("text displayed after user input when the command would be "
|
||||
"executed locally (NOT sent to the remote WeeChat) "
|
||||
"(note: content is evaluated, see /help eval)"),
|
||||
@@ -1942,7 +1942,7 @@ relay_config_init (void)
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
relay_config_api_remote_input_cmd_remote = weechat_config_new_option (
|
||||
relay_config_file, relay_config_section_api,
|
||||
"remote_input_cmd_remote", "string",
|
||||
"remote_input_cmd_remote", "string|themable",
|
||||
N_("text displayed after user input when the command would be "
|
||||
"executed on the remote WeeChat (NOT executed locally) "
|
||||
"(note: content is evaluated, see /help eval)"),
|
||||
|
||||
@@ -394,6 +394,36 @@ TEST(CoreConfigFile, OptionMalloc)
|
||||
/* TODO: write tests */
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an option with the given type, read its "themable" flag, then free
|
||||
* it.
|
||||
*
|
||||
* Return the value of the "themable" flag (0 or 1), or -1 if the option could
|
||||
* not be created (invalid type).
|
||||
*/
|
||||
|
||||
int
|
||||
test_new_option_themable (struct t_config_section *section,
|
||||
const char *name, const char *type,
|
||||
const char *string_values,
|
||||
const char *default_value)
|
||||
{
|
||||
struct t_config_option *option;
|
||||
int themable;
|
||||
|
||||
option = config_file_new_option (
|
||||
weechat_config_file, section,
|
||||
name, type, "", string_values, 0, 123456, default_value, NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
if (!option)
|
||||
return -1;
|
||||
themable = option->themable;
|
||||
config_file_option_free (option, 0);
|
||||
return themable;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test functions:
|
||||
* config_file_new_option
|
||||
@@ -401,7 +431,70 @@ TEST(CoreConfigFile, OptionMalloc)
|
||||
|
||||
TEST(CoreConfigFile, NewOption)
|
||||
{
|
||||
/* TODO: write tests */
|
||||
struct t_config_option *ptr_option;
|
||||
int *ptr_themable;
|
||||
|
||||
/* plain types are not themable */
|
||||
LONGS_EQUAL(0, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "boolean", NULL, "off"));
|
||||
LONGS_EQUAL(0, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "integer", NULL, "100"));
|
||||
LONGS_EQUAL(0, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "string", NULL, "value"));
|
||||
LONGS_EQUAL(0, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "enum", "v1|v2|v3", "v2"));
|
||||
|
||||
/* color options are always themable, even without the suffix */
|
||||
LONGS_EQUAL(1, test_new_option_themable (
|
||||
weechat_config_section_color,
|
||||
"test_themable", "color", NULL, "blue"));
|
||||
|
||||
/* the "|themable" suffix marks an option of any type as themable */
|
||||
LONGS_EQUAL(1, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "boolean|themable", NULL, "off"));
|
||||
LONGS_EQUAL(1, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "integer|themable", NULL, "100"));
|
||||
LONGS_EQUAL(1, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "string|themable", NULL, "value"));
|
||||
LONGS_EQUAL(1, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "enum|themable", "v1|v2|v3", "v2"));
|
||||
LONGS_EQUAL(1, test_new_option_themable (
|
||||
weechat_config_section_color,
|
||||
"test_themable", "color|themable", NULL, "blue"));
|
||||
|
||||
/* an invalid type or unknown suffix is refused (option not created) */
|
||||
LONGS_EQUAL(-1, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "string|xxx", NULL, "value"));
|
||||
LONGS_EQUAL(-1, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "string|", NULL, "value"));
|
||||
LONGS_EQUAL(-1, test_new_option_themable (
|
||||
weechat_config_section_look,
|
||||
"test_themable", "xxx", NULL, "value"));
|
||||
|
||||
/* the flag is reachable via config_file_option_get_pointer */
|
||||
ptr_option = config_file_new_option (
|
||||
weechat_config_file, weechat_config_section_look,
|
||||
"test_themable", "string|themable", "", NULL, 0, 0, "value", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
CHECK(ptr_option);
|
||||
ptr_themable = (int *)config_file_option_get_pointer (ptr_option,
|
||||
"themable");
|
||||
CHECK(ptr_themable);
|
||||
POINTERS_EQUAL(&ptr_option->themable, ptr_themable);
|
||||
LONGS_EQUAL(1, *ptr_themable);
|
||||
config_file_option_free (ptr_option, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user