lib/Devel/Trepan/DB/Colors.pm

filter: Statementstmt 57.5% 19 / 33 Branchbran 25.0% 2 / 8 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 45.7% 27 / 59 CC 5 SCAR 13.6
CC
5
Cov
47%
setup
5.9
setup
5.9
BEGIN
1.0
CRAP 3.9
« blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Substitute_Subcmd/String.pm ↑ Summary example/gcd.pl »
1 # Pretty much cut and paste from Syntax::Highlight::Perl's viewperl
2 package Devel::Trepan::DB::Colors;
3 =head1 NAME
4  
5 Devel::Trepan::DB::Colors - Set up L<Devel::Trepan>'s formatter to do ANSI colors.
6  
7 =cut
8  
9 14 ▶use warnings; use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
10 14 ▶use Syntax::Highlight::Perl::Improved;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 14 ▶use vars qw(%ANSI_colors);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # See also Term::ANSIColor.
15 #
16 14 %ANSI_colors = (
17 none => "\e[0m",
18  
19 black => "\e[m",
20 red => "\e[0;31m",
21 green => "\e[0;32m",
22 yellow => "\e[0;33m",
23 blue => "\e[0;34m",
24 magenta => "\e[0;35m",
25 cyan => "\e[0;36m",
26 white => "\e[0;37m",
27  
28 gray => "\e[1;30m",
29 bred => "\e[1;31m",
30 bgreen => "\e[1;32m",
31 byellow => "\e[1;33m",
32 bblue => "\e[1;34m",
33 bmagenta => "\e[1;35m",
34 bcyan => "\e[1;36m",
35 bwhite => "\e[1;37m",
36  
37 bgred => "\e[41m",
38 bggreen => "\e[42m",
39 bgyellow => "\e[43m",
40 bgblue => "\e[44m",
41 bgmagenta => "\e[45m",
42 bgcyan => "\e[46m",
43 bgwhite => "\e[47m",
44 );
45  
46 sub setup
47 14 ▶{
Subroutine setup: called CC=3 SCAR=17.7
Pod undocumented
48 0 ▶ my $perl_formatter = new Syntax::Highlight::Perl::Improved;
Subroutine setup: not called CC=3 SCAR=17.7
Pod undocumented
49 0 $perl_formatter->unstable(1);
50 0 ▶ if (scalar @_ && $_[0] eq 'darkbg') {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @_ and $_[0] eq 'darkbg') { } 0 14 14
if (scalar @_ and $_[0] eq 'darkbg') { } 0 0 0
Condition16%1/6
scalar @_ and $_[0] eq "darkbg"
!ll&&!rl&&r
0140
scalar @_ and $_[0] eq "darkbg"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @_ and $_[0] eq "darkbg"
scalar @_ $_[0] eq "darkbg"
MC/DC0%0/2
scalar @_ and $_[0] eq "darkbg"
scalar @_ $_[0] eq "darkbg"
Truth table33%1/3
A and B
A= scalar @_B= $_[0] eq "darkbg"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= scalar @_B= $_[0] eq "darkbg"
ABresult
0X0
100
111
51 $perl_formatter->set_format(
52 'Comment_Normal' => [$ANSI_colors{'yellow'}, $ANSI_colors{'none'}],
53 'Comment_POD' => [$ANSI_colors{'yellow'}, $ANSI_colors{'none'}],
54 'Directive' => [$ANSI_colors{'magenta'}, $ANSI_colors{'none'}],
55 'Label' => [$ANSI_colors{'magenta'}, $ANSI_colors{'none'}],
56 'Quote' => [$ANSI_colors{'black'}, $ANSI_colors{'none'}],
57 'String' => [$ANSI_colors{'cyan'}, $ANSI_colors{'none'}],
58 'Subroutine' => [$ANSI_colors{'yellow'}, $ANSI_colors{'none'}],
59 'Variable_Scalar' => [$ANSI_colors{'green'}, $ANSI_colors{'none'}],
60 'Variable_Array' => [$ANSI_colors{'magenta'}, $ANSI_colors{'none'}],
61 'Variable_Hash' => [$ANSI_colors{'green'}, $ANSI_colors{'none'}],
62 'Variable_Typeglob'=> [$ANSI_colors{'black'}, $ANSI_colors{'none'}],
63 'Whitespace' => ['', '' ],
64 'Character' => [$ANSI_colors{'red'}, $ANSI_colors{'none'}],
65 'Keyword' => [$ANSI_colors{'yellow'}, $ANSI_colors{'none'}],
66 'Builtin_Function' => [$ANSI_colors{'grey'}, $ANSI_colors{'none'}],
67 'Builtin_Operator' => [$ANSI_colors{'white'}, $ANSI_colors{'none'}],
68 'Operator' => [$ANSI_colors{'white'}, $ANSI_colors{'none'}],
69 'Bareword' => [$ANSI_colors{'grey'}, $ANSI_colors{'none'}],
70 'Package' => [$ANSI_colors{'green'}, $ANSI_colors{'none'}],
71 'Number' => [$ANSI_colors{'magenta'}, $ANSI_colors{'none'}],
72 'Symbol' => [$ANSI_colors{'cyan'}, $ANSI_colors{'none'}],
73 'CodeTerm' => [$ANSI_colors{'gray'}, $ANSI_colors{'none'}],
74 'DATA' => [$ANSI_colors{'gray'}, $ANSI_colors{'none'}],
75  
76 'Line' => [$ANSI_colors{'byellow'}, $ANSI_colors{'none'}],
77 'File_Name' => [$ANSI_colors{'red'} . $ANSI_colors{'bgwhite'},
78 0 $ANSI_colors{'none'}],);
79 } else {
80 $perl_formatter->set_format(
81 'Comment_Normal' => [$ANSI_colors{'red'}, $ANSI_colors{'none'}],
82 'Comment_POD' => [$ANSI_colors{'bblue'}, $ANSI_colors{'none'}],
83 'Directive' => [$ANSI_colors{'magenta'}, $ANSI_colors{'none'}],
84 'Label' => [$ANSI_colors{'bblue'}, $ANSI_colors{'none'}],
85 'Quote' => [$ANSI_colors{'black'}, $ANSI_colors{'none'}],
86 'String' => [$ANSI_colors{'gray'}, $ANSI_colors{'none'}],
87 'Subroutine' => [$ANSI_colors{'blue'}, $ANSI_colors{'none'}],
88 'Variable_Scalar' => [$ANSI_colors{'bgreen'}, $ANSI_colors{'none'}],
89 'Variable_Array' => [$ANSI_colors{'magenta'}, $ANSI_colors{'none'}],
90 'Variable_Hash' => [$ANSI_colors{'bgreen'}, $ANSI_colors{'none'}],
91 'Variable_Typeglob'=> [$ANSI_colors{'black'}, $ANSI_colors{'none'}],
92 'Whitespace' => ['', '' ],
93 'Character' => [$ANSI_colors{'bred'}, $ANSI_colors{'none'}],
94 'Keyword' => [$ANSI_colors{'bblue'}, $ANSI_colors{'none'}],
95 'Builtin_Function' => [$ANSI_colors{'bwhite'}, $ANSI_colors{'none'}],
96 'Builtin_Operator' => [$ANSI_colors{'black'}, $ANSI_colors{'none'}],
97 'Operator' => [$ANSI_colors{'black'}, $ANSI_colors{'none'}],
98 'Bareword' => [$ANSI_colors{'white'}, $ANSI_colors{'none'}],
99 'Package' => [$ANSI_colors{'green'}, $ANSI_colors{'none'}],
100 'Number' => [$ANSI_colors{'gray'}, $ANSI_colors{'none'}],
101 'Symbol' => [$ANSI_colors{'gray'}, $ANSI_colors{'none'}],
102 'CodeTerm' => [$ANSI_colors{'gray'}, $ANSI_colors{'none'}],
103 'DATA' => [$ANSI_colors{'gray'}, $ANSI_colors{'none'}],
104  
105 'Line' => [$ANSI_colors{'byellow'}, $ANSI_colors{'none'}],
106 'File_Name' => [$ANSI_colors{'red'} . $ANSI_colors{'bgwhite'},
107 0 $ANSI_colors{'none'}],
108 );
109 }
110 0 $perl_formatter;
111 }
112  
113 14 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 14 14
114 0 my $perl_formatter = Devel::Trepan::DB::Colors::setup();
115 0 my $colors_file = __FILE__;
116 0 ▶ open my $fh, "<", __FILE__ or die "Why can't I read myself?: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", __FILE__ or die "Why can't I read myself?: $!" 0 0 0
117 0 local $/; # enable localized slurp mode
118 0 my $content = <$fh>;
119 0 close $fh;
120 0 print $perl_formatter->format_string($content);
121  
122 }
« blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Substitute_Subcmd/String.pm ↑ Summary example/gcd.pl »