diff options
author | Tom Feist <shabble@metavore.org> | 2011-04-06 10:18:11 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2011-04-06 10:18:11 +0000 |
commit | 4d83ae6e3f6044e3e4c9bf1d87054c13ce5751a6 (patch) | |
tree | 652c5a26d7c60507e758d597d1e2d0cd1d7dc4ea /vim-mode | |
parent | vim_mode: ex_hist documentation additions and cleanup. (diff) | |
download | irssi-scripts-4d83ae6e3f6044e3e4c9bf1d87054c13ce5751a6.tar.gz irssi-scripts-4d83ae6e3f6044e3e4c9bf1d87054c13ce5751a6.zip |
vim_mode: C-c cancels ex mode. Start of <Leader> variable support.
Diffstat (limited to 'vim-mode')
-rw-r--r-- | vim-mode/vim_mode.pl | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index e247e35..d04324e 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -538,6 +538,8 @@ my $settings ex_history_size => { type => S_INT, value => 100 }, # prompt_leading_space prompt_leading_space => { type => S_BOOL, value => 1 }, + # <Leader> value for prepending to commands. + map_leader => { type => S_STR, value => '\\' }, }; sub DEBUG { $settings->{debug}->{value} } @@ -2040,6 +2042,7 @@ sub _parse_mapping { my ($string) = @_; $string =~ s/<([^>]+)>/_parse_mapping_bracket($1)/ge; + _warn("Parse mapping: $string"); if (index($string, '<invalid>') != -1) { return undef; } @@ -2065,6 +2068,8 @@ sub _parse_mapping_bracket { # <BS> } elsif ($string eq 'bs') { $string = chr(127); + } elsif ($string eq 'leader') { + $string = $settings->{map_leader}->{value}; # Invalid char, return special string to recognize the error. } else { $string = '<invalid>'; @@ -2074,6 +2079,9 @@ sub _parse_mapping_bracket { sub _parse_mapping_reverse { my ($string) = @_; + my $escaped_leader = quotemeta($settings->{map_leader}->{value}); + $string =~ s/$escaped_leader/<Leader>/g; + # Convert char to <char-name>. $string =~ s/ /<Space>/g; $string =~ s/\n/<CR>/g; @@ -2088,6 +2096,9 @@ sub _parse_mapping_reverse { sub _parse_partial_command_reverse { my ($string) = @_; + my $escaped_leader = quotemeta($settings->{map_leader}->{value}); + $string =~ s/$escaped_leader/<Leader>/g; + # Convert Ctrl-X to ^X. $string =~ s/([\x01-\x1A])/"^" . chr(ord($1) + 64)/ge; # Convert Ctrl-6 and Ctrl-^ to <C-^>. @@ -2327,8 +2338,8 @@ sub got_key { $input_buf_timer = Irssi::timeout_add_once(10, \&handle_input_buffer, undef); print "Buffer Timer tag: $input_buf_timer" if DEBUG; - } elsif ($mode == M_INS) { - if ($key == 3) { # Ctrl-C enter command mode + } elsif ($mode == M_INS or $mode == M_EX) { + if ($key == 3) { # Ctrl-C enters command mode, or cancels ex mode. _update_mode(M_CMD); _stop(); return; @@ -3032,7 +3043,7 @@ sub delete_map { } push @add, $keys; - # Restore default keybindings in case we :unmaped a <Nop> or a remapped + # Restore default keybindings in case we :unmapped a <Nop> or a remapped # key. foreach my $key (@add) { if (exists $commands->{$key}) { |