Skip to content
Browse files

Hacky fixups: my completion. Using Term::ReadLine::Perl5 until it is …

…in Term::ReadLine.
  • Loading branch information...
1 parent 8c4704e commit 2ccce5afe46331ebae017137875847e88e69ab6e Rocky Bernstein committed Mar 20, 2013
View
19 lib/Devel/Trepan/CmdProcessor/Command/Info_Subcmd/Variables_Subcmd/My.pm
@@ -62,6 +62,21 @@ sub get_var_hash($;$)
sub complete($$;$)
{
my ($self, $prefix, $fixup_num) = @_;
+
+ # This is really hacky
+ unless ($fixup_num) {
+ my $i = 0;
+ while (my ($pkg, $file, $line, $fn) = caller($i++)) {
+ last if $pkg eq 'Devel::Trepan::CmdProcessor' && $fn eq '(eval)';
+ last if $pkg eq 'Devel::Trepan::Core' &&
+ $fn eq 'Devel::Trepan::CmdProcessor::process_commands';
+ };
+
+ $fixup_num = $i;
+ }
+
+ # print "FIXUP_NUM is $fixup_num\n";
+
my $var_hash = $self->get_var_hash($fixup_num);
my @vars = sort keys %$var_hash;
Devel::Trepan::Complete::complete_token(\@vars, $prefix) ;
@@ -180,10 +195,10 @@ unless (caller) {
print '-' x 40, "\n";
$cmd->run($cmd->{prefix}, -1);
print '-' x 40, "\n";
- my @complete = $cmd->complete('', -1);
+ my @complete = $cmd->complete('', -2);
print join(', ', @complete), "\n";
print '-' x 40, "\n";
- @complete = $cmd->complete('$p', -1);
+ @complete = $cmd->complete('$p', -2);
print join(', ', @complete), "\n";
}
View
19 lib/Devel/Trepan/IO/Input.pm
@@ -14,13 +14,21 @@ use rlib '../../..';
use Devel::Trepan::Util qw(hash_merge);
use Devel::Trepan::IO;
-use vars qw(@EXPORT @ISA $HAVE_TERM_READLINE);
+## FIXME: REVERT TERM_READLINE5
+use vars qw(@EXPORT @ISA $HAVE_TERM_READLINE $HAVE_TERM_READLINE5);
@ISA = qw(Devel::Trepan::IO::InputBase Exporter);
@EXPORT = qw($HAVE_TERM_READLINE);
BEGIN {
$ENV{'PERL_RL'} ||= 'perl';
- $HAVE_TERM_READLINE = eval("use Term::ReadLine; 1") ? 1 : 0;
+ # We will clean this up when Florian and Jordan get their acts together.
+ ## FIXME: REVERT TERM_READLINE5
+ $HAVE_TERM_READLINE5 = eval("use Term::ReadLine::Perl5; 1") ? 1 : 0;
+ if ($HAVE_TERM_READLINE5) {
+ $HAVE_TERM_READLINE = 'Perl';
+ } else {
+ $HAVE_TERM_READLINE = eval("use Term::ReadLine; 1") ? 1 : 0
+ }
sub GLOBAL_have_term_readline {
if (!defined($HAVE_TERM_READLINE)) {
@@ -47,7 +55,12 @@ sub new($;$$) {
if ($opts->{readline} && GLOBAL_have_term_readline()) {
my $rc = 0;
$rc = eval {
- $self->{readline} = Term::ReadLine->new('trepan.pl');
+ ## FIXME: REVERT TERM_READLINE5
+ if ($HAVE_TERM_READLINE5) {
+ $self->{readline} = Term::ReadLine::Perl5->new('trepan.pl');
+ } else {
+ $self->{readline} = Term::ReadLine->new('trepan.pl');
+ }
1 ;
};
if ($rc) {
View
8 lib/Devel/Trepan/Interface/User.pm
@@ -50,7 +50,7 @@ sub new
my $attribs = $inp->{readline}->Attribs;
$attribs->{attempted_completion_function} = $self->{opts}{complete};
}
- $self->read_history;
+ $self->read_history();
}
return $self;
}
@@ -136,10 +136,12 @@ sub save_history($)
if ($self->{histfile} && $self->{opts}{history_save} &&
$self->want_term_readline &&
$self->{input}{readline}) {
+
$self->{input}{readline}->StifleHistory($self->{histsize}) if
$self->{input}{readline}->can("StifleHistory");
- $self->{input}{readline}->WriteHistory($self->{histfile}) if
- $self->{input}{readline}->can("WriteHistory");
+ if ($self->{input}{readline}->can("WriteHistory")) {
+ $self->{input}{readline}->WriteHistory($self->{histfile})
+ }
}
}

0 comments on commit 2ccce5a

Please sign in to comment.
Something went wrong with that request. Please try again.