lib/TUI/Dialogs/StaticText.pm

filter: Statementstmt 35.1% 39 / 111 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 55.0% 11 / 20 Podpod 87.5% 7 / 8 totaltotal 27.9% 57 / 204 CC 24 SCAR 51.4
CC
24
Cov
24%
draw
380.0
BUILD
12.0
DEMOLISH
12.0
CRAP 170.3
« lib/TUI/Views/Frame.pm ↑ Summary lib/TUI/ColorSel/ColorSelector.pm »
1 package TUI::Dialogs::StaticText;
2 # ABSTRACT: Displays fixed text inside a dialog
3
4 29 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 29 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 29 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 29 our $VERSION = '2.000002';
9 29 $VERSION =~ tr/_//d;
10 29 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 29 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 29 our @EXPORT = qw(
14 TStaticText
15 new_TStaticText
16 );
17
18 29 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 29 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
20 is_Object
21 :types
22 29 );
23
24 29 ▶use TUI::Dialogs::Const qw( cpStaticText );
Subroutine BEGIN: called CC=1 SCAR=0.0
25 29 ▶use TUI::Views::Const qw( gfFixed );
Subroutine BEGIN: called CC=1 SCAR=0.0
26 29 ▶use TUI::Views::DrawBuffer;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 29 ▶use TUI::Views::Palette;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 29 ▶use TUI::Views::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
29
30 sub TStaticText() { __PACKAGE__ }
31 sub name() { 'TStaticText' }
32 0 ▶sub new_TStaticText { __PACKAGE__->from(@_) }
Subroutine new_TStaticText: not called CC=1 SCAR=6.9
Pod documented
33
34 29 extends TView;
35
36 # protected attributes
37 0 ▶has text => ( is => 'ro', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
38
39 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
40 0 state $sig = signature(
41 method => 1,
42 named => [
43 bounds => Object,
44 text => Str, { alias => 'aText' },
45 ],
46 caller_level => +1,
47 );
48 0 my ( $class, $args ) = $sig->( @_ );
49 0 return { %$args };
50 }
51
52 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod documented
53 0 my ( $self, $args ) = @_;
54 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
55 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
56 0 $self->{growMode} |= gfFixed;
57 0 return;
58 }
59
60 0 ▶sub from { # $obj ($bounds, $aText)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
61 0 state $sig = signature(
62 method => 1,
63 pos => [Object, Str],
64 );
65 0 my ( $class, @args ) = $sig->( @_ );
66 0 return $class->new( bounds => $args[0], text => $args[1] );
67 }
68
69 0 ▶sub DEMOLISH { # void ($in_global_destruction)
Subroutine DEMOLISH: not called CC=3 SCAR=24.8
Pod documented
70 0 my ( $self, $in_global_destruction ) = @_;
71 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
72 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
73 0 $self->{text} = undef;
74 0 return;
75 }
76
77 0 ▶sub draw { # void ()
Subroutine draw: not called CC=19 SCAR=59.4
Pod documented
78 0 state $sig = signature(
79 method => Object,
80 pos => [],
81 );
82 0 my ( $self ) = $sig->( @_ );
83
84 0 my $color;
85 my $center;
86 0 my ( $i, $j, $l, $p, $y );
87 0 my $b = TDrawBuffer->new();
88 0 my $s;
89
90 0 $color = $self->getColor( 1 );
91 0 $self->getText( \$s );
92 0 $l = length( $s );
93 0 $p = 0;
94 0 $y = 0;
95 0 $center = false;
96 0 ▶ while ( $y < $self->{size}{y} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y < $self->{"size"}{"y"}) 0 0 0
97 0 $b->moveChar( 0, ' ', $color, $self->{size}{x} );
98 0 ▶ if ( $p < $l ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p < $l) 0 0 0
99 0 ▶ if ( substr( $s, $p, 1 ) eq "\003" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($s, $p, 1) eq "\3") 0 0 0
100 0 $center = 1;
101 0 ++$p;
102 }
103 0 $i = $p;
104 do {
105 0 $j = $p;
106 0 ▶ while ( $p < $l && substr( $s, $p, 1 ) eq ' ' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p < $l and substr($s, $p, 1) eq " ") 0 0 0
Condition0%0/3
$p < $l and substr($s, $p, 1) eq " "
!ll&&!rl&&r
000
MC/DC0%0/2
$p < $l and substr($s, $p, 1) eq " "
$p < $l substr($s, $p, 1) eq " "
Truth table0%0/3
A and B
A= $p < $lB= substr($s, $p, 1) eq " "
ABresult
0X0
100
111
107 0 ++$p;
108 }
109 0 ▶ while ( $p < $l
Branch: 1 branch
BranchTrueFalseTotal
if ($p < $l and substr($s, $p, 1) ne " " and substr($s, $p, 1) ne "\n") 0 0 0
Condition0%0/6
$p < $l and substr($s, $p, 1) ne " " and substr($s, $p, 1) ne "\n"
!ll&&!rl&&r
000
$p < $l and substr($s, $p, 1) ne " "
!ll&&!rl&&r
000
MC/DC0%0/3
$p < $l and substr($s, $p, 1) ne " " and substr($s, $p, 1) ne "\n"
$p < $l substr($s, $p, 1) ne " " substr($s, $p, 1) ne "\n"
Truth table0%0/4
A and B and C
A= $p < $lB= substr($s, $p, 1) ne " "C= substr($s, $p, 1) ne "\n"
ABCresult
0XX0
10X0
1100
1111
110 && substr( $s, $p, 1 ) ne ' '
111 && substr( $s, $p, 1 ) ne "\n" )
112 {
113 0 ++$p;
114 }
115 } while ( $p < $l
116 && $p < $i + $self->{size}{x}
117 0 ▶ && substr( $s, $p, 1 ) ne "\n"
Branch: 1 branch
BranchTrueFalseTotal
$p < $l and $p < $i + $self->{"size"}{"x"} and substr($s, $p, 1) ne "\n" and do { do { $j = $p; while ($p < $l and substr($s, $p, 1) eq " ") { ++$p; } ; while ($p < $l and substr($s, $p, 1) ne " " and substr($s, $p, 1) ne "\n") { ++$p; } } } 0 0 0
Condition0%0/6
$p < $l and $p < $i + $self->{"size"}{"x"} and substr($s, $p, 1) ne "\n"
!ll&&!rl&&r
000
$p < $l and $p < $i + $self->{"size"}{"x"}
!ll&&!rl&&r
000
MC/DC0%0/3
$p < $l and $p < $i + $self->{"size"}{"x"} and substr($s, $p, 1) ne "\n"
$p < $l $p < $i + $self->{"size"}{"x"} substr($s, $p, 1) ne "\n"
Truth table0%0/4
A and B and C
A= $p < $lB= $p < $i + $self->{"size"}{"x"}C= substr($s, $p, 1) ne "\n"
ABCresult
0XX0
10X0
1100
1111
118 );
119 0 ▶ if ( $p > $i + $self->{size}{x} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p > $i + $self->{"size"}{"x"}) 0 0 0
120 0 ▶ if ( $j > $i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j > $i) { } 0 0 0
121 0 $p = $j;
122 }
123 else {
124 0 $p = $i + $self->{size}{x};
125 }
126 }
127 0 ▶ if ( $center ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($center) { } 0 0 0
128 0 $j = int( ( $self->{size}{x} - $p + $i ) / 2 );
129 }
130 else {
131 0 $j = 0;
132 }
133 0 $b->moveStr( $j, substr( $s, $i, $p - $i ), $color );
134 0 ▶ while ( $p < $l && substr( $s, $p, 1 ) eq ' ' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p < $l and substr($s, $p, 1) eq " ") 0 0 0
Condition0%0/3
$p < $l and substr($s, $p, 1) eq " "
!ll&&!rl&&r
000
MC/DC0%0/2
$p < $l and substr($s, $p, 1) eq " "
$p < $l substr($s, $p, 1) eq " "
Truth table0%0/3
A and B
A= $p < $lB= substr($s, $p, 1) eq " "
ABresult
0X0
100
111
135 0 ++$p;
136 }
137 0 ▶ if ( $p < $l && substr( $s, $p, 1 ) eq "\n" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p < $l and substr($s, $p, 1) eq "\n") 0 0 0
Condition0%0/3
$p < $l and substr($s, $p, 1) eq "\n"
!ll&&!rl&&r
000
MC/DC0%0/2
$p < $l and substr($s, $p, 1) eq "\n"
$p < $l substr($s, $p, 1) eq "\n"
Truth table0%0/3
A and B
A= $p < $lB= substr($s, $p, 1) eq "\n"
ABresult
0X0
100
111
138 0 $center = 0;
139 0 ++$p;
140 }
141 } #/ if ( $p < $l )
142 0 $self->writeLine( 0, $y++, $self->{size}{x}, 1, $b );
143 } #/ while ( $y < $self->{size...})
144 0 return;
145 } #/ sub draw
146
147 0 ▶sub getPalette { # $palette ()
Subroutine getPalette: not called CC=1 SCAR=6.9
Pod documented
148 0 state $sig = signature(
149 method => Object,
150 pos => [],
151 );
152 0 my ( $self ) = $sig->( @_ );
153 0 state $palette = TPalette->new(
154 data => cpStaticText,
155 size => length( cpStaticText ),
156 );
157 0 return $palette->clone();
158 }
159
160 0 ▶sub getText { # void (\$s)
Subroutine getText: not called CC=2 SCAR=17.9
Pod documented
161 0 state $sig = signature(
162 method => Object,
163 pos => [ScalarRef],
164 );
165 0 my ( $self, $s ) = $sig->( @_ );
166 0 ▶ if ( !$self->{text} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'text'}) { } 0 0 0
167 0 $$s = '';
168 }
169 else {
170 0 $$s = substr( $self->{text}, 0, 255 );
171 }
172 0 return;
173 }
174
175 29 1
176
177 __END__
« lib/TUI/Views/Frame.pm ↑ Summary lib/TUI/ColorSel/ColorSelector.pm »