summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2017-06-02 20:54:51 +0200
committerSébastien Helleu <flashcode@flashtux.org>2017-06-25 16:35:27 +0200
commite2a68f9b4c4894b33990a17e18e7f1588253bbf5 (patch)
tree5e9b189a502567bc7492e9d9e50dfdcad260668d /src
parentcffa55e05ea690d2a90652568ee9cc13344d3716 (diff)
downloadweechat-e2a68f9b4c4894b33990a17e18e7f1588253bbf5.zip
fset: add option fset.look.use_color_value
Diffstat (limited to 'src')
-rw-r--r--src/plugins/fset/fset-buffer.c79
-rw-r--r--src/plugins/fset/fset-config.c25
-rw-r--r--src/plugins/fset/fset-config.h1
3 files changed, 82 insertions, 23 deletions
diff --git a/src/plugins/fset/fset-buffer.c b/src/plugins/fset/fset-buffer.c
index fd89da098..5fa42a526 100644
--- a/src/plugins/fset/fset-buffer.c
+++ b/src/plugins/fset/fset-buffer.c
@@ -109,12 +109,11 @@ fset_buffer_fills_field (char *field, int size,
void
fset_buffer_display_line (int y, struct t_fset_option *fset_option)
{
- char *line, str_field[4096];
+ char *line, str_field[4096], str_color_value[128], str_color_quotes[128];
const char *ptr_field, *ptr_parent_value;
int selected_line;
int default_value_undef, value_undef, value_changed;
int type, marked, add_quotes, add_quotes_parent;
- struct t_config_option *ptr_option_color_value, *ptr_option_color_quotes;
if (!fset_option)
return;
@@ -230,10 +229,13 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option)
ptr_field = weechat_hdata_string (fset_hdata_fset_option,
fset_option, "default_value");
add_quotes = (ptr_field && (fset_option->type == FSET_OPTION_TYPE_STRING)) ? 1 : 0;
- if (default_value_undef)
- ptr_option_color_value = fset_config_color_value_undef[selected_line];
- else
- ptr_option_color_value = fset_config_color_default_value[selected_line];
+ snprintf (str_color_value, sizeof (str_color_value),
+ "%s",
+ weechat_color (
+ weechat_config_string (
+ (default_value_undef) ?
+ fset_config_color_value_undef[selected_line] :
+ fset_config_color_default_value[selected_line])));
snprintf (str_field, sizeof (str_field),
"%s", (ptr_field) ? ptr_field : FSET_OPTION_VALUE_NULL);
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
@@ -242,7 +244,7 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option)
"%s%s%s%s%s%s",
(add_quotes) ? weechat_color (weechat_config_string (fset_config_color_quotes[selected_line])) : "",
(add_quotes) ? "\"" : "",
- weechat_color (weechat_config_string (ptr_option_color_value)),
+ str_color_value,
(ptr_field) ? ptr_field : FSET_OPTION_VALUE_NULL,
(add_quotes) ? weechat_color (weechat_config_string (fset_config_color_quotes[selected_line])) : "",
(add_quotes) ? "\"" : "");
@@ -256,20 +258,51 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option)
ptr_field = weechat_hdata_string (fset_hdata_fset_option,
fset_option, "value");
add_quotes = (ptr_field && (fset_option->type == FSET_OPTION_TYPE_STRING)) ? 1 : 0;
- if (value_undef)
+ if ((fset_option->type == FSET_OPTION_TYPE_COLOR)
+ && weechat_config_boolean (fset_config_look_use_color_value))
{
- ptr_option_color_value = fset_config_color_value_undef[selected_line];
- ptr_option_color_quotes = fset_config_color_quotes[selected_line];
+ snprintf (str_color_value, sizeof (str_color_value),
+ "%s",
+ weechat_color (fset_option->value));
+ }
+ else if (value_undef)
+ {
+ snprintf (str_color_value, sizeof (str_color_value),
+ "%s",
+ weechat_color (
+ weechat_config_string (
+ fset_config_color_value_undef[selected_line])));
+ snprintf (str_color_quotes, sizeof (str_color_quotes),
+ "%s",
+ weechat_color (
+ weechat_config_string (
+ fset_config_color_quotes[selected_line])));
}
else if (value_changed)
{
- ptr_option_color_value = fset_config_color_value_changed[selected_line];
- ptr_option_color_quotes = fset_config_color_quotes_changed[selected_line];
+ snprintf (str_color_value, sizeof (str_color_value),
+ "%s",
+ weechat_color (
+ weechat_config_string (
+ fset_config_color_value_changed[selected_line])));
+ snprintf (str_color_quotes, sizeof (str_color_quotes),
+ "%s",
+ weechat_color (
+ weechat_config_string (
+ fset_config_color_quotes_changed[selected_line])));
}
else
{
- ptr_option_color_value = fset_config_color_value[selected_line];
- ptr_option_color_quotes = fset_config_color_quotes[selected_line];
+ snprintf (str_color_value, sizeof (str_color_value),
+ "%s",
+ weechat_color (
+ weechat_config_string (
+ fset_config_color_value[selected_line])));
+ snprintf (str_color_quotes, sizeof (str_color_quotes),
+ "%s",
+ weechat_color (
+ weechat_config_string (
+ fset_config_color_quotes[selected_line])));
}
snprintf (str_field, sizeof (str_field),
"%s", (ptr_field) ? ptr_field : FSET_OPTION_VALUE_NULL);
@@ -277,11 +310,11 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option)
"__value", str_field);
snprintf (str_field, sizeof (str_field),
"%s%s%s%s%s%s",
- (add_quotes) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "",
+ (add_quotes) ? str_color_quotes : "",
(add_quotes) ? "\"" : "",
- weechat_color (weechat_config_string (ptr_option_color_value)),
+ str_color_value,
(ptr_field) ? ptr_field : FSET_OPTION_VALUE_NULL,
- (add_quotes) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "",
+ (add_quotes) ? str_color_quotes : "",
(add_quotes) ? "\"" : "");
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
"_value", str_field);
@@ -303,11 +336,11 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option)
"__value2", str_field);
snprintf (str_field, sizeof (str_field),
"%s%s%s%s%s%s%s -> %s%s%s%s%s%s",
- (add_quotes) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "",
+ (add_quotes) ? str_color_quotes : "",
(add_quotes) ? "\"" : "",
- weechat_color (weechat_config_string (ptr_option_color_value)),
+ str_color_value,
(ptr_field) ? ptr_field : FSET_OPTION_VALUE_NULL,
- (add_quotes) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "",
+ (add_quotes) ? str_color_quotes : "",
(add_quotes) ? "\"" : "",
weechat_color ("default"),
(add_quotes_parent) ? weechat_color (weechat_config_string (fset_config_color_quotes[selected_line])) : "",
@@ -331,11 +364,11 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option)
"__value2", str_field);
snprintf (str_field, sizeof (str_field),
"%s%s%s%s%s%s",
- (add_quotes) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "",
+ (add_quotes) ? str_color_quotes : "",
(add_quotes) ? "\"" : "",
- weechat_color (weechat_config_string (ptr_option_color_value)),
+ str_color_value,
(ptr_field) ? ptr_field : FSET_OPTION_VALUE_NULL,
- (add_quotes) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "",
+ (add_quotes) ? str_color_quotes : "",
(add_quotes) ? "\"" : "");
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
"_value2", str_field);
diff --git a/src/plugins/fset/fset-config.c b/src/plugins/fset/fset-config.c
index 866a3561a..24f3c5eff 100644
--- a/src/plugins/fset/fset-config.c
+++ b/src/plugins/fset/fset-config.c
@@ -41,6 +41,7 @@ struct t_config_option *fset_config_look_marked_string;
struct t_config_option *fset_config_look_show_plugin_description;
struct t_config_option *fset_config_look_sort;
struct t_config_option *fset_config_look_unmarked_string;
+struct t_config_option *fset_config_look_use_color_value;
struct t_config_option *fset_config_look_use_keys;
struct t_config_option *fset_config_look_use_mute;
@@ -140,6 +141,22 @@ fset_config_change_sort_cb (const void *pointer, void *data,
}
/*
+ * Callback for changes on option "fset.look.use_color_value".
+ */
+
+void
+fset_config_change_use_color_value_cb (const void *pointer, void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) option;
+
+ fset_buffer_refresh (0);
+}
+
+/*
* Callback for changes on option "fset.look.use_keys".
*/
@@ -312,6 +329,14 @@ fset_config_init ()
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
+ fset_config_look_use_color_value = weechat_config_new_option (
+ fset_config_file, ptr_section,
+ "use_color_value", "boolean",
+ N_("use the color to display value of color options"),
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &fset_config_change_use_color_value_cb, NULL, NULL,
+ NULL, NULL, NULL);
fset_config_look_use_keys = weechat_config_new_option (
fset_config_file, ptr_section,
"use_keys", "boolean",
diff --git a/src/plugins/fset/fset-config.h b/src/plugins/fset/fset-config.h
index 305f7c8c4..bb15e6a7f 100644
--- a/src/plugins/fset/fset-config.h
+++ b/src/plugins/fset/fset-config.h
@@ -31,6 +31,7 @@ extern struct t_config_option *fset_config_look_marked_string;
extern struct t_config_option *fset_config_look_show_plugin_description;
extern struct t_config_option *fset_config_look_sort;
extern struct t_config_option *fset_config_look_unmarked_string;
+extern struct t_config_option *fset_config_look_use_color_value;
extern struct t_config_option *fset_config_look_use_keys;
extern struct t_config_option *fset_config_look_use_mute;