From 7a08099d1808e6e2e5b6377470c023e7ff662803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Thu, 1 Jun 2017 21:53:14 +0200 Subject: [PATCH] fset: add options fset.color.quotes_changed and fset.color.quotes_changed_selected --- src/plugins/fset/fset-buffer.c | 23 ++++++++++++++++------- src/plugins/fset/fset-config.c | 26 ++++++++++++++++++++++---- src/plugins/fset/fset-config.h | 1 + 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/plugins/fset/fset-buffer.c b/src/plugins/fset/fset-buffer.c index 6b2eb397a..b03f90a82 100644 --- a/src/plugins/fset/fset-buffer.c +++ b/src/plugins/fset/fset-buffer.c @@ -114,7 +114,7 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option) 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; + struct t_config_option *ptr_option_color_value, *ptr_option_color_quotes; selected_line = (y == fset_buffer_selected_line) ? 1 : 0; @@ -250,22 +250,31 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option) fset_option, "value"); add_quotes = (ptr_field && (fset_option->type == FSET_OPTION_TYPE_STRING)) ? 1 : 0; if (value_undef) + { ptr_option_color_value = fset_config_color_value_undef[selected_line]; + ptr_option_color_quotes = 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]; + } else + { ptr_option_color_value = fset_config_color_value[selected_line]; + ptr_option_color_quotes = fset_config_color_quotes[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, "__value", str_field); snprintf (str_field, sizeof (str_field), "%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_quotes)) : "", (add_quotes) ? "\"" : "", weechat_color (weechat_config_string (ptr_option_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) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "", (add_quotes) ? "\"" : ""); weechat_hashtable_set (fset_buffer_hashtable_extra_vars, "_value", str_field); @@ -287,11 +296,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 (fset_config_color_quotes[selected_line])) : "", + (add_quotes) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "", (add_quotes) ? "\"" : "", weechat_color (weechat_config_string (ptr_option_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) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "", (add_quotes) ? "\"" : "", weechat_color ("default"), (add_quotes_parent) ? weechat_color (weechat_config_string (fset_config_color_quotes[selected_line])) : "", @@ -315,11 +324,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 (fset_config_color_quotes[selected_line])) : "", + (add_quotes) ? weechat_color (weechat_config_string (ptr_option_color_quotes)) : "", (add_quotes) ? "\"" : "", weechat_color (weechat_config_string (ptr_option_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) ? weechat_color (weechat_config_string (ptr_option_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 014033582..69d02ed20 100644 --- a/src/plugins/fset/fset-config.c +++ b/src/plugins/fset/fset-config.c @@ -63,6 +63,7 @@ struct t_config_option *fset_config_color_name[2]; struct t_config_option *fset_config_color_parent_name[2]; struct t_config_option *fset_config_color_parent_value[2]; struct t_config_option *fset_config_color_quotes[2]; +struct t_config_option *fset_config_color_quotes_changed[2]; struct t_config_option *fset_config_color_string_values[2]; struct t_config_option *fset_config_color_type[2]; struct t_config_option *fset_config_color_unmarked[2]; @@ -517,6 +518,23 @@ fset_config_init () NULL, NULL, NULL, &fset_config_change_color, NULL, NULL, NULL, NULL, NULL); + fset_config_color_quotes_changed[0] = weechat_config_new_option ( + fset_config_file, ptr_section, + "quotes_changed", "color", + N_("color for quotes around string values which are changed"), + NULL, 0, 0, "default", NULL, 0, + NULL, NULL, NULL, + &fset_config_change_color, NULL, NULL, + NULL, NULL, NULL); + fset_config_color_quotes_changed[1] = weechat_config_new_option ( + fset_config_file, ptr_section, + "quotes_changed_selected", "color", + N_("color for quotes around string values which are changed " + "on the selected line"), + NULL, 0, 0, "white", NULL, 0, + NULL, NULL, NULL, + &fset_config_change_color, NULL, NULL, + NULL, NULL, NULL); fset_config_color_string_values[0] = weechat_config_new_option ( fset_config_file, ptr_section, "string_values", "color", @@ -537,7 +555,7 @@ fset_config_init () fset_config_file, ptr_section, "type", "color", N_("color for type"), - NULL, 0, 0, "brown", NULL, 0, + NULL, 0, 0, "green", NULL, 0, NULL, NULL, NULL, &fset_config_change_color, NULL, NULL, NULL, NULL, NULL); @@ -545,7 +563,7 @@ fset_config_init () fset_config_file, ptr_section, "type_selected", "color", N_("color for type on the selected line"), - NULL, 0, 0, "yellow", NULL, 0, + NULL, 0, 0, "lightgreen", NULL, 0, NULL, NULL, NULL, &fset_config_change_color, NULL, NULL, NULL, NULL, NULL); @@ -585,7 +603,7 @@ fset_config_init () fset_config_file, ptr_section, "value_changed", "color", N_("color for value changed (different from default)"), - NULL, 0, 0, "green", NULL, 0, + NULL, 0, 0, "brown", NULL, 0, NULL, NULL, NULL, &fset_config_change_color, NULL, NULL, NULL, NULL, NULL); @@ -594,7 +612,7 @@ fset_config_init () "value_changed_selected", "color", N_("color for value changed (different from default) on the selected " "line"), - NULL, 0, 0, "lightgreen", NULL, 0, + NULL, 0, 0, "yellow", NULL, 0, NULL, NULL, NULL, &fset_config_change_color, NULL, NULL, NULL, NULL, NULL); diff --git a/src/plugins/fset/fset-config.h b/src/plugins/fset/fset-config.h index 80fef6f4d..ba0fd5f10 100644 --- a/src/plugins/fset/fset-config.h +++ b/src/plugins/fset/fset-config.h @@ -50,6 +50,7 @@ extern struct t_config_option *fset_config_color_name[2]; extern struct t_config_option *fset_config_color_parent_name[2]; extern struct t_config_option *fset_config_color_parent_value[2]; extern struct t_config_option *fset_config_color_quotes[2]; +extern struct t_config_option *fset_config_color_quotes_changed[2]; extern struct t_config_option *fset_config_color_string_values[2]; extern struct t_config_option *fset_config_color_type[2]; extern struct t_config_option *fset_config_color_unmarked[2];