summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortokuhirom <tokuhirom@gmail.com>2013-08-13 13:20:26 +0900
committertokuhirom <tokuhirom@gmail.com>2013-08-13 13:49:30 +0900
commitbf558b660b29dfb10e752c9982a6bdb1713c2b32 (patch)
treedd0dc81fa7db1a45210b469fdfb83638f953da3f
parent48cc772251f743537652dea6083c6d6c293a508a (diff)
downloadreply-bf558b660b29dfb10e752c9982a6bdb1713c2b32.tar.gz
reply-bf558b660b29dfb10e752c9982a6bdb1713c2b32.zip
Plugin::ReadLine: Added Term::ReadLine::Caroline support.
-rw-r--r--lib/Reply/Plugin/ReadLine.pm19
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;