diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-08-13 07:35:01 -0700 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-08-13 07:35:01 -0700 |
commit | bdd59a68eb7f45a94bab22bc8850d61e9daa3324 (patch) | |
tree | dd0dc81fa7db1a45210b469fdfb83638f953da3f | |
parent | 48cc772251f743537652dea6083c6d6c293a508a (diff) | |
parent | bf558b660b29dfb10e752c9982a6bdb1713c2b32 (diff) | |
download | reply-bdd59a68eb7f45a94bab22bc8850d61e9daa3324.tar.gz reply-bdd59a68eb7f45a94bab22bc8850d61e9daa3324.zip |
Merge pull request #24 from tokuhirom/rl-caroline
Plugin::ReadLine: Added Term::ReadLine::Caroline support.
-rw-r--r-- | lib/Reply/Plugin/ReadLine.pm | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/Reply/Plugin/ReadLine.pm b/lib/Reply/Plugin/ReadLine.pm index 31f0e80..55baa38 100644 --- a/lib/Reply/Plugin/ReadLine.pm +++ b/lib/Reply/Plugin/ReadLine.pm @@ -49,13 +49,14 @@ sub new { $self->{rl_gnu} = $self->{term}->ReadLine eq 'Term::ReadLine::Gnu'; $self->{rl_perl5} = $self->{term}->ReadLine eq 'Term::ReadLine::Perl5'; + $self->{rl_caroline} = $self->{term}->ReadLine eq 'Term::ReadLine::Caroline'; if ($self->{rl_perl5}) { # output compatible with Term::ReadLine::Gnu $readline::rl_scroll_nextline = 0; } - if ($self->{rl_perl5} || $self->{rl_gnu}) { + if ($self->{rl_perl5} || $self->{rl_gnu} || $self->{rl_caroline}) { $self->{term}->StifleHistory($opts{history_length}) if defined $opts{history_length} && $opts{history_length} >= 0; } @@ -90,7 +91,7 @@ sub DESTROY { return if defined $self->{history_length} && $self->{history_length} == 0; # XXX support more later - return unless ($self->{rl_gnu} || $self->{rl_perl5}); + return unless ($self->{rl_gnu} || $self->{rl_perl5} || $self->{rl_caroline}); $self->{term}->WriteHistory($self->{history_file}) or warn "Couldn't write history to $self->{history_file}"; @@ -132,6 +133,20 @@ sub _register_tab_complete { return scalar(@matches) ? @matches : (); }; } + + if ($self->{rl_caroline}) { + $term->caroline->completion_callback(sub { + my ($line) = @_; + + my @matches = $weakself->publish('tab_handler', $line); + # for variable completion, method name completion. + if (@matches && $line =~ /\W/) { + $line =~ s/[:\w]+\z//; + @matches = map { $line.$_ } @matches; + } + return scalar(@matches) ? @matches : (); + }); + } } 1; |