| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Term::SimpleColor; |
|
2
|
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
237004
|
use strict; |
|
|
10
|
|
|
|
|
23
|
|
|
|
10
|
|
|
|
|
419
|
|
|
4
|
10
|
|
|
10
|
|
50
|
use warnings; |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
260
|
|
|
5
|
10
|
|
|
10
|
|
1422
|
use utf8; |
|
|
10
|
|
|
|
|
32
|
|
|
|
10
|
|
|
|
|
64
|
|
|
6
|
10
|
|
|
10
|
|
253
|
use Carp; |
|
|
10
|
|
|
|
|
18
|
|
|
|
10
|
|
|
|
|
960
|
|
|
7
|
10
|
|
|
10
|
|
52
|
use base 'Exporter'; |
|
|
10
|
|
|
|
|
12
|
|
|
|
10
|
|
|
|
|
27929
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.0.3'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT = qw/ black red green yellow blue magenta cyan gray white default /; |
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = |
|
13
|
|
|
|
|
|
|
qw/ bg_default bg_black bg_red bg_green bg_yellow bg_blue bg_magenta bg_cyan bg_gray underscore bold invert dc_default /; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
16
|
|
|
|
|
|
|
all => \@EXPORT_OK, |
|
17
|
|
|
|
|
|
|
background => [ |
|
18
|
|
|
|
|
|
|
qw(bg_default bg_black bg_red bg_green bg_yellow bg_blue bg_magenta bg_cyan bg_gray) |
|
19
|
|
|
|
|
|
|
], |
|
20
|
|
|
|
|
|
|
decoration => [qw(underscore bold invert dc_default)], |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# TRIVIA: \x1b is escape code |
|
25
|
|
|
|
|
|
|
my %COLOR = ( |
|
26
|
|
|
|
|
|
|
black => "\x1b[30m", |
|
27
|
|
|
|
|
|
|
red => "\x1b[31m", |
|
28
|
|
|
|
|
|
|
green => "\x1b[32m", |
|
29
|
|
|
|
|
|
|
yellow => "\x1b[33m", |
|
30
|
|
|
|
|
|
|
blue => "\x1b[34m", |
|
31
|
|
|
|
|
|
|
magenta => "\x1b[35m", |
|
32
|
|
|
|
|
|
|
cyan => "\x1b[36m", |
|
33
|
|
|
|
|
|
|
white => "\x1b[37m", |
|
34
|
|
|
|
|
|
|
default => "\x1b[39m", |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my %BG_COLOR = ( |
|
38
|
|
|
|
|
|
|
bg_black => "\x1b[40m", |
|
39
|
|
|
|
|
|
|
bg_red => "\x1b[41m", |
|
40
|
|
|
|
|
|
|
bg_green => "\x1b[42m", |
|
41
|
|
|
|
|
|
|
bg_yellow => "\x1b[43m", |
|
42
|
|
|
|
|
|
|
bg_blue => "\x1b[44m", |
|
43
|
|
|
|
|
|
|
bg_magenta => "\x1b[45m", |
|
44
|
|
|
|
|
|
|
bg_cyan => "\x1b[46m", |
|
45
|
|
|
|
|
|
|
bg_gray => "\x1b[47m", |
|
46
|
|
|
|
|
|
|
bg_default => "\x1b[49m", |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my %DECORATE = ( |
|
50
|
|
|
|
|
|
|
underscore => "\x1b[4m", |
|
51
|
|
|
|
|
|
|
bold => "\x1b[1m", |
|
52
|
|
|
|
|
|
|
invert => "\x1b[7m", |
|
53
|
|
|
|
|
|
|
dc_default => "\x1b[0m", |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _code { |
|
58
|
27
|
|
|
27
|
|
48
|
my ( $color_key, $string ) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
27
|
50
|
33
|
|
|
114
|
if ( !defined($color_key) || !defined( $COLOR{$color_key} ) ) { |
|
61
|
0
|
|
|
|
|
0
|
croak 'The color is NOT defined'; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
27
|
100
|
|
|
|
199
|
return $COLOR{$color_key} unless defined($string); |
|
65
|
9
|
|
|
|
|
29
|
return $COLOR{$color_key} . $string . default(); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub default { |
|
70
|
11
|
|
|
11
|
1
|
3565
|
my ($string) = @_; |
|
71
|
11
|
|
|
|
|
73
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
72
|
11
|
|
|
|
|
35
|
return _code($me, $string); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub black { |
|
77
|
2
|
|
|
2
|
1
|
3997
|
my ($string) = @_; |
|
78
|
2
|
|
|
|
|
25
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
79
|
2
|
|
|
|
|
9
|
return _code($me, $string); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub red { |
|
85
|
2
|
|
|
2
|
1
|
3103
|
my ($string) = @_; |
|
86
|
2
|
|
|
|
|
18
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
87
|
2
|
|
|
|
|
7
|
return _code($me, $string); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub green { |
|
91
|
2
|
|
|
2
|
1
|
2915
|
my ($string) = @_; |
|
92
|
2
|
|
|
|
|
20
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
93
|
2
|
|
|
|
|
7
|
return _code($me, $string); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub yellow { |
|
97
|
2
|
|
|
2
|
1
|
3173
|
my ($string) = @_; |
|
98
|
2
|
|
|
|
|
21
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
99
|
2
|
|
|
|
|
7
|
return _code($me, $string); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub blue { |
|
103
|
2
|
|
|
2
|
1
|
4882
|
my ($string) = @_; |
|
104
|
2
|
|
|
|
|
29
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
105
|
2
|
|
|
|
|
9
|
return _code($me, $string); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub magenta { |
|
109
|
2
|
|
|
2
|
1
|
3969
|
my ($string) = @_; |
|
110
|
2
|
|
|
|
|
24
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
111
|
2
|
|
|
|
|
8
|
return _code($me, $string); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub cyan { |
|
115
|
2
|
|
|
2
|
1
|
4042
|
my ($string) = @_; |
|
116
|
2
|
|
|
|
|
23
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
117
|
2
|
|
|
|
|
8
|
return _code($me, $string); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub white { |
|
122
|
2
|
|
|
2
|
1
|
4220
|
my ($string) = @_; |
|
123
|
2
|
|
|
|
|
25
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
124
|
2
|
|
|
|
|
8
|
return _code($me, $string); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _bg_code { |
|
129
|
108
|
|
|
108
|
|
181
|
my ( $color_key, $string ) = @_; |
|
130
|
|
|
|
|
|
|
|
|
131
|
108
|
50
|
33
|
|
|
475
|
if ( !defined($color_key) || !defined( $BG_COLOR{$color_key} ) ) { |
|
132
|
0
|
|
|
|
|
0
|
croak 'The color is NOT defined'; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
108
|
100
|
|
|
|
862
|
return $BG_COLOR{$color_key} unless defined($string); |
|
136
|
36
|
|
|
|
|
130
|
return $BG_COLOR{$color_key} . $string . bg_default(); |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
0
|
return ''; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub bg_default { |
|
143
|
44
|
|
|
44
|
1
|
12775
|
my ($string) = @_; |
|
144
|
44
|
|
|
|
|
309
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
145
|
44
|
|
|
|
|
131
|
return _bg_code($me, $string); |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub bg_black { |
|
149
|
8
|
|
|
8
|
1
|
19031
|
my ($string) = @_; |
|
150
|
8
|
|
|
|
|
103
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
151
|
8
|
|
|
|
|
31
|
return _bg_code($me, $string); |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub bg_red { |
|
156
|
8
|
|
|
8
|
1
|
13307
|
my ($string) = @_; |
|
157
|
8
|
|
|
|
|
83
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
158
|
8
|
|
|
|
|
32
|
return _bg_code($me, $string); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub bg_green { |
|
162
|
8
|
|
|
8
|
1
|
12914
|
my ($string) = @_; |
|
163
|
8
|
|
|
|
|
88
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
164
|
8
|
|
|
|
|
31
|
return _bg_code($me, $string); |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub bg_yellow { |
|
168
|
8
|
|
|
8
|
1
|
15632
|
my ($string) = @_; |
|
169
|
8
|
|
|
|
|
99
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
170
|
8
|
|
|
|
|
32
|
return _bg_code($me, $string); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub bg_blue { |
|
174
|
8
|
|
|
8
|
1
|
14926
|
my ($string) = @_; |
|
175
|
8
|
|
|
|
|
97
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
176
|
8
|
|
|
|
|
31
|
return _bg_code($me, $string); |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub bg_magenta { |
|
180
|
8
|
|
|
8
|
1
|
12853
|
my ($string) = @_; |
|
181
|
8
|
|
|
|
|
87
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
182
|
8
|
|
|
|
|
4541
|
return _bg_code($me, $string); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub bg_cyan { |
|
186
|
8
|
|
|
8
|
1
|
13024
|
my ($string) = @_; |
|
187
|
8
|
|
|
|
|
227
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
188
|
8
|
|
|
|
|
32
|
return _bg_code($me, $string); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub bg_gray { |
|
192
|
8
|
|
|
8
|
1
|
19501
|
my ($string) = @_; |
|
193
|
8
|
|
|
|
|
94
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
194
|
8
|
|
|
|
|
523
|
return _bg_code($me, $string); |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub _dc_code { |
|
200
|
48
|
|
|
48
|
|
74
|
my ( $color_key, $string ) = @_; |
|
201
|
|
|
|
|
|
|
|
|
202
|
48
|
50
|
33
|
|
|
362
|
if ( !defined($color_key) || !defined( $DECORATE{$color_key} ) ) { |
|
203
|
0
|
|
|
|
|
0
|
croak 'The color is NOT defined.', " $color_key" ; |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
48
|
100
|
|
|
|
394
|
return $DECORATE{$color_key} unless defined($string); |
|
207
|
16
|
|
|
|
|
65
|
return $DECORATE{$color_key} . $string . dc_default(); |
|
208
|
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
0
|
return ''; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub dc_default { |
|
213
|
24
|
|
|
24
|
1
|
13234
|
my ($string) = @_; |
|
214
|
24
|
|
|
|
|
172
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
215
|
24
|
|
|
|
|
80
|
return _dc_code($me, $string); |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub underscore { |
|
219
|
8
|
|
|
8
|
1
|
23067
|
my ($string) = @_; |
|
220
|
8
|
|
|
|
|
92
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
221
|
8
|
|
|
|
|
32
|
return _dc_code($me, $string); |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub bold { |
|
225
|
8
|
|
|
8
|
1
|
15228
|
my ($string) = @_; |
|
226
|
8
|
|
|
|
|
572
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
227
|
8
|
|
|
|
|
45
|
return _dc_code($me, $string); |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub invert { |
|
231
|
8
|
|
|
8
|
1
|
12607
|
my ($string) = @_; |
|
232
|
8
|
|
|
|
|
88
|
my $me = (split('::', (caller(0))[3]))[-1]; |
|
233
|
8
|
|
|
|
|
32
|
return _dc_code($me, $string); |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
1; |
|
237
|
|
|
|
|
|
|
__END__ |