line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::TextMode::Pixel; |
2
|
|
|
|
|
|
|
|
3
|
30
|
|
|
30
|
|
1133
|
use Moo; |
|
30
|
|
|
|
|
11662
|
|
|
30
|
|
|
|
|
151
|
|
4
|
30
|
|
|
30
|
|
9072
|
use Types::Standard qw( Int ); |
|
30
|
|
|
|
|
54189
|
|
|
30
|
|
|
|
|
198
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Attribute byte constants |
7
|
|
|
|
|
|
|
my $ATTR_BG_NB = 240; |
8
|
|
|
|
|
|
|
my $ATTR_BLINK = 128; |
9
|
|
|
|
|
|
|
my $ATTR_BG = 112; |
10
|
|
|
|
|
|
|
my $ATTR_FG = 15; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'char' => ( is => 'rw', isa => sub { die '$_[ 0 ] is not a single character' unless length( $_[ 0 ] ) == 1 } ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'fg' => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
isa => Int, |
17
|
|
|
|
|
|
|
default => 0, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'bg' => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => Int, |
23
|
|
|
|
|
|
|
default => 0, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'blink' => ( |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
isa => Int, |
29
|
|
|
|
|
|
|
default => 0, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Image::TextMode::Pixel - A base class to represent a text mode "pixel" |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Represents a "pixel; i.e. a character plus, foreground and background colors and |
39
|
|
|
|
|
|
|
an blink mode setting. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 ACCESSORS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over 4 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item * char - The character for the pixel |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * fg - The foreground palette index |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item * bg - The background palette index |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item * blink - The blink bit |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=back |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 new( %args ) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Creates a new pixel. If you supply an C argument, then it will be |
60
|
|
|
|
|
|
|
broken down into its components (fg, bg, and blink). By default, blink mode |
61
|
|
|
|
|
|
|
is off (aka iCEColor is on). Pass a true value for C to enabled |
62
|
|
|
|
|
|
|
it. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 BUILDARGS( %args ) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
A Moose override to extract the C key and convert it to components, |
67
|
|
|
|
|
|
|
should it exist. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub BUILDARGS { |
72
|
3
|
|
|
3
|
1
|
8291
|
my ( $class, @rest ) = @_; |
73
|
|
|
|
|
|
|
|
74
|
3
|
|
|
|
|
6
|
my $options = {}; |
75
|
3
|
100
|
|
|
|
12
|
if ( @rest % 2 != 0 ) { |
76
|
2
|
|
|
|
|
6
|
$options = pop @rest; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
7
|
my %args = @rest; |
80
|
3
|
|
|
|
|
7
|
my $attr = delete $args{ attr }; |
81
|
|
|
|
|
|
|
|
82
|
3
|
100
|
|
|
|
7
|
if ( $attr ) { |
83
|
2
|
|
|
|
|
7
|
$attr = $class->_attr_to_components( $attr, $options ); |
84
|
2
|
|
|
|
|
11
|
%args = ( %args, %$attr ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
3
|
|
|
|
|
49
|
return \%args; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _attr_to_components { |
91
|
2
|
|
|
2
|
|
2
|
my ( $self, $attr, $options ) = @_; |
92
|
2
|
|
50
|
|
|
7
|
$options ||= {}; |
93
|
2
|
|
|
|
|
3
|
my $blink = $options->{ blink_mode }; |
94
|
2
|
|
|
|
|
3
|
my %data; |
95
|
|
|
|
|
|
|
|
96
|
2
|
|
|
|
|
3
|
$data{ fg } = $attr & $ATTR_FG; |
97
|
2
|
100
|
|
|
|
6
|
$data{ bg } = ( $attr & ( $blink ? $ATTR_BG : $ATTR_BG_NB ) ) >> 4; |
98
|
2
|
100
|
33
|
|
|
9
|
$data{ blink } = ( $attr && $ATTR_BLINK ) >> 7 if $blink; |
99
|
|
|
|
|
|
|
|
100
|
2
|
|
|
|
|
4
|
return \%data; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Brian Cassidy Ebricas@cpan.orgE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright 2008-2015 by Brian Cassidy |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
112
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |