3 package Devel::REPL::Plugin::Colors;
5 our $VERSION = '1.003027';
7 use Devel::REPL::Plugin;
9 use namespace::autoclean;
12 is => 'rw', lazy => 1,
17 is => 'rw', lazy => 1,
18 default => 'bold red',
21 around format_error => sub {
24 return color($self->error_color)
29 # we can't just munge @_ because that screws up DDS
30 around format_result => sub {
33 no warnings 'uninitialized';
35 color($self->normal_color),
41 # make arbitrary warns colored -- somewhat difficult because warn doesn't
42 # get $self, so we localize $SIG{__WARN__} during eval so it can get
49 local $SIG{__WARN__} = sub {
52 warn color($self->error_color || 'bold red')
61 around compile => \&_wrap_warn;
62 around execute => \&_wrap_warn;
70 Devel::REPL::Plugin::Colors - add color to return values, warnings, and errors
76 my $repl = Devel::REPL->new;
77 $repl->load_plugin('LexEnv');
78 $repl->load_plugin('History');
79 $repl->load_plugin('Colors');
84 Colors are very pretty.
86 This plugin causes certain prints, warns, and errors to be colored. Generally
87 the return value(s) of each line will be colored green (you can override this
88 by setting C<< $_REPL->normal_color >> in your rcfile). Warnings and
89 compile/runtime errors will be colored with C<< $_REPL->error_color >>. This
90 plugin uses L<Term::ANSIColor>, so consult that module for valid colors. The
91 defaults are actually 'green' and 'bold red'.
99 Shawn M Moore, C<< <sartak at gmail dot com> >>
101 =head1 COPYRIGHT AND LICENSE
103 Copyright (C) 2007 by Shawn M Moore
105 This library is free software; you can redistribute it and/or modify
106 it under the same terms as Perl itself.