3 package Devel::REPL::Plugin::Colors;
5 use Devel::REPL::Plugin;
7 use namespace::autoclean;
10 is => 'rw', lazy => 1,
15 is => 'rw', lazy => 1,
16 default => 'bold red',
19 around format_error => sub {
22 return color($self->error_color)
27 # we can't just munge @_ because that screws up DDS
28 around format_result => sub {
31 no warnings 'uninitialized';
33 color($self->normal_color),
39 # make arbitrary warns colored -- somewhat difficult because warn doesn't
40 # get $self, so we localize $SIG{__WARN__} during eval so it can get
47 local $SIG{__WARN__} = sub {
50 warn color($self->error_color || 'bold red')
59 around compile => \&_wrap_warn;
60 around execute => \&_wrap_warn;
68 Devel::REPL::Plugin::Colors - add color to return values, warnings, and errors
77 my $repl = Devel::REPL->new;
78 $repl->load_plugin('LexEnv');
79 $repl->load_plugin('History');
80 $repl->load_plugin('Colors');
85 Colors are very pretty.
87 This plugin causes certain prints, warns, and errors to be colored. Generally
88 the return value(s) of each line will be colored green (you can override this
89 by setting C<< $_REPL->normal_color >> in your rcfile). Warnings and
90 compile/runtime errors will be colored with C<< $_REPL->error_color >>. This
91 plugin uses L<Term::ANSIColor>, so consult that module for valid colors. The
92 defaults are actually 'green' and 'bold red'.
100 Shawn M Moore, C<< <sartak at gmail dot com> >>
102 =head1 COPYRIGHT AND LICENSE
104 Copyright (C) 2007 by Shawn M Moore
106 This library is free software; you can redistribute it and/or modify
107 it under the same terms as Perl itself.