line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::MilkyHolmes::Role::HasPersonalColor; |
2
|
3
|
|
|
3
|
|
1313
|
use Mouse::Role; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
16
|
|
3
|
3
|
|
|
3
|
|
2253
|
use Encode; |
|
3
|
|
|
|
|
23653
|
|
|
3
|
|
|
|
|
1021
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
requires 'color'; |
6
|
|
|
|
|
|
|
requires 'color_enable'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $ansi_colors = { |
9
|
|
|
|
|
|
|
pink => '1;35', # Light Purple |
10
|
|
|
|
|
|
|
yellow => '1;33', |
11
|
|
|
|
|
|
|
green => '0;32', |
12
|
|
|
|
|
|
|
blue => '0;34', |
13
|
|
|
|
|
|
|
black => '0;30;47', #background is white |
14
|
|
|
|
|
|
|
white => '1;37;40', #background is black |
15
|
|
|
|
|
|
|
cyan => '0;36', |
16
|
|
|
|
|
|
|
red => '0;31', |
17
|
|
|
|
|
|
|
purple => '0;35', |
18
|
|
|
|
|
|
|
brown => '0;33', |
19
|
|
|
|
|
|
|
lightgray => '0;37', |
20
|
|
|
|
|
|
|
darkgray => '1;30', |
21
|
|
|
|
|
|
|
lightblue => '1;34', |
22
|
|
|
|
|
|
|
lightgreen => '1;32', |
23
|
|
|
|
|
|
|
lightcyan => '1;36', |
24
|
|
|
|
|
|
|
lightred => '1;31', |
25
|
|
|
|
|
|
|
lightpurple => '1;35', |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub color_enable { |
29
|
0
|
|
|
0
|
0
|
0
|
my ($self) = shift; |
30
|
0
|
|
|
|
|
0
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub color { |
34
|
12
|
|
|
12
|
0
|
3867
|
my ($self) = @_; |
35
|
12
|
|
|
|
|
91
|
return $self->common->[0]->{color}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub say { |
40
|
0
|
|
|
0
|
0
|
|
my ($self, $comment) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $message = encode_utf8($self->nickname . ': ' . $comment); |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
0
|
|
|
|
if ( defined $self->color && $self->color_enable ) { |
45
|
0
|
|
|
|
|
|
$message = $self->_escaped_message($self->color, $message); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
print "$message\n"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _escaped_color_begin { |
52
|
0
|
|
|
0
|
|
|
my ($self, $color_name) = @_; |
53
|
0
|
|
|
|
|
|
return "\e[" . $ansi_colors->{$color_name} . "m" |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _escape_end { |
57
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
58
|
0
|
|
|
|
|
|
return "\e[m"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _escaped_message { |
62
|
0
|
|
|
0
|
|
|
my ($self, $color_name, $message) = @_; |
63
|
0
|
|
|
|
|
|
return $self->_escaped_color_begin($color_name) . $message . $self->_escape_end(); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|