diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 4ef3cb5c8..a071f9ee6 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] New features:: + * api: add function config_option_get_string() * buflist: add keys kbd:[F1]/kbd:[F2], kbd:[Alt+F1]/kbd:[Alt+F2] to scroll the buflist bar Improvements:: diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index b6984f54e..f2929d3b2 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -6055,6 +6055,47 @@ weechat.config_option_rename(option, new_name) weechat.config_option_rename(option, "new_name") ---- +==== config_option_get_string + +_WeeChat ≥ 1.9._ + +Return string value of an option property. + +Prototype: + +[source,C] +---- +const char *weechat_config_option_get_string (struct t_config_option *option, + const char *property); +---- + +Arguments: + +* _option_: option pointer +* _property_: property name: +** _name_: option name +** _parent_name_: name of parent option +** _type_: option type, one of: +*** _boolean_ +*** _integer_ +*** _string_ +*** _color_ +** _description_: option description + +Return value: + +* string value of property + +C example: + +[source,C] +---- +const char *type = weechat_config_option_get_string (option, "type"); +---- + +[NOTE] +This function is not available in scripting API. + ==== config_option_get_pointer Return a pointer on an option property. diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index d8e635b81..67b27a493 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -6154,6 +6154,47 @@ weechat.config_option_rename(option, new_name) weechat.config_option_rename(option, "nouveau_nom") ---- +==== config_option_get_string + +_WeeChat ≥ 1.9._ + +Retourner la valeur d'une propriété de l'option sous forme de chaîne. + +Prototype : + +[source,C] +---- +const char *weechat_config_option_get_string (struct t_config_option *option, + const char *property); +---- + +Paramètres : + +* _option_ : pointeur vers l'option +* _property_ : nom de la propriété : +** _name_ : nom de l'option +** _parent_name_ : nom de l'option parente +** _type_ : type de l'option, un parmi ceux-ci : +*** _boolean_ +*** _integer_ +*** _string_ +*** _color_ +** _description_ : description de l'option + +Valeur de retour : + +* valeur de la propriété, sous forme de chaîne + +Exemple en C : + +[source,C] +---- +const char *type = weechat_config_option_get_string (option, "type"); +---- + +[NOTE] +Cette fonction n'est pas disponible dans l'API script. + ==== config_option_get_pointer Retourner un pointeur vers une propriété de l'option. diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index b2a8d78c3..795aa9cbd 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -6255,6 +6255,50 @@ weechat.config_option_rename(option, new_name) weechat.config_option_rename(option, "new_name") ---- +==== config_option_get_string + +_WeeChat ≥ 1.9._ + +// TRANSLATION MISSING +Return string value of an option property. + +Prototype: + +[source,C] +---- +const char *weechat_config_option_get_string (struct t_config_option *option, + const char *property); +---- + +Argomenti: + +// TRANSLATION MISSING +* _option_: puntatore all'opzione +* _property_: nome della proprietà: +** _name_: option name +** _parent_name_: name of parent option +** _type_: option type, one of: +*** _boolean_ +*** _integer_ +*** _string_ +*** _color_ +** _description_: option description + +Valore restituito: + +// TRANSLATION MISSING +* string value of property + +Esempio in C: + +[source,C] +---- +const char *type = weechat_config_option_get_string (option, "type"); +---- + +[NOTE] +Questa funzione non è disponibile nelle API per lo scripting. + ==== config_option_get_pointer Restituisce un puntatore alla proprietà di un'opzione. diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index 74d438720..3109f8e89 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -6059,6 +6059,50 @@ weechat.config_option_rename(option, new_name) weechat.config_option_rename(option, "new_name") ---- +==== config_option_get_string + +_WeeChat ≥ 1.9._ + +// TRANSLATION MISSING +Return string value of an option property. + +Prototype: + +[source,C] +---- +const char *weechat_config_option_get_string (struct t_config_option *option, + const char *property); +---- + +引数: + +// TRANSLATION MISSING +* _option_: オプションへのポインタ +* _property_: プロパティ名: +** _name_: option name +** _parent_name_: name of parent option +** _type_: option type, one of: +*** _boolean_ +*** _integer_ +*** _string_ +*** _color_ +** _description_: option description + +戻り値: + +// TRANSLATION MISSING +* string value of property + +C 言語での使用例: + +[source,C] +---- +const char *type = weechat_config_option_get_string (option, "type"); +---- + +[NOTE] +スクリプト API ではこの関数を利用できません。 + ==== config_option_get_pointer あるオプションのプロパティへのポインタを返す。 diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 3a5bcd3e3..f0a7a33eb 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -1906,7 +1906,30 @@ config_file_option_value_to_string (struct t_config_option *option, } /* - * Gets a pointer of an option property. + * Gets a string value of an option property. + */ + +const char * +config_file_option_get_string (struct t_config_option *option, + const char *property) +{ + if (!option || !property) + return NULL; + + if (string_strcasecmp (property, "name") == 0) + return option->name; + else if (string_strcasecmp (property, "parent_name") == 0) + return option->parent_name; + else if (string_strcasecmp (property, "type") == 0) + return config_option_type_string[option->type]; + else if (string_strcasecmp (property, "description") == 0) + return option->description; + + return NULL; +} + +/* + * Gets a pointer on an option property. */ void * diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h index d835b87e9..10b635e44 100644 --- a/src/core/wee-config-file.h +++ b/src/core/wee-config-file.h @@ -264,6 +264,8 @@ extern char *config_file_option_value_to_string (struct t_config_option *option, int default_value, int add_delimiters, int use_colors); +extern const char *config_file_option_get_string (struct t_config_option *option, + const char *property); extern void *config_file_option_get_pointer (struct t_config_option *option, const char *property); extern int config_file_option_is_null (struct t_config_option *option); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 326df8edf..bb2c25e7d 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -728,6 +728,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv) new_plugin->config_option_set_null = &config_file_option_set_null; new_plugin->config_option_unset = &config_file_option_unset; new_plugin->config_option_rename = &config_file_option_rename; + new_plugin->config_option_get_string = &config_file_option_get_string; new_plugin->config_option_get_pointer = &config_file_option_get_pointer; new_plugin->config_option_is_null = &config_file_option_is_null; new_plugin->config_option_default_is_null = &config_file_option_default_is_null; diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 2a44d692d..9d3fe101c 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -59,7 +59,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 "20170401-01" +#define WEECHAT_PLUGIN_API_VERSION "20170530-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -561,6 +561,8 @@ struct t_weechat_plugin int (*config_option_unset) (struct t_config_option *option); void (*config_option_rename) (struct t_config_option *option, const char *new_name); + const char *(*config_option_get_string) (struct t_config_option *option, + const char *property); void *(*config_option_get_pointer) (struct t_config_option *option, const char *property); int (*config_option_is_null) (struct t_config_option *option); @@ -1492,6 +1494,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); (weechat_plugin->config_option_unset)(__option) #define weechat_config_option_rename(__option, __new_name) \ (weechat_plugin->config_option_rename)(__option, __new_name) +#define weechat_config_option_get_string(__option, __property) \ + (weechat_plugin->config_option_get_string)(__option, __property) #define weechat_config_option_get_pointer(__option, __property) \ (weechat_plugin->config_option_get_pointer)(__option, __property) #define weechat_config_option_is_null(__option) \