X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/ae2fe673d167d2199420799b2041c286433c4f56..8b4070b51e98191e73b51fc28c42b8a10e0d92dc:/weechat/perl/iset.pl diff --git a/weechat/perl/iset.pl b/weechat/perl/iset.pl index 7d72847..4b922ee 100644 --- a/weechat/perl/iset.pl +++ b/weechat/perl/iset.pl @@ -19,6 +19,11 @@ # # History: # +# 2014-01-30, stfn : +# version 3.4: add new options "color_value_diff" and "color_value_diff_selected" +# 2014-01-16, luz : +# version 3.3: fix bug with column alignment in iset buffer when option +# name contains unicode characters # 2013-08-03, Sebastien Helleu : # version 3.2: allow "q" as input in iset buffer to close it # 2013-07-14, Sebastien Helleu : @@ -108,7 +113,7 @@ use strict; my $PRGNAME = "iset"; -my $VERSION = "3.2"; +my $VERSION = "3.4"; my $DESCR = "Interactive Set for configuration options"; my $AUTHOR = "Sebastien Helleu "; my $LICENSE = "GPL3"; @@ -122,6 +127,7 @@ my @iset_focus = (); my @options_names = (); my @options_types = (); my @options_values = (); +my @options_default_values = (); my @options_is_null = (); my $option_max_length = 0; my $current_line = 0; @@ -325,6 +331,7 @@ sub iset_get_options @options_names = (); @options_types = (); @options_values = (); + @options_default_values = (); @options_is_null = (); $option_max_length = 0; my %options_internal = (); @@ -343,6 +350,7 @@ sub iset_get_options next if (weechat::config_boolean($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1); my $type = weechat::infolist_string($infolist, "type"); my $value = weechat::infolist_string($infolist, "value"); + my $default_value = weechat::infolist_string($infolist, "default_value"); my $is_null = weechat::infolist_integer($infolist, "value_is_null"); if ($search_mode == 3) { @@ -351,6 +359,7 @@ sub iset_get_options { $options_internal{$name}{"type"} = $type; $options_internal{$name}{"value"} = $value; + $options_internal{$name}{"default_value"} = $default_value; $options_internal{$name}{"is_null"} = $is_null; $option_max_length = length($name) if (length($name) > $option_max_length); $iset_struct{$key} = $options_internal{$name}; @@ -361,6 +370,7 @@ sub iset_get_options { $options_internal{$name}{"type"} = $type; $options_internal{$name}{"value"} = $value; + $options_internal{$name}{"default_value"} = $default_value; $options_internal{$name}{"is_null"} = $is_null; $option_max_length = length($name) if (length($name) > $option_max_length); $iset_struct{$key} = $options_internal{$name}; @@ -375,6 +385,7 @@ sub iset_get_options push(@options_names, $name); push(@options_types, $options_internal{$name}{"type"}); push(@options_values, $options_internal{$name}{"value"}); + push(@options_default_values, $options_internal{$name}{"default_value"}); push(@options_is_null, $options_internal{$name}{"is_null"}); } } @@ -399,6 +410,7 @@ sub iset_search_values @options_names = (); @options_types = (); @options_values = (); + @options_default_values = (); @options_is_null = (); $option_max_length = 0; my %options_internal = (); @@ -411,12 +423,14 @@ sub iset_search_values my $type = weechat::infolist_string($infolist, "type"); my $is_null = weechat::infolist_integer($infolist, "value_is_null"); my $value = weechat::infolist_string($infolist, "value"); + my $default_value = weechat::infolist_string($infolist, "default_value"); if ($search_mode) { if ( grep /\Q$var_value/,lc($value) ) { $options_internal{$name}{"type"} = $type; $options_internal{$name}{"value"} = $value; + $options_internal{$name}{"default_value"} = $default_value; $options_internal{$name}{"is_null"} = $is_null; $option_max_length = length($name) if (length($name) > $option_max_length); } @@ -428,6 +442,7 @@ sub iset_search_values { $options_internal{$name}{"type"} = $type; $options_internal{$name}{"value"} = $value; + $options_internal{$name}{"default_value"} = $default_value; $options_internal{$name}{"is_null"} = $is_null; $option_max_length = length($name) if (length($name) > $option_max_length); } @@ -440,6 +455,7 @@ sub iset_search_values push(@options_names, $name); push(@options_types, $options_internal{$name}{"type"}); push(@options_values, $options_internal{$name}{"value"}); + push(@options_default_values, $options_internal{$name}{"default_value"}); push(@options_is_null, $options_internal{$name}{"is_null"}); } } @@ -452,7 +468,16 @@ sub iset_refresh_line if ($y <= $#options_names) { return if (! defined($options_types[$y])); - my $format = sprintf("%%s%%-%ds %%s %%-7s %%s %%s%%s%%s", $option_max_length); + my $format = sprintf("%%s%%s%%s %%s %%-7s %%s %%s%%s%%s"); + my $padding; + if ($wee_version_number >= 0x00040200) + { + $padding = " " x ($option_max_length - weechat::strlen_screen($options_names[$y])); + } + else + { + $padding = " " x ($option_max_length - length($options_names[$y])); + } my $around = ""; $around = "\"" if ((!$options_is_null[$y]) && ($options_types[$y] eq "string")); @@ -463,6 +488,10 @@ sub iset_refresh_line { $color3 = weechat::color(weechat::config_color($options_iset{"color_value_undef"})); } + elsif ($options_values[$y] ne $options_default_values[$y]) + { + $color3 = weechat::color(weechat::config_color($options_iset{"color_value_diff"})); + } else { $color3 = weechat::color(weechat::config_color($options_iset{"color_value"})); @@ -475,6 +504,10 @@ sub iset_refresh_line { $color3 = weechat::color(weechat::config_color($options_iset{"color_value_undef_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"})); } + elsif ($options_values[$y] ne $options_default_values[$y]) + { + $color3 = weechat::color(weechat::config_color($options_iset{"color_value_diff_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"})); + } else { $color3 = weechat::color(weechat::config_color($options_iset{"color_value_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"})); @@ -483,7 +516,7 @@ sub iset_refresh_line my $value = $options_values[$y]; $value = "(undef)" if ($options_is_null[$y]); my $strline = sprintf($format, - $color1, $options_names[$y], + $color1, $options_names[$y], $padding, $color2, $options_types[$y], $color3, $around, $value, $around); weechat::print_y($iset_buffer, $y, $strline); @@ -675,6 +708,7 @@ sub iset_config_cb { $options_types[$index] = weechat::infolist_string($infolist, "type"); $options_values[$index] = weechat::infolist_string($infolist, "value"); + $options_default_values[$index] = weechat::infolist_string($infolist, "default_value"); $options_is_null[$index] = weechat::infolist_integer($infolist, "value_is_null"); iset_refresh_line($index); iset_title() if ($option_name eq "iset.look.show_current_line"); @@ -1221,6 +1255,14 @@ sub iset_config_init $iset_config_file, $section_color, "value_selected", "color", "Color for selected option value", "", 0, 0, "lightcyan", "lightcyan", 0, "", "", "full_refresh_cb", "", "", ""); + $options_iset{"color_value_diff"} = weechat::config_new_option( + $iset_config_file, $section_color, + "value_diff", "color", "Color for option value different from default", "", 0, 0, + "magenta", "magenta", 0, "", "", "full_refresh_cb", "", "", ""); + $options_iset{"color_value_diff_selected"} = weechat::config_new_option( + $iset_config_file, $section_color, + "value_diff_selected", "color", "Color for selected option value different from default", "", 0, 0, + "lightmagenta", "lightmagenta", 0, "", "", "full_refresh_cb", "", "", ""); $options_iset{"color_value_undef"} = weechat::config_new_option( $iset_config_file, $section_color, "value_undef", "color", "Color for option value undef", "", 0, 0,