diff options
author | Tom Feist <shabble@metavore.org> | 2010-09-30 22:45:01 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2010-09-30 22:45:01 +0000 |
commit | f3cc5f447c46ac58f9ac70a6c9ad7397997df0cf (patch) | |
tree | e27586bcb98d45986537c340ff4db43479b96efb /vim-mode/vim_mode.pl | |
parent | mostly working undo/redo support. Still adding history entries though, which we (diff) | |
parent | vim_mode: Add ; and ,. (diff) | |
download | irssi-scripts-f3cc5f447c46ac58f9ac70a6c9ad7397997df0cf.tar.gz irssi-scripts-f3cc5f447c46ac58f9ac70a6c9ad7397997df0cf.zip |
Merge remote branch 'origin/dev'
Diffstat (limited to '')
-rw-r--r-- | vim-mode/vim_mode.pl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index d0f1d46..5e5096d 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -106,6 +106,7 @@ use List::Util; use Irssi; use Irssi::TextUI; # for sbar_items_redraw +use Irssi::Irc; # necessary for 0.8.14 use vars qw($VERSION %IRSSI); @@ -173,6 +174,12 @@ my $last 'movement' => undef, 'register' => '"', }; +# last ftFT movement, used by ; and , +my $last_ftFT + = { + type => undef, # f, t, F or T + char => undef, + }; # what Vi mode we're in. We start in insert mode. my $mode = M_INS; @@ -246,6 +253,8 @@ my $movements 't' => { func => \&cmd_movement_t }, 'F' => { func => \&cmd_movement_F }, 'T' => { func => \&cmd_movement_T }, + ';' => { func => \&cmd_movement_semicolon }, + ',' => { func => \&cmd_movement_comma }, # word movement 'w' => { func => \&cmd_movement_w }, 'b' => { func => \&cmd_movement_b }, @@ -489,6 +498,8 @@ sub cmd_movement_f { if ($pos != -1) { _input_pos($pos); } + + $last_ftFT = { type => 'f', char => $char }; } sub cmd_movement_t { my ($count, $pos, $repeat, $char) = @_; @@ -497,6 +508,8 @@ sub cmd_movement_t { if ($pos != -1) { _input_pos($pos - 1); } + + $last_ftFT = { type => 't', char => $char }; } sub cmd_movement_F { my ($count, $pos, $repeat, $char) = @_; @@ -506,6 +519,8 @@ sub cmd_movement_F { if ($pos != -1) { _input_pos(length($input) - $pos - 1); } + + $last_ftFT = { type => 'F', char => $char }; } sub cmd_movement_T { my ($count, $pos, $repeat, $char) = @_; @@ -515,6 +530,8 @@ sub cmd_movement_T { if ($pos != -1) { _input_pos(length($input) - $pos - 1 + 1); } + + $last_ftFT = { type => 'T', char => $char }; } # Find $count-th next occurrence of $char. sub _next_occurrence { @@ -804,6 +821,31 @@ sub cmd_movement_tilde { _input_pos($pos + $count); } +sub cmd_movement_semicolon { + my ($count, $pos, $repeat) = @_; + + return if not defined $last_ftFT; + + $movements->{$last_ftFT->{type}} + ->{func}($count, $pos, $repeat, $last_ftFT->{char}); +} +sub cmd_movement_comma { + my ($count, $pos, $repeat) = @_; + + return if not defined $last_ftFT; + + # Change direction. + my $save = $last_ftFT->{type}; + my $type = $save; + $type =~ tr/ftFT/FTft/; + + $movements->{$type} + ->{func}($count, $pos, $repeat, $last_ftFT->{char}); + # Restore type as the move functions overwrites it. + $last_ftFT->{type} = $save; +} + + sub cmd_movement_register { my ($count, $pos, $repeat, $char) = @_; |