[Bps-public-commit] r12390 - in Carp-REPL: .
sartak at bestpractical.com
sartak at bestpractical.com
Fri May 16 08:10:41 EDT 2008
Author: sartak
Date: Fri May 16 08:10:41 2008
New Revision: 12390
Modified:
Carp-REPL/ (props changed)
Carp-REPL/lib/Devel/REPL/Plugin/LexEnvCarp.pm
Log:
r55995 at onn: sartak | 2008-05-16 08:10:02 -0400
:list command. Don't require matching $ because some plugins do wonky things
Modified: Carp-REPL/lib/Devel/REPL/Plugin/LexEnvCarp.pm
==============================================================================
--- Carp-REPL/lib/Devel/REPL/Plugin/LexEnvCarp.pm (original)
+++ Carp-REPL/lib/Devel/REPL/Plugin/LexEnvCarp.pm Fri May 16 08:10:41 2008
@@ -72,32 +72,59 @@
my ($self, @rest) = @_;
my $line = $self->$orig(@rest);
- return if !defined($line) || $line =~ /^\s*:q\s*$/;
+ return if !defined($line) || $line =~ /^\s*:q\s*/;
- if ($line =~ /^\s*:b?t\s*$/)
+ if ($line =~ /^\s*:b?t\s*/)
{
print $self->backtrace;
return '';
}
- if ($line =~ /^\s*:e?(?:nv)?\s*$/)
+ if ($line =~ /^\s*:up?\s*/)
{
- Dump($self->environments->[$self->frame])->Names('Env')->Out;
+ $self->frame($self->frame + 1);
return '';
}
- if ($line =~ /^\s*:up?\s*$/)
+ if ($line =~ /^\s*:d(?:own)?\s*/)
{
- $self->frame($self->frame + 1);
+ $self->frame($self->frame - 1);
return '';
}
- if ($line =~ /^\s*:d(?:own)?\s*$/)
+ if ($line =~ /^\s*:l(?:ist)?\s*/) {
+ my ($package, $file, $num) = @{$self->packages->[$self->frame]};
+ open my $handle, '<', $file or do {
+ warn "Unable to open $file for reading: $!\n";
+ return '';
+ };
+ my @code = <$handle>;
+
+ my $min = $num - 6;
+ my $max = $num + 4;
+ $min = 0 if $min < 0;
+ $max = $#code if $max > $#code;
+
+ for my $cur ($min .. $max) {
+ next if !defined($code[$cur]);
+
+ printf "%s%*d: %s",
+ $cur + 1 == $num ? '*' : ' ',
+ length($max),
+ $cur + 1,
+ $code[$cur];
+ }
+
+ return '';
+ }
+
+ if ($line =~ /^\s*:e?(?:nv)?\s*/)
{
- $self->frame($self->frame - 1);
+ Dump($self->environments->[$self->frame])->Names('Env')->Out;
return '';
}
+
return $line;
};
More information about the Bps-public-commit
mailing list