X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/2512c622d1a79a40a95f4d26dda652fc825930fc..3570955f51a6173f2b1ff76ed2be1549840b280e:/weechat/perl/iset.pl?ds=inline diff --git a/weechat/perl/iset.pl b/weechat/perl/iset.pl index 377b7c3..f179022 100644 --- a/weechat/perl/iset.pl +++ b/weechat/perl/iset.pl @@ -1,6 +1,6 @@ # -# Copyright (C) 2008-2013 Sebastien Helleu -# Copyright (C) 2010-2012 Nils Görs +# Copyright (C) 2008-2014 Sebastien Helleu +# Copyright (C) 2010-2014 Nils Görs # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,6 +19,12 @@ # # History: # +# 2014-09-30, arza : +# version 3.6: fix current line counter when options aren't found +# 2014-06-03, nils_2 : +# version 3.5: add new option "use_mute" +# 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 @@ -111,7 +117,7 @@ use strict; my $PRGNAME = "iset"; -my $VERSION = "3.3"; +my $VERSION = "3.6"; my $DESCR = "Interactive Set for configuration options"; my $AUTHOR = "Sebastien Helleu "; my $LICENSE = "GPL3"; @@ -125,6 +131,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; @@ -150,7 +157,17 @@ sub iset_title if ($iset_buffer ne "") { my $current_line_counter = ""; - $current_line_counter = ($current_line + 1) . "/" if (weechat::config_boolean($options_iset{"show_current_line"}) == 1); + if (weechat::config_boolean($options_iset{"show_current_line"}) == 1) + { + if (@options_names eq 0) + { + $current_line_counter = "0/"; + } + else + { + $current_line_counter = ($current_line + 1) . "/"; + } + } my $show_filter = ""; if ($search_mode eq 0) { @@ -328,6 +345,7 @@ sub iset_get_options @options_names = (); @options_types = (); @options_values = (); + @options_default_values = (); @options_is_null = (); $option_max_length = 0; my %options_internal = (); @@ -346,6 +364,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) { @@ -354,6 +373,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}; @@ -364,6 +384,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}; @@ -378,6 +399,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"}); } } @@ -402,6 +424,7 @@ sub iset_search_values @options_names = (); @options_types = (); @options_values = (); + @options_default_values = (); @options_is_null = (); $option_max_length = 0; my %options_internal = (); @@ -414,12 +437,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); } @@ -431,6 +456,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); } @@ -443,6 +469,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"}); } } @@ -475,6 +502,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"})); @@ -487,6 +518,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"})); @@ -687,6 +722,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"); @@ -946,10 +982,14 @@ sub iset_cmd_cb { $quote = "\"" if ($options_types[$current_line] eq "string"); } - weechat::buffer_set($iset_buffer, "input", "/set ".$options_names[$current_line]." ".$quote.$value.$quote); + my $set_command = "/set"; + $set_command = "/mute " . $set_command if (weechat::config_boolean($options_iset{"use_mute"}) == 1); + + weechat::buffer_set($iset_buffer, "input", $set_command." ".$options_names[$current_line]." ".$quote.$value.$quote); weechat::command($iset_buffer, "/input move_beginning_of_line"); weechat::command($iset_buffer, "/input move_next_word"); weechat::command($iset_buffer, "/input move_next_word"); + weechat::command($iset_buffer, "/input move_next_word") if (weechat::config_boolean($options_iset{"use_mute"}) == 1); weechat::command($iset_buffer, "/input move_next_char"); weechat::command($iset_buffer, "/input move_next_char") if ($quote ne ""); } @@ -1233,6 +1273,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, @@ -1297,6 +1345,10 @@ sub iset_config_init $iset_config_file, $section_look, "show_current_line", "boolean", "show current line in title bar.", "", 0, 0, "on", "on", 0, "", "", "", "", "", ""); + $options_iset{"use_mute"} = weechat::config_new_option( + $iset_config_file, $section_look, + "use_mute", "boolean", "/mute command will be used in input bar", "", 0, 0, + "off", "off", 0, "", "", "", "", "", ""); } sub iset_config_reload_cb