diff options
author | Tom Feist <shabble@metavore.org> | 2010-10-01 00:10:46 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2010-10-01 00:10:46 +0000 |
commit | c65a0f8388e2b55f753303ad5654033ad74af528 (patch) | |
tree | 72860b677a6345ecabad4e99f478cfab88690e21 /vim-mode | |
parent | added a brief snippet showing how to intercept 'print text' signals, and updated (diff) | |
parent | vim_mode: Add Ctrl-D, Ctrl-U, Ctrl-F, Ctrl-B for scrolling. (diff) | |
download | irssi-scripts-c65a0f8388e2b55f753303ad5654033ad74af528.tar.gz irssi-scripts-c65a0f8388e2b55f753303ad5654033ad74af528.zip |
Merge remote branch 'origin/dev'
Diffstat (limited to '')
-rw-r--r-- | vim-mode/vim_mode.pl | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 5460d3c..517b31c 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -282,15 +282,19 @@ my $movements # to end of line 'C' => { func => \&cmd_movement_dollar }, 'D' => { func => \&cmd_movement_dollar }, + # scrolling + "\x04" => { func => \&cmd_movement_ctrl_d }, # half screen down + "\x15" => { func => \&cmd_movement_ctrl_u }, # half screen up + "\x06" => { func => \&cmd_movement_ctrl_f }, # screen down + "\x02" => { func => \&cmd_movement_ctrl_b }, # screen up # misc '~' => { func => \&cmd_movement_tilde }, '.' => {}, '"' => { func => \&cmd_movement_register }, + "\x1e" => { func => \&cmd_movement_ctrl_6 }, # undo 'u' => { func => \&cmd_undo }, "\x12" => { func => \&cmd_redo }, - "\x04" => { func => \&_print_undo_buffer }, - }; # special movements which take an additional key @@ -809,6 +813,38 @@ sub _paste_at_position { _insert_at_position($registers->{$register}, $count, $pos); } +sub cmd_movement_ctrl_d { + my ($count, $pos, $repeat) = @_; + + my $window = Irssi::active_win(); + # no count = half of screen + if (not defined $count) { + $count = $window->{height} / 2; + } + $window->view()->scroll($count); +} +sub cmd_movement_ctrl_u { + my ($count, $pos, $repeat) = @_; + + my $window = Irssi::active_win(); + # no count = half of screen + if (not defined $count) { + $count = $window->{height} / 2; + } + $window->view()->scroll($count * -1); +} +sub cmd_movement_ctrl_f { + my ($count, $pos, $repeat) = @_; + + my $window = Irssi::active_win(); + $window->view()->scroll($count * $window->{height}); +} +sub cmd_movement_ctrl_b { + my ($count, $pos, $repeat) = @_; + + cmd_movement_ctrl_f($count * -1, $pos, $repeat); +} + sub cmd_movement_tilde { my ($count, $pos, $repeat) = @_; @@ -869,6 +905,11 @@ sub cmd_movement_register { print "Changing register to $register" if DEBUG; } +sub cmd_movement_ctrl_6 { + # like :b# + Irssi::command('window last'); +} + # Adapt the input position depending if an operator is active or not. sub _fix_input_pos { my ($pos, $length) = @_; @@ -967,6 +1008,8 @@ sub cmd_ex_command { # :ls and :buffers } elsif ($arg_str eq 'ls' or $arg_str eq 'buffers') { Irssi::command('window list'); + } elsif ($arg_str eq 'undol' or $arg_str eq 'undolist') { + _print_undo_buffer(); } } @@ -1306,8 +1349,10 @@ sub handle_command_cmd { if ($skip) { print "Skipping movement and operator." if DEBUG; } else { - # Make sure count is at least 1. - if (not $numeric_prefix) { + # Make sure count is at least 1 except for functions which need to + # know if no count was used + if (not $numeric_prefix and $char ne "\x04" # ctrl-d + and $char ne "\x15") { # ctrl-u $numeric_prefix = 1; } |