diff options
author | Tom Feist <shabble@metavore.org> | 2010-09-26 21:43:06 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2010-09-26 21:43:06 +0000 |
commit | a8d289618a16c639cf41efeda48e1468f111b175 (patch) | |
tree | 6fe15ce55ad313942380099eb6d0b0b167853b1a /vim-mode/vim_mode.pl | |
parent | modified script info block to contain real names. (diff) | |
download | irssi-scripts-a8d289618a16c639cf41efeda48e1468f111b175.tar.gz irssi-scripts-a8d289618a16c639cf41efeda48e1468f111b175.zip |
refactored enter handling code into _commit_line(), and intercepted enter from ins mode too
Diffstat (limited to 'vim-mode/vim_mode.pl')
-rw-r--r-- | vim-mode/vim_mode.pl | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index a87c99c..e15e39e 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -604,11 +604,17 @@ sub got_key { $esc_buf_timer = Irssi::timeout_add_once(10, \&handle_esc_buffer, undef); - # Ctrl-C - } elsif ($key == 3 && $mode == M_INS) { - _update_mode(M_CMD); - _stop(); - return; + } elsif ($mode == M_INS) { + if ($key == 3) { # Ctrl-C enter command mode + _update_mode(M_CMD); + _stop(); + return; + } elsif ($key == 10) { # enter. + _commit_line(_input()); + @undo_buffer = (); + $undo_index = undef; + _stop(); + } } if ($esc_buf_enabled) { @@ -811,22 +817,7 @@ sub handle_command { # Enter key sends the current input line in command mode as well. } elsif ($key == 10) { - my $input = _input(); - my $cmdchars = Irssi::settings_get_str('cmdchars'); - - my $signal; - if ($input =~ /^[\Q$cmdchars\E]/) { - $signal = 'send command'; - } else { - $signal = 'send text'; - } - # TODO: don't try to send this signal unless server and win are - # defined (At least for 'send text' signals. There's no reason - # to send text to an empty window anyway(?) - Irssi::signal_emit $signal, $input, Irssi::active_server(), - Irssi::active_win()->{active}; - _input(''); - _update_mode(M_INS); + _commit_line(_input()); } } @@ -838,6 +829,28 @@ sub vim_mode_init { Irssi::statusbar_item_register ('vim_mode', 0, 'vim_mode_cb'); } +sub _commit_line { + my ($line) = @_; + + my $cmdchars = Irssi::settings_get_str('cmdchars'); + + my $signal; + if ($line =~ /^[\Q$cmdchars\E]/) { + $signal = 'send command'; + } else { + $signal = 'send text'; + } + + print "Committing line as $signal" if DEBUG; + + # TODO: don't try to send this signal unless server and win are + # defined (At least for 'send text' signals. There's no reason + # to send text to an empty window anyway(?) + Irssi::signal_emit $signal, $line, Irssi::active_server(), + Irssi::active_win()->{active}; + _input(''); + _update_mode(M_INS); +} sub _input { my ($data) = @_; |