lib/TUI/Drivers/ColorAttr.pm

filter: Statementstmt 96.0% 172 / 179 Branchbran 70.8% 34 / 48 Conditioncond 52.5% 42 / 80 MC/DCmcdc 17.3% 8 / 46 Subroutinesub 100% 30 / 30 Podpod 100% 17 / 17 totaltotal 75.7% 303 / 400 CC 52 SCAR 31.3
CC
52
Cov
81%
__ANON__
61.0
new
7.2
equals
4.2
CRAP 22.9
« lib/TUI/App/Program.pm ↑ Summary lib/TUI/Menus/MenuBar.pm »
1 package TUI::Drivers::ColorAttr;
2 # ABSTRACT: color attribute value type for screen cells
3
4 105 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 105 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 105 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 105 our $VERSION = '2.000002';
9 105 $VERSION =~ tr/_//d;
10 105 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 105 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 105 our @EXPORT = qw(
14 TColorAttr
15 );
16
17 105 require bytes;
18 105 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 105 ▶use PerlX::Assert::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 105 ▶use Scalar::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 blessed
22 looks_like_number
23 105 );
24
25 105 ▶use TUI::Drivers::Const qw( :slXXXX );
Subroutine BEGIN: called CC=1 SCAR=0.0
26 105 ▶use TUI::Drivers::Color;
Subroutine BEGIN: called CC=1 SCAR=0.0
27
28 sub TColorAttr() { __PACKAGE__ }
29
30 105 ▶use constant SUPPORTS_64BIT_IV => $Config{ivsize} >= 8 ? 1 : 0;
Subroutine BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
$TUI::Drivers::ColorAttr::Config{'ivsize'} >= 8 ? : 105 0 105
31
32 # macro for coercing a value into a TColor object
33 26 ▶my $coerceColor = sub {
Subroutine __ANON__: called CC=28 SCAR=41.1
34 26 my ( $value ) = @_;
35
36 # Already TColor.
37 26 ▶ return $value if blessed $value;
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) 10 16 26
38
39 # {} -> default
40 16 ▶ if ( ref $value eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "HASH") 4 12 16
41 4 return TColor->new( %$value );
42 }
43
44 # [] -> Abbreviations
45 12 ▶ if ( ref $value eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "ARRAY") 12 0 12
46
47 # []
48 12 ▶ return TColor->new()
Branch: 1 branch
BranchTrueFalseTotal
unless @$value 0 12 12
49 unless @$value;
50
51 # ['\x7'], ['\x07'], ['\x{07}']
52 12 ▶ if ( @$value == 1
Branch: 1 branch
BranchTrueFalseTotal
if (@$value == 1 and not ref $value->[0] and $value->[0] =~ /^\\x(?:\{([[:xdigit:]]+)\}|([[:xdigit:]]{1,2}))$/) 3 9 12
Condition83%5/6
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^\\x(?:\{([[:xdigit:]]+)\}|([[:xdigit:]]{1,2}))$/
!ll&&!rl&&r
273
@$value == 1 and not ref $value->[0]
!ll&&!rl&&r
2010
MC/DC66%2/3
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^\\x(?:\{([[:xdigit:]]+)\}|([[:xdigit:]]{1,2}))$/
@$value == 1 not ref $value->[0] $value->[0] =~ /^\\x(?:\{([[:xdigit:]]+)\}|([[:xdigit:]]{1,2}))$/
Truth table75%3/4
A and not(B) and C
A= @$value == 1B= not ref $value->[0]C= $value->[0] =~ /^\\x(?:\{([[:xdigit:]]+)\}|([[:xdigit:]]{1,2}))$/
ABCresult
0XX0
10X0
1100
1111
53 && !ref( $value->[0] )
54 && $value->[0] =~ /^\\x(?:\{([[:xdigit:]]+)\}|([[:xdigit:]]{1,2}))$/ )
55 {
56 3 ▶ return TColor->new(
Condition33%1/3
$1 // $2
l!l&&r!l&&!r
030
MC/DC0%0/2
$1 // $2
$1 $2
Truth table33%1/3
A // B
A= $1B= $2
ABresult
1X1
011
000
57 bios => hex( $1 // $2 ),
58 );
59 }
60
61 # ['\007'], ['\o{007}']
62 9 ▶ if ( @$value == 1
Branch: 1 branch
BranchTrueFalseTotal
if (@$value == 1 and not ref $value->[0] and $value->[0] =~ /^\\(?:o\{([0-7]+)\}|([0-7]{1,3}))$/) 0 9 9
Condition66%4/6
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^\\(?:o\{([0-7]+)\}|([0-7]{1,3}))$/
!ll&&!rl&&r
270
@$value == 1 and not ref $value->[0]
!ll&&!rl&&r
207
MC/DC0%0/3
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^\\(?:o\{([0-7]+)\}|([0-7]{1,3}))$/
@$value == 1 not ref $value->[0] $value->[0] =~ /^\\(?:o\{([0-7]+)\}|([0-7]{1,3}))$/
Truth table50%2/4
A and not(B) and C
A= @$value == 1B= not ref $value->[0]C= $value->[0] =~ /^\\(?:o\{([0-7]+)\}|([0-7]{1,3}))$/
ABCresult
0XX0
10X0
1100
1111
63 && !ref( $value->[0] )
64 && $value->[0] =~ /^\\(?:o\{([0-7]+)\}|([0-7]{1,3}))$/
65 ) {
66 0 ▶ return TColor->new(
Condition0%0/3
$1 // $2
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 // $2
$1 $2
Truth table0%0/3
A // B
A= $1B= $2
ABresult
1X1
011
000
67 bios => oct( $1 // $2 ),
68 );
69 }
70
71 # ['0b0111']
72 9 ▶ if ( @$value == 1
Branch: 1 branch
BranchTrueFalseTotal
if (@$value == 1 and not ref $value->[0] and $value->[0] =~ /^(0b[01]{4})$/) 0 9 9
Condition66%4/6
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^(0b[01]{4})$/
!ll&&!rl&&r
270
@$value == 1 and not ref $value->[0]
!ll&&!rl&&r
207
MC/DC0%0/3
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^(0b[01]{4})$/
@$value == 1 not ref $value->[0] $value->[0] =~ /^(0b[01]{4})$/
Truth table50%2/4
A and not(B) and C
A= @$value == 1B= not ref $value->[0]C= $value->[0] =~ /^(0b[01]{4})$/
ABCresult
0XX0
10X0
1100
1111
73 && !ref( $value->[0] )
74 && $value->[0] =~ /^(0b[01]{4})$/ )
75 {
76 0 return TColor->new(
77 bios => oct( $1 ),
78 );
79 }
80
81 # [196]
82 9 ▶ if ( @$value == 1 && looks_like_number( $value->[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$value == 1 and &looks_like_number($value->[0])) 6 3 9
Condition100%3/3
@$value == 1 and &looks_like_number($value->[0])
!ll&&!rl&&r
216
MC/DC100%2/2
@$value == 1 and &looks_like_number($value->[0])
@$value == 1 &looks_like_number($value->[0])
Truth table100%3/3
A and B
A= @$value == 1B= &looks_like_number($value->[0])
ABresult
0X0
100
111
83 6 return TColor->new(
84 xterm => $value->[0],
85 );
86 }
87 # ["\x7"]: a single already-resolved byte (e.g. from a double-quoted
88 # escape) is read directly as a BIOS value via its ordinal. Only
89 # printable digits ('0'..'9') are excluded, as those are already
90 # handled above as xterm indices.
91 3 ▶ if ( @$value == 1
Branch: 1 branch
BranchTrueFalseTotal
if (@$value == 1 and not ref $value->[0] and length $value->[0] == 1) 1 2 3
Condition66%4/6
@$value == 1 and not ref $value->[0] and length $value->[0] == 1
!ll&&!rl&&r
201
@$value == 1 and not ref $value->[0]
!ll&&!rl&&r
201
MC/DC33%1/3
@$value == 1 and not ref $value->[0] and length $value->[0] == 1
@$value == 1 not ref $value->[0] length $value->[0] == 1
Truth table50%2/4
A and not(B) and C
A= @$value == 1B= not ref $value->[0]C= length $value->[0] == 1
ABCresult
0XX0
10X0
1100
1111
92 && !ref( $value->[0] )
93 && length( $value->[0] ) == 1
94 ) {
95 1 return TColor->new(
96 bios => ord( $value->[0] ),
97 );
98 }
99 # ['#7fbb00'] (rgb8, one byte per channel)
100 2 ▶ if ( @$value == 1
Branch: 1 branch
BranchTrueFalseTotal
if (@$value == 1 and not ref $value->[0] and $value->[0] =~ /^#([[:xdigit:]]{6})$/) 0 2 2
Condition33%2/6
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^#([[:xdigit:]]{6})$/
!ll&&!rl&&r
200
@$value == 1 and not ref $value->[0]
!ll&&!rl&&r
200
MC/DC0%0/3
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^#([[:xdigit:]]{6})$/
@$value == 1 not ref $value->[0] $value->[0] =~ /^#([[:xdigit:]]{6})$/
Truth table25%1/4
A and not(B) and C
A= @$value == 1B= not ref $value->[0]C= $value->[0] =~ /^#([[:xdigit:]]{6})$/
ABCresult
0XX0
10X0
1100
1111
101 && !ref( $value->[0] )
102 && $value->[0] =~ /^#([[:xdigit:]]{6})$/
103 ) {
104 0 return TColor->new(
105 rgb => hex( $1 ),
106 );
107 }
108
109 # ['#7fb'] (shorthand, each digit doubled)
110 2 ▶ if ( @$value == 1
Branch: 1 branch
BranchTrueFalseTotal
if (@$value == 1 and not ref $value->[0] and $value->[0] =~ /^#([[:xdigit:]])([[:xdigit:]])([[:xdigit:]])$/) 0 2 2
Condition33%2/6
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^#([[:xdigit:]])([[:xdigit:]])([[:xdigit:]])$/
!ll&&!rl&&r
200
@$value == 1 and not ref $value->[0]
!ll&&!rl&&r
200
MC/DC0%0/3
@$value == 1 and not ref $value->[0] and $value->[0] =~ /^#([[:xdigit:]])([[:xdigit:]])([[:xdigit:]])$/
@$value == 1 not ref $value->[0] $value->[0] =~ /^#([[:xdigit:]])([[:xdigit:]])([[:xdigit:]])$/
Truth table25%1/4
A and not(B) and C
A= @$value == 1B= not ref $value->[0]C= $value->[0] =~ /^#([[:xdigit:]])([[:xdigit:]])([[:xdigit:]])$/
ABCresult
0XX0
10X0
1100
1111
111 && !ref( $value->[0] )
112 && $value->[0] =~ /^#([[:xdigit:]])([[:xdigit:]])([[:xdigit:]])$/
113 ) {
114 0 return TColor->new(
115 rgb => hex( "$1$1$2$2$3$3" ),
116 );
117 }
118
119 # [127,0,187]
120 2 ▶ if ( @$value == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$value == 3) 2 0 2
121 2 return TColor->new(
122 rgb => $value,
123 );
124 }
125 } #/ if ( ref( $value ) eq ...)
126
127 0 return;
128 105 };
129
130 # macro for coercing a value into a TColorAttr object
131 4 ▶my $coerceAttr = sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
132 4 ▶ return ref $_[0] ? $_[0] : TColorAttr->new( bios => $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 4 0 4
133 105 };
134
135 318 ▶sub new { # $attr (|%args)
Subroutine new: called CC=7 SCAR=19.7
Pod documented
136 318 my ( $class, @args ) = @_;
137
138 318 my ( $style, $fg, $bg );
139
140 # TColorAttr->new()
141 318 ▶ if ( !@args ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not @args) { } 14 304 318
elsif (@args == 2 and $args[0] eq 'bios') { } 291 13 304
elsif (@args % 2 == 0) { } 13 0 13
142 # Watch out! This is a trivial constructor.
143 14 $fg = $bg = bless \($style = 0), TColor;
144 }
145
146 # TColorAttr->new( bios => Int )
147 ▶ elsif ( @args == 2 && $args[0] eq 'bios' ) {
Condition66%2/3
@args == 2 and $args[0] eq "bios"
!ll&&!rl&&r
130291
MC/DC50%1/2
@args == 2 and $args[0] eq "bios"
@args == 2 $args[0] eq "bios"
Truth table66%2/3
A and B
A= @args == 2B= $args[0] eq "bios"
ABresult
0X0
100
111
148 291 my $bios = $args[1] & 0xff;
149 291 assert ( looks_like_number $bios );
150
151 291 $style = 0;
152 291 $fg = TColor->new( bios => $bios & 0xf );
153 291 $bg = TColor->new( bios => $bios >> 4 );
154 }
155
156 # TColorAttr->new(
157 # fg => TColor,
158 # bg => TColor,
159 # | style => Int
160 # )
161 elsif ( @args % 2 == 0 ) {
162 13 my %args = @args;
163 13 ▶ assert ( defined $args{fg} && defined $args{bg} );
Condition33%1/3
defined $args{'fg'} && defined $args{'bg'}
!ll&&!rl&&r
0013
MC/DC0%0/2
defined $args{'fg'} && defined $args{'bg'}
defined $args{'fg'} defined $args{'bg'}
Truth table33%1/3
A && B
A= defined $args{'fg'}B= defined $args{'bg'}
ABresult
0X0
100
111
164
165 13 ▶ $style = ( $args{style} // 0 ) & 0x3ff;
Condition100%2/2
$args{"style"} // 0
l!l
49
MC/DC100%1/1
$args{"style"} // 0
$args{"style"}
Truth table100%2/2
A
A= $args{"style"}
Aresult
11
00
166 13 $fg = $args{fg}->$coerceColor();
167 13 $bg = $args{bg}->$coerceColor();
168 }
169
170 else {
171 0 return;
172 }
173
174 318 assert ( looks_like_number $style );
175 318 assert ( blessed $fg );
176 318 assert ( blessed $bg );
177
178 # Fields are implemented as ScalarRef so that both copy and comparison
179 # operations can be optimized:
180 # Bit 0: Foreground (27 bits)
181 # Bit 27: Background (27 bits)
182 # Bit 54: Style (10 bits)
183 # or as a packed structure for 32-bit systems:
184 # 0-3: foreground (V)
185 # 4-7: background (V)
186 # 8-9: style (v)
187
188 318 my $v = SUPPORTS_64BIT_IV
189 ? $$fg | ( $$bg << 27 ) | ( $style << 54 )
190 : pack( 'VVv', $$fg, $$bg, $style );
191
192 318 return bless \$v, $class;
193 } #/ sub new
194
195 1 ▶sub assign { # void ($other)
Subroutine assign: called CC=1 SCAR=0.0
Pod documented
196 1 my ( $self, $other ) = @_;
197 1 assert ( blessed $self );
198 1 assert ( blessed $other );
199 1 $$self = $$other;
200 1 return;
201 }
202
203 9 ▶sub clone { # $attr ()
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
204 9 my ( $self ) = @_;
205 9 assert ( blessed $self );
206 9 my $v = $$self;
207 9 return bless \$v, ref $self;
208 }
209
210 578 ▶sub getForeground { # $fg ()
Subroutine getForeground: called CC=1 SCAR=0.0
Pod documented
211 578 my ( $self ) = @_;
212 578 assert ( blessed $self );
213 578 my $fg = SUPPORTS_64BIT_IV
214 ? $$self & 0x7ffffff
215 : unpack( 'V', $$self );
216 578 return bless \$fg, TColor;
217 }
218
219 2 ▶sub setForeground { # void ($color)
Subroutine setForeground: called CC=2 SCAR=7.1
Pod documented
220 2 my ( $self, $color ) = @_;
221 2 assert ( blessed $self );
222 2 ▶ assert ( blessed $color or looks_like_number $color );
Condition33%1/3
builtin::blessed($color) || &looks_like_number($color)
l!l&&r!l&&!r
200
MC/DC0%0/2
builtin::blessed($color) || &looks_like_number($color)
builtin::blessed($color) &looks_like_number($color)
Truth table33%1/3
A || B
A= builtin::blessed($color)B= &looks_like_number($color)
ABresult
1X1
011
000
223 2 my $fg = $color->$coerceAttr();
224 2 if ( SUPPORTS_64BIT_IV ) {
225 2 $$self = ( $$self & ~0x7ffffff ) | $$fg;
226 }
227 else {
228 bytes::substr( $$self, 0, 4, pack( 'V', $$fg ) );
229 }
230 2 return;
231 }
232
233 561 ▶sub getBackground { # $bg ()
Subroutine getBackground: called CC=1 SCAR=0.0
Pod documented
234 561 my ( $self ) = @_;
235 561 assert ( blessed $self );
236 561 my $bg = SUPPORTS_64BIT_IV
237 ? ( $$self >> 27 ) & 0x7ffffff
238 : unpack( 'x4V', $$self );
239 561 return bless \$bg, TColor;
240 }
241
242 2 ▶sub setBackground { # void ($color)
Subroutine setBackground: called CC=2 SCAR=7.1
Pod documented
243 2 my ( $self, $color ) = @_;
244 2 assert ( blessed $self );
245 2 ▶ assert ( blessed $color or looks_like_number $color );
Condition33%1/3
builtin::blessed($color) || &looks_like_number($color)
l!l&&r!l&&!r
200
MC/DC0%0/2
builtin::blessed($color) || &looks_like_number($color)
builtin::blessed($color) &looks_like_number($color)
Truth table33%1/3
A || B
A= builtin::blessed($color)B= &looks_like_number($color)
ABresult
1X1
011
000
246 2 my $bg = $color->$coerceAttr();
247 2 if ( SUPPORTS_64BIT_IV ) {
248 2 $$self = ( $$self & ~( 0x7ffffff << 27 ) ) | ( $$bg << 27 );
249 }
250 else {
251 bytes::substr( $$self, 4, 4, pack( 'V', $$bg ) );
252 }
253 2 return;
254 }
255
256 555 ▶sub getStyle { # sytle ()
Subroutine getStyle: called CC=1 SCAR=0.0
Pod documented
257 555 my ( $self ) = @_;
258 555 assert ( blessed $self );
259 555 my $style = SUPPORTS_64BIT_IV
260 ? ( ( $$self >> 54 ) & 0x3ff )
261 : unpack( 'x8v', $$self );
262 555 return $style;
263 }
264
265 1 ▶sub setStyle { # void ($style)
Subroutine setStyle: called CC=1 SCAR=0.0
Pod documented
266 1 my ( $self, $style ) = @_;
267 1 assert ( blessed $self );
268 1 assert ( looks_like_number $style );
269 1 $style &= 0x3ff;
270 1 if ( SUPPORTS_64BIT_IV ) {
271 1 $$self = ( $$self & ~( 0x3ff << 54 ) ) | ( $style << 54 );
272 }
273 else {
274 bytes::substr( $$self, 8, 2, pack( 'v', $style ) );
275 }
276 1 return;
277 }
278
279 1 ▶sub reversed { # $attr ()
Subroutine reversed: called CC=3 SCAR=11.5
Pod documented
280 1 my ( $self ) = @_;
281 1 my $attr = TColorAttr->new();
282 1 $$attr = $$self;
283
284 1 my $fg = $attr->getForeground();
285 1 my $bg = $attr->getBackground();
286 # The 'slReverse' attribute is represented differently by every terminal,
287 # so it is better to swap the colors manually unless any of them is default.
288 1 ▶ if ( $fg->isDefault() || $bg->isDefault() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fg->isDefault or $bg->isDefault) { } 0 1 1
Condition33%1/3
$fg->isDefault or $bg->isDefault
l!l&&r!l&&!r
001
MC/DC0%0/2
$fg->isDefault or $bg->isDefault
$fg->isDefault $bg->isDefault
Truth table33%1/3
A or B
A= $fg->isDefaultB= $bg->isDefault
ABresult
1X1
011
000
289 0 $attr->setStyle( $attr->getStyle() ^ slReverse );
290 }
291 else {
292 1 $attr->setForeground( $bg );
293 1 $attr->setBackground( $fg );
294 }
295 1 return $attr;
296 }
297
298 # Convert to a BIOS color attribute, using quantization if necessary.
299 # Style flags are ignored.
300
301 2 ▶sub toBIOS { # $attr ()
Subroutine toBIOS: called CC=1 SCAR=0.0
Pod documented
302 2 my ( $self ) = @_;
303 2 assert ( blessed $self );
304 2 my $fg = $self->getForeground();
305 2 my $bg = $self->getBackground();
306 2 return ( $fg->toBIOS( 1 ) | ( $bg->toBIOS( 0 ) << 4 ) ) & 0xff;
307 }
308
309 # Backward-compatibility functions:
310 #
311 # Return the corresponding BIOS color attribute when both the foreground
312 # and background are BIOS colors, and there are no style flags. Otherwise,
313 # return a fixed color (white on magenta) indicating that the cast is invalid.
314
315 290 ▶sub asBIOS { # $attr ()
Subroutine asBIOS: called CC=3 SCAR=11.0
Pod documented
316 290 my ( $self ) = @_;
317 290 assert ( blessed $self );
318
319 # $self must be a BIOS attribute, or else a fixed color will be returned
320 # instead. The key point is that the result shouldn't be '\x0' unless this
321 # is the BIOS attribute '\x0', so that legacy code comparing a TColorAttr
322 # against '0' keeps working.
323 290 my ( $fg, $bg );
324 290 if ( SUPPORTS_64BIT_IV ) {
325 290 $fg = $$self & 0x7ffffff;
326 290 $bg = ( $$self >> 27 ) & 0x7ffffff;
327 }
328 else {
329 ( $fg, $bg ) = unpack( 'VV', $$self );
330 }
331 290 my $bios = ( $fg & 0xf ) | ( ( $bg & 0xf ) << 4 );
332 290 ▶ return 0 unless $bios;
Branch: 1 branch
BranchTrueFalseTotal
unless $bios 3 287 290
333 287 ▶ return $self->isBIOS() ? $bios : 0x5f;
Branch: 1 branch
BranchTrueFalseTotal
$self->isBIOS ? : 287 0 287
334 }
335
336 551 ▶sub isBIOS { # $bool ()
Subroutine isBIOS: called CC=3 SCAR=11.3
Pod documented
337 551 my ( $self ) = @_;
338 551 assert ( blessed $self );
339 551 ▶ return $self->getForeground->isBIOS()
Condition66%4/6
$self->getForeground->isBIOS && $self->getBackground->isBIOS && !$self->getStyle
!ll&&!rl&&r
50546
$self->getForeground->isBIOS and $self->getBackground->isBIOS
!ll&&!rl&&r
50546
MC/DC33%1/3
$self->getForeground->isBIOS && $self->getBackground->isBIOS && !$self->getStyle
$self->getForeground->isBIOS $self->getBackground->isBIOS !$self->getStyle
Truth table50%2/4
A and B && not(C)
A= $self->getForeground->isBIOSB= $self->getBackground->isBIOSC= !$self->getStyle
ABCresult
0XX0
10X0
1100
1111
340 && $self->getBackground->isBIOS()
341 && !$self->getStyle();
342 }
343
344 9 ▶sub equals { # $bool ($other|$bios)
Subroutine equals: called CC=4 SCAR=14.3
Pod documented
345 9 my ( $self, $other ) = @_;
346 9 assert ( blessed $self );
347 9 ▶ assert ( blessed $other or looks_like_number $other );
Condition66%2/3
builtin::blessed($other) || &looks_like_number($other)
l!l&&r!l&&!r
810
MC/DC0%0/2
builtin::blessed($other) || &looks_like_number($other)
builtin::blessed($other) &looks_like_number($other)
Truth table66%2/3
A || B
A= builtin::blessed($other)B= &looks_like_number($other)
ABresult
1X1
011
000
348 9 ▶ return $self->asBIOS() == $other
Branch: 1 branch
BranchTrueFalseTotal
unless ref $other 1 8 9
349 unless ref $other;
350 8 ▶ return ref $self eq ref $other
Condition33%1/3
ref $self eq ref $other && $$self == $$other
!ll&&!rl&&r
008
MC/DC0%0/2
ref $self eq ref $other && $$self == $$other
ref $self eq ref $other $$self == $$other
Truth table33%1/3
A && B
A= ref $self eq ref $otherB= $$self == $$other
ABresult
0X0
100
111
351 && ( SUPPORTS_64BIT_IV ? $$self == $$other : $$self eq $$other );
352 }
353
354 # Used to support operations in legacy code.
355
356 2 ▶sub lshift { # $result ($shift)
Subroutine lshift: called CC=2 SCAR=6.9
Pod documented
357 2 my ( $self, $shift, $swap ) = @_;
358 2 assert ( blessed $self );
359 2 assert ( looks_like_number $shift );
360 2 assert ( not $swap );
361 2 require TUI::Drivers::AttrPair;
362
363 # Legacy code may use '<< 8' on an attribute to construct an attribute pair.
364 2 ▶ return TUI::Drivers::AttrPair->new(
Branch: 1 branch
BranchTrueFalseTotal
if $shift == 8 1 1 2
365 lo => TColorAttr->new( bios => 0 ),
366 hi => $self
367 ) if $shift == 8;
368 1 return TUI::Drivers::AttrPair->new( bios => $self->asBIOS() << $shift );
369 }
370
371 2 ▶sub and {
Subroutine and: called CC=3 SCAR=11.4
Pod documented
372 2 my ( $self, $c ) = @_;
373 2 assert ( blessed $self );
374 2 ▶ assert ( blessed $c or looks_like_number $c );
Condition33%1/3
builtin::blessed($c) || &looks_like_number($c)
l!l&&r!l&&!r
020
MC/DC0%0/2
builtin::blessed($c) || &looks_like_number($c)
builtin::blessed($c) &looks_like_number($c)
Truth table33%1/3
A || B
A= builtin::blessed($c)B= &looks_like_number($c)
ABresult
1X1
011
000
375 2 my $lhs = $self->asBIOS();
376 2 ▶ my $rhs = ref $c ? $c->asBIOS() : $c;
Branch: 1 branch
BranchTrueFalseTotal
ref $c ? : 0 2 2
377 2 my $class = ref $self;
378 2 return $class->new( bios => $lhs & $rhs );
379 }
380
381 2 ▶sub or {
Subroutine or: called CC=3 SCAR=11.4
Pod documented
382 2 my ( $self, $c ) = @_;
383 2 assert ( blessed $self );
384 2 ▶ assert ( blessed $c or looks_like_number $c );
Condition33%1/3
builtin::blessed($c) || &looks_like_number($c)
l!l&&r!l&&!r
020
MC/DC0%0/2
builtin::blessed($c) || &looks_like_number($c)
builtin::blessed($c) &looks_like_number($c)
Truth table33%1/3
A || B
A= builtin::blessed($c)B= &looks_like_number($c)
ABresult
1X1
011
000
385 2 my $lhs = $self->asBIOS();
386 2 ▶ my $rhs = ref $c ? $c->asBIOS() : $c;
Branch: 1 branch
BranchTrueFalseTotal
ref $c ? : 0 2 2
387 2 my $class = ref $self;
388 2 return $class->new( bios => $lhs | $rhs );
389 }
390
391 use overload
392 105 ▶ '0+' => \&asBIOS,
Subroutine BEGIN: called CC=1 SCAR=0.0
393 '==' => \&equals,
394 '<<' => \&lshift,
395 '&' => \&and,
396 '|' => \&or,
397 105 fallback => 1;
398
399 105 1
400
401 __END__
« lib/TUI/App/Program.pm ↑ Summary lib/TUI/Menus/MenuBar.pm »