From 3612dd366635d607d74ee449201dfd5874b80dbf Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Thu, 16 Jul 2015 22:20:43 +0200 Subject: weechat: iset.pl: 3.7 -> 3.9 --- weechat/perl/iset.pl | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'weechat') diff --git a/weechat/perl/iset.pl b/weechat/perl/iset.pl index 0a4f8b5..af74767 100644 --- a/weechat/perl/iset.pl +++ b/weechat/perl/iset.pl @@ -19,6 +19,10 @@ # # History: # +# 2015-05-16, Sebastien Helleu : +# version 3.9: fix cursor position when editing an option with WeeChat >= 1.2 +# 2015-05-02, arza : +# version 3.8: don't append "null" to /set when setting an undefined setting # 2015-05-01, nils_2 : # version 3.7: fix two perl warnings (reported by t3chguy) # 2014-09-30, arza : @@ -119,7 +123,7 @@ use strict; my $PRGNAME = "iset"; -my $VERSION = "3.7"; +my $VERSION = "3.9"; my $DESCR = "Interactive Set for configuration options"; my $AUTHOR = "Sebastien Helleu "; my $LICENSE = "GPL3"; @@ -982,22 +986,34 @@ sub iset_cmd_cb my $value = $options_values[$current_line]; if ($options_is_null[$current_line]) { - $value = "null"; + $value = ""; } else { $quote = "\"" if ($options_types[$current_line] eq "string"); } + $value = " ".$quote.$value.$quote if ($value ne "" or $quote ne ""); + 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 ""); + my $start_index = 5; + if (weechat::config_boolean($options_iset{"use_mute"}) == 1) + { + $set_command = "/mute ".$set_command; + $start_index += 11; + } + $set_command = $set_command." ".$options_names[$current_line].$value; + my $pos_space = index($set_command, " ", $start_index); + if ($pos_space < 0) + { + $pos_space = 9999; + } + else + { + $pos_space = $pos_space + 1; + $pos_space = $pos_space + 1 if ($quote ne ""); + } + weechat::buffer_set($iset_buffer, "input", $set_command); + weechat::buffer_set($iset_buffer, "input_pos", "".$pos_space); } } weechat::bar_item_update("isetbar_help") if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1); -- cgit v1.2.3-70-g09d2