diff options
| -rw-r--r-- | prompt_info/prompt_info.pl | 26 | ||||
| -rw-r--r-- | vim-mode/vim_mode.pl | 62 | 
2 files changed, 70 insertions, 18 deletions
| diff --git a/prompt_info/prompt_info.pl b/prompt_info/prompt_info.pl index 51e5c16..8ad63ba 100644 --- a/prompt_info/prompt_info.pl +++ b/prompt_info/prompt_info.pl @@ -9,10 +9,30 @@  #  #    prompt = "[$*$prompt_additional] "  # -# Then add this script to your autorun directory (~/.irssi/scripts/autorun/) +# Then place this script to your ~/.irssi/scripts directory (~/.irssi/scripts/) +# and symlink it to the ~/.irssi/scripts/autorun directory (which may need to +# be created first)  # -# You can modify your prompt content by using the '/set_prompt <string>' command, -# or from scripts by Irssi:signal_emit('change prompt', $string); +# You can also load it manually once the theme has been edited via +# +# /script load prompt_info.pl +# +# You will also need to reload your theme with the following command: +# +# /script exec Irssi::themes_reload() +# +# Once loaded, you can modify your prompt content by using the following command: +# +# /set_prompt <string> +# +# You can also use it from other scripts by issuing a signal as follows: +# +# Irssi:signal_emit('change prompt', +# +# report bugs / feature requests to http://github.com/shabble/irssi-scripts/issues +# +# NOTE: it does not appear to be possible to use colours in your prompt at present. +# This is unlikely to change without source-code changes to Irssi itself.  use strict;  use warnings; diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index e40d15f..085ea78 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -249,6 +249,7 @@ my $movements       # undo       'u'    => { func => \&cmd_undo },       "\x12" => { func => \&cmd_redo }, +     "\x04" => { func => \&_print_undo_buffer },      }; @@ -266,16 +267,16 @@ my $movements_multiple =  sub cmd_undo {      print "Undo!" if DEBUG; -    if ($undo_index > $#undo_buffer) { -        $undo_index = $#undo_buffer; -        print "No further undo." if DEBUG; -    } elsif ($undo_index != $#undo_buffer) { -        $undo_index++; -    } -    print "Undoing entry $undo_index of " . $#undo_buffer if DEBUG; +    print "Undoing entry index: $undo_index of " . scalar(@undo_buffer) if DEBUG;      _restore_undo_entry($undo_index); + +    if ($undo_index != $#undo_buffer) { +        $undo_index++; +    } else { +        print "No further undo." if DEBUG; +    }  }  sub cmd_redo { @@ -1170,6 +1171,7 @@ sub vim_mode_init {      Irssi::settings_add_bool('vim_mode', 'vim_mode_utf8', 1);      setup_changed(); +    _reset_undo_buffer();  }  sub setup_changed { @@ -1201,7 +1203,7 @@ sub setup_changed {      if ($new_utf8 and (!$^V or $^V lt v5.8.1)) {          _warn("Warning: UTF-8 isn't supported very well in perl < 5.8.1! " . -              "Please disable vim_mode_utf8."); +              "Please disable the vim_mode_utf8 setting.");      }      $utf8 = $new_utf8; @@ -1227,29 +1229,59 @@ sub _restore_undo_entry {      _input_pos($entry->[1]);  } -sub _clear_undo_buffer { +sub _print_undo_buffer { + +    my $i = 0; +    my @buf; +    foreach my $entry (@undo_buffer) { +        my $str = ''; +        if ($i == $undo_index) { +            $str .= '* '; +        } else { +            $str .= '  '; +        } +        $str .= sprintf('%02d %s [%d]', $i, $entry->[0], $entry->[1]); +        push @buf, $str; +        $i++; +    } +    print "------ undo buffer ------"; +    print join("\n", @buf); +    print "------------------ ------"; + +} + +sub _reset_undo_buffer { +    my ($line, $pos) = @_; +    $line = _input()     unless defined $line; +    $pos  = _input_pos() unless defined $pos; +      print "Clearing undo buffer" if DEBUG; -    @undo_buffer = (['', 0]); -    $undo_index = 0; +    @undo_buffer = ([$line, $pos]); +    $undo_index  = 0;  }  sub _commit_line {      _update_mode(M_INS); -    _clear_undo_buffer(); +    _reset_undo_buffer('', 0);  }  sub _input { -    my ($data, $ignore) = @_; +    my ($data, $ignore_undo) = @_;      my $current_data = Irssi::parse_special('$L', 0, 0); +      if ($utf8) {          $current_data = decode_utf8($current_data);      }      if (defined $data) { -        if (!$ignore && ($data ne $current_data)) { -            _add_undo_entry($current_data, _input_pos()); +        if (!$ignore_undo && ($data ne $current_data)) { +            if ($undo_index != 0) { # ??? +                _reset_undo_buffer($current_data, _input_pos()); +            } else { +                _add_undo_entry($current_data, _input_pos()); +            }          }          if ($utf8) {              Irssi::gui_input_set(encode_utf8($data)); | 
