summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-18 06:49:00 -0700
committerJesse Luehrs <doy@tozt.net>2013-07-18 06:49:00 -0700
commit35c4719f28a9bb1ed4a722453bdb1ffba4f36bd0 (patch)
tree70d21a3ede0f06f5e3088ba7d2df1460a12cc6ab
parentc64879747f508ccd054e36c161635c1506d107cf (diff)
parente17844e2332173a4e5db9a7716851e43079a15f1 (diff)
downloadreply-35c4719f28a9bb1ed4a722453bdb1ffba4f36bd0.tar.gz
reply-35c4719f28a9bb1ed4a722453bdb1ffba4f36bd0.zip
Merge pull request #22 from co-me/readline-perl-bugfix
Fix a bug that can't handle correct ReadLine class
-rw-r--r--lib/Reply/Plugin/ReadLine.pm13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Reply/Plugin/ReadLine.pm b/lib/Reply/Plugin/ReadLine.pm
index 18c944b..899d563 100644
--- a/lib/Reply/Plugin/ReadLine.pm
+++ b/lib/Reply/Plugin/ReadLine.pm
@@ -46,12 +46,15 @@ sub new {
$history
);
- if ($self->{term}->ReadLine eq 'Term::ReadLine::Perl5') {
+ $self->{rl_gnu} = $self->{term}->ReadLine eq 'Term::ReadLine::Gnu';
+ $self->{rl_perl5} = $self->{term}->ReadLine eq 'Term::ReadLine::Perl5';
+
+ if ($self->{rl_perl5}) {
# output compatible with Term::ReadLine::Gnu
$readline::rl_scroll_nextline = 0;
}
- if ($self->{term}->ReadLine eq ('Term::ReadLine::Gnu' or 'Term::ReadLine::Perl5')) {
+ if ($self->{rl_perl5} || $self->{rl_gnu}) {
$self->{term}->StifleHistory($opts{history_length})
if defined $opts{history_length} && $opts{history_length} >= 0;
}
@@ -86,7 +89,7 @@ sub DESTROY {
return if defined $self->{history_length} && $self->{history_length} == 0;
# XXX support more later
- return unless $self->{term}->ReadLine eq ('Term::ReadLine::Gnu' or 'Term::ReadLine::Perl5');
+ return unless ($self->{rl_gnu} || $self->{rl_perl5});
$self->{term}->WriteHistory($self->{history_file})
or warn "Couldn't write history to $self->{history_file}";
@@ -99,7 +102,7 @@ sub _register_tab_complete {
weaken(my $weakself = $self);
- if ($term->ReadLine eq 'Term::ReadLine::Gnu') {
+ if ($self->{rl_gnu}) {
$term->Attribs->{attempted_completion_function} = sub {
my ($text, $line, $start, $end) = @_;
@@ -116,7 +119,7 @@ sub _register_tab_complete {
};
}
- if ($term->ReadLine eq 'Term::ReadLine::Perl5') {
+ if ($self->{rl_perl5}) {
$term->Attribs->{completion_function} = sub {
my ($text, $line, $start) = @_;
my $end = $start + length($text);