blib/lib/Term/Fabulous/Render/Target/Mask.pm

filter: Statementstmt 38.0% 35 / 92 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 50.0% 7 / 14 Podpod 33.3% 2 / 6 totaltotal 30.7% 44 / 143 CC 12 SCAR 27.0
CC
12
Cov
30%
_is_kept
42.0
set_cell
12.0
extend_cell
12.0
CRAP 14.9
« blib/lib/Term/Fabulous/Roving.pm ↑ Summary blib/lib/Term/Fabulous/Widget/Table/Borders.pm »
1 package Term::Fabulous::Render::Target::Mask;
2  
3 1 ▶use v5.32;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.05';
9  
10 1 ▶use Object::Pad 0.825;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 role Term::Fabulous::Render::Target::Mask {
13 1 ▶ use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶ use Term::Fabulous::Render::Geometry qw(row_spans_outside);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # Provided by the target: reset every cell outside the given rects, show
17 # the frame, and write cells unconditionally.
18 1 method clear_cells;
19 1 method present_cells;
20 1 method put_cell;
21 1 method put_extension;
22 1 method put_row;
23  
24 # Rects whose cells this frame must leave alone, until they are released.
25 1 field @_kept_rects;
26  
27 0 ▶ sub _is_kept ( $x, $y, $rects ) {
Subroutine _is_kept: not called CC=6 SCAR=37.4
28 0 foreach my $rect (@$rects) {
29 0 ▶ return 1 if $x >= $rect->[0] && $x < $rect->[2] && $y >= $rect->[1] && $y < $rect->[3];
Branch: 1 branch
BranchTrueFalseTotal
if $x >= $rect->[0] and $x < $rect->[2] and $y >= $rect->[1] and $y < $rect->[3] 0 0 0
Condition0%0/9
$x >= $rect->[0] and $x < $rect->[2] and $y >= $rect->[1] and $y < $rect->[3]
!ll&&!rl&&r
000
$x >= $rect->[0] and $x < $rect->[2] and $y >= $rect->[1]
!ll&&!rl&&r
000
$x >= $rect->[0] and $x < $rect->[2]
!ll&&!rl&&r
000
MC/DC0%0/4
$x >= $rect->[0] and $x < $rect->[2] and $y >= $rect->[1] and $y < $rect->[3]
$x >= $rect->[0] $x < $rect->[2] $y >= $rect->[1] $y < $rect->[3]
Truth table0%0/5
A and B and C and D
A= $x >= $rect->[0]B= $x < $rect->[2]C= $y >= $rect->[1]D= $y < $rect->[3]
ABCDresult
0XXX0
10XX0
110X0
11100
11111
30 }
31 0 return 0;
32 }
33  
34 0 ▶ method begin_frame (@kept_rects) {
Subroutine begin_frame: not called CC=1 SCAR=6.9
Pod undocumented
35 0 @_kept_rects = @kept_rects;
36 0 $self->clear_cells(@kept_rects);
37 0 return;
38 1 }
39  
40 0 ▶ method end_frame () {
Subroutine end_frame: not called CC=1 SCAR=6.9
Pod documented
41 0 @_kept_rects = ();
42 0 $self->present_cells;
43 0 return;
44 1 }
45  
46 0 ▶ method release_rect ($rect) {
Subroutine release_rect: not called CC=1 SCAR=6.9
Pod documented
47 0 @_kept_rects = grep { refaddr($_) != refaddr($rect) } @_kept_rects;
48 0 return;
49 1 }
50  
51 0 ▶ method set_cell ( $x, $y, $glyph, $fg, $bg ) {
Subroutine set_cell: not called CC=3 SCAR=24.8
Pod undocumented
52 0 ▶ return if @_kept_rects && _is_kept( $x, $y, \@_kept_rects );
Branch: 1 branch
BranchTrueFalseTotal
if @_kept_rects and _is_kept($x, $y, \@_kept_rects) 0 0 0
Condition0%0/3
@_kept_rects and _is_kept($x, $y, \@_kept_rects)
!ll&&!rl&&r
000
MC/DC0%0/2
@_kept_rects and _is_kept($x, $y, \@_kept_rects)
@_kept_rects _is_kept($x, $y, \@_kept_rects)
Truth table0%0/3
A and B
A= @_kept_rectsB= _is_kept($x, $y, \@_kept_rects)
ABresult
0X0
100
111
53 0 $self->put_cell( $x, $y, $glyph, $fg, $bg );
54 0 return;
55 1 }
56  
57 0 ▶ method extend_cell ( $x, $y, $character ) {
Subroutine extend_cell: not called CC=3 SCAR=24.8
Pod undocumented
58 0 ▶ return if @_kept_rects && _is_kept( $x, $y, \@_kept_rects );
Branch: 1 branch
BranchTrueFalseTotal
if @_kept_rects and _is_kept($x, $y, \@_kept_rects) 0 0 0
Condition0%0/3
@_kept_rects and _is_kept($x, $y, \@_kept_rects)
!ll&&!rl&&r
000
MC/DC0%0/2
@_kept_rects and _is_kept($x, $y, \@_kept_rects)
@_kept_rects _is_kept($x, $y, \@_kept_rects)
Truth table0%0/3
A and B
A= @_kept_rectsB= _is_kept($x, $y, \@_kept_rects)
ABresult
0X0
100
111
59 0 $self->put_extension( $x, $y, $character );
60 0 return;
61 1 }
62  
63 0 ▶ method fill_row ( $x, $y, $columns, $bg ) {
Subroutine fill_row: not called CC=3 SCAR=24.8
Pod undocumented
64 0 ▶ if ( !@_kept_rects ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_kept_rects) 0 0 0
65 0 $self->put_row( $x, $y, $columns, $bg );
66 0 return;
67 }
68 0 foreach my $span ( row_spans_outside( $y, $x, $x + $columns, @_kept_rects ) ) {
69 0 my ( $from, $to ) = @$span;
70 0 $self->put_row( $from, $y, $to - $from, $bg );
71 }
72 0 return;
73 1 }
74 }
75  
76 1 1;
77  
78 __END__
« blib/lib/Term/Fabulous/Roving.pm ↑ Summary blib/lib/Term/Fabulous/Widget/Table/Borders.pm »