diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-05-31 23:07:11 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-25 16:35:27 +0200 |
commit | b50e5d016f4e1418ff36c1a750bdff0038ced0ef (patch) | |
tree | 71689dc5cc5a6d747d1c9b651c70805140eeb6e7 /src | |
parent | eccce0bb4f9e82ae6472048ae71e0e69deed931a (diff) | |
download | weechat-b50e5d016f4e1418ff36c1a750bdff0038ced0ef.zip |
fset: fix display of default value and string values in help bar
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/fset/fset-bar-item.c | 79 |
1 files changed, 50 insertions, 29 deletions
diff --git a/src/plugins/fset/fset-bar-item.c b/src/plugins/fset/fset-bar-item.c index 2d7fd5a58..eb069e130 100644 --- a/src/plugins/fset/fset-bar-item.c +++ b/src/plugins/fset/fset-bar-item.c @@ -58,7 +58,7 @@ fset_bar_item_fset_cb (const void *pointer, void *data, { struct t_fset_option *ptr_fset_option; struct t_config_option *ptr_option; - char str_help[8192], **string_values; + char str_help[8192], **default_and_values; const char **ptr_string_values; int i; @@ -78,10 +78,45 @@ fset_bar_item_fset_cb (const void *pointer, void *data, if (!ptr_fset_option) return NULL; - string_values = weechat_string_dyn_alloc (256); - if (!string_values) + default_and_values = weechat_string_dyn_alloc (256); + if (!default_and_values) return NULL; + weechat_string_dyn_concat (default_and_values, weechat_color ("bar_fg")); + weechat_string_dyn_concat (default_and_values, _("default:")); + weechat_string_dyn_concat (default_and_values, " "); + if (ptr_fset_option->default_value) + { + if (ptr_fset_option->type == FSET_OPTION_TYPE_STRING) + { + weechat_string_dyn_concat (default_and_values, + weechat_color ( + weechat_config_string ( + fset_config_color_help_quotes))); + weechat_string_dyn_concat (default_and_values, "\""); + } + weechat_string_dyn_concat ( + default_and_values, + weechat_color (weechat_config_string (fset_config_color_help_default_value))); + weechat_string_dyn_concat (default_and_values, + ptr_fset_option->default_value); + if (ptr_fset_option->type == FSET_OPTION_TYPE_STRING) + { + weechat_string_dyn_concat (default_and_values, + weechat_color ( + weechat_config_string ( + fset_config_color_help_quotes))); + weechat_string_dyn_concat (default_and_values, "\""); + } + } + else + { + weechat_string_dyn_concat ( + default_and_values, + weechat_color (weechat_config_string (fset_config_color_help_default_value))); + weechat_string_dyn_concat (default_and_values, FSET_OPTION_VALUE_NULL); + } + if (ptr_fset_option->string_values && ptr_fset_option->string_values[0]) { ptr_option = weechat_config_get (ptr_fset_option->name); @@ -91,59 +126,45 @@ fset_bar_item_fset_cb (const void *pointer, void *data, ptr_option, "string_values"); if (ptr_string_values) { - weechat_string_dyn_concat (string_values, + weechat_string_dyn_concat (default_and_values, weechat_color ("bar_fg")); - weechat_string_dyn_concat (string_values, ", "); - weechat_string_dyn_concat (string_values, _("values:")); - weechat_string_dyn_concat (string_values, " "); + weechat_string_dyn_concat (default_and_values, ", "); + weechat_string_dyn_concat (default_and_values, _("values:")); + weechat_string_dyn_concat (default_and_values, " "); for (i = 0; ptr_string_values[i]; i++) { if (i > 0) { - weechat_string_dyn_concat (string_values, + weechat_string_dyn_concat (default_and_values, weechat_color ("bar_fg")); - weechat_string_dyn_concat (string_values, ", "); + weechat_string_dyn_concat (default_and_values, ", "); } weechat_string_dyn_concat ( - string_values, - weechat_color ( - weechat_config_string ( - fset_config_color_help_quotes))); - weechat_string_dyn_concat (string_values, "\""); - weechat_string_dyn_concat ( - string_values, + default_and_values, weechat_color ( weechat_config_string ( fset_config_color_help_string_values))); - weechat_string_dyn_concat (string_values, + weechat_string_dyn_concat (default_and_values, ptr_string_values[i]); - weechat_string_dyn_concat ( - string_values, - weechat_color ( - weechat_config_string ( - fset_config_color_help_quotes))); - weechat_string_dyn_concat (string_values, "\""); } } } } snprintf (str_help, sizeof (str_help), - _("%s%s%s: %s %s[%sdefault: %s%s%s%s]%s"), + /* TRANSLATORS: "%s%s%s:" at beginning of string it the name of option */ + _("%s%s%s: %s %s[%s%s]%s"), weechat_color (weechat_config_string (fset_config_color_help_name)), ptr_fset_option->name, weechat_color ("bar_fg"), (ptr_fset_option->description && ptr_fset_option->description[0]) ? _(ptr_fset_option->description) : _("(no description)"), weechat_color ("bar_delim"), - weechat_color ("bar_fg"), - weechat_color (weechat_config_string (fset_config_color_help_default_value)), - ptr_fset_option->default_value, - *string_values, + *default_and_values, weechat_color ("bar_delim"), weechat_color ("bar_fg")); - weechat_string_dyn_free (string_values, 1); + weechat_string_dyn_free (default_and_values, 1); return strdup (str_help); } |