From eb90c4d2d750c60c051190f3df1242e36f9903f7 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 15 Oct 2010 23:14:53 +0200 Subject: vim_mode: Display partial commands in carret notation. --- vim-mode/vim_mode.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index cce0700..f6af710 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2032,7 +2032,7 @@ sub vim_mode_cb { } else { $mode_str = '%_Command%_'; if ($partial_command) { - my $p_copy = $partial_command; + my $p_copy = _parse_mapping_reverse($partial_command); $p_copy =~ s/\\/\\\\\\\\/g; $mode_str .= " ($p_copy)"; } -- cgit v1.2.3 From 229d57f1b61aeb48bf52d4b6cb79bb5ae7510424 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 15 Oct 2010 23:36:18 +0200 Subject: vim_mode: Partially revert 11e71fbcfec0bcb2754cbd92b18ceffb27ee9300 and fix partial command. --- vim-mode/vim_mode.pl | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index f6af710..871440e 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -403,7 +403,7 @@ my $commands '~' => { char => '~', func => \&cmd_tilde, type => C_NORMAL, repeatable => 1, no_operator => 1 }, '"' => { char => '"', func => \&cmd_register, type => C_NEEDSKEY, - no_operator => 1, dont_clear_partial_keys => 1 }, + no_operator => 1 }, '.' => { char => '.', type => C_NORMAL, repeatable => 1, no_operator => 1 }, ':' => { char => ':', type => C_NORMAL }, @@ -527,10 +527,6 @@ my $numeric_prefix = undef; my $operator = undef; # vi movements, only used when a movement needs more than one key (like f t). my $movement = undef; - -# current partial command = all pending keys currently entered -my $partial_command = ''; - # last vi command, used by . my $last = { @@ -1476,8 +1472,6 @@ sub cmd_register { return (undef, undef); } - $partial_command .= $char; - # make sure black hole register is always empty if ($char eq '_') { $registers->{_} = ''; @@ -2031,10 +2025,27 @@ sub vim_mode_cb { $mode_str = '%_Ex%_'; } else { $mode_str = '%_Command%_'; - if ($partial_command) { - my $p_copy = _parse_mapping_reverse($partial_command); - $p_copy =~ s/\\/\\\\\\\\/g; - $mode_str .= " ($p_copy)"; + if ($register ne '"' or $numeric_prefix or $operator or $movement or + $pending_map) { + my $partial = ''; + if ($register ne '"') { + $partial .= '"' . $register; + } + if ($numeric_prefix) { + $partial .= $numeric_prefix; + } + if ($operator) { + $partial .= $operator->{char}; + } + if ($movement) { + $partial .= $movement->{char}; + } + if (defined $pending_map) { + $partial .= $pending_map; + } + $partial = _parse_mapping_reverse($partial); + $partial =~ s/\\/\\\\\\\\/g; + $mode_str .= " ($partial)"; } } $sb_item->default_handler($get_size_only, "{sb $mode_str}", '', 0); @@ -2250,7 +2261,6 @@ sub handle_command_cmd { ($char =~ m/[1-9]/ or ($numeric_prefix && $char =~ m/[0-9]/))) { print "Processing numeric prefix: $char" if DEBUG; handle_numeric_prefix($char); - $partial_command .= $char; return 1; # call _stop() } @@ -2269,8 +2279,6 @@ sub handle_command_cmd { } elsif (exists $maps->{$char}) { $map = $maps->{$char}; - $partial_command .= $char; - # We have multiple mappings starting with this key sequence. if (!$pending_map_flushed and scalar keys %{$map->{maps}} > 0) { if (not defined $pending_map) { @@ -2290,7 +2298,6 @@ sub handle_command_cmd { print "No mapping found for $char" if DEBUG; $pending_map = undef; $numeric_prefix = undef; - $partial_command = ''; return 1; # call _stop() } @@ -2301,7 +2308,6 @@ sub handle_command_cmd { # Make sure we have a valid $cmd. if (not defined $cmd) { print "Bug in pending_map_flushed() $map->{char}" if DEBUG; - $partial_command = ''; return 1; # call _stop() } @@ -2312,7 +2318,6 @@ sub handle_command_cmd { $cmd->{func}->(substr($cmd->{char}, 1), $numeric_prefix); $numeric_prefix = undef; - $partial_command = ''; return 1; # call _stop() # As can irssi commands. } elsif ($cmd->{type} == C_IRSSI) { @@ -2320,14 +2325,12 @@ sub handle_command_cmd { Irssi::command($cmd->{func}); $numeric_prefix = undef; - $partial_command = ''; return 1; # call _stop(); # does nothing. } elsif ($cmd->{type} == C_NOP) { print "Processing : $map->{char}" if DEBUG; $numeric_prefix = undef; - $partial_command = ''; return 1; # call _stop(); } @@ -2368,7 +2371,6 @@ sub handle_command_cmd { $numeric_prefix = undef; $operator = undef; $movement = undef; - $partial_command = ''; # Set new operator. } else { $operator = $cmd; @@ -2492,10 +2494,6 @@ sub handle_command_cmd { $last->{movement} = $movement; $last->{register} = $register; } - - if (!$cmd->{dont_clear_partial_keys}) { - $partial_command = ''; - } } # Reset the count unless we go into insert mode, _update_mode() needs @@ -2863,8 +2861,6 @@ sub _update_mode { # It's necessary when pressing enter so the next line can be repeated. } elsif ($mode == M_CMD and $new_mode == M_INS) { $last->{cmd} = $commands->{i}; - - $partial_command = ''; # Make sure prompt is cleared when leaving ex mode. } elsif ($mode == M_EX and $new_mode != M_EX) { _set_prompt(''); @@ -2884,7 +2880,6 @@ sub _update_mode { $register = '"'; $pending_map = undef; - $partial_command = ''; # Also clear ex-mode buffer. @ex_buf = (); -- cgit v1.2.3 From 1810f78a87ce5c1c286dbab09281f804350a6685 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 15 Oct 2010 23:42:14 +0200 Subject: vim_mode: Correctly display partial commands with ^X notation. Reported by estragib. --- vim-mode/vim_mode.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 871440e..6cbf617 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1865,6 +1865,16 @@ sub _parse_mapping_reverse { return $string; } +sub _parse_partial_command_reverse { + my ($string) = @_; + + # Convert Ctrl-X to ^X. + $string =~ s/([\x01-\x1A])/"^" . chr(ord($1) + 64)/ge; + # Convert Ctrl-6 and Ctrl-^ to . + $string =~ s/\x1E/^^/g; + + return $string; +} sub ex_source { my ($arg_str, $count) = @_; @@ -2043,7 +2053,7 @@ sub vim_mode_cb { if (defined $pending_map) { $partial .= $pending_map; } - $partial = _parse_mapping_reverse($partial); + $partial = _parse_partial_command_reverse($partial); $partial =~ s/\\/\\\\\\\\/g; $mode_str .= " ($partial)"; } -- cgit v1.2.3 From e3f47424682bac05fcc6cd65d1e9174d0f902dda Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 15 Oct 2010 23:57:42 +0200 Subject: vim_mode: Hopefully fix undo/redo with 'start_cmd'. --- vim-mode/vim_mode.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 6cbf617..045ae80 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2776,10 +2776,12 @@ sub delete_map { sub _commit_line { _update_mode(M_INS); - _reset_undo_buffer('', 0); + # separate from call above as _update_mode() does additional internal work # and we need to make sure it gets correctly called. _update_mode(M_CMD) if $settings->{start_cmd}->{value}; + + _reset_undo_buffer('', 0); } sub _input { -- cgit v1.2.3 From b97a6b5a400a7cb6eb921d529aa8bce6eca0e6cf Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 16 Oct 2010 00:15:00 +0200 Subject: vim_mode: Fix undo for cc/yy. Reported by estragib. --- vim-mode/vim_mode.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 045ae80..2c7e744 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2372,6 +2372,9 @@ sub handle_command_cmd { # Restore position for yy. if ($cmd == $commands->{y}) { _input_pos($pos); + # And save undo for other operators. + } else { + _add_undo_entry(_input(), _input_pos()); } if ($register ne '"') { print 'Changing register to "' if DEBUG; -- cgit v1.2.3