diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-05-19 20:36:22 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-25 16:35:27 +0200 |
commit | e66b3ffd573f21f9ad860501f940594c4e6fc9fd (patch) | |
tree | 2c9fd79c5db13af7ec7af754811da0aaad665d7a /src/plugins/fset/fset-buffer.c | |
parent | cd131db925c60f96813fc2387a059cf89bf6a375 (diff) | |
download | weechat-e66b3ffd573f21f9ad860501f940594c4e6fc9fd.zip |
fset: add colors for diff/undef values
Diffstat (limited to 'src/plugins/fset/fset-buffer.c')
-rw-r--r-- | src/plugins/fset/fset-buffer.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/plugins/fset/fset-buffer.c b/src/plugins/fset/fset-buffer.c index 4dfe40716..08d8bf521 100644 --- a/src/plugins/fset/fset-buffer.c +++ b/src/plugins/fset/fset-buffer.c @@ -47,10 +47,15 @@ void fset_buffer_display_line (int y, struct t_fset_option *option) { char *line, str_format[32], str_value[1024]; - int i, selected_line, *ptr_length; + const char *ptr_value; + int i, selected_line, *ptr_length, value_undef, value_diff; + struct t_config_option *ptr_option_color_value; selected_line = (y == fset_buffer_selected_line) ? 1 : 0; + value_undef = (option->value == NULL) ? 1 : 0; + value_diff = (fset_option_value_different_from_default (option)) ? 1 : 0; + /* set pointers */ weechat_hashtable_set (fset_buffer_hashtable_pointers, "fset_option", option); @@ -62,11 +67,12 @@ fset_buffer_display_line (int y, struct t_fset_option *option) snprintf (str_format, sizeof (str_format), "%%-%ds", (ptr_length) ? *ptr_length : fset_buffer_columns_default_size[i]); + ptr_value = weechat_hdata_string (fset_hdata_fset_option, + option, + fset_buffer_columns[i]); snprintf (str_value, sizeof (str_value), str_format, - weechat_hdata_string (fset_hdata_fset_option, - option, - fset_buffer_columns[i])); + (ptr_value) ? ptr_value : "null"); weechat_hashtable_set (fset_buffer_hashtable_extra_vars, fset_buffer_columns[i], str_value); @@ -88,12 +94,23 @@ fset_buffer_display_line (int y, struct t_fset_option *option) weechat_color (weechat_config_string (fset_config_color_default_value[selected_line]))); weechat_hashtable_set (fset_buffer_hashtable_extra_vars, "color_default_value", str_value); + if (value_undef) + ptr_option_color_value = fset_config_color_value_undef[selected_line]; + else if (value_diff) + ptr_option_color_value = fset_config_color_value_diff[selected_line]; + else + ptr_option_color_value = fset_config_color_value[selected_line]; snprintf (str_value, sizeof (str_value), "%s", - weechat_color (weechat_config_string (fset_config_color_value[selected_line]))); + weechat_color (weechat_config_string (ptr_option_color_value))); weechat_hashtable_set (fset_buffer_hashtable_extra_vars, "color_value", str_value); + /* set other variables depending on the value */ + weechat_hashtable_set (fset_buffer_hashtable_extra_vars, + "value_undef", + (option->value == NULL) ? "1" : "0"); + /* build string for line */ line = weechat_string_eval_expression ( (selected_line) ? fset_config_eval_format_option_current : weechat_config_string (fset_config_format_option), |