Subject: | Term::ReadLine::Perl5 support |
Attached is a patch to add Term::ReadLine::Perl5 support in Devel::REPL. Term::ReadLine::Perl5 is like Term::ReadLine::Perl, but it has the history functions that are in Term::ReadLine::Gnu (and GNU readline itself). Also, if there is a problem with Term::ReadLine::Perl5, it will probably get addressed much quicker than Term::ReadLine::Perl.
Subject: | Term::ReadLine::Perl5-support.patch |
diff --git a/lib/Devel/REPL/Plugin/Completion.pm b/lib/Devel/REPL/Plugin/Completion.pm
index dcc1837..144d0d5 100644
--- a/lib/Devel/REPL/Plugin/Completion.pm
+++ b/lib/Devel/REPL/Plugin/Completion.pm
@@ -34,9 +34,9 @@ has do_readline_filename_completion => ( # so default is no if Completion loade
before 'read' => sub {
my ($self) = @_;
- if ((!$self->term->isa("Term::ReadLine::Gnu") and !$self->term->isa("Term::ReadLine::Perl"))
+ if ((!$self->term->isa("Term::ReadLine::Gnu") and !$self->term->isa("Term::ReadLine::Perl") and !$self->term->isa("Term::ReadLine::Perl5"))
and !$self->no_term_class_warning) {
- warn "Term::ReadLine::Gnu or Term::ReadLine::Perl is required for the Completion plugin to work";
+ warn "Term::ReadLine::Gnu, Term::ReadLine::Perl5 or Term::ReadLine::Perl are required for the Completion plugin to work";
$self->no_term_class_warning(1);
}
@@ -49,7 +49,7 @@ before 'read' => sub {
};
}
- if ($self->term->isa("Term::ReadLine::Perl")) {
+ if ($self->term->isa("Term::ReadLine::Perl") or $self->term->isa("Term::ReadLine::Perl")) {
$self->term->Attribs->{completion_function} = sub {
$weakself->_completion(@_);
};
@@ -138,4 +138,3 @@ Set the attribute C<do_readline_filename_completion> to 1 to enable this feature
Shawn M Moore, C<< <sartak at gmail dot com> >>
=cut
-
diff --git a/lib/Devel/REPL/Plugin/ReadLineHistory.pm b/lib/Devel/REPL/Plugin/ReadLineHistory.pm
index 75e3b3b..bfec2a1 100644
--- a/lib/Devel/REPL/Plugin/ReadLineHistory.pm
+++ b/lib/Devel/REPL/Plugin/ReadLineHistory.pm
@@ -20,14 +20,15 @@ my $hist_len=$ENV{PERLREPL_HISTLEN} || 100;
around 'run' => sub {
my $orig=shift;
my ($self, @args)=@_;
- if ($self->term->ReadLine eq 'Term::ReadLine::Gnu') {
+ if ($self->term->ReadLine eq 'Term::ReadLine::Gnu' or
+ $self->term->ReadLine eq 'Term::ReadLine::Perl5') {
$self->term->stifle_history($hist_len);
- }
- if ($self->term->ReadLine eq 'Term::ReadLine::Perl') {
+ } elsif ($self->term->ReadLine eq 'Term::ReadLine::Perl') {
$self->term->Attribs->{MaxHistorySize} = $hist_len;
}
if (-f($hist_file)) {
- if ($self->term->ReadLine eq 'Term::ReadLine::Gnu') {
+ if ($self->term->ReadLine eq 'Term::ReadLine::Gnu' or
+ $self->term->ReadLine eq 'Term::ReadLine::Perl5') {
$self->term->ReadHistory($hist_file);
}
if ($self->term->ReadLine eq 'Term::ReadLine::Perl') {
@@ -104,7 +105,6 @@ expansion method. In that case, you may wish to use the
Devel::REPL History plugin which provides similar functions.
Work is underway to make use of either History or
ReadLineHistory consistent for expansion with either the
-Term::ReadLine::Gnu support or Term::ReadLine::Perl.
+Term::ReadLine::Gnu support Term::ReadLine::Perl5, or Term::ReadLine::Perl.
=cut
-