use namespaace::clean in turtles completion driver
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Colors.pm
index aa87abf..2fc6e93 100644 (file)
@@ -14,7 +14,7 @@ has error_color => (
   default => 'bold red',
 );
 
-around error_return => sub {
+around format_error => sub {
   my $orig = shift;
   my $self = shift;
   return color($self->error_color)
@@ -23,19 +23,22 @@ around error_return => sub {
 };
 
 # we can't just munge @_ because that screws up DDS
-around print => sub {
+around format_result => sub {
   my $orig = shift;
   my $self = shift;
-  print {$self->out_fh} color($self->normal_color);
-  $orig->($self, @_);
-  print {$self->out_fh} color('reset');
+  no warnings 'uninitialized';
+  return join "", (
+    color($self->normal_color),
+    $orig->($self, @_),
+    color('reset'),
+  );
 };
 
 # make arbitrary warns colored -- somewhat difficult because warn doesn't
 # get $self, so we localize $SIG{__WARN__} during eval so it can get
 # error_color
 
-around execute => sub {
+sub _wrap_warn {
   my $orig = shift;
   my $self = shift;
 
@@ -51,6 +54,9 @@ around execute => sub {
   $orig->($self, @_);
 };
 
+around compile => \&_wrap_warn;
+around execute => \&_wrap_warn;
+
 1;
 
 __END__