diff options
33 files changed, 2328 insertions, 24 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 8cbb74a83..dd1afe9fc 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -19,7 +19,7 @@ New features:: * core: add option `-s` in command `/command` to execute multiple commands separated by semicolons * core: allow case insensitive search of partial buffer name with `(?i)name` in command `/buffer` * core: use function util_strftimeval in evaluation of expression `date:xxx` - * api: add functions config_option_get_string and config_option_get_pointer in scripting API + * api: add functions config_option_get_{string|pointer} and config_{boolean|integer|string|color|enum}_inherited in scripting API * api: add info "plugin_loaded" * api: add support of specifier `%!` for timestamp in function util_strftimeval * api: add support of base64url in encode/decode functions diff --git a/doc/de/weechat_scripting.de.adoc b/doc/de/weechat_scripting.de.adoc index 8f75aa889..5405cf116 100644 --- a/doc/de/weechat_scripting.de.adoc +++ b/doc/de/weechat_scripting.de.adoc @@ -635,12 +635,19 @@ Liste der Skript API Funktionen: config_option_default_is_null + config_boolean + config_boolean_default + + config_boolean_inherited + config_integer + config_integer_default + + config_integer_inherited + config_string + config_string_default + + config_string_inherited + config_color + config_color_default + + config_color_inherited + + config_enum + + config_enum_default + + config_enum_inherited + config_write_option + config_write_line + config_write + diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index e71097f42..557ced193 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -8017,6 +8017,49 @@ if weechat.config_boolean_default(option): # ... ---- +==== config_boolean_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited boolean value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototype: + +[source,c] +---- +int weechat_config_boolean_inherited (struct t_config_option *option); +---- + +Arguments: + +* _option_: option pointer + +Return value: see functions <<_config_boolean,config_boolean>> and +<<_config_boolean_default,config_boolean_default>>. + +C example: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autoconnect"); +int autoconnect = weechat_config_boolean_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_boolean_inherited(option: str) -> int: ... + +# example +option = weechat.config_get("irc.server.libera.autoconnect") +autoconect = weechat.config_boolean_inherited(option) +---- + ==== config_integer Return integer value of option. @@ -8103,6 +8146,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_integer_default(option) ---- +==== config_integer_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited integer value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototype: + +[source,c] +---- +int weechat_config_integer_inherited (struct t_config_option *option); +---- + +Arguments: + +* _option_: option pointer + +Return value: see functions <<_config_integer,config_integer>> and +<<_config_integer_default,config_integer_default>>. + +C example: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autojoin_delay"); +int delay = weechat_config_integer_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_integer_inherited(option: str) -> int: ... + +# example +option = weechat.config_get("irc.server.libera.autojoin_delay") +delay = weechat.config_integer_inherited(option) +---- + ==== config_string Return string value of option. @@ -8189,6 +8275,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_string_default(option) ---- +==== config_string_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited string value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototype: + +[source,c] +---- +const char *weechat_config_string_inherited (struct t_config_option *option); +---- + +Arguments: + +* _option_: option pointer + +Return value: see functions <<_config_string,config_string>> and +<<_config_string_default,config_string_default>>. + +C example: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.msg_quit"); +const char *msg_quit = weechat_config_string_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_string_inherited(option: str) -> str: ... + +# example +option = weechat.config_get("irc.server.libera.msg_quit") +msg_quit = weechat.config_string_inherited(option) +---- + ==== config_color Return color value of option. @@ -8229,7 +8358,7 @@ def config_color(option: str) -> str: ... # example option = weechat.config_get("plugin.section.option") -value = weechat.config_color(option) +color = weechat.config_color(option) ---- ==== config_color_default @@ -8272,7 +8401,50 @@ def config_color_default(option: str) -> str: ... # example option = weechat.config_get("plugin.section.option") -value = weechat.config_color_default(option) +color = weechat.config_color_default(option) +---- + +==== config_color_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited color value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototype: + +[source,c] +---- +const char *weechat_config_color_inherited (struct t_config_option *option); +---- + +Arguments: + +* _option_: option pointer + +Return value: see functions <<_config_color,config_color>> and +<<_config_color_default,config_color_default>>. + +C example: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("plugin.section.option"); +const char *color = weechat_config_color_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_color_inherited(option: str) -> str: ... + +# example +option = weechat.config_get("plugin.section.option") +color = weechat.config_color_inherited(option) ---- ==== config_enum @@ -8365,6 +8537,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_enum_default(option) ---- +==== config_enum_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited enum value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototype: + +[source,c] +---- +int weechat_config_enum_inherited (struct t_config_option *option); +---- + +Arguments: + +* _option_: option pointer + +Return value: see functions <<_config_enum,config_enum>> and +<<_config_enum_default,config_enum_default>>. + +C example: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.sasl_fail"); +int sasl_fail = weechat_config_enum_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_enum_inherited(option: str) -> int: ... + +# example +option = weechat.config_get("irc.server.libera.sasl_fail") +sasl_fail = weechat.config_enum_inherited(option) +---- + ==== config_write_option Write a line in a configuration file with option and its value (this function diff --git a/doc/en/weechat_scripting.en.adoc b/doc/en/weechat_scripting.en.adoc index d6e8cf8ee..b0a1bdd89 100644 --- a/doc/en/weechat_scripting.en.adoc +++ b/doc/en/weechat_scripting.en.adoc @@ -620,12 +620,19 @@ List of functions in script API: config_option_default_is_null + config_boolean + config_boolean_default + + config_boolean_inherited + config_integer + config_integer_default + + config_integer_inherited + config_string + config_string_default + + config_string_inherited + config_color + config_color_default + + config_color_inherited + + config_enum + + config_enum_default + + config_enum_inherited + config_write_option + config_write_line + config_write + diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index 65ad30de5..409b00a6d 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -6378,7 +6378,7 @@ _WeeChat ≥ 2.2._ Ajouter les éléments d'une infolist dans une table de hachage. -Prototype: +Prototype : [source,c] ---- @@ -8151,6 +8151,49 @@ if weechat.config_boolean_default(option): # ... ---- +==== config_boolean_inherited + +_WeeChat ≥ 4.3.0._ + +Retourner la valeur booléenne héritée de l'option : la valeur si l'option n'est +pas NULL, ou la valeur de l'option parente (si l'option hérite d'une autre option). + +Si l'option parente n'est pas trouvée, retourner la valeur par défaut de l'option. + +Si la valeur parente est NULL, retourner la valeur par défaut de l'option parente. + +Prototype : + +[source,c] +---- +int weechat_config_boolean_inherited (struct t_config_option *option); +---- + +Paramètres : + +* _option_ : pointeur vers l'option + +Valeur de retour : voir les fonctions <<_config_boolean,config_boolean>> et +<<_config_boolean_default,config_boolean_default>>. + +Exemple en C : + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autoconnect"); +int autoconnect = weechat_config_boolean_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_boolean_inherited(option: str) -> int: ... + +# exemple +option = weechat.config_get("irc.server.libera.autoconnect") +autoconect = weechat.config_boolean_inherited(option) +---- + ==== config_integer Retourner la valeur entière de l'option. @@ -8237,6 +8280,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_integer_default(option) ---- +==== config_integer_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited integer value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototype : + +[source,c] +---- +int weechat_config_integer_inherited (struct t_config_option *option); +---- + +Paramètres : + +* _option_ : pointeur vers l'option + +Valeur de retour : voir les fonctions <<_config_integer,config_integer>> et +<<_config_integer_default,config_integer_default>>. + +Exemple en C : + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autojoin_delay"); +int delay = weechat_config_integer_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_integer_inherited(option: str) -> int: ... + +# exemple +option = weechat.config_get("irc.server.libera.autojoin_delay") +delay = weechat.config_integer_inherited(option) +---- + ==== config_string Retourner la valeur de l'option, sous forme de chaîne. @@ -8323,6 +8409,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_string_default(option) ---- +==== config_string_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited string value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototype : + +[source,c] +---- +const char *weechat_config_string_inherited (struct t_config_option *option); +---- + +Paramètres : + +* _option_ : pointeur vers l'option + +Valeur de retour : voir les fonctions <<_config_string,config_string>> et +<<_config_string_default,config_string_default>>. + +Exemple en C : + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.msg_quit"); +const char *msg_quit = weechat_config_string_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_string_inherited(option: str) -> str: ... + +# exemple +option = weechat.config_get("irc.server.libera.msg_quit") +msg_quit = weechat.config_string_inherited(option) +---- + ==== config_color Retourner la valeur de l'option, sous forme de couleur. @@ -8363,7 +8492,7 @@ def config_color(option: str) -> str: ... # exemple option = weechat.config_get("plugin.section.option") -value = weechat.config_color(option) +color = weechat.config_color(option) ---- ==== config_color_default @@ -8406,7 +8535,50 @@ def config_color_default(option: str) -> str: ... # exemple option = weechat.config_get("plugin.section.option") -value = weechat.config_color_default(option) +color = weechat.config_color_default(option) +---- + +==== config_color_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited color value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototype : + +[source,c] +---- +const char *weechat_config_color_inherited (struct t_config_option *option); +---- + +Paramètres : + +* _option_ : pointeur vers l'option + +Valeur de retour : voir les fonctions <<_config_color,config_color>> et +<<_config_color_default,config_color_default>>. + +Exemple en C : + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("plugin.section.option"); +const char *color = weechat_config_color_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_color_inherited(option: str) -> str: ... + +# exemple +option = weechat.config_get("plugin.section.option") +color = weechat.config_color_inherited(option) ---- ==== config_enum @@ -8494,11 +8666,54 @@ Script (Python) : # prototype def config_enum_default(option: str) -> int: ... -# example +# exemple option = weechat.config_get("plugin.section.option") value = weechat.config_enum_default(option) ---- +==== config_enum_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited enum value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototype : + +[source,c] +---- +int weechat_config_enum_inherited (struct t_config_option *option); +---- + +Paramètres : + +* _option_ : pointeur vers l'option + +Valeur de retour : voir les fonctions <<_config_enum,config_enum>> et +<<_config_enum_default,config_enum_default>>. + +Exemple en C : + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.sasl_fail"); +int sasl_fail = weechat_config_enum_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototype +def config_enum_inherited(option: str) -> int: ... + +# exemple +option = weechat.config_get("irc.server.libera.sasl_fail") +sasl_fail = weechat.config_enum_inherited(option) +---- + ==== config_write_option Écrire une ligne dans le fichier de configuration avec l'option et sa valeur diff --git a/doc/fr/weechat_scripting.fr.adoc b/doc/fr/weechat_scripting.fr.adoc index dc7699b92..adfa19104 100644 --- a/doc/fr/weechat_scripting.fr.adoc +++ b/doc/fr/weechat_scripting.fr.adoc @@ -641,12 +641,19 @@ Liste des fonctions de l'API script : config_option_default_is_null + config_boolean + config_boolean_default + + config_boolean_inherited + config_integer + config_integer_default + + config_integer_inherited + config_string + config_string_default + + config_string_inherited + config_color + config_color_default + + config_color_inherited + + config_enum + + config_enum_default + + config_enum_inherited + config_write_option + config_write_line + config_write + diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index c7efed09f..3d2ceee00 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -8329,6 +8329,49 @@ if weechat.config_boolean_default(option): # ... ---- +==== config_boolean_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited boolean value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototipo: + +[source,c] +---- +int weechat_config_boolean_inherited (struct t_config_option *option); +---- + +Argomenti: + +* _option_: puntatore all'opzione + +Return value: see functions <<_config_boolean,config_boolean>> and +<<_config_boolean_default,config_boolean_default>>. + +Esempio in C: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autoconnect"); +int autoconnect = weechat_config_boolean_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototipo +def config_boolean_inherited(option: str) -> int: ... + +# esempio +option = weechat.config_get("irc.server.libera.autoconnect") +autoconect = weechat.config_boolean_inherited(option) +---- + ==== config_integer Restituisce il valore intero di un'opzione. @@ -8417,6 +8460,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_integer_default(option) ---- +==== config_integer_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited integer value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototipo: + +[source,c] +---- +int weechat_config_integer_inherited (struct t_config_option *option); +---- + +Argomenti: + +* _option_: puntatore all'opzione + +Return value: see functions <<_config_integer,config_integer>> and +<<_config_integer_default,config_integer_default>>. + +Esempio in C: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autojoin_delay"); +int delay = weechat_config_integer_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototipo +def config_integer_inherited(option: str) -> int: ... + +# esempio +option = weechat.config_get("irc.server.libera.autojoin_delay") +delay = weechat.config_integer_inherited(option) +---- + ==== config_string Restituisce il valore stringa di un'opzione. @@ -8505,6 +8591,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_string_default(option) ---- +==== config_string_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited string value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototipo: + +[source,c] +---- +const char *weechat_config_string_inherited (struct t_config_option *option); +---- + +Argomenti: + +* _option_: puntatore all'opzione + +Return value: see functions <<_config_string,config_string>> and +<<_config_string_default,config_string_default>>. + +Esempio in C: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.msg_quit"); +const char *msg_quit = weechat_config_string_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototipo +def config_string_inherited(option: str) -> str: ... + +# esempio +option = weechat.config_get("irc.server.libera.msg_quit") +msg_quit = weechat.config_string_inherited(option) +---- + ==== config_color Restituisce il valore colore di un'opzione. @@ -8546,7 +8675,7 @@ def config_color(option: str) -> str: ... # esempio option = weechat.config_get("plugin.section.option") -value = weechat.config_color(option) +color = weechat.config_color(option) ---- ==== config_color_default @@ -8590,7 +8719,50 @@ def config_color_default(option: str) -> str: ... # esempio option = weechat.config_get("plugin.section.option") -value = weechat.config_color_default(option) +color = weechat.config_color_default(option) +---- + +==== config_color_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited color value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototipo: + +[source,c] +---- +const char *weechat_config_color_inherited (struct t_config_option *option); +---- + +Argomenti: + +* _option_: puntatore all'opzione + +Return value: see functions <<_config_color,config_color>> and +<<_config_color_default,config_color_default>>. + +Esempio in C: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("plugin.section.option"); +const char *color = weechat_config_color_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototipo +def config_color_inherited(option: str) -> str: ... + +# esempio +option = weechat.config_get("plugin.section.option") +color = weechat.config_color_inherited(option) ---- // TRANSLATION MISSING @@ -8685,6 +8857,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_enum_default(option) ---- +==== config_enum_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited enum value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Prototipo: + +[source,c] +---- +int weechat_config_enum_inherited (struct t_config_option *option); +---- + +Argomenti: + +* _option_: puntatore all'opzione + +Return value: see functions <<_config_enum,config_enum>> and +<<_config_enum_default,config_enum_default>>. + +Esempio in C: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.sasl_fail"); +int sasl_fail = weechat_config_enum_inherited (option); +---- + +Script (Python): + +[source,python] +---- +# prototipo +def config_enum_inherited(option: str) -> int: ... + +# esempio +option = weechat.config_get("irc.server.libera.sasl_fail") +sasl_fail = weechat.config_enum_inherited(option) +---- + ==== config_write_option Scrive una riga nel file di configurazione con l'opzione ed il suo valore diff --git a/doc/it/weechat_scripting.it.adoc b/doc/it/weechat_scripting.it.adoc index bd01da28c..b2621a8bb 100644 --- a/doc/it/weechat_scripting.it.adoc +++ b/doc/it/weechat_scripting.it.adoc @@ -650,12 +650,19 @@ Elenco di funzioni nelle API per gli script: config_option_default_is_null + config_boolean + config_boolean_default + + config_boolean_inherited + config_integer + config_integer_default + + config_integer_inherited + config_string + config_string_default + + config_string_inherited + config_color + config_color_default + + config_color_inherited + + config_enum + + config_enum_default + + config_enum_inherited + config_write_option + config_write_line + config_write + diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index 61f3d1269..152441be1 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -8115,6 +8115,49 @@ if weechat.config_boolean_default(option): # ... ---- +==== config_boolean_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited boolean value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +プロトタイプ: + +[source,c] +---- +int weechat_config_boolean_inherited (struct t_config_option *option); +---- + +引数: + +* _option_: オプションへのポインタ + +Return value: see functions <<_config_boolean,config_boolean>> and +<<_config_boolean_default,config_boolean_default>>. + +C 言語での使用例: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autoconnect"); +int autoconnect = weechat_config_boolean_inherited (option); +---- + +スクリプト (Python) での使用例: + +[source,python] +---- +# プロトタイプ +def config_boolean_inherited(option: str) -> int: ... + +# 例 +option = weechat.config_get("irc.server.libera.autoconnect") +autoconect = weechat.config_boolean_inherited(option) +---- + ==== config_integer オプションの整数値を返す。 @@ -8203,6 +8246,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_integer_default(option) ---- +==== config_integer_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited integer value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +プロトタイプ: + +[source,c] +---- +int weechat_config_integer_inherited (struct t_config_option *option); +---- + +引数: + +* _option_: オプションへのポインタ + +Return value: see functions <<_config_integer,config_integer>> and +<<_config_integer_default,config_integer_default>>. + +C 言語での使用例: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autojoin_delay"); +int delay = weechat_config_integer_inherited (option); +---- + +スクリプト (Python) での使用例: + +[source,python] +---- +# プロトタイプ +def config_integer_inherited(option: str) -> int: ... + +# 例 +option = weechat.config_get("irc.server.libera.autojoin_delay") +delay = weechat.config_integer_inherited(option) +---- + ==== config_string オプションの文字列値を返す。 @@ -8291,6 +8377,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_string_default(option) ---- +==== config_string_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited string value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +プロトタイプ: + +[source,c] +---- +const char *weechat_config_string_inherited (struct t_config_option *option); +---- + +引数: + +* _option_: オプションへのポインタ + +Return value: see functions <<_config_string,config_string>> and +<<_config_string_default,config_string_default>>. + +C 言語での使用例: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.msg_quit"); +const char *msg_quit = weechat_config_string_inherited (option); +---- + +スクリプト (Python) での使用例: + +[source,python] +---- +# プロトタイプ +def config_string_inherited(option: str) -> str: ... + +# 例 +option = weechat.config_get("irc.server.libera.msg_quit") +msg_quit = weechat.config_string_inherited(option) +---- + ==== config_color オプションの色値を返す。 @@ -8331,7 +8460,7 @@ def config_color(option: str) -> str: ... # 例 option = weechat.config_get("plugin.section.option") -value = weechat.config_color(option) +color = weechat.config_color(option) ---- ==== config_color_default @@ -8374,7 +8503,50 @@ def config_color_default(option: str) -> str: ... # 例 option = weechat.config_get("plugin.section.option") -value = weechat.config_color_default(option) +color = weechat.config_color_default(option) +---- + +==== config_color_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited color value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +プロトタイプ: + +[source,c] +---- +const char *weechat_config_color_inherited (struct t_config_option *option); +---- + +引数: + +* _option_: オプションへのポインタ + +Return value: see functions <<_config_color,config_color>> and +<<_config_color_default,config_color_default>>. + +C 言語での使用例: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("plugin.section.option"); +const char *color = weechat_config_color_inherited (option); +---- + +スクリプト (Python) での使用例: + +[source,python] +---- +# プロトタイプ +def config_color_inherited(option: str) -> str: ... + +# 例 +option = weechat.config_get("plugin.section.option") +color = weechat.config_color_inherited(option) ---- // TRANSLATION MISSING @@ -8469,6 +8641,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_enum_default(option) ---- +==== config_enum_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited enum value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +プロトタイプ: + +[source,c] +---- +int weechat_config_enum_inherited (struct t_config_option *option); +---- + +引数: + +* _option_: オプションへのポインタ + +Return value: see functions <<_config_enum,config_enum>> and +<<_config_enum_default,config_enum_default>>. + +C 言語での使用例: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.sasl_fail"); +int sasl_fail = weechat_config_enum_inherited (option); +---- + +スクリプト (Python) での使用例: + +[source,python] +---- +# プロトタイプ +def config_enum_inherited(option: str) -> int: ... + +# 例 +option = weechat.config_get("irc.server.libera.sasl_fail") +sasl_fail = weechat.config_enum_inherited(option) +---- + ==== config_write_option 設定ファイルにオプションとその値を収めた行を書き込む (この関数をセクションの diff --git a/doc/ja/weechat_scripting.ja.adoc b/doc/ja/weechat_scripting.ja.adoc index b48197d77..28852cbf9 100644 --- a/doc/ja/weechat_scripting.ja.adoc +++ b/doc/ja/weechat_scripting.ja.adoc @@ -642,12 +642,19 @@ link:weechat_plugin_api.ja.html[WeeChat プラグイン API リファレンス config_option_default_is_null + config_boolean + config_boolean_default + + config_boolean_inherited + config_integer + config_integer_default + + config_integer_inherited + config_string + config_string_default + + config_string_inherited + config_color + config_color_default + + config_color_inherited + + config_enum + + config_enum_default + + config_enum_inherited + config_write_option + config_write_line + config_write + diff --git a/doc/pl/weechat_scripting.pl.adoc b/doc/pl/weechat_scripting.pl.adoc index 126521559..dc131efdc 100644 --- a/doc/pl/weechat_scripting.pl.adoc +++ b/doc/pl/weechat_scripting.pl.adoc @@ -628,12 +628,19 @@ Lista funkcji w API skryptów: config_option_default_is_null + config_boolean + config_boolean_default + + config_boolean_inherited + config_integer + config_integer_default + + config_integer_inherited + config_string + config_string_default + + config_string_inherited + config_color + config_color_default + + config_color_inherited + + config_enum + + config_enum_default + + config_enum_inherited + config_write_option + config_write_line + config_write + diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc index 59d78117c..4f6ee5b20 100644 --- a/doc/sr/weechat_plugin_api.sr.adoc +++ b/doc/sr/weechat_plugin_api.sr.adoc @@ -2170,7 +2170,7 @@ C пример: unsigned long long size = weechat_parse_size ("1.34m"); /* size == 1340000 */ ---- -Script (Python): +Скрипта (Python): [source,python] ---- @@ -6461,7 +6461,7 @@ weechat_config_set_version (config_file, 2, &my_config_update_cb, NULL, NULL); weechat_config_read (config_file); ---- -Script (Python): +Скрипта (Python): [source,python] ---- @@ -7794,6 +7794,92 @@ if weechat.config_boolean_default(option): # ... ---- +==== config_boolean_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited boolean value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Прототип: + +[source,c] +---- +int weechat_config_boolean_inherited (struct t_config_option *option); +---- + +Аргументи: + +* _option_: показивач на опцију + +Return value: see functions <<_config_boolean,config_boolean>> and +<<_config_boolean_default,config_boolean_default>>. + +C пример: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autoconnect"); +int autoconnect = weechat_config_boolean_inherited (option); +---- + +Скрипта (Python): + +[source,python] +---- +# прототип +def config_boolean_inherited(option: str) -> int: ... + +# пример +option = weechat.config_get("irc.server.libera.autoconnect") +autoconect = weechat.config_boolean_inherited(option) +---- + +==== config_integer + +Return integer value of option. + +Прототип: + +[source,c] +---- +int weechat_config_integer (struct t_config_option *option); +---- + +Аргументи: + +* _option_: показивач на опцију + +Return value, depending on the option type: + +* _boolean_: boolean value of option (0 or 1) +* _integer_: integer value of option +* _string_: 0 +* _color_: color index +* _enum_: integer value of option (index of enum value) + +C пример: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("plugin.section.option"); +int value = weechat_config_integer (option); +---- + +Скрипта (Python): + +[source,python] +---- +# прототип +def config_integer(option: str) -> int: ... + +# пример +option = weechat.config_get("plugin.section.option") +value = weechat.config_integer(option) +---- + ==== config_integer Враћа целобројну вредност опције. @@ -7880,6 +7966,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_integer_default(option) ---- +==== config_integer_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited integer value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Прототип: + +[source,c] +---- +int weechat_config_integer_inherited (struct t_config_option *option); +---- + +Аргументи: + +* _option_: показивач на опцију + +Return value: see functions <<_config_integer,config_integer>> and +<<_config_integer_default,config_integer_default>>. + +C пример: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.autojoin_delay"); +int delay = weechat_config_integer_inherited (option); +---- + +Скрипта (Python): + +[source,python] +---- +# прототип +def config_integer_inherited(option: str) -> int: ... + +# пример +option = weechat.config_get("irc.server.libera.autojoin_delay") +delay = weechat.config_integer_inherited(option) +---- + ==== config_string Враћа стринг вредност опције. @@ -7966,6 +8095,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_string_default(option) ---- +==== config_string_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited string value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Прототип: + +[source,c] +---- +const char *weechat_config_string_inherited (struct t_config_option *option); +---- + +Аргументи: + +* _option_: показивач на опцију + +Return value: see functions <<_config_string,config_string>> and +<<_config_string_default,config_string_default>>. + +C пример: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.msg_quit"); +const char *msg_quit = weechat_config_string_inherited (option); +---- + +Скрипта (Python): + +[source,python] +---- +# прототип +def config_string_inherited(option: str) -> str: ... + +# пример +option = weechat.config_get("irc.server.libera.msg_quit") +msg_quit = weechat.config_string_inherited(option) +---- + ==== config_color Враћа вредност опције као боју. @@ -8006,7 +8178,7 @@ def config_color(option: str) -> str: ... # пример option = weechat.config_get("plugin.section.option") -value = weechat.config_color(option) +color = weechat.config_color(option) ---- ==== config_color_default @@ -8049,7 +8221,50 @@ def config_color_default(option: str) -> str: ... # пример option = weechat.config_get("plugin.section.option") -value = weechat.config_color_default(option) +color = weechat.config_color_default(option) +---- + +==== config_color_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited color value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Прототип: + +[source,c] +---- +const char *weechat_config_color_inherited (struct t_config_option *option); +---- + +Аргументи: + +* _option_: показивач на опцију + +Return value: see functions <<_config_color,config_color>> and +<<_config_color_default,config_color_default>>. + +C пример: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("plugin.section.option"); +const char *color = weechat_config_color_inherited (option); +---- + +Скрипта (Python): + +[source,python] +---- +# прототип +def config_color_inherited(option: str) -> str: ... + +# пример +option = weechat.config_get("plugin.section.option") +color = weechat.config_color_inherited(option) ---- ==== config_enum @@ -8142,6 +8357,49 @@ option = weechat.config_get("plugin.section.option") value = weechat.config_enum_default(option) ---- +==== config_enum_inherited + +_WeeChat ≥ 4.3.0._ + +Return inherited enum value of option: value of option if not NULL, +or value of the parent option (if option inherits from another option). + +If the parent option is not found, return the default value of the option. + +If the parent value is NULL, return the default value of the parent option. + +Прототип: + +[source,c] +---- +int weechat_config_enum_inherited (struct t_config_option *option); +---- + +Аргументи: + +* _option_: показивач на опцију + +Return value: see functions <<_config_enum,config_enum>> and +<<_config_enum_default,config_enum_default>>. + +C пример: + +[source,c] +---- +struct t_config_option *option = weechat_config_get ("irc.server.libera.sasl_fail"); +int sasl_fail = weechat_config_enum_inherited (option); +---- + +Скрипта (Python): + +[source,python] +---- +# прототип +def config_enum_inherited(option: str) -> int: ... + +# пример +option = weechat.config_get("irc.server.libera.sasl_fail") +sasl_fail = weechat.config_enum_inherited(option) +---- + ==== config_write_option Уписује линију у конфигурациони фајл са опцијом и њеном вредности (ова функција би требало да се позове само у „write” или „write_default” функцијама повратног позива за одељак). diff --git a/doc/sr/weechat_scripting.sr.adoc b/doc/sr/weechat_scripting.sr.adoc index 3fa685ce9..6eb3b9f88 100644 --- a/doc/sr/weechat_scripting.sr.adoc +++ b/doc/sr/weechat_scripting.sr.adoc @@ -581,12 +581,19 @@ weechat_hook_timer(1000, 0, 1, $timer_cb, 'test'); config_option_default_is_null + config_boolean + config_boolean_default + + config_boolean_inherited + config_integer + config_integer_default + + config_integer_inherited + config_string + config_string_default + + config_string_inherited + config_color + config_color_default + + config_color_inherited + + config_enum + + config_enum_default + + config_enum_inherited + config_write_option + config_write_line + config_write + diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index e47187b27..7ce1ac771 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -1184,6 +1184,28 @@ config_file_search_with_string (const char *option_name, } /* + * Gets pointer to parent option, NULL if the option has no parent. + */ + +struct t_config_option * +config_file_get_parent_option (struct t_config_option *option) +{ + struct t_config_option *ptr_parent_option; + + if (!option || !option->parent_name) + return NULL; + + config_file_search_with_string ( + option->parent_name, + NULL, /* config_file */ + NULL, /* section */ + &ptr_parent_option, + NULL); /* pos_option_name */ + + return ptr_parent_option; +} + +/* * Checks if a string with boolean value is valid. * * Returns: @@ -2686,6 +2708,34 @@ config_file_option_boolean_default (struct t_config_option *option) } /* + * Returns inherited boolean value of an option: value of option if not NULL, + * or value of the parent option (if option inherits from another option). + * + * If the parent option is not found, returns the default value of the option. + * If the parent value is NULL, returns the default value of the parent option. + */ + +int +config_file_option_boolean_inherited (struct t_config_option *option) +{ + struct t_config_option *ptr_parent_option; + + if (option && option->value) + { + return config_file_option_boolean (option); + } + else + { + ptr_parent_option = config_file_get_parent_option (option); + if (!ptr_parent_option) + return config_file_option_boolean_default (option); + if (!ptr_parent_option->value) + return config_file_option_boolean_default (ptr_parent_option); + return config_file_option_boolean (ptr_parent_option); + } +} + +/* * Returns integer value of an option. */ @@ -2748,6 +2798,34 @@ config_file_option_integer_default (struct t_config_option *option) } /* + * Returns inherited integer value of an option: value of option if not NULL, + * or value of the parent option (if option inherits from another option). + * + * If the parent option is not found, returns the default value of the option. + * If the parent value is NULL, returns the default value of the parent option. + */ + +int +config_file_option_integer_inherited (struct t_config_option *option) +{ + struct t_config_option *ptr_parent_option; + + if (option && option->value) + { + return config_file_option_integer (option); + } + else + { + ptr_parent_option = config_file_get_parent_option (option); + if (!ptr_parent_option) + return config_file_option_integer_default (option); + if (!ptr_parent_option->value) + return config_file_option_integer_default (ptr_parent_option); + return config_file_option_integer (ptr_parent_option); + } +} + +/* * Returns string value of an option. */ @@ -2810,6 +2888,34 @@ config_file_option_string_default (struct t_config_option *option) } /* + * Returns inherited string value of an option: value of option if not NULL, + * or value of the parent option (if option inherits from another option). + * + * If the parent option is not found, returns the default value of the option. + * If the parent value is NULL, returns the default value of the parent option. + */ + +const char * +config_file_option_string_inherited (struct t_config_option *option) +{ + struct t_config_option *ptr_parent_option; + + if (option && option->value) + { + return config_file_option_string (option); + } + else + { + ptr_parent_option = config_file_get_parent_option (option); + if (!ptr_parent_option) + return config_file_option_string_default (option); + if (!ptr_parent_option->value) + return config_file_option_string_default (ptr_parent_option); + return config_file_option_string (ptr_parent_option); + } +} + +/* * Returns color value of an option. */ @@ -2836,6 +2942,32 @@ config_file_option_color_default (struct t_config_option *option) } /* + * Returns inherited color value of an option: value of option if not NULL, + * or value of the parent option (if option inherits from another option). + * + * If the parent option is not found, returns the default value of the option. + * If the parent value is NULL, returns the default value of the parent option. + */ + +const char * +config_file_option_color_inherited (struct t_config_option *option) +{ + struct t_config_option *ptr_parent_option; + + if (option && option->value) + return config_file_option_color (option); + else + { + ptr_parent_option = config_file_get_parent_option (option); + if (!ptr_parent_option) + return config_file_option_color_default (option); + if (!ptr_parent_option->value) + return config_file_option_color_default (ptr_parent_option); + return config_file_option_color (ptr_parent_option); + } +} + +/* * Returns enum value of an option. */ @@ -2898,6 +3030,34 @@ config_file_option_enum_default (struct t_config_option *option) } /* + * Returns inherited enum value of an option: value of option if not NULL, + * or value of the parent option (if option inherits from another option). + * + * If the parent option is not found, returns the default value of the option. + * If the parent value is NULL, returns the default value of the parent option. + */ + +int +config_file_option_enum_inherited (struct t_config_option *option) +{ + struct t_config_option *ptr_parent_option; + + if (option && option->value) + { + return config_file_option_enum (option); + } + else + { + ptr_parent_option = config_file_get_parent_option (option); + if (!ptr_parent_option) + return config_file_option_enum_default (option); + if (!ptr_parent_option->value) + return config_file_option_enum_default (ptr_parent_option); + return config_file_option_enum (ptr_parent_option); + } +} + +/* * Returns a char to add before the name of option to escape it. * * Returns: diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h index 104cd2f8c..643080535 100644 --- a/src/core/wee-config-file.h +++ b/src/core/wee-config-file.h @@ -314,14 +314,19 @@ extern int config_file_option_default_is_null (struct t_config_option *option); extern int config_file_option_has_changed (struct t_config_option *option); extern int config_file_option_set_with_string (const char *option_name, const char *value); extern int config_file_option_boolean (struct t_config_option *option); +extern int config_file_option_boolean_inherited (struct t_config_option *option); extern int config_file_option_boolean_default (struct t_config_option *option); extern int config_file_option_integer (struct t_config_option *option); +extern int config_file_option_integer_inherited (struct t_config_option *option); extern int config_file_option_integer_default (struct t_config_option *option); extern const char *config_file_option_string (struct t_config_option *option); +extern const char *config_file_option_string_inherited (struct t_config_option *option); extern const char *config_file_option_string_default (struct t_config_option *option); extern const char *config_file_option_color (struct t_config_option *option); +extern const char *config_file_option_color_inherited (struct t_config_option *option); extern const char *config_file_option_color_default (struct t_config_option *option); extern int config_file_option_enum (struct t_config_option *option); +extern int config_file_option_enum_inherited (struct t_config_option *option); extern int config_file_option_enum_default (struct t_config_option *option); extern int config_file_write_option (struct t_config_file *config_file, struct t_config_option *option); diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 290e069b2..a04e6d5a8 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -1607,6 +1607,20 @@ weechat_guile_api_config_boolean_default (SCM option) } SCM +weechat_guile_api_config_boolean_inherited (SCM option) +{ + int value; + + API_INIT_FUNC(1, "config_boolean_inherited", API_RETURN_INT(0)); + if (!scm_is_string (option)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_config_boolean_inherited (API_STR2PTR(API_SCM_TO_STRING(option))); + + API_RETURN_INT(value); +} + +SCM weechat_guile_api_config_integer (SCM option) { int value; @@ -1635,6 +1649,20 @@ weechat_guile_api_config_integer_default (SCM option) } SCM +weechat_guile_api_config_integer_inherited (SCM option) +{ + int value; + + API_INIT_FUNC(1, "config_integer_inherited", API_RETURN_INT(0)); + if (!scm_is_string (option)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_config_integer_inherited (API_STR2PTR(API_SCM_TO_STRING(option))); + + API_RETURN_INT(value); +} + +SCM weechat_guile_api_config_string (SCM option) { const char *result; @@ -1665,6 +1693,21 @@ weechat_guile_api_config_string_default (SCM option) } SCM +weechat_guile_api_config_string_inherited (SCM option) +{ + const char *result; + SCM return_value; + + API_INIT_FUNC(1, "config_string_inherited", API_RETURN_EMPTY); + if (!scm_is_string (option)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_config_string_inherited (API_STR2PTR(API_SCM_TO_STRING(option))); + + API_RETURN_STRING(result); +} + +SCM weechat_guile_api_config_color (SCM option) { const char *result; @@ -1695,6 +1738,21 @@ weechat_guile_api_config_color_default (SCM option) } SCM +weechat_guile_api_config_color_inherited (SCM option) +{ + const char *result; + SCM return_value; + + API_INIT_FUNC(1, "config_color_inherited", API_RETURN_EMPTY); + if (!scm_is_string (option)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_config_color_inherited (API_STR2PTR(API_SCM_TO_STRING(option))); + + API_RETURN_STRING(result); +} + +SCM weechat_guile_api_config_enum (SCM option) { int value; @@ -1723,6 +1781,20 @@ weechat_guile_api_config_enum_default (SCM option) } SCM +weechat_guile_api_config_enum_inherited (SCM option) +{ + int value; + + API_INIT_FUNC(1, "config_enum_inherited", API_RETURN_INT(0)); + if (!scm_is_string (option)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_config_enum_inherited (API_STR2PTR(API_SCM_TO_STRING(option))); + + API_RETURN_INT(value); +} + +SCM weechat_guile_api_config_write_option (SCM config_file, SCM option) { API_INIT_FUNC(1, "config_write_option", API_RETURN_ERROR); @@ -5407,14 +5479,19 @@ weechat_guile_api_module_init (void *data) API_DEF_FUNC(config_option_default_is_null, 1); API_DEF_FUNC(config_boolean, 1); API_DEF_FUNC(config_boolean_default, 1); + API_DEF_FUNC(config_boolean_inherited, 1); API_DEF_FUNC(config_integer, 1); API_DEF_FUNC(config_integer_default, 1); + API_DEF_FUNC(config_integer_inherited, 1); API_DEF_FUNC(config_string, 1); API_DEF_FUNC(config_string_default, 1); + API_DEF_FUNC(config_string_inherited, 1); API_DEF_FUNC(config_color, 1); API_DEF_FUNC(config_color_default, 1); + API_DEF_FUNC(config_color_inherited, 1); API_DEF_FUNC(config_enum, 1); API_DEF_FUNC(config_enum_default, 1); + API_DEF_FUNC(config_enum_inherited, 1); API_DEF_FUNC(config_write_option, 2); API_DEF_FUNC(config_write_line, 3); API_DEF_FUNC(config_write, 1); diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index 12d1c79ae..0e139fc70 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -1514,6 +1514,20 @@ API_FUNC(config_boolean_default) API_RETURN_INT(value); } +API_FUNC(config_boolean_inherited) +{ + int value; + + API_INIT_FUNC(1, "config_boolean_inherited", "s", API_RETURN_INT(0)); + + v8::String::Utf8Value option(args[0]); + + value = weechat_config_boolean_inherited ( + (struct t_config_option *)API_STR2PTR(*option)); + + API_RETURN_INT(value); +} + API_FUNC(config_integer) { int value; @@ -1542,6 +1556,20 @@ API_FUNC(config_integer_default) API_RETURN_INT(value); } +API_FUNC(config_integer_inherited) +{ + int value; + + API_INIT_FUNC(1, "config_integer_inherited", "s", API_RETURN_INT(0)); + + v8::String::Utf8Value option(args[0]); + + value = weechat_config_integer_inherited ( + (struct t_config_option *)API_STR2PTR(*option)); + + API_RETURN_INT(value); +} + API_FUNC(config_string) { const char *result; @@ -1570,6 +1598,20 @@ API_FUNC(config_string_default) API_RETURN_STRING(result); } +API_FUNC(config_string_inherited) +{ + const char *result; + + API_INIT_FUNC(1, "config_string_inherited", "s", API_RETURN_EMPTY); + + v8::String::Utf8Value option(args[0]); + + result = weechat_config_string_inherited ( + (struct t_config_option *)API_STR2PTR(*option)); + + API_RETURN_STRING(result); +} + API_FUNC(config_color) { const char *result; @@ -1598,6 +1640,20 @@ API_FUNC(config_color_default) API_RETURN_STRING(result); } +API_FUNC(config_color_inherited) +{ + const char *result; + + API_INIT_FUNC(1, "config_color_inherited", "s", API_RETURN_EMPTY); + + v8::String::Utf8Value option(args[0]); + + result = weechat_config_color_inherited ( + (struct t_config_option *)API_STR2PTR(*option)); + + API_RETURN_STRING(result); +} + API_FUNC(config_enum) { int value; @@ -1626,6 +1682,20 @@ API_FUNC(config_enum_default) API_RETURN_INT(value); } +API_FUNC(config_enum_inherited) +{ + int value; + + API_INIT_FUNC(1, "config_enum_inherited", "s", API_RETURN_INT(0)); + + v8::String::Utf8Value option(args[0]); + + value = weechat_config_enum_inherited ( + (struct t_config_option *)API_STR2PTR(*option)); + + API_RETURN_INT(value); +} + API_FUNC(config_write_option) { API_INIT_FUNC(1, "config_write_option", "ss", API_RETURN_ERROR); @@ -5358,14 +5428,19 @@ WeechatJsV8::loadLibs() API_DEF_FUNC(config_option_default_is_null); API_DEF_FUNC(config_boolean); API_DEF_FUNC(config_boolean_default); + API_DEF_FUNC(config_boolean_inherited); API_DEF_FUNC(config_integer); API_DEF_FUNC(config_integer_default); + API_DEF_FUNC(config_integer_inherited); API_DEF_FUNC(config_string); API_DEF_FUNC(config_string_default); + API_DEF_FUNC(config_string_inherited); API_DEF_FUNC(config_color); API_DEF_FUNC(config_color_default); + API_DEF_FUNC(config_color_inherited); API_DEF_FUNC(config_enum); API_DEF_FUNC(config_enum_default); + API_DEF_FUNC(config_enum_inherited); API_DEF_FUNC(config_write_option); API_DEF_FUNC(config_write_line); API_DEF_FUNC(config_write); diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index 222ed500a..36a43adde 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -1651,6 +1651,22 @@ API_FUNC(config_boolean_default) API_RETURN_INT(value); } +API_FUNC(config_boolean_inherited) +{ + const char *option; + int value; + + API_INIT_FUNC(1, "config_boolean_inherited", API_RETURN_INT(0)); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + option = lua_tostring (L, -1); + + value = weechat_config_boolean_inherited (API_STR2PTR(option)); + + API_RETURN_INT(value); +} + API_FUNC(config_integer) { const char *option; @@ -1683,6 +1699,22 @@ API_FUNC(config_integer_default) API_RETURN_INT(value); } +API_FUNC(config_integer_inherited) +{ + const char *option; + int value; + + API_INIT_FUNC(1, "config_integer_inherited", API_RETURN_INT(0)); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + option = lua_tostring (L, -1); + + value = weechat_config_integer_inherited (API_STR2PTR(option)); + + API_RETURN_INT(value); +} + API_FUNC(config_string) { const char *option, *result; @@ -1713,6 +1745,21 @@ API_FUNC(config_string_default) API_RETURN_STRING(result); } +API_FUNC(config_string_inherited) +{ + const char *option, *result; + + API_INIT_FUNC(1, "config_string_inherited", API_RETURN_EMPTY); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_EMPTY); + + option = lua_tostring (L, -1); + + result = weechat_config_string_inherited (API_STR2PTR(option)); + + API_RETURN_STRING(result); +} + API_FUNC(config_color) { const char *option, *result; @@ -1743,6 +1790,21 @@ API_FUNC(config_color_default) API_RETURN_STRING(result); } +API_FUNC(config_color_inherited) +{ + const char *option, *result; + + API_INIT_FUNC(1, "config_color_inherited", API_RETURN_EMPTY); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_EMPTY); + + option = lua_tostring (L, -1); + + result = weechat_config_color_inherited (API_STR2PTR(option)); + + API_RETURN_STRING(result); +} + API_FUNC(config_enum) { const char *option; @@ -1775,6 +1837,22 @@ API_FUNC(config_enum_default) API_RETURN_INT(value); } +API_FUNC(config_enum_inherited) +{ + const char *option; + int value; + + API_INIT_FUNC(1, "config_enum_inherited", API_RETURN_INT(0)); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + option = lua_tostring (L, -1); + + value = weechat_config_enum_inherited (API_STR2PTR(option)); + + API_RETURN_INT(value); +} + API_FUNC(config_write_option) { const char *config_file, *option; @@ -5727,14 +5805,19 @@ const struct luaL_Reg weechat_lua_api_funcs[] = { API_DEF_FUNC(config_option_default_is_null), API_DEF_FUNC(config_boolean), API_DEF_FUNC(config_boolean_default), + API_DEF_FUNC(config_boolean_inherited), API_DEF_FUNC(config_integer), API_DEF_FUNC(config_integer_default), + API_DEF_FUNC(config_integer_inherited), API_DEF_FUNC(config_string), API_DEF_FUNC(config_string_default), + API_DEF_FUNC(config_string_inherited), API_DEF_FUNC(config_color), API_DEF_FUNC(config_color_default), + API_DEF_FUNC(config_color_inherited), API_DEF_FUNC(config_enum), API_DEF_FUNC(config_enum_default), + API_DEF_FUNC(config_enum_inherited), API_DEF_FUNC(config_write_option), API_DEF_FUNC(config_write_line), API_DEF_FUNC(config_write), diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 62caf2984..5617e29d1 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -1584,6 +1584,20 @@ API_FUNC(config_boolean_default) API_RETURN_INT(value); } +API_FUNC(config_boolean_inherited) +{ + int value; + dXSARGS; + + API_INIT_FUNC(1, "config_boolean_inherited", API_RETURN_INT(0)); + if (items < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_config_boolean_inherited (API_STR2PTR(SvPV_nolen (ST (0)))); /* option */ + + API_RETURN_INT(value); +} + API_FUNC(config_integer) { int value; @@ -1612,6 +1626,20 @@ API_FUNC(config_integer_default) API_RETURN_INT(value); } +API_FUNC(config_integer_inherited) +{ + int value; + dXSARGS; + + API_INIT_FUNC(1, "config_integer_inherited", API_RETURN_INT(0)); + if (items < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_config_integer_inherited (API_STR2PTR(SvPV_nolen (ST (0)))); /* option */ + + API_RETURN_INT(value); +} + API_FUNC(config_string) { const char *result; @@ -1640,6 +1668,20 @@ API_FUNC(config_string_default) API_RETURN_STRING(result); } +API_FUNC(config_string_inherited) +{ + const char *result; + dXSARGS; + + API_INIT_FUNC(1, "config_string_inherited", API_RETURN_EMPTY); + if (items < 1) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_config_string_inherited (API_STR2PTR(SvPV_nolen (ST (0)))); /* option */ + + API_RETURN_STRING(result); +} + API_FUNC(config_color) { const char *result; @@ -1668,6 +1710,20 @@ API_FUNC(config_color_default) API_RETURN_STRING(result); } +API_FUNC(config_color_inherited) +{ + const char *result; + dXSARGS; + + API_INIT_FUNC(1, "config_color_inherited", API_RETURN_EMPTY); + if (items < 1) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_config_color_inherited (API_STR2PTR(SvPV_nolen (ST (0)))); /* option */ + + API_RETURN_STRING(result); +} + API_FUNC(config_enum) { int value; @@ -1696,6 +1752,20 @@ API_FUNC(config_enum_default) API_RETURN_INT(value); } +API_FUNC(config_enum_inherited) +{ + int value; + dXSARGS; + + API_INIT_FUNC(1, "config_enum_inherited", API_RETURN_INT(0)); + if (items < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_config_enum_inherited (API_STR2PTR(SvPV_nolen (ST (0)))); /* option */ + + API_RETURN_INT(value); +} + API_FUNC(config_write_option) { char *config_file, *option; @@ -5666,14 +5736,19 @@ weechat_perl_api_init (pTHX) API_DEF_FUNC(config_option_default_is_null); API_DEF_FUNC(config_boolean); API_DEF_FUNC(config_boolean_default); + API_DEF_FUNC(config_boolean_inherited); API_DEF_FUNC(config_integer); API_DEF_FUNC(config_integer_default); + API_DEF_FUNC(config_integer_inherited); API_DEF_FUNC(config_string); API_DEF_FUNC(config_string_default); + API_DEF_FUNC(config_string_inherited); API_DEF_FUNC(config_color); API_DEF_FUNC(config_color_default); + API_DEF_FUNC(config_color_inherited); API_DEF_FUNC(config_enum); API_DEF_FUNC(config_enum_default); + API_DEF_FUNC(config_enum_inherited); API_DEF_FUNC(config_write_option); API_DEF_FUNC(config_write_line); API_DEF_FUNC(config_write); diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index bc6328f42..43ec87cab 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -1679,6 +1679,23 @@ API_FUNC(config_boolean_default) API_RETURN_INT(result); } +API_FUNC(config_boolean_inherited) +{ + zend_string *z_option; + struct t_config_option *option; + int result; + + API_INIT_FUNC(1, "config_boolean_inherited", API_RETURN_INT(0)); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) + API_WRONG_ARGS(API_RETURN_INT(0)); + + option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + + result = weechat_config_boolean_inherited (option); + + API_RETURN_INT(result); +} + API_FUNC(config_integer) { zend_string *z_option; @@ -1713,6 +1730,23 @@ API_FUNC(config_integer_default) API_RETURN_INT(result); } +API_FUNC(config_integer_inherited) +{ + zend_string *z_option; + struct t_config_option *option; + int result; + + API_INIT_FUNC(1, "config_integer_inherited", API_RETURN_INT(0)); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) + API_WRONG_ARGS(API_RETURN_INT(0)); + + option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + + result = weechat_config_integer_inherited (option); + + API_RETURN_INT(result); +} + API_FUNC(config_string) { zend_string *z_option; @@ -1747,6 +1781,23 @@ API_FUNC(config_string_default) API_RETURN_STRING(result); } +API_FUNC(config_string_inherited) +{ + zend_string *z_option; + struct t_config_option *option; + const char *result; + + API_INIT_FUNC(1, "config_string_inherited", API_RETURN_EMPTY); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) + API_WRONG_ARGS(API_RETURN_EMPTY); + + option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + + result = weechat_config_string_inherited (option); + + API_RETURN_STRING(result); +} + API_FUNC(config_color) { zend_string *z_option; @@ -1781,6 +1832,23 @@ API_FUNC(config_color_default) API_RETURN_STRING(result); } +API_FUNC(config_color_inherited) +{ + zend_string *z_option; + struct t_config_option *option; + const char *result; + + API_INIT_FUNC(1, "config_color_inherited", API_RETURN_EMPTY); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) + API_WRONG_ARGS(API_RETURN_EMPTY); + + option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + + result = weechat_config_color_inherited (option); + + API_RETURN_STRING(result); +} + API_FUNC(config_enum) { zend_string *z_option; @@ -1815,6 +1883,23 @@ API_FUNC(config_enum_default) API_RETURN_INT(result); } +API_FUNC(config_enum_inherited) +{ + zend_string *z_option; + struct t_config_option *option; + int result; + + API_INIT_FUNC(1, "config_enum_inherited", API_RETURN_INT(0)); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_option) == FAILURE) + API_WRONG_ARGS(API_RETURN_INT(0)); + + option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + + result = weechat_config_enum_inherited (option); + + API_RETURN_INT(result); +} + API_FUNC(config_write_option) { zend_string *z_config_file, *z_option; diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h index 40b8dd1aa..240053c4e 100644 --- a/src/plugins/php/weechat-php-api.h +++ b/src/plugins/php/weechat-php-api.h @@ -102,14 +102,19 @@ PHP_FUNCTION(weechat_config_option_is_null); PHP_FUNCTION(weechat_config_option_default_is_null); PHP_FUNCTION(weechat_config_boolean); PHP_FUNCTION(weechat_config_boolean_default); +PHP_FUNCTION(weechat_config_boolean_inherited); PHP_FUNCTION(weechat_config_integer); PHP_FUNCTION(weechat_config_integer_default); +PHP_FUNCTION(weechat_config_integer_inherited); PHP_FUNCTION(weechat_config_string); PHP_FUNCTION(weechat_config_string_default); +PHP_FUNCTION(weechat_config_string_inherited); PHP_FUNCTION(weechat_config_color); PHP_FUNCTION(weechat_config_color_default); +PHP_FUNCTION(weechat_config_color_inherited); PHP_FUNCTION(weechat_config_enum); PHP_FUNCTION(weechat_config_enum_default); +PHP_FUNCTION(weechat_config_enum_inherited); PHP_FUNCTION(weechat_config_write_option); PHP_FUNCTION(weechat_config_write_line); PHP_FUNCTION(weechat_config_write); diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 5324d8320..d17aba86f 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -160,14 +160,19 @@ const zend_function_entry weechat_functions[] = { PHP_FE(weechat_config_option_default_is_null, arginfo_weechat_config_option_default_is_null) PHP_FE(weechat_config_boolean, arginfo_weechat_config_boolean) PHP_FE(weechat_config_boolean_default, arginfo_weechat_config_boolean_default) + PHP_FE(weechat_config_boolean_inherited, arginfo_weechat_config_boolean_inherited) PHP_FE(weechat_config_integer, arginfo_weechat_config_integer) PHP_FE(weechat_config_integer_default, arginfo_weechat_config_integer_default) + PHP_FE(weechat_config_integer_inherited, arginfo_weechat_config_integer_inherited) PHP_FE(weechat_config_string, arginfo_weechat_config_string) PHP_FE(weechat_config_string_default, arginfo_weechat_config_string_default) + PHP_FE(weechat_config_string_inherited, arginfo_weechat_config_string_inherited) PHP_FE(weechat_config_color, arginfo_weechat_config_color) PHP_FE(weechat_config_color_default, arginfo_weechat_config_color_default) + PHP_FE(weechat_config_color_inherited, arginfo_weechat_config_color_inherited) PHP_FE(weechat_config_enum, arginfo_weechat_config_enum) PHP_FE(weechat_config_enum_default, arginfo_weechat_config_enum_default) + PHP_FE(weechat_config_enum_inherited, arginfo_weechat_config_enum_inherited) PHP_FE(weechat_config_write_option, arginfo_weechat_config_write_option) PHP_FE(weechat_config_write_line, arginfo_weechat_config_write_line) PHP_FE(weechat_config_write, arginfo_weechat_config_write) diff --git a/src/plugins/php/weechat-php.stub.php b/src/plugins/php/weechat-php.stub.php index 32ef0dcca..5ed87ae77 100644 --- a/src/plugins/php/weechat-php.stub.php +++ b/src/plugins/php/weechat-php.stub.php @@ -68,14 +68,19 @@ function weechat_config_option_is_null(string $p0): int {} function weechat_config_option_default_is_null(string $p0): int {} function weechat_config_boolean(string $p0): int {} function weechat_config_boolean_default(string $p0): int {} +function weechat_config_boolean_inherited(string $p0): int {} function weechat_config_integer(string $p0): int {} function weechat_config_integer_default(string $p0): int {} +function weechat_config_integer_inherited(string $p0): int {} function weechat_config_string(string $p0): string {} function weechat_config_string_default(string $p0): string {} +function weechat_config_string_inherited(string $p0): string {} function weechat_config_color(string $p0): string {} function weechat_config_color_default(string $p0): string {} +function weechat_config_color_inherited(string $p0): string {} function weechat_config_enum(string $p0): int {} function weechat_config_enum_default(string $p0): int {} +function weechat_config_enum_inherited(string $p0): int {} function weechat_config_write_option(string $p0, string $p1): int {} function weechat_config_write_line(string $p0, string $p1, string $p2): int {} function weechat_config_write(string $p0): int {} diff --git a/src/plugins/php/weechat-php_arginfo.h b/src/plugins/php/weechat-php_arginfo.h index 225a00abe..a4d83439f 100644 --- a/src/plugins/php/weechat-php_arginfo.h +++ b/src/plugins/php/weechat-php_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 2c52caa5a78009856a6e6ced63555d1b1e2be0fe */ + * Stub hash: 59292da89eab98ef1f615c173d9722b9fdafad80 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_register, 0, 7, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0) @@ -173,22 +173,32 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_config_boolean_default arginfo_weechat_charset_set +#define arginfo_weechat_config_boolean_inherited arginfo_weechat_charset_set + #define arginfo_weechat_config_integer arginfo_weechat_charset_set #define arginfo_weechat_config_integer_default arginfo_weechat_charset_set +#define arginfo_weechat_config_integer_inherited arginfo_weechat_charset_set + #define arginfo_weechat_config_string arginfo_weechat_plugin_get_name #define arginfo_weechat_config_string_default arginfo_weechat_plugin_get_name +#define arginfo_weechat_config_string_inherited arginfo_weechat_plugin_get_name + #define arginfo_weechat_config_color arginfo_weechat_plugin_get_name #define arginfo_weechat_config_color_default arginfo_weechat_plugin_get_name +#define arginfo_weechat_config_color_inherited arginfo_weechat_plugin_get_name + #define arginfo_weechat_config_enum arginfo_weechat_charset_set #define arginfo_weechat_config_enum_default arginfo_weechat_charset_set +#define arginfo_weechat_config_enum_inherited arginfo_weechat_charset_set + #define arginfo_weechat_config_write_option arginfo_weechat_string_has_highlight ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_config_write_line, 0, 3, IS_LONG, 0) diff --git a/src/plugins/php/weechat-php_legacy_arginfo.h b/src/plugins/php/weechat-php_legacy_arginfo.h index 9b620112b..224fe77f8 100644 --- a/src/plugins/php/weechat-php_legacy_arginfo.h +++ b/src/plugins/php/weechat-php_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 2c52caa5a78009856a6e6ced63555d1b1e2be0fe */ + * Stub hash: 59292da89eab98ef1f615c173d9722b9fdafad80 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_register, 0, 0, 7) ZEND_ARG_INFO(0, p0) @@ -138,22 +138,32 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_config_boolean_default arginfo_weechat_plugin_get_name +#define arginfo_weechat_config_boolean_inherited arginfo_weechat_plugin_get_name + #define arginfo_weechat_config_integer arginfo_weechat_plugin_get_name #define arginfo_weechat_config_integer_default arginfo_weechat_plugin_get_name +#define arginfo_weechat_config_integer_inherited arginfo_weechat_plugin_get_name + #define arginfo_weechat_config_string arginfo_weechat_plugin_get_name #define arginfo_weechat_config_string_default arginfo_weechat_plugin_get_name +#define arginfo_weechat_config_string_inherited arginfo_weechat_plugin_get_name + #define arginfo_weechat_config_color arginfo_weechat_plugin_get_name #define arginfo_weechat_config_color_default arginfo_weechat_plugin_get_name +#define arginfo_weechat_config_color_inherited arginfo_weechat_plugin_get_name + #define arginfo_weechat_config_enum arginfo_weechat_plugin_get_name #define arginfo_weechat_config_enum_default arginfo_weechat_plugin_get_name +#define arginfo_weechat_config_enum_inherited arginfo_weechat_plugin_get_name + #define arginfo_weechat_config_write_option arginfo_weechat_iconv_to_internal #define arginfo_weechat_config_write_line arginfo_weechat_ngettext diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 12edccb3f..ada30e87d 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -761,14 +761,19 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv) new_plugin->config_option_is_null = &config_file_option_is_null; new_plugin->config_option_default_is_null = &config_file_option_default_is_null; new_plugin->config_boolean = &config_file_option_boolean; + new_plugin->config_boolean_inherited = &config_file_option_boolean_inherited; new_plugin->config_boolean_default = &config_file_option_boolean_default; new_plugin->config_integer = &config_file_option_integer; + new_plugin->config_integer_inherited = &config_file_option_integer_inherited; new_plugin->config_integer_default = &config_file_option_integer_default; new_plugin->config_enum = &config_file_option_enum; + new_plugin->config_enum_inherited = &config_file_option_enum_inherited; new_plugin->config_enum_default = &config_file_option_enum_default; new_plugin->config_string = &config_file_option_string; + new_plugin->config_string_inherited = &config_file_option_string_inherited; new_plugin->config_string_default = &config_file_option_string_default; new_plugin->config_color = &config_file_option_color; + new_plugin->config_color_inherited = &config_file_option_color_inherited; new_plugin->config_color_default = &config_file_option_color_default; new_plugin->config_write_option = &config_file_write_option; new_plugin->config_write_line = &config_file_write_line; diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index d4a1118c4..298db8ff1 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -1573,6 +1573,21 @@ API_FUNC(config_boolean_default) API_RETURN_INT(value); } +API_FUNC(config_boolean_inherited) +{ + char *option; + int value; + + API_INIT_FUNC(1, "config_boolean_inherited", API_RETURN_INT(0)); + option = NULL; + if (!PyArg_ParseTuple (args, "s", &option)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_config_boolean_inherited (API_STR2PTR(option)); + + API_RETURN_INT(value); +} + API_FUNC(config_integer) { char *option; @@ -1603,6 +1618,21 @@ API_FUNC(config_integer_default) API_RETURN_INT(value); } +API_FUNC(config_integer_inherited) +{ + char *option; + int value; + + API_INIT_FUNC(1, "config_integer_inherited", API_RETURN_INT(0)); + option = NULL; + if (!PyArg_ParseTuple (args, "s", &option)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_config_integer_inherited (API_STR2PTR(option)); + + API_RETURN_INT(value); +} + API_FUNC(config_string) { char *option; @@ -1633,6 +1663,21 @@ API_FUNC(config_string_default) API_RETURN_STRING(result); } +API_FUNC(config_string_inherited) +{ + char *option; + const char *result; + + API_INIT_FUNC(1, "config_string_inherited", API_RETURN_EMPTY); + option = NULL; + if (!PyArg_ParseTuple (args, "s", &option)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_config_string_inherited (API_STR2PTR(option)); + + API_RETURN_STRING(result); +} + API_FUNC(config_color) { char *option; @@ -1663,6 +1708,21 @@ API_FUNC(config_color_default) API_RETURN_STRING(result); } +API_FUNC(config_color_inherited) +{ + char *option; + const char *result; + + API_INIT_FUNC(1, "config_color_inherited", API_RETURN_EMPTY); + option = NULL; + if (!PyArg_ParseTuple (args, "s", &option)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_config_color_inherited (API_STR2PTR(option)); + + API_RETURN_STRING(result); +} + API_FUNC(config_enum) { char *option; @@ -1693,6 +1753,21 @@ API_FUNC(config_enum_default) API_RETURN_INT(value); } +API_FUNC(config_enum_inherited) +{ + char *option; + int value; + + API_INIT_FUNC(1, "config_enum_inherited", API_RETURN_INT(0)); + option = NULL; + if (!PyArg_ParseTuple (args, "s", &option)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_config_enum_inherited (API_STR2PTR(option)); + + API_RETURN_INT(value); +} + API_FUNC(config_write_option) { char *config_file, *option; @@ -5591,14 +5666,19 @@ PyMethodDef weechat_python_funcs[] = API_DEF_FUNC(config_option_default_is_null), API_DEF_FUNC(config_boolean), API_DEF_FUNC(config_boolean_default), + API_DEF_FUNC(config_boolean_inherited), API_DEF_FUNC(config_integer), API_DEF_FUNC(config_integer_default), + API_DEF_FUNC(config_integer_inherited), API_DEF_FUNC(config_string), API_DEF_FUNC(config_string_default), + API_DEF_FUNC(config_string_inherited), API_DEF_FUNC(config_color), API_DEF_FUNC(config_color_default), + API_DEF_FUNC(config_color_inherited), API_DEF_FUNC(config_enum), API_DEF_FUNC(config_enum_default), + API_DEF_FUNC(config_enum_inherited), API_DEF_FUNC(config_write_option), API_DEF_FUNC(config_write_line), API_DEF_FUNC(config_write), diff --git a/src/plugins/python/weechat.pyi b/src/plugins/python/weechat.pyi index 56807119b..cee9dc069 100644 --- a/src/plugins/python/weechat.pyi +++ b/src/plugins/python/weechat.pyi @@ -795,6 +795,17 @@ def config_boolean_default(option: str) -> int: ... +def config_boolean_inherited(option: str) -> int: + """`config_boolean_inherited in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_config_boolean_inherited>`_ + :: + + # example + option = weechat.config_get("irc.server.libera.autoconnect") + autoconect = weechat.config_boolean_inherited(option) + """ + ... + + def config_integer(option: str) -> int: """`config_integer in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_config_integer>`_ :: @@ -817,6 +828,17 @@ def config_integer_default(option: str) -> int: ... +def config_integer_inherited(option: str) -> int: + """`config_integer_inherited in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_config_integer_inherited>`_ + :: + + # example + option = weechat.config_get("irc.server.libera.autojoin_delay") + delay = weechat.config_integer_inherited(option) + """ + ... + + def config_string(option: str) -> str: """`config_string in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_config_string>`_ :: @@ -839,13 +861,24 @@ def config_string_default(option: str) -> str: ... +def config_string_inherited(option: str) -> str: + """`config_string_inherited in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_config_string_inherited>`_ + :: + + # example + option = weechat.config_get("irc.server.libera.msg_quit") + msg_quit = weechat.config_string_inherited(option) + """ + ... + + def config_color(option: str) -> str: """`config_color in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_config_color>`_ :: # example option = weechat.config_get("plugin.section.option") - value = weechat.config_color(option) + color = weechat.config_color(option) """ ... @@ -856,7 +889,18 @@ def config_color_default(option: str) -> str: # example option = weechat.config_get("plugin.section.option") - value = weechat.config_color_default(option) + color = weechat.config_color_default(option) + """ + ... + + +def config_color_inherited(option: str) -> str: + """`config_color_inherited in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_config_color_inherited>`_ + :: + + # example + option = weechat.config_get("plugin.section.option") + color = weechat.config_color_inherited(option) """ ... @@ -883,6 +927,17 @@ def config_enum_default(option: str) -> int: ... +def config_enum_inherited(option: str) -> int: + """`config_enum_inherited in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_config_enum_inherited>`_ + :: + + # example + option = weechat.config_get("irc.server.libera.sasl_fail") + sasl_fail = weechat.config_enum_inherited(option) + """ + ... + + def config_write_option(config_file: str, option: str) -> int: """`config_write_option in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_config_write_option>`_ :: diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 7d31d374c..8d840641d 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -1933,6 +1933,25 @@ weechat_ruby_api_config_boolean_default (VALUE class, VALUE option) } static VALUE +weechat_ruby_api_config_boolean_inherited (VALUE class, VALUE option) +{ + char *c_option; + int value; + + API_INIT_FUNC(1, "config_boolean_inherited", API_RETURN_INT(0)); + if (NIL_P (option)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + Check_Type (option, T_STRING); + + c_option = StringValuePtr (option); + + value = weechat_config_boolean_inherited (API_STR2PTR(c_option)); + + API_RETURN_INT(value); +} + +static VALUE weechat_ruby_api_config_integer (VALUE class, VALUE option) { char *c_option; @@ -1971,6 +1990,25 @@ weechat_ruby_api_config_integer_default (VALUE class, VALUE option) } static VALUE +weechat_ruby_api_config_integer_inherited (VALUE class, VALUE option) +{ + char *c_option; + int value; + + API_INIT_FUNC(1, "config_integer_inherited", API_RETURN_INT(0)); + if (NIL_P (option)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + Check_Type (option, T_STRING); + + c_option = StringValuePtr (option); + + value = weechat_config_integer_inherited (API_STR2PTR(c_option)); + + API_RETURN_INT(value); +} + +static VALUE weechat_ruby_api_config_string (VALUE class, VALUE option) { char *c_option; @@ -2009,6 +2047,25 @@ weechat_ruby_api_config_string_default (VALUE class, VALUE option) } static VALUE +weechat_ruby_api_config_string_inherited (VALUE class, VALUE option) +{ + char *c_option; + const char *result; + + API_INIT_FUNC(1, "config_string_inherited", API_RETURN_EMPTY); + if (NIL_P (option)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + Check_Type (option, T_STRING); + + c_option = StringValuePtr (option); + + result = weechat_config_string_inherited (API_STR2PTR(c_option)); + + API_RETURN_STRING(result); +} + +static VALUE weechat_ruby_api_config_color (VALUE class, VALUE option) { char *c_option; @@ -2047,6 +2104,25 @@ weechat_ruby_api_config_color_default (VALUE class, VALUE option) } static VALUE +weechat_ruby_api_config_color_inherited (VALUE class, VALUE option) +{ + char *c_option; + const char *result; + + API_INIT_FUNC(1, "config_color_inherited", API_RETURN_EMPTY); + if (NIL_P (option)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + Check_Type (option, T_STRING); + + c_option = StringValuePtr (option); + + result = weechat_config_color_inherited (API_STR2PTR(c_option)); + + API_RETURN_STRING(result); +} + +static VALUE weechat_ruby_api_config_enum (VALUE class, VALUE option) { char *c_option; @@ -2085,6 +2161,25 @@ weechat_ruby_api_config_enum_default (VALUE class, VALUE option) } static VALUE +weechat_ruby_api_config_enum_inherited (VALUE class, VALUE option) +{ + char *c_option; + int value; + + API_INIT_FUNC(1, "config_enum_inherited", API_RETURN_INT(0)); + if (NIL_P (option)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + Check_Type (option, T_STRING); + + c_option = StringValuePtr (option); + + value = weechat_config_enum_inherited (API_STR2PTR(c_option)); + + API_RETURN_INT(value); +} + +static VALUE weechat_ruby_api_config_write_option (VALUE class, VALUE config_file, VALUE option) { @@ -6935,13 +7030,18 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) API_DEF_FUNC(config_option_default_is_null, 1); API_DEF_FUNC(config_boolean, 1); API_DEF_FUNC(config_boolean_default, 1); + API_DEF_FUNC(config_boolean_inherited, 1); API_DEF_FUNC(config_integer, 1); API_DEF_FUNC(config_integer_default, 1); + API_DEF_FUNC(config_integer_inherited, 1); API_DEF_FUNC(config_string, 1); API_DEF_FUNC(config_string_default, 1); + API_DEF_FUNC(config_string_inherited, 1); API_DEF_FUNC(config_color, 1); API_DEF_FUNC(config_color_default, 1); + API_DEF_FUNC(config_color_inherited, 1); API_DEF_FUNC(config_enum, 1); + API_DEF_FUNC(config_enum_inherited, 1); API_DEF_FUNC(config_enum_default, 1); API_DEF_FUNC(config_write_option, 2); API_DEF_FUNC(config_write_line, 3); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index b05a0b7da..eadb740f3 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -1644,6 +1644,19 @@ API_FUNC(config_boolean_default) API_RETURN_INT(result); } +API_FUNC(config_boolean_inherited) +{ + int result; + + API_INIT_FUNC(1, "config_boolean_inherited", API_RETURN_INT(0)); + if (objc < 2) + API_WRONG_ARGS(API_RETURN_INT(0)); + + result = weechat_config_boolean_inherited (API_STR2PTR(Tcl_GetString (objv[1]))); /* option */ + + API_RETURN_INT(result); +} + API_FUNC(config_integer) { int result; @@ -1670,6 +1683,19 @@ API_FUNC(config_integer_default) API_RETURN_INT(result); } +API_FUNC(config_integer_inherited) +{ + int result; + + API_INIT_FUNC(1, "config_integer_inherited", API_RETURN_INT(0)); + if (objc < 2) + API_WRONG_ARGS(API_RETURN_INT(0)); + + result = weechat_config_integer_inherited (API_STR2PTR(Tcl_GetString (objv[1]))); /* option */ + + API_RETURN_INT(result); +} + API_FUNC(config_string) { const char *result; @@ -1696,6 +1722,19 @@ API_FUNC(config_string_default) API_RETURN_STRING(result); } +API_FUNC(config_string_inherited) +{ + const char *result; + + API_INIT_FUNC(1, "config_string_inherited", API_RETURN_EMPTY); + if (objc < 2) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_config_string_inherited (API_STR2PTR(Tcl_GetString (objv[1]))); /* option */ + + API_RETURN_STRING(result); +} + API_FUNC(config_color) { const char *result; @@ -1722,6 +1761,19 @@ API_FUNC(config_color_default) API_RETURN_STRING(result); } +API_FUNC(config_color_inherited) +{ + const char *result; + + API_INIT_FUNC(1, "config_color_inherited", API_RETURN_EMPTY); + if (objc < 2) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_config_color_inherited (API_STR2PTR(Tcl_GetString (objv[1]))); /* option */ + + API_RETURN_STRING(result); +} + API_FUNC(config_enum) { int result; @@ -1748,6 +1800,19 @@ API_FUNC(config_enum_default) API_RETURN_INT(result); } +API_FUNC(config_enum_inherited) +{ + int result; + + API_INIT_FUNC(1, "config_enum_inherited", API_RETURN_INT(0)); + if (objc < 2) + API_WRONG_ARGS(API_RETURN_INT(0)); + + result = weechat_config_enum_inherited (API_STR2PTR(Tcl_GetString (objv[1]))); /* option */ + + API_RETURN_INT(result); +} + API_FUNC(config_write_option) { char *config_file, *option; @@ -5700,13 +5765,18 @@ void weechat_tcl_api_init (Tcl_Interp *interp) API_DEF_FUNC(config_option_default_is_null); API_DEF_FUNC(config_boolean); API_DEF_FUNC(config_boolean_default); + API_DEF_FUNC(config_boolean_inherited); API_DEF_FUNC(config_integer); API_DEF_FUNC(config_integer_default); + API_DEF_FUNC(config_integer_inherited); API_DEF_FUNC(config_string); API_DEF_FUNC(config_string_default); + API_DEF_FUNC(config_string_inherited); API_DEF_FUNC(config_color); API_DEF_FUNC(config_color_default); + API_DEF_FUNC(config_color_inherited); API_DEF_FUNC(config_enum); + API_DEF_FUNC(config_enum_inherited); API_DEF_FUNC(config_enum_default); API_DEF_FUNC(config_write_option); API_DEF_FUNC(config_write_line); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 3711fab1d..26733e8c2 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -71,7 +71,7 @@ struct timeval; * please change the date with current one; for a second change at same * date, increment the 01, otherwise please keep 01. */ -#define WEECHAT_PLUGIN_API_VERSION "20240114-01" +#define WEECHAT_PLUGIN_API_VERSION "20240304-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -660,14 +660,19 @@ struct t_weechat_plugin int (*config_option_is_null) (struct t_config_option *option); int (*config_option_default_is_null) (struct t_config_option *option); int (*config_boolean) (struct t_config_option *option); + int (*config_boolean_inherited) (struct t_config_option *option); int (*config_boolean_default) (struct t_config_option *option); int (*config_integer) (struct t_config_option *option); + int (*config_integer_inherited) (struct t_config_option *option); int (*config_integer_default) (struct t_config_option *option); int (*config_enum) (struct t_config_option *option); + int (*config_enum_inherited) (struct t_config_option *option); int (*config_enum_default) (struct t_config_option *option); const char *(*config_string) (struct t_config_option *option); + const char *(*config_string_inherited) (struct t_config_option *option); const char *(*config_string_default) (struct t_config_option *option); const char *(*config_color) (struct t_config_option *option); + const char *(*config_color_inherited) (struct t_config_option *option); const char *(*config_color_default) (struct t_config_option *option); int (*config_write_option) (struct t_config_file *config_file, struct t_config_option *option); @@ -1740,22 +1745,32 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); (weechat_plugin->config_option_default_is_null)(__option) #define weechat_config_boolean(__option) \ (weechat_plugin->config_boolean)(__option) +#define weechat_config_boolean_inherited(__option) \ + (weechat_plugin->config_boolean_inherited)(__option) #define weechat_config_boolean_default(__option) \ (weechat_plugin->config_boolean_default)(__option) #define weechat_config_integer(__option) \ (weechat_plugin->config_integer)(__option) +#define weechat_config_integer_inherited(__option) \ + (weechat_plugin->config_integer_inherited)(__option) #define weechat_config_integer_default(__option) \ (weechat_plugin->config_integer_default)(__option) #define weechat_config_enum(__option) \ (weechat_plugin->config_enum)(__option) +#define weechat_config_enum_inherited(__option) \ + (weechat_plugin->config_enum_inherited)(__option) #define weechat_config_enum_default(__option) \ (weechat_plugin->config_enum_default)(__option) #define weechat_config_string(__option) \ (weechat_plugin->config_string)(__option) +#define weechat_config_string_inherited(__option) \ + (weechat_plugin->config_string_inherited)(__option) #define weechat_config_string_default(__option) \ (weechat_plugin->config_string_default)(__option) #define weechat_config_color(__option) \ (weechat_plugin->config_color)(__option) +#define weechat_config_color_inherited(__option) \ + (weechat_plugin->config_color_inherited)(__option) #define weechat_config_color_default(__option) \ (weechat_plugin->config_color_default)(__option) #define weechat_config_write_option(__config, __option) \ diff --git a/tests/scripts/python/testapi.py b/tests/scripts/python/testapi.py index 4cbe6ddab..06745a9a6 100644 --- a/tests/scripts/python/testapi.py +++ b/tests/scripts/python/testapi.py @@ -199,10 +199,8 @@ def option_delete_cb(data, option): def test_config(): """Test config functions.""" # config - ptr_config = weechat.config_new( - 'test_config_' + '{SCRIPT_LANGUAGE}', - 'config_reload_cb', 'config_reload_data', - ) + ptr_config = weechat.config_new('test_config_' + '{SCRIPT_LANGUAGE}', + 'config_reload_cb', 'config_reload_data') check(ptr_config != '') # set version weechat.config_set_version(ptr_config, 2, @@ -237,6 +235,18 @@ def test_config(): check(weechat.config_option_reset(ptr_opt_bool, 1) == 2) # SET_OK_CHANGED check(weechat.config_option_reset(ptr_opt_bool, 1) == 1) # SET_OK_SAME_VALUE check(weechat.config_boolean(ptr_opt_bool) == 1) + # boolean option with parent option + ptr_opt_bool_child = weechat.config_new_option( + ptr_config, ptr_section, + 'option_bool_child << test_config_' + '{SCRIPT_LANGUAGE}' + '.section1.option_bool', + 'boolean', 'bool option', '', 0, 0, None, None, 1, + 'option_check_value_cb', '', + 'option_change_cb', '', + 'option_delete_cb', '', + ) + check(ptr_opt_bool_child != '') + check(weechat.config_boolean(ptr_opt_bool_child) == 0) + check(weechat.config_boolean_inherited(ptr_opt_bool_child) == 1) # integer option ptr_opt_int = weechat.config_new_option( ptr_config, ptr_section, 'option_int', 'integer', 'int option', @@ -254,6 +264,18 @@ def test_config(): check(weechat.config_option_reset(ptr_opt_int, 1) == 2) # SET_OK_CHANGED check(weechat.config_option_reset(ptr_opt_int, 1) == 1) # SET_OK_SAME_VALUE check(weechat.config_integer(ptr_opt_int) == 2) + # integer option with parent option + ptr_opt_int_child = weechat.config_new_option( + ptr_config, ptr_section, + 'option_int_child << test_config_' + '{SCRIPT_LANGUAGE}' + '.section1.option_int', + 'integer', 'int option', '', 0, 256, None, None, 1, + 'option_check_value_cb', '', + 'option_change_cb', '', + 'option_delete_cb', '', + ) + check(ptr_opt_int_child != '') + check(weechat.config_integer(ptr_opt_int_child) == 0) + check(weechat.config_integer_inherited(ptr_opt_int_child) == 2) # integer option (with string values: enum with WeeChat >= 4.1.0) ptr_opt_int_str = weechat.config_new_option( ptr_config, ptr_section, 'option_int_str', 'integer', 'int option str', @@ -275,6 +297,19 @@ def test_config(): check(weechat.config_option_reset(ptr_opt_int_str, 1) == 1) # SET_OK_SAME_VALUE check(weechat.config_integer(ptr_opt_int_str) == 1) check(weechat.config_string(ptr_opt_int_str) == 'val2') + # integer option with parent option (with string values: enum with WeeChat >= 4.1.0) + ptr_opt_int_str_child = weechat.config_new_option( + ptr_config, ptr_section, + 'option_int_str_child << test_config_' + '{SCRIPT_LANGUAGE}' + '.section1.option_int_str', + 'integer', 'int option str', + 'val1|val2|val3', 0, 0, None, None, 1, + 'option_check_value_cb', '', + 'option_change_cb', '', + 'option_delete_cb', '', + ) + check(ptr_opt_int_str_child != '') + check(weechat.config_integer(ptr_opt_int_str_child) == 0) + check(weechat.config_integer_inherited(ptr_opt_int_str_child) == 1) # string option ptr_opt_str = weechat.config_new_option( ptr_config, ptr_section, 'option_str', 'string', 'str option', @@ -301,6 +336,18 @@ def test_config(): check(weechat.config_option_unset(ptr_opt_str) == 0) # UNSET_OK_NO_RESET check(weechat.config_string(ptr_opt_str) == 'value') check(weechat.config_option_default_is_null(ptr_opt_str) == 0) + # string option with parent option + ptr_opt_str_child = weechat.config_new_option( + ptr_config, ptr_section, + 'option_str_child << test_config_' + '{SCRIPT_LANGUAGE}' + '.section1.option_str', + 'string', 'str option', '', 0, 0, None, None, 1, + 'option_check_value_cb', '', + 'option_change_cb', '', + 'option_delete_cb', '', + ) + check(ptr_opt_str_child != '') + check(weechat.config_string(ptr_opt_str_child) == '') + check(weechat.config_string_inherited(ptr_opt_str_child) == 'value') # color option ptr_opt_col = weechat.config_new_option( ptr_config, ptr_section, 'option_col', 'color', 'col option', @@ -318,6 +365,18 @@ def test_config(): check(weechat.config_option_reset(ptr_opt_col, 1) == 2) # SET_OK_CHANGED check(weechat.config_option_reset(ptr_opt_col, 1) == 1) # SET_OK_SAME_VALUE check(weechat.config_color(ptr_opt_col) == 'lightgreen') + # color option with parent option + ptr_opt_col_child = weechat.config_new_option( + ptr_config, ptr_section, + 'option_col_child << test_config_' + '{SCRIPT_LANGUAGE}' + '.section1.option_col', + 'color', 'col option', '', 0, 0, None, None, 1, + 'option_check_value_cb', '', + 'option_change_cb', '', + 'option_delete_cb', '', + ) + check(ptr_opt_col_child != '') + check(weechat.config_color(ptr_opt_col_child) == '') + check(weechat.config_color_inherited(ptr_opt_col_child) == 'lightgreen') # enum option ptr_opt_enum = weechat.config_new_option( ptr_config, ptr_section, 'option_enum', 'enum', 'enum option', @@ -343,6 +402,18 @@ def test_config(): check(weechat.config_enum(ptr_opt_enum) == 1) check(weechat.config_integer(ptr_opt_enum) == 1) check(weechat.config_string(ptr_opt_enum) == 'val2') + # enum option with parent option + ptr_opt_enum_child = weechat.config_new_option( + ptr_config, ptr_section, + 'option_enum_child << test_config_' + '{SCRIPT_LANGUAGE}' + '.section1.option_enum', + 'enum', 'enum option', 'val1|val2|val3', 0, 0, None, None, 1, + 'option_check_value_cb', '', + 'option_change_cb', '', + 'option_delete_cb', '', + ) + check(ptr_opt_enum_child != '') + check(weechat.config_enum(ptr_opt_enum_child) == 0) + check(weechat.config_enum_inherited(ptr_opt_enum_child) == 1) # search option ptr_opt_bool2 = weechat.config_search_option(ptr_config, ptr_section, 'option_bool') diff --git a/tests/unit/core/test-core-config-file.cpp b/tests/unit/core/test-core-config-file.cpp index d55aeebb3..44ac72e3a 100644 --- a/tests/unit/core/test-core-config-file.cpp +++ b/tests/unit/core/test-core-config-file.cpp @@ -41,11 +41,17 @@ extern const char *config_file_option_escape (const char *name); } struct t_config_option *ptr_option_bool = NULL; +struct t_config_option *ptr_option_bool_child = NULL; struct t_config_option *ptr_option_int = NULL; +struct t_config_option *ptr_option_int_child = NULL; struct t_config_option *ptr_option_int_str = NULL; +struct t_config_option *ptr_option_int_str_child = NULL; struct t_config_option *ptr_option_str = NULL; +struct t_config_option *ptr_option_str_child = NULL; struct t_config_option *ptr_option_col = NULL; +struct t_config_option *ptr_option_col_child = NULL; struct t_config_option *ptr_option_enum = NULL; +struct t_config_option *ptr_option_enum_child = NULL; TEST_GROUP(CoreConfigFile) { @@ -74,12 +80,26 @@ TEST_GROUP(CoreConfigFileWithNewOptions) NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ptr_option_bool_child = config_file_new_option ( + weechat_config_file, weechat_config_section_look, + "test_boolean_child << weechat.look.test_boolean", + "boolean", "", NULL, 0, 0, NULL, NULL, 1, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); ptr_option_int = config_file_new_option ( weechat_config_file, weechat_config_section_look, "test_integer", "integer", "", NULL, 0, 123456, "100", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ptr_option_int_child = config_file_new_option ( + weechat_config_file, weechat_config_section_look, + "test_integer_child << weechat.look.test_integer", + "integer", "", NULL, 0, 123456, NULL, NULL, 1, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); /* auto-created as enum with WeeChat >= 4.1.0 */ ptr_option_int_str = config_file_new_option ( weechat_config_file, weechat_config_section_look, @@ -87,40 +107,80 @@ TEST_GROUP(CoreConfigFileWithNewOptions) NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ptr_option_int_str_child = config_file_new_option ( + weechat_config_file, weechat_config_section_look, + "test_integer_values_child << weechat.look.test_integer_values", + "integer", "", "v1|v2|v3", 0, 0, NULL, NULL, 1, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); ptr_option_str = config_file_new_option ( weechat_config_file, weechat_config_section_look, "test_string", "string", "", NULL, 0, 0, "value", NULL, 0, &option_str_check_cb, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ptr_option_str_child = config_file_new_option ( + weechat_config_file, weechat_config_section_look, + "test_string_child << weechat.look.test_string", + "string", "", NULL, 0, 0, NULL, NULL, 1, + &option_str_check_cb, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); ptr_option_col = config_file_new_option ( weechat_config_file, weechat_config_section_color, "test_color", "color", "", NULL, 0, 0, "blue", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ptr_option_col_child = config_file_new_option ( + weechat_config_file, weechat_config_section_color, + "test_color_child << weechat.color.test_color", + "color", "", NULL, 0, 0, NULL, NULL, 1, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); ptr_option_enum = config_file_new_option ( weechat_config_file, weechat_config_section_look, "test_enum", "enum", "", "v1|v2|v3", 0, 0, "v2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ptr_option_enum_child = config_file_new_option ( + weechat_config_file, weechat_config_section_look, + "test_enum_child << weechat.look.test_enum", + "enum", "", "v1|v2|v3", 0, 0, NULL, NULL, 1, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); } void teardown () { config_file_option_free (ptr_option_bool, 0); ptr_option_bool = NULL; + config_file_option_free (ptr_option_bool_child, 0); + ptr_option_bool_child = NULL; config_file_option_free (ptr_option_int, 0); ptr_option_int = NULL; + config_file_option_free (ptr_option_int_child, 0); + ptr_option_int_child = NULL; config_file_option_free (ptr_option_int_str, 0); ptr_option_int_str = NULL; + config_file_option_free (ptr_option_int_str_child, 0); + ptr_option_int_str_child = NULL; config_file_option_free (ptr_option_str, 0); ptr_option_str = NULL; + config_file_option_free (ptr_option_str_child, 0); + ptr_option_str_child = NULL; config_file_option_free (ptr_option_col, 0); ptr_option_col = NULL; + config_file_option_free (ptr_option_col_child, 0); + ptr_option_col_child = NULL; config_file_option_free (ptr_option_enum, 0); ptr_option_enum = NULL; + config_file_option_free (ptr_option_enum_child, 0); + ptr_option_enum_child = NULL; } }; @@ -1148,6 +1208,22 @@ TEST(CoreConfigFileWithNewOptions, OptionBoolean) /* * Tests functions: + * config_file_option_boolean_inherited + */ + +TEST(CoreConfigFileWithNewOptions, OptionBooleanInherited) +{ + LONGS_EQUAL(0, config_file_option_boolean_inherited (NULL)); + + LONGS_EQUAL(0, config_file_option_boolean_inherited (ptr_option_bool_child)); + config_file_option_set (ptr_option_bool, "on", 1); + LONGS_EQUAL(1, config_file_option_boolean_inherited (ptr_option_bool_child)); + config_file_option_reset (ptr_option_bool, 1); + LONGS_EQUAL(0, config_file_option_boolean_inherited (ptr_option_bool_child)); +} + +/* + * Tests functions: * config_file_option_integer * config_file_option_integer_default */ @@ -1185,6 +1261,22 @@ TEST(CoreConfigFileWithNewOptions, OptionInteger) /* * Tests functions: + * config_file_option_integer_inherited + */ + +TEST(CoreConfigFileWithNewOptions, OptionIntegerInherited) +{ + LONGS_EQUAL(0, config_file_option_integer_inherited (NULL)); + + LONGS_EQUAL(100, config_file_option_integer_inherited (ptr_option_int_child)); + config_file_option_set (ptr_option_int, "123", 1); + LONGS_EQUAL(123, config_file_option_integer_inherited (ptr_option_int_child)); + config_file_option_reset (ptr_option_int, 1); + LONGS_EQUAL(100, config_file_option_integer_inherited (ptr_option_int_child)); +} + +/* + * Tests functions: * config_file_option_string * config_file_option_string_default */ @@ -1228,6 +1320,28 @@ TEST(CoreConfigFileWithNewOptions, OptionString) /* * Tests functions: + * config_file_option_string_inherited + */ + +TEST(CoreConfigFileWithNewOptions, OptionStringInherited) +{ + POINTERS_EQUAL(NULL, config_file_option_string_inherited (NULL)); + + STRCMP_EQUAL("v2", config_file_option_string_inherited (ptr_option_int_str_child)); + config_file_option_set (ptr_option_int_str, "v3", 1); + STRCMP_EQUAL("v3", config_file_option_string_inherited (ptr_option_int_str_child)); + config_file_option_reset (ptr_option_int_str, 1); + STRCMP_EQUAL("v2", config_file_option_string_inherited (ptr_option_int_str_child)); + + STRCMP_EQUAL("value", config_file_option_string_inherited (ptr_option_str_child)); + config_file_option_set (ptr_option_str, "test", 1); + STRCMP_EQUAL("test", config_file_option_string_inherited (ptr_option_str_child)); + config_file_option_reset (ptr_option_str, 1); + STRCMP_EQUAL("value", config_file_option_string_inherited (ptr_option_str_child)); +} + +/* + * Tests functions: * config_file_option_color * config_file_option_color_default */ @@ -1261,6 +1375,22 @@ TEST(CoreConfigFileWithNewOptions, OptionColor) /* * Tests functions: + * config_file_option_color_inherited + */ + +TEST(CoreConfigFileWithNewOptions, OptionColorInherited) +{ + POINTERS_EQUAL(NULL, config_file_option_color_inherited (NULL)); + + STRCMP_EQUAL("blue", config_file_option_color_inherited (ptr_option_col_child)); + config_file_option_set (ptr_option_col, "red", 1); + STRCMP_EQUAL("red", config_file_option_color_inherited (ptr_option_col_child)); + config_file_option_reset (ptr_option_col, 1); + STRCMP_EQUAL("blue", config_file_option_color_inherited (ptr_option_col_child)); +} + +/* + * Tests functions: * config_file_option_enum * config_file_option_enum_default */ @@ -1300,6 +1430,22 @@ TEST(CoreConfigFileWithNewOptions, OptionEnum) /* * Tests functions: + * config_file_option_enum_inherited + */ + +TEST(CoreConfigFileWithNewOptions, OptionEnumInherited) +{ + LONGS_EQUAL(0, config_file_option_enum_inherited (NULL)); + + LONGS_EQUAL(1, config_file_option_enum_inherited (ptr_option_enum_child)); + config_file_option_set (ptr_option_enum, "v3", 1); + LONGS_EQUAL(2, config_file_option_enum_inherited (ptr_option_enum_child)); + config_file_option_reset (ptr_option_enum, 1); + LONGS_EQUAL(1, config_file_option_enum_inherited (ptr_option_enum_child)); +} + +/* + * Tests functions: * config_file_option_escape */ |