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
74 my $repl = Devel::REPL->new;
75 $repl->load_plugin('LexEnv');
76 $repl->load_plugin('History');
77 $repl->load_plugin('Colors');
82 Colors are very pretty.
84 This plugin causes certain prints, warns, and errors to be colored. Generally
85 the return value(s) of each line will be colored green (you can override this
86 by setting C<< $_REPL->normal_color >> in your rcfile). Warnings and
87 compile/runtime errors will be colored with C<< $_REPL->error_color >>. This
88 plugin uses L<Term::ANSIColor>, so consult that module for valid colors. The
89 defaults are actually 'green' and 'bold red'.
97 Shawn M Moore, C<< <sartak at gmail dot com> >>
99 =head1 COPYRIGHT AND LICENSE
101 Copyright (C) 2007 by Shawn M Moore
103 This library is free software; you can redistribute it and/or modify
104 it under the same terms as Perl itself.