| 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
Condition0%0/9
$x >= $rect->[0] and $x < $rect->[2] and $y >= $rect->[1] and $y < $rect->[3]
$x >= $rect->[0] and $x < $rect->[2] and $y >= $rect->[1]
$x >= $rect->[0] and $x < $rect->[2]
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]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
@_kept_rects and _is_kept($x, $y, \@_kept_rects)
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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
@_kept_rects and _is_kept($x, $y, \@_kept_rects)
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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||