diff options
author | Tom Feist <shabble@metavore.org> | 2010-10-14 21:10:42 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2010-10-14 21:10:42 +0000 |
commit | dab4d33fc753f6d8e66b50482adabc5bd6c973c6 (patch) | |
tree | b07c6a4bc9a48a205e40625e6fb63168dba4e8f6 | |
parent | prompt: uberprompt no longer applies abstract replaces on prompt format. (diff) | |
parent | prompt: uberprompt no longer applies abstract replaces on prompt format. (diff) | |
download | irssi-scripts-dab4d33fc753f6d8e66b50482adabc5bd6c973c6.tar.gz irssi-scripts-dab4d33fc753f6d8e66b50482adabc5bd6c973c6.zip |
Merge remote branch 'origin/dev'
-rw-r--r-- | docs/allsigs-clean.txt | 379 | ||||
-rw-r--r-- | prompt_info/prompt_replace.pl | 346 | ||||
-rw-r--r-- | test/irssi/config | 4 | ||||
-rw-r--r-- | vim-mode/vim_mode.pl | 119 |
4 files changed, 822 insertions, 26 deletions
diff --git a/docs/allsigs-clean.txt b/docs/allsigs-clean.txt new file mode 100644 index 0000000..bd7d960 --- /dev/null +++ b/docs/allsigs-clean.txt @@ -0,0 +1,379 @@ +away mode changed" +"awaylog show" +"ban type changed" +"beep" +"channel created" +"channel destroyed" +"channel joined" +"channel rejoin new" +"channel sync" +"channel wholist" +"chanquery abort" +"chanquery ban end" +"chanquery ban" +"chanquery mode" +"chanquery who end" +"chat protocol created" +"chat protocol deinit" +"chat protocol destroyed" +"chat protocol unknown" +"chatnet destroyed" +"chatnet read" +"chatnet saved" +"command clear" +"command scrollback" +"complete command action" +"complete command alias" +"complete command away" +"complete command bind" +"complete command cat" +"complete command connect" +"complete command dcc send" +"complete command disconnect" +"complete command format" +"complete command help" +"complete command load" +"complete command msg" +"complete command query" +"complete command rawlog open" +"complete command rawlog save" +"complete command recode remove" +"complete command reconnect" +"complete command reload" +"complete command save" +"complete command script load" +"complete command script unload" +"complete command server add" +"complete command server remove" +"complete command server" +"complete command set" +"complete command stats" +"complete command toggle" +"complete command topic" +"complete command unalias" +"complete command window goto" +"complete command window item move" +"complete command window server" +"complete erase command action" +"complete erase command msg" +"complete erase command query" +"complete erase" +"complete word" +"ctcp action" +"ctcp msg clientinfo" +"ctcp msg dcc accept" +"ctcp msg dcc chat" +"ctcp msg dcc resume" +"ctcp msg dcc send" +"ctcp msg dcc" +"ctcp msg ping" +"ctcp msg time" +"ctcp msg userinfo" +"ctcp msg version" +"ctcp msg" +"ctcp reply dcc reject" +"ctcp reply dcc" +"ctcp reply ping" +"ctcp reply" +"dcc chat message" +"dcc closed" +"dcc connected" +"dcc ctcp action" +"dcc ctcp dcc" +"dcc destroyed" +"dcc error close not found" +"dcc error connect" +"dcc error ctcp" +"dcc error file create" +"dcc error file open" +"dcc error get not found" +"dcc error send exists" +"dcc error send no route" +"dcc error unknown type" +"dcc error write" +"dcc list print" +"dcc rejected" +"dcc reply dcc" +"dcc reply send pasv" +"dcc request send" +"dcc request" +"dcc server message" +"dcc server started" +"default command server" +"default command" +"default ctcp msg dcc" +"default ctcp msg" +"default ctcp reply dcc" +"default ctcp reply" +"default dcc ctcp" +"default event numeric" +"default event" +"error command" +"event 001" +"event 004" +"event 005" +"event 221" +"event 254" +"event 271" +"event 272" +"event 281" +"event 301" +"event 302" +"event 303" +"event 305" +"event 306" +"event 311" +"event 312" +"event 313" +"event 314" +"event 315" +"event 317" +"event 318" +"event 319" +"event 324" +"event 326" +"event 327" +"event 328" +"event 329" +"event 330" +"event 332" +"event 333" +"event 338" +"event 341" +"event 344" +"event 345" +"event 346" +"event 347" +"event 348" +"event 349" +"event 352" +"event 353" +"event 364" +"event 365" +"event 366" +"event 367" +"event 368" +"event 369" +"event 372" +"event 375" +"event 376" +"event 377" +"event 378" +"event 379" +"event 381" +"event 386" +"event 387" +"event 388" +"event 389" +"event 396" +"event 401" +"event 403" +"event 404" +"event 405" +"event 407" +"event 408" +"event 421" +"event 422" +"event 432" +"event 433" +"event 436" +"event 437" +"event 438" +"event 439" +"event 442" +"event 465" +"event 470" +"event 471" +"event 472" +"event 473" +"event 474" +"event 475" +"event 476" +"event 477" +"event 478" +"event 479" +"event 482" +"event 486" +"event 489" +"event 494" +"event 506" +"event 707" +"event 716" +"event 717" +"event 728" +"event 729" +"event connected" +"event empty" +"event error" +"event invite" +"event join" +"event kick" +"event kill" +"event mode" +"event nick" +"event notice" +"event part" +"event ping" +"event pong" +"event privmsg" +"event quit" +"event silence" +"event topic" +"event wallops" +"exec input" +"expando timer" +"flood" +"gui dialog" +"gui entry redirect" +"gui exit" +"gui key pressed" +"gui page scrolled" +"gui print text finished" +"gui print text" +"gui window create override" +"gui window created" +"ignore changed" +"ignore created" +"ignore destroyed" +"irssi init finished" +"irssi init read settings" +"lag ping error" +"lag pong" +"layout reset" +"layout restore item" +"layout restore window" +"layout restore" +"layout save item" +"layout save window" +"layout save" +"list subcommands" +"log config read" +"log config save" +"log create failed" +"log locked" +"log new" +"log written" +"mainwindow destroyed" +"mainwindow moved" +"mainwindow resized" +"message dcc action" +"message dcc ctcp" +"message dcc own" +"message dcc own_action" +"message dcc own_ctcp" +"message dcc" +"message invite" +"message irc action" +"message irc ctcp" +"message irc mode" +"message irc notice" +"message irc op_public" +"message irc own_action" +"message irc own_ctcp" +"message irc own_notice" +"message irc own_wall" +"message join" +"message kick" +"message nick" +"message own_nick" +"message own_private" +"message own_public" +"message part" +"message private" +"message public" +"message quit" +"message topic" +"module error" +"module loaded" +"module unloaded" +"netsplit new" +"nickfind event whois" +"nicklist changed" +"nicklist host changed" +"nicklist new" +"nicklist remove" +"notifylist away changed" +"notifylist event whois away" +"notifylist event whois end" +"notifylist event whois" +"notifylist event" +"notifylist joined" +"notifylist left" +"pidwait" +"print format" +"print starting" +"print text" +"proxy client dump" +"query created" +"query destroyed" +"query nick changed" +"query server changed" +"reload" +"requested usermode change" +"script destroyed" +"script error" +"send command" +"send text" +"server add fill" +"server connect copy" +"server connect failed" +"server connected" +"server connecting" +"server disconnected" +"server event" +"server incoming" +"server lag disconnect" +"server lag" +"server looking" +"server nick changed" +"server quit" +"server reconnect not found" +"server reconnect remove" +"server reconnect save status" +"server sendmsg" +"server setup fill chatnet" +"server setup fill connect" +"server setup fill reconn" +"server setup read" +"server setup saved" +"session restore channel" +"session restore nick" +"session restore server" +"session restore" +"session save channel" +"session save server" +"session save" +"settings errors" +"setup changed" +"setup reread" +"silent event who" +"silent event whois" +"terminal resized" +"theme changed" +"theme destroyed" +"user mode changed" +"userhost event" +"whois away" +"whois default event" +"whois end" +"whois event not found" +"whois event" +"whois oper" +"whois try whowas" +"whowas away" +"whowas event end" +"whowas event" +"window activity" +"window changed automatic" +"window changed" +"window created" +"window dehilight" +"window destroyed" +"window hilight" +"window history changed" +"window item changed" +"window item remove" +"window item server changed" +"window print info" +"window refnum changed" +"window server changed" diff --git a/prompt_info/prompt_replace.pl b/prompt_info/prompt_replace.pl new file mode 100644 index 0000000..30120f7 --- /dev/null +++ b/prompt_info/prompt_replace.pl @@ -0,0 +1,346 @@ +use strict; +use warnings; + +use Irssi; +use Irssi::TextUI; # for sbar_items_redraw +use Data::Dumper; + + + +our $VERSION = "0.1"; +our %IRSSI = + ( + authors => "shabble", + contact => 'shabble+irssi@metavore.org, shabble@#irssi/Freenode', + name => "prompt_info", + description => "Helper script for dynamically adding text " + . "into the input-bar prompt.", + license => "Public Domain", + changed => "24/7/2010" + ); + +sub DEBUG () { 1 } +#sub DEBUG () { 0 } + +my $prompt_data = undef; +my $prompt_item = undef; + +my $region_active = 0; + +my ($term_w, $term_h) = (0, 0); + +# visual region selected. +my ($region_start, $region_end) = (0, 0); +my $region_content = ''; + +my $prompt_format = ''; + +init(); + +sub update_terminal_size { + + my @stty_data = qx/stty -a/; + my $line = $stty_data[0]; + + # linux + # speed 38400 baud; rows 36; columns 126; line = 0; + if ($line =~ m/rows (\d+); columns (\d+);/) { + $term_h = $1; + $term_w = $2; + # osx + # speed 9600 baud; 40 rows; 235 columns; + } elsif ($line =~ m/(\d+) rows; (\d+) columns;/) { + $term_h = $1; + $term_w = $2; + } else { + # guess? + $term_h = 24; + $term_w = 80; + } + + print "Terminal detected as $term_w cols by $term_h rows" if DEBUG; +} + +sub prompt_subcmd_handler { + my ($data, $server, $item) = @_; + $data =~ s/\s+$//g; # strip trailing whitespace. + Irssi::command_runsub('prompt', $data, $server, $item); +} + +sub visual_subcmd_handler { + my ($data, $server, $item) = @_; + $data =~ s/\s+$//g; # strip trailing whitespace. + Irssi::command_runsub('visual', $data, $server, $item); +} + +sub init { + + Irssi::statusbar_item_register ('uberprompt', 0, 'uberprompt_draw'); + + Irssi::settings_add_str('uberprompt', 'uberprompt_format', '[$*] '); + + Irssi::command_bind("prompt", \&prompt_subcmd_handler); + Irssi::command_bind('prompt on', \&replace_prompt_items); + Irssi::command_bind('prompt off', \&restore_prompt_items); + Irssi::command_bind('prompt set', + sub { Irssi::signal_emit 'change prompt', shift; }); + Irssi::command_bind('prompt clear', + sub { Irssi::signal_emit 'change prompt', '$p'; }); + + # misc faff + Irssi::command_bind('visual', \&visual_subcmd_handler); + Irssi::command_bind('visual toggle', \&cmd_toggle_visual); + Irssi::command_bind('visual clear', \&cmd_clear_visual); + + Irssi::command("^BIND ^F /visual toggle"); + Irssi::command("^BIND ^G /visual clear"); + + Irssi::command_bind 'print_test', + sub { + Irssi::gui_printtext(0, 0, '%8hello there%n'); + }; + + # redraw interception + Irssi::signal_add_last('command redraw', \&augment_redraw); + Irssi::signal_add_first('gui key pressed', \&ctrl_l_intercept); + + # for updating the overlay. + Irssi::signal_add_last ('gui key pressed', \&key_pressed); + + # things to refresh the overlay for. + Irssi::signal_add('window changed', \&uberprompt_refresh); + Irssi::signal_add('window name changed', \&uberprompt_refresh); + Irssi::signal_add('window changed automatic', \&uberprompt_refresh); + Irssi::signal_add('window item changed', \&uberprompt_refresh); + + Irssi::signal_add('terminal resized', \&update_terminal_size); + Irssi::signal_add('setup changed', \&reload_settings); + + # so we know where the bottom line is + update_terminal_size(); + + # intialise the prompt format. + reload_settings(); + + # install our statusbars. + replace_prompt_items(); + + # the actual API signals. + Irssi::signal_register({'change prompt' => [qw/string/]}); + Irssi::signal_add('change prompt' => \&change_prompt_sig); + + Irssi::signal_register({'prompt changed' => [qw/string int/]}); +} + +sub change_prompt_sig { + my ($text) = @_; + + $text = '$p' . $text; + print "Got prompt change sig with: $text" if DEBUG; + + my $changed; + $changed = defined $prompt_data ? $prompt_data ne $text : 1; + + $prompt_data = $text; + + if ($changed) { + print "Redrawing prompt" if DEBUG; + uberprompt_refresh(); + } +} + + +sub UNLOAD { + # remove uberprompt and return the original ones. + restore_prompt_items(); +} + +sub reload_settings { + my $new = Irssi::settings_get_str('uberprompt_format'); + if ($prompt_format ne $new) { + print "Updated prompt format" if DEBUG; + $prompt_format = $new; + Irssi::abstracts_register(['uberprompt', $prompt_format]); + } +} + +sub uberprompt_draw { + my ($sb_item, $get_size_only) = @_; + + my $default_prompt = ''; + + my $window = Irssi::active_win; + + # hack to produce the same defaults as prompt/prompt_empty sbars. + + if (scalar( () = $window->items )) { + $default_prompt = '{uberprompt $[.15]itemname}'; + } else { + $default_prompt = '{uberprompt $winname}'; + } + + my $p_copy = $prompt_data; + + if (defined $prompt_data) { + # replace the special marker '$p' with the original prompt. + $p_copy =~ s/\$p/$default_prompt/; + } else { + $p_copy = $default_prompt; + } + print "Redrawing with: $p_copy, size-only: $get_size_only" if DEBUG; + + $prompt_item = $sb_item; + + my $ret = $sb_item->default_handler($get_size_only, $p_copy, '', 0); + + Irssi::signal_emit('prompt changed', $p_copy, $sb_item->{size}); + + return $ret; +} + +sub augment_redraw { + print "Redraw called" if DEBUG; + uberprompt_refresh(); + Irssi::timeout_add_once(10, \&refresh_visual_overlay, 0); +} + +sub uberprompt_refresh { + Irssi::statusbar_items_redraw('uberprompt'); +} + + +sub cmd_clear_visual { + _clear_visual_region(); + #refresh_visual_overlay(); + Irssi::statusbar_items_redraw('input'); +} + +sub cmd_toggle_visual { + + $region_active = not $region_active; + + if ($region_active) { + $region_start = _pos(); + $region_end = 0; # reset end marker. + print "visual mode started at $region_start" if DEBUG; + } else { + $region_end = _pos(); + print "Visual mode ended at $region_end" if DEBUG; + + if ($region_end > $region_start) { + my $input = Irssi::parse_special('$L', 0, 0); + my $str = substr($input, $region_start, $region_end - $region_start); + print "Region selected: $str" if DEBUG; + } else { + print "Invalid region selection: [ $region_start - $region_end ]" + if DEBUG; + $region_start = $region_end = 0; + } + cmd_clear_visual(); + } +} + +sub ctrl_l_intercept { + my $key = shift; + + if ($key == 12) { # C-l + print "C-l pressed" if DEBUG; + Irssi::command("redraw"); + Irssi::signal_stop(); + } elsif ($key == 10) { # RET + _clear_visual_region(); + } +} + +sub key_pressed { + # this handler needs to be last so the actual character is printed by irssi + # before we overlay on it. Otherwise things are all a bit off-by-1 + return unless $region_active; + + refresh_visual_overlay(); +} + +sub _clear_visual_region { + print "Clearing Region markers" if DEBUG; + $region_end = 0; + $region_start = 0; +} + + +sub refresh_visual_overlay { + + my $end_pos = $region_end; + $end_pos ||= _pos(); # if not set, take current position as end. + + my $len = $end_pos - $region_start; + return unless $len; # no point drawing an empty overlay + + my $input = Irssi::parse_special('$L'); + my $offset = $prompt_item->{size} + $region_start; + + my $text = substr($input, $region_start, $len); + + print "printing '$text' at $offset [$region_start, $end_pos] ($len)" if DEBUG; + + $text = '%8' . $text . '%8'; + _draw_overlay($offset, $text, $len); + +} + +sub _draw_overlay { + my ($offset, $text, $len) = @_; + Irssi::gui_printtext($offset, $term_h, $text); +} + +sub replace_prompt_items { + # remove existing ones. + print "Removing original prompt" if DEBUG; + + _sbar_command('prompt', 'remove', 'prompt'); + _sbar_command('prompt', 'remove', 'prompt_empty'); + + # add the new one. + + _sbar_command('prompt', 'add', 'uberprompt', + qw/-alignment left -before input -priority '-1'/); + + _sbar_command('prompt', 'position', '100'); +} + +sub restore_prompt_items { + + _sbar_command('prompt', 'remove', 'uberprompt'); + + print "Restoring original prompt" if DEBUG; + + _sbar_command('prompt', 'add', 'prompt', + qw/-alignment left -before input -priority '-1'/); + _sbar_command('prompt', 'add', 'prompt_empty', + qw/-alignment left -after prompt -priority '-1'/); + + _sbar_command('prompt', 'position', '100'); + +} + +sub _sbar_command { + my ($bar, $cmd, $item, @args) = @_; + + my $args_str = join ' ', @args; + + $args_str .= ' ' if length $args_str && defined $item; + + my $command = sprintf 'STATUSBAR %s %s %s%s', + $bar, $cmd, $args_str, defined($item)?$item:''; + + print "Running command: $command" if DEBUG; + Irssi::command($command); +} + +sub _pos { + return Irssi::gui_input_get_pos(); +} + + +# bit of fakery so things don't complain about the lack of prompt_info (hoepfully) + +%Irssi::Script::prompt_info:: = (); diff --git a/test/irssi/config b/test/irssi/config index 3b32ee9..5a7b307 100644 --- a/test/irssi/config +++ b/test/irssi/config @@ -133,6 +133,7 @@ aliases = { KB = "kickban"; KN = "knockout"; BANS = "ban"; + B = "ban"; MUB = "unban *"; UB = "unban"; IG = "ignore"; @@ -268,7 +269,8 @@ statusbar = { }; prompt = { items = { - uberprompt = { priority = "-1"; }; + prompt = { }; + prompt_empty = { }; input = { priority = "10"; }; }; position = "100"; diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index a00421a..6ff8c78 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -81,6 +81,9 @@ # * Substitute: :s/// - i and g are supported as flags, only /// can be # used as separator, uses Perl regex instead of # Vim regex +# * Settings: :se[t] - display all options +# :se[t] {option} - display all matching options +# :se[t] {option} {value} - change option to value # # # Mappings: @@ -102,11 +105,19 @@ # :unmap <C-E> - restore default behavior of <C-E> after disabling it # # -# The following irssi settings are available: +# Settings: +# +# The settings are stored as irssi settings and can be set using /set as usual +# (prepend vim_mode_ to setting name) or using the :set ex-command. The +# following settings are available: +# +# * utf8: support UTF-8 characters, boolean, default on +# * debug: enable debug output, boolean, default off +# * cmd_seq: char that when double-pressed simulates <esc>, string, default '' +# +# In contrast to irssi's settings, :set accepts 0 and 1 as values for boolean +# settings, but only vim_mode's settings can be set/displayed. # -# * vim_mode_utf8: support UTF-8 characters, default on -# * vim_mode_debug: enable debug output, default off -# * vim_mode_cmd_seq: char that when double-pressed simulates <esc> # # The following statusbar items are available: # @@ -259,6 +270,11 @@ sub C_IRSSI () { 6 } # does nothing sub C_NOP () { 7 } +# setting types, match irssi types as they are stored as irssi settings +sub S_BOOL () { 0 } +sub S_INT () { 1 } +sub S_STR () { 2 } + # word and non-word regex, keep in sync with setup_changed()! my $word = qr/[\w_]/o; my $non_word = qr/[^\w_\s]/o; @@ -439,6 +455,10 @@ my $commands_ex type => C_EX }, mkv => { char => ':mkv', func => \&ex_mkvimrc, type => C_EX }, + se => { char => ':se', func => \&ex_set, + type => C_EX }, + set => { char => ':set', func => \&ex_set, + type => C_EX }, }; # MAPPINGS @@ -454,12 +474,20 @@ foreach my $char (keys %$commands) { # GLOBAL VARIABLES -my $DEBUG_ENABLED = 0; - -sub DEBUG { $DEBUG_ENABLED } +# all vim_mode settings, must be enabled in vim_mode_init() before usage +my $settings + = { + # print debug output + debug => { type => S_BOOL, value => 0 }, + # use UTF-8 internally for string calculations/manipulations + utf8 => { type => S_BOOL, value => 1 }, + # esc-shortcut in insert mode + cmd_seq => { type => S_STR, value => '' }, + # not used yet + max_undo_lines => { type => S_INT, value => 50 }, + }; -# use UTF-8 internally for string calculations/manipulations -my $utf8 = 1; +sub DEBUG { $settings->{debug}->{value} } # buffer to keep track of the last N keystrokes, used for Esc detection and # insert mode mappings @@ -712,7 +740,7 @@ sub cmd_j { } elsif ($history_index >= 0) { my $history = $history[$history_index]; # History is not in UTF-8! - if ($utf8) { + if ($settings->{utf8}->{value}) { $history = decode_utf8($history); } _input($history); @@ -744,7 +772,7 @@ sub cmd_k { if ($history_index >= 0) { my $history = $history[$history_index]; # History is not in UTF-8! - if ($utf8) { + if ($settings->{utf8}->{value}) { $history = decode_utf8($history); } _input($history); @@ -781,7 +809,7 @@ sub cmd_G { my $history = $history[$history_index]; # History is not in UTF-8! - if ($utf8) { + if ($settings->{utf8}->{value}) { $history = decode_utf8($history); } _input($history); @@ -1870,6 +1898,45 @@ sub ex_mkvimrc { close $file; } +sub ex_set { + my ($arg_str, $count) = @_; + + # :se[t] [option] [value] + if ($arg_str =~ /^se(?:t)?(?:\s(\S+)(?:\s(.+)$)?)?/) { + # :se[t] {option} {value} + if (defined $1 and defined $2) { + if (not exists $settings->{$1}) { + return _warn_ex('map', "setting '$1' not found"); + } + my $name = $1; + my $value = $2; + # Also accept numeric values for boolean options. + if ($settings->{$name}->{type} == S_BOOL and + $value !~ /^(on|off)$/) { + $value = $value ? 'on' : 'off'; + } + Irssi::command("set vim_mode_$name $value"); + + # :se[t] [option] + } else { + my $search = defined $1 ? $1 : ''; + my $active_window = Irssi::active_win(); + foreach my $setting (sort keys %$settings) { + next if $setting !~ /^\Q$search\E/; # skip non-matches + my $value = $settings->{$setting}->{value}; + # Irssi only accepts 'on' and 'off' as values for boolean + # options. + if ($settings->{$setting}->{type} == S_BOOL) { + $value = $value ? 'on' : 'off'; + } + $active_window->print($setting . '=' . $value); + } + } + } else { + _warn_ex('map'); + } +} + sub _warn_ex { my ($command, $description) = @_; my $message = "Error in ex-mode command $command"; @@ -2481,38 +2548,40 @@ sub vim_mode_init { sub setup_changed { my $value; - # Delete all possible imaps created by /set vim_mode_cmd_seq. - foreach my $char ('a' .. 'z') { - delete $imaps->{$char}; + if ($settings->{cmd_seq}->{value} ne '') { + delete $imaps->{$settings->{cmd_seq}->{value}}; } - $value = Irssi::settings_get_str('vim_mode_cmd_seq'); - if ($value) { + if ($value eq '') { + $settings->{cmd_seq}->{value} = $value; + } else { if (length $value == 1) { $imaps->{$value} = { 'map' => $value, 'func' => sub { _update_mode(M_CMD) } }; + $settings->{cmd_seq}->{value} = $value; } else { _warn("Error: vim_mode_cmd_seq must be a single character"); } } - $DEBUG_ENABLED = Irssi::settings_get_bool('vim_mode_debug'); + $settings->{debug}->{value} = Irssi::settings_get_bool('vim_mode_debug'); my $new_utf8 = Irssi::settings_get_bool('vim_mode_utf8'); - - if ($new_utf8 != $utf8) { + if ($new_utf8 != $settings->{utf8}->{value}) { # recompile the patterns when switching to/from utf-8 $word = qr/[\w_]/o; $non_word = qr/[^\w_\s]/o; - } + $settings->{utf8}->{value} = $new_utf8; + } if ($new_utf8 and (!$^V or $^V lt v5.8.1)) { _warn("Warning: UTF-8 isn't supported very well in perl < 5.8.1! " . "Please disable the vim_mode_utf8 setting."); } - $utf8 = $new_utf8; + $settings->{max_undo_lines}->{value} + = Irssi::settings_get_int('vim_mode_max_undo_lines'); } sub UNLOAD { @@ -2545,7 +2614,7 @@ sub _add_undo_entry { unshift @undo_buffer, [$line, $pos]; $undo_index = 0; } - my $max = Irssi::settings_get_int('vim_mode_max_undo_lines'); + my $max = $settings->{max_undo_lines}->{value}; } sub _restore_undo_entry { @@ -2671,12 +2740,12 @@ sub _input { my $current_data = Irssi::parse_special('$L', 0, 0); - if ($utf8) { + if ($settings->{utf8}->{value}) { $current_data = decode_utf8($current_data); } if (defined $data) { - if ($utf8) { + if ($settings->{utf8}->{value}) { Irssi::gui_input_set(encode_utf8($data)); } else { Irssi::gui_input_set($data); |