lib/TUI/Dialogs/StaticText.pm

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