From 611532140494a2b281d699bf8897ac344257e782 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 1 Dec 2010 12:30:33 +0000 Subject: vim_mode: prototype of partial ex bindings map with :map # Invoking the mapped keys will insert into the ex buffer, and leave it active for you to add further arguments. --- vim-mode/vim_mode.pl | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index bad556e..4f071c4 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -487,6 +487,8 @@ my $commands_ex type => C_EX }, sprev => { char => ':serverprev', func => \&ex_server_prev, type => C_EX }, + exinsert => { char => ':exins', func => \&ex_insert_str, + type => C_EX }, }; @@ -1621,6 +1623,18 @@ sub _fix_input_pos { # EX MODE COMMANDS +sub ex_insert { + my ($arg_str, $count) = @_; + $count = defined $count ? $count : 1; + print "EX-Inserting: $arg_str cnt: $count" if DEBUG; + + push @ex_buf, split '', $arg_str; + _set_prompt(':' . join '', @ex_buf); + _update_mode(M_EX); + + Irssi::statusbar_items_redraw("vim_windows"); + +} sub cmd_ex_command { my $arg_str = join '', @ex_buf; @@ -1937,8 +1951,8 @@ sub ex_map { # Add new mapping. my $command; - # Ex-mode command - if (index($rhs, ':') == 0) { + + if (index($rhs, ':') == 0) { # Ex-mode command $rhs =~ /^:(\S+)(\s.+)?$/; if (not exists $commands_ex->{$1}) { return _warn_ex('map', "$rhs not found"); @@ -1948,8 +1962,21 @@ sub ex_map { type => C_EX, }; } - # Irssi command - } elsif (index($rhs, '/') == 0) { + } elsif (index($rhs, '#') == 0) { # partial ex-mode command (insert) + if ($rhs =~ /^#(.+)/) { + my $parsed_rhs = _parse_mapping($1); + $command = { + char => $parsed_rhs, + func => \&ex_insert, + type => C_EX, + }; + } else { + _warn_ex('invalid partial ex-mode mapping ' . $rhs); + } + } elsif (index($rhs, '/') == 0) { # Irssi command + # TODO: check for $cmdchars instead of just /? + # except when it interferes with : for ex. + $command = { char => $rhs, func => substr($rhs, 1), type => C_IRSSI, -- cgit v1.2.3