line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
803
|
use 5.006; # our |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
13
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
70
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package App::colourhexdump::ColourProfile; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.000001'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: A Role for Colour Profiles |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
174
|
use Moose::Role qw( requires ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use namespace::autoclean; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
requires 'get_colour_for'; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
requires 'get_display_symbol_for'; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use Term::ANSIColor 3.00 qw( RESET ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
## no critic ( RequireArgUnpacking ) |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub get_string_pre { |
80
|
|
|
|
|
|
|
my ( $self, $char ) = ( $_[0], $_[1] ); |
81
|
|
|
|
|
|
|
my $colourcode = $self->get_colour_for($char); |
82
|
|
|
|
|
|
|
if ( defined $colourcode ) { |
83
|
|
|
|
|
|
|
return $colourcode; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
return q{}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
## no critic ( RequireArgUnpacking ) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub get_string_post { |
98
|
|
|
|
|
|
|
my ( $self, $char ) = ( $_[0], $_[1] ); |
99
|
|
|
|
|
|
|
my $colourcode = $self->get_colour_for($char); |
100
|
|
|
|
|
|
|
if ( defined $colourcode ) { |
101
|
|
|
|
|
|
|
return RESET; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
return q{}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
no Moose::Role; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=pod |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=encoding UTF-8 |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 NAME |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
App::colourhexdump::ColourProfile - A Role for Colour Profiles |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 VERSION |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
version 1.000001 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SYNOPSIS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
package App::colourhexdump::ColourProfileName |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
use Moose; |
129
|
|
|
|
|
|
|
with qw( App::colourhexdump::ColourProfile ); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub get_colour_for { |
132
|
|
|
|
|
|
|
my ( $self, $char ) = @_ ; |
133
|
|
|
|
|
|
|
... |
134
|
|
|
|
|
|
|
return "\e[31m" if /badthings/; |
135
|
|
|
|
|
|
|
return undef; # don't colour |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
sub get_display_symbol_for { |
138
|
|
|
|
|
|
|
my ($self, $char) = @_ ; |
139
|
|
|
|
|
|
|
... |
140
|
|
|
|
|
|
|
return '.' if $char =~ /badthings/ |
141
|
|
|
|
|
|
|
return $char; # printable |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 REQUIRED |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 get_colour_for |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my $colour = $object->get_colour_for( "\n" ); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Return any string of data that should be prepended every time a given character is seen. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Generally, you only want to print ANSI Escape codes. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Don't worry about resetting things, we put a C<^[[0m> in for you. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Return C<undef> if you do not wish to apply colouring. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 get_display_symbol_for |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
my $symbol = $object->get_display_symbol_for( "\n" ); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Returns a user viewable alternative to the matched string. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 PROVIDED |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 get_string_pre |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Wraps L</get_colour_for> and returns either a string sequence or ''. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 get_string_post |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Wraps L</get_colour_for> and returns either an ANSI Reset Code, or '', depending |
173
|
|
|
|
|
|
|
on what was returned. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 AUTHOR |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Kent Fredric <kentnl@cpan.org>. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
184
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |