1 package Devel::REPL::Plugin::Colors;
5 use namespace::clean -except => [ 'meta' ];
13 is => 'rw', lazy => 1,
14 default => 'bold red',
17 around error_return => sub {
20 return color($self->error_color)
25 # we can't just munge @_ because that screws up DDS
29 print {$self->out_fh} color($self->normal_color);
31 print {$self->out_fh} color('reset');
34 # make arbitrary warns colored -- somewhat difficult because warn doesn't
35 # get $self, so we localize $SIG{__WARN__} during eval so it can get
42 local $SIG{__WARN__} = sub {
45 warn color($self->error_color || 'bold red')
54 around compile => \&_wrap_warn;
55 around execute => \&_wrap_warn;
63 Devel::REPL::Plugin::Colors - add color to return values, warnings, and errors
72 my $repl = Devel::REPL->new;
73 $repl->load_plugin('LexEnv');
74 $repl->load_plugin('History');
75 $repl->load_plugin('Colors');
80 Colors are very pretty.
82 This plugin causes certain prints, warns, and errors to be colored. Generally
83 the return value(s) of each line will be colored green (you can override this
84 by setting C<< $_REPL->normal_color >> in your rcfile). Warnings and
85 compile/runtime errors will be colored with C<< $_REPL->error_color >>. This
86 plugin uses L<Term::ANSIColor>, so consult that module for valid colors. The
87 defaults are actually 'green' and 'bold red'.
95 Shawn M Moore, C<< <sartak at gmail dot com> >>
97 =head1 COPYRIGHT AND LICENSE
99 Copyright (C) 2007 by Shawn M Moore
101 This library is free software; you can redistribute it and/or modify
102 it under the same terms as Perl itself.