lib/TUI/Views/Group.pm

filter: Statementstmt 15.9% 102 / 641 Branchbran 0.0% 0 / 288 Conditioncond 0.0% 0 / 72 MC/DCmcdc 0.0% 0 / 44 Subroutinesub 28.2% 24 / 85 Podpod 90.9% 40 / 44 totaltotal 14.1% 166 / 1174 CC 171 SCAR 36.3
CC
171
Cov
10%
__ANON__
210.0
__ANON__
110.0
removeView
72.3
CRAP 37.8
« lib/TUI/Menus/SubMenu.pm ↑ Summary lib/TUI/Dialogs/History.pm »
1 package TUI::Views::Group;
2 # ABSTRACT: Base class for all group components
3
4 70 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 70 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 70 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 70 our $VERSION = '2.000003';
9 70 $VERSION =~ tr/_//d;
10 70 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 70 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 70 our @EXPORT = qw(
14 TGroup
15 new_TGroup
16 );
17
18 70 ▶use Devel::StrictMode;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 70 ▶use Scalar::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
20 weaken
21 isweak
22 70 );
23 70 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 70 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
25 Maybe
26 :is
27 :types
28 70 );
29
30 70 ▶use TUI::Objects::Point;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 70 ▶use TUI::Objects::Rect;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 70 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
33 :evXXXX
34 70 );
35 70 ▶use TUI::Drivers::ScreenCell;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 70 ▶use TUI::Drivers::Event;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 70 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
38 :phaseType
39 :selectMode
40 :cmXXXX
41 :evXXXX
42 :hcXXXX
43 :ofXXXX
44 :sfXXXX
45 70 );
46 70 ▶use TUI::Views::CommandSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 70 ▶use TUI::Views::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
48
49 sub TGroup() { __PACKAGE__ }
50 sub name() { 'TGroup' }
51 0 ▶sub new_TGroup { __PACKAGE__->from(@_) }
Subroutine new_TGroup: not called CC=1 SCAR=6.9
Pod documented
52
53 70 extends TView;
54
55 # declare global variables
56 70 our $TheTopView;
57 70 our $ownerGroup;
58
59 # public attributes
60 70 has current => ( is => 'bare' );
61 70 has last => ( is => 'ro' );
62 70 has clip => ( is => 'rw' );
63 70 has phase => ( is => 'ro', default => phFocused );
64 70 has buffer => ( is => 'ro' );
65 70 has lockFlag => ( is => 'rw', default => 0 );
66 70 has endState => ( is => 'rw', default => 0 );
67
68 # predeclare private methods
69 my (
70 70 $invalid,
71 $focusView,
72 $selectView,
73 $findNext,
74 $doPut,
75 );
76
77 0 ▶my $lock_value = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
78 0 ▶ Internals::SvREADONLY( $_[0] => 1 )
Branch: 1 branch
BranchTrueFalseTotal
if exists &Internals::SvREADONLY 0 0 0
79 if exists &Internals::SvREADONLY;
80 70 };
81
82 0 ▶my $unlock_value = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
83 0 ▶ Internals::SvREADONLY( $_[0] => 0 )
Branch: 1 branch
BranchTrueFalseTotal
if exists &Internals::SvREADONLY 0 0 0
84 if exists &Internals::SvREADONLY;
85 70 };
86
87 0 ▶my $weaken = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
88 # warn join(',' => caller()), "\n";
89 0 &$unlock_value( $_[0] ) if STRICT;
90 0 weaken $_[0];
91 0 &$lock_value( $_[0] ) if STRICT;
92 70 };
93
94 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=4 SCAR=30.0
Pod documented
95 0 my ( $self, $args ) = @_;
96 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
97 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
98 0 $self->{eventMask} = 0xffff;
99 0 $self->{options} |= ofSelectable | ofBuffered;
100 0 $self->{clip} = $self->getExtent();
101 0 ▶ weaken( $self->{current} ) if $self->{current};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"current"} 0 0 0
102 0 &$lock_value( $self->{current} ) if STRICT;
103 0 return;
104 }
105
106 0 ▶sub DEMOLISH { # void ($in_global_destruction)
Subroutine DEMOLISH: not called CC=5 SCAR=34.0
Pod documented
107 0 my ( $self, $in_global_destruction ) = @_;
108 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
109 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
110 0 ▶ assert ( is_Bool $in_global_destruction );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($in_global_destruction) 0 0 0
111 0 &$unlock_value( $self->{current} ) if STRICT;
112 0 ▶ $self->shutDown() unless $in_global_destruction;
Branch: 1 branch
BranchTrueFalseTotal
unless $in_global_destruction 0 0 0
113 0 return;
114 }
115
116 0 ▶sub shutDown { # void ()
Subroutine shutDown: not called CC=6 SCAR=37.4
Pod documented
117 0 state $sig = signature(
118 method => Object,
119 pos => [],
120 );
121 0 my ( $self ) = $sig->( @_ );
122 0 my $p = $self->{last};
123 0 ▶ if ( $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p) 0 0 0
124 do {
125 0 $p->hide();
126 0 $p = $p->prev();
127 0 ▶ } while ( $p && $p != $self->{last} );
Branch: 1 branch
BranchTrueFalseTotal
$p and $p != $self->{"last"} and do { do { $p->hide; $p = $p->prev } } 0 0 0
Condition0%0/3
$p and $p != $self->{"last"}
!ll&&!rl&&r
000
MC/DC0%0/2
$p and $p != $self->{"last"}
$p $p != $self->{"last"}
Truth table0%0/3
A and B
A= $pB= $p != $self->{"last"}
ABresult
0X0
100
111
128
129 0 ▶ while ( $p && $self->{last} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p and $self->{"last"}) 0 0 0
Condition0%0/3
$p and $self->{"last"}
!ll&&!rl&&r
000
MC/DC0%0/2
$p and $self->{"last"}
$p $self->{"last"}
Truth table0%0/3
A and B
A= $pB= $self->{"last"}
ABresult
0X0
100
111
130 0 my $T = $p->prev();
131 0 $self->destroy( $p );
132 0 $p = $T;
133 }
134 } #/ if ( $p )
135 0 $self->freeBuffer();
136 0 $self->current( undef );
137 0 $self->SUPER::shutDown();
138 0 return;
139 } #/ sub shutDown
140
141 0 ▶sub execView { # $int ($p|undef)
Subroutine execView: not called CC=5 SCAR=34.0
Pod documented
142 0 state $sig = signature(
143 method => Object,
144 pos => [Maybe[Object]],
145 );
146 0 my ( $self, $p ) = $sig->( @_ );
147 0 alias: for $p ( $_[1] ) {
148 0 ▶ return cmCancel
Branch: 1 branch
BranchTrueFalseTotal
unless $p 0 0 0
149 unless $p;
150
151 0 my $saveOptions = $p->{options};
152 0 my $saveOwner = $p->{owner};
153 0 my $saveTopView = $TheTopView;
154 0 my $saveCurrent = $self->{current};
155 0 my $saveCommands = TCommandSet->new();
156 0 $self->getCommands( $saveCommands );
157 0 weaken( $TheTopView = $p );
158 0 $p->{options} &= ~ofSelectable;
159 0 $p->setState( sfModal, true );
160 0 $self->setCurrent( $p, enterSelect );
161 0 ▶ $self->insert( $p )
Branch: 1 branch
BranchTrueFalseTotal
unless $saveOwner 0 0 0
162 unless $saveOwner;
163 0 my $retval = $p->execute();
164 0 ▶ $self->remove( $p )
Branch: 1 branch
BranchTrueFalseTotal
unless $saveOwner 0 0 0
165 unless $saveOwner;
166 0 $self->setCurrent( $saveCurrent, leaveSelect );
167 0 $p->setState( sfModal, false );
168 0 $p->{options} = $saveOptions;
169 0 weaken( $TheTopView = $saveTopView );
170 0 $self->setCommands( $saveCommands );
171 0 return $retval;
172 } #/ alias:
173 } #/ sub execView
174
175 0 ▶sub execute { # $int ()
Subroutine execute: not called CC=4 SCAR=30.0
Pod documented
176 0 state $sig = signature(
177 method => Object,
178 pos => [],
179 );
180 0 my ( $self ) = $sig->( @_ );
181 do {
182 0 $self->{endState} = 0;
183 do {
184 0 my $e = TEvent->new();
185 0 $self->getEvent( $e );
186 0 $self->handleEvent( $e );
187 0 ▶ if ( $e->{what} != evNothing ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{"what"} != 0) 0 0 0
188 0 $self->eventError( $e );
189 }
190 0 ▶ } while ( !$self->{endState} );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"endState"} or do { do { my $e = "TUI::Drivers::Event"->new; $self->getEvent($e); $self->handleEvent($e); if ($e->{"what"} != 0) { $self->eventError($e); } } } 0 0 0
191 0 ▶ } while ( !$self->valid( $self->{endState} ) );
Branch: 1 branch
BranchTrueFalseTotal
$self->valid($self->{"endState"}) or do { do { $self->{"endState"} = 0; do { my $e = "TUI::Drivers::Event"->new; $self->getEvent($e); $self->handleEvent($e); if ($e->{"what"} != 0) { $self->eventError($e); } } until $self->{"endState"} } } 0 0 0
192 0 return $self->{endState};
193 }
194
195 0 ▶my $doAwaken = sub { # void ($v, $p)
Subroutine __ANON__: not called CC=3 SCAR=24.8
196 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
197 0 ▶ assert ( is_Object $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($_[0]) 0 0 0
198 0 $_[0]->awaken();
199 0 return;
200 70 };
201
202 0 ▶sub awaken { # void ()
Subroutine awaken: not called CC=1 SCAR=6.9
Pod documented
203 0 state $sig = signature(
204 method => Object,
205 pos => [],
206 );
207 0 my ( $self ) = $sig->( @_ );
208 0 $self->forEach( $doAwaken, undef );
209 0 return;
210 }
211
212 0 ▶sub insertView { # void ($p, $Target|undef)
Subroutine insertView: not called CC=6 SCAR=37.4
Pod documented
213 0 state $sig = signature(
214 method => Object,
215 pos => [Object, Maybe[Object]],
216 );
217 0 my ( $self, $p, $Target ) = $sig->( @_ );
218 0 $p->owner( $self );
219 0 ▶ if ( $Target ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Target) { } 0 0 0
220 0 ▶ assert ( $Target->{owner} == $self );
Branch: 1 branch
BranchTrueFalseTotal
unless $Target->{"owner"} == $self 0 0 0
221 0 ▶ assert ( $self->{last} );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"last"} 0 0 0
222
223 # Check if the cycle needs to be weakened again.
224 0 my $weak_cycle = $self->{last} == $Target;
225
226 # Insert new element (as originally)
227 0 $Target = $Target->prev();
228 0 $p->next( $Target->{next} );
229 0 $Target->next( $p );
230
231 0 q/*
232 warn "\t\$Target => $Target\n";
233 warn "\t\$p => $p\n";
234 my $s = $self->{last};
235 while ( $s->{next} && $s->{next} != $self->{last} ) {
236 warn "\t\t\$" . $s . "->{next} => \\%" . $s->{next} . "\n";
237 $s = $s->{next};
238 }
239 warn "\t\t\$" . $s . "->{next} => " . ( $s->{next} || 'undef' ) . "\n";
240 */ if 0;
241
242 # Set new weak reference if necessary
243 0 ▶ &$weaken( $self->{last}->prev()->{next} ) if $weak_cycle;
Branch: 1 branch
BranchTrueFalseTotal
if $weak_cycle 0 0 0
244 }
245 else {
246 0 ▶ if ( !$self->{last} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'last'}) { } 0 0 0
247 0 $p->next( $p );
248 0 $self->{last} = $p;
249 0 &$weaken( $p->{next} );
250 }
251 else {
252 0 my $last = $self->{last};
253 0 my $first = $last->{next};
254 0 my $prev = $last->prev();
255
256 # Move the weak link to the new end of the ring.
257 0 $prev->next( $last );
258
259 0 $p->next( $first );
260 0 $last->next( $p );
261 0 &$weaken( $last->{next} );
262
263 0 $self->{last} = $p;
264 }
265 } #/ else [ if ( $Target ) ]
266 0 q/*
267 require Devel::Cycle;
268 warn $_ if local $_ = Devel::Cycle::find_cycle( $p );
269 */ if 0;
270 0 return;
271 } #/ sub insertView
272
273 0 ▶sub remove { # void ($p|undef)
Subroutine remove: not called CC=3 SCAR=24.8
Pod documented
274 0 state $sig = signature(
275 method => Object,
276 pos => [Maybe[Object]],
277 );
278 0 my ( $self, $p ) = $sig->( @_ );
279 0 ▶ if ( $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p) 0 0 0
280 0 my $saveState = $p->{state};
281 0 $p->hide();
282 0 $self->removeView( $p );
283 0 $p->owner( undef );
284 0 $p->next( undef );
285 0 ▶ if ( $saveState & sfVisible ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($saveState & 1) 0 0 0
286 0 $p->show();
287 }
288 } #/ if ( $p )
289 0 return;
290 } #/ sub remove
291
292 # The following subroutine was ported from the framework
293 # "A modern port of Turbo Vision 2.0", which is licensed under MIT licence.
294 #
295 # Copyright 2019-2021 by magiblot <magiblot@hotmail.com>
296 #
297 # I<tgrmv.cpp>
298 0 ▶sub removeView { # void ($p)
Subroutine removeView: not called CC=9 SCAR=42.8
Pod documented
299 0 state $sig = signature(
300 method => Object,
301 pos => [Object],
302 );
303 0 my ( $self, $p ) = $sig->( @_ );
304 0 ▶ if ( $self->{last} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"last"}) 0 0 0
305 70 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
306 0 my $s = $self->{last};
307
308 # Check if the cycle needs to be weakened again.
309 0 ▶ my $weak_cycle = $s == $p || $s == $p->{next};
Condition0%0/3
$s == $p || $s == $p->{'next'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$s == $p || $s == $p->{'next'}
$s == $p $s == $p->{'next'}
Truth table0%0/3
A || B
A= $s == $pB= $s == $p->{'next'}
ABresult
1X1
011
000
310
311 0 ▶ while ( $s->{next} != $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->{"next"} != $p) 0 0 0
312 return
313 0 ▶ if $s->{next} == $self->{last};
Branch: 1 branch
BranchTrueFalseTotal
if $s->{"next"} == $self->{"last"} 0 0 0
314 0 $s = $s->{next};
315 }
316 0 $s->next( $p->{next} );
317
318 # Weaken the {next} field of the removed entry.
319 0 ▶ &$weaken( $p->{next} ) unless isweak $p->{next};
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::is_weak($p->{"next"}) 0 0 0
320
321 0 ▶ if ( $p == $self->{last} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p == $self->{"last"}) 0 0 0
322 0 ▶ if ( $p == $p->{next} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p == $p->{"next"}) 0 0 0
323 0 $self->{last} = undef;
324 0 return;
325 }
326 0 $self->{last} = $s;
327 }
328
329 # Set new weak reference if necessary
330 0 ▶ &$weaken( $self->{last}->prev()->{next} ) if $weak_cycle;
Branch: 1 branch
BranchTrueFalseTotal
if $weak_cycle 0 0 0
331 0 q/*
332 require Devel::Cycle;
333 warn $_ if local $_ = Devel::Cycle::find_cycle( $p );
334 */ if 0;
335 } #/ if ( $self->{last} )
336 0 return;
337 } #/ sub removeView
338
339 0 ▶sub resetCurrent { # void ()
Subroutine resetCurrent: not called CC=1 SCAR=6.9
Pod undocumented
340 0 state $sig = signature(
341 method => Object,
342 pos => [],
343 );
344 0 my ( $self ) = $sig->( @_ );
345 0 $self->setCurrent( $self->firstMatch( sfVisible, ofSelectable ),
346 normalSelect );
347 0 return;
348 }
349
350 0 ▶sub setCurrent { # void ($p|undef, $mode)
Subroutine setCurrent: not called CC=8 SCAR=40.1
Pod documented
351 70 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
352 0 state $sig = signature(
353 method => Object,
354 pos => [Maybe[Object], PositiveOrZeroInt],
355 );
356 0 my ( $self, $p, $mode ) = $sig->( @_ );
357 return
358 0 ▶ if $self->{current} == $p;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"current"} == $p 0 0 0
359
360 0 $self->lock();
361 0 $self->$focusView( $self->{current}, false );
362 $self->{current}->setState( sfSelected, false )
363 if $mode != enterSelect
364 0 ▶ && $self->{current};
Branch: 1 branch
BranchTrueFalseTotal
if $mode != 1 and $self->{"current"} 0 0 0
Condition0%0/3
$mode != 1 and $self->{"current"}
!ll&&!rl&&r
000
MC/DC0%0/2
$mode != 1 and $self->{"current"}
$mode != 1 $self->{"current"}
Truth table0%0/3
A and B
A= $mode != 1B= $self->{"current"}
ABresult
0X0
100
111
365 0 ▶ $p->setState( sfSelected, true )
Branch: 1 branch
BranchTrueFalseTotal
if $mode != 2 and $p 0 0 0
Condition0%0/3
$mode != 2 and $p
!ll&&!rl&&r
000
MC/DC0%0/2
$mode != 2 and $p
$mode != 2 $p
Truth table0%0/3
A and B
A= $mode != 2B= $p
ABresult
0X0
100
111
366 if $mode != leaveSelect && $p;
367 $p->setState( sfFocused, true )
368 0 ▶ if ( $self->{state} & sfFocused ) && $p;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"} & 64 and $p 0 0 0
Condition0%0/3
$self->{"state"} & 64 and $p
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"state"} & 64 and $p
$self->{"state"} & 64 $p
Truth table0%0/3
A and B
A= $self->{"state"} & 64B= $p
ABresult
0X0
100
111
369 0 $self->current( $p );
370 0 $self->unlock();
371 0 return;
372 } #/ sub setCurrent
373
374 0 ▶sub selectNext { # void ($forwards)
Subroutine selectNext: not called CC=3 SCAR=24.8
Pod documented
375 0 state $sig = signature(
376 method => Object,
377 pos => [Bool],
378 );
379 0 my ( $self, $forwards ) = $sig->( @_ );
380 0 ▶ if ( $self->{current} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"current"}) 0 0 0
381 0 my $p = $self->$findNext( $forwards );
382 0 ▶ $p->select() if $p;
Branch: 1 branch
BranchTrueFalseTotal
if $p 0 0 0
383 }
384 0 return;
385 } #/ sub selectNext
386
387 0 ▶sub firstThat { # $view|undef (\&Test, @args)
Subroutine firstThat: not called CC=4 SCAR=25.6
Pod documented
388 0 state $sig = signature(
389 method => Object,
390 pos => [
391 CodeRef,
392 ArrayRef, { slurpy => 1 }
393 ],
394 );
395 0 my ( $self, $func, $args ) = $sig->( @_ );
396 0 my $temp = $self->{last};
397 return undef
398 0 ▶ unless $temp;
Branch: 1 branch
BranchTrueFalseTotal
unless $temp 0 0 0
399
400 70 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
401 do {
402 0 $temp = $temp->{next};
403 0 ▶ return $temp
Branch: 1 branch
BranchTrueFalseTotal
if &$func($temp, @$args) 0 0 0
404 if $func->( $temp, @$args );
405 0 ▶ } while ( $temp != $self->{last} );
Branch: 1 branch
BranchTrueFalseTotal
$temp != $self->{"last"} and do { do { $temp = $temp->{"next"}; return $temp if &$func($temp, @$args) } } 0 0 0
406 0 return undef;
407 } #/ sub firstThat
408
409 0 ▶sub focusNext { # $bool ($forwards)
Subroutine focusNext: not called CC=2 SCAR=17.9
Pod undocumented
410 0 state $sig = signature(
411 method => Object,
412 pos => [Bool],
413 );
414 0 my ( $self, $forwards ) = $sig->( @_ );
415 0 my $p = $self->$findNext( $forwards );
416 0 ▶ return $p ? $p->focus() : true;
Branch: 1 branch
BranchTrueFalseTotal
$p ? : 0 0 0
417 }
418
419 0 ▶sub forEach { # void (\&action, @args)
Subroutine forEach: not called CC=3 SCAR=21.1
Pod documented
420 0 state $sig = signature(
421 method => Object,
422 pos => [
423 CodeRef,
424 ArrayRef, { slurpy => 1 }
425 ],
426 );
427 0 my ( $self, $func, $args ) = $sig->( @_ );
428 0 my $term = $self->{last};
429 0 my $temp = $self->{last};
430 return
431 0 ▶ unless $temp;
Branch: 1 branch
BranchTrueFalseTotal
unless $temp 0 0 0
432
433 70 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
434 0 my $next = $temp->{next};
435 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$temp != $term and do { do { $temp = $next; $next = $temp->{"next"}; &$func($temp, @$args) } } 0 0 0
436 0 $temp = $next;
437 0 $next = $temp->{next};
438 0 $func->( $temp, @$args );
439 } while ( $temp != $term );
440 0 return;
441 } #/ sub forEach
442
443 0 ▶sub insert { # void ($p|undef)
Subroutine insert: not called CC=1 SCAR=6.9
Pod documented
444 0 state $sig = signature(
445 method => Object,
446 pos => [Maybe[Object]],
447 );
448 0 my ( $self, $p ) = $sig->( @_ );
449 0 $self->insertBefore( $p, $self->first() );
450 0 return;
451 }
452
453 0 ▶sub insertBefore { # void ($p|undef, $Target|undef)
Subroutine insertBefore: not called CC=9 SCAR=42.4
Pod documented
454 70 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
455 0 state $sig = signature(
456 method => Object,
457 pos => [Maybe[Object], Maybe[Object]],
458 );
459 0 my ( $self, $p, $Target ) = $sig->( @_ );
460 0 ▶ if ( $p && !$p->{owner} && ( !$Target || $Target->{owner} == $self ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p and not $p->{"owner"} and !$Target || $Target->{"owner"} == $self) 0 0 0
Condition0%0/9
$p and not $p->{"owner"} and !$Target || $Target->{"owner"} == $self
!ll&&!rl&&r
000
$p and not $p->{"owner"}
!ll&&!rl&&r
000
not $Target or $Target->{"owner"} == $self
l!l&&r!l&&!r
000
MC/DC0%0/4
$p and not $p->{"owner"} and !$Target || $Target->{"owner"} == $self
$p not $p->{"owner"} not $Target $Target->{"owner"} == $self
Truth table0%0/5
A and not(B) and not(C) or D
A= $pB= not $p->{"owner"}C= not $TargetD= $Target->{"owner"} == $self
ABCDresult
0XXX0
10XX0
11000
111X1
11011
461 $p->{origin}{x} = ( $self->{size}{x} - $p->{size}{x} ) >> 1
462 0 ▶ if $p->{options} & ofCenterX;
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"options"} & 256 0 0 0
463 $p->{origin}{y} = ( $self->{size}{y} - $p->{size}{y} ) >> 1
464 0 ▶ if $p->{options} & ofCenterY;
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"options"} & 512 0 0 0
465 0 my $saveState = $p->{state};
466 0 $p->hide();
467 0 $self->insertView( $p, $Target );
468 0 ▶ $p->show()
Branch: 1 branch
BranchTrueFalseTotal
if $saveState & 1 0 0 0
469 if $saveState & sfVisible;
470 0 ▶ $p->setState( sfActive, true )
Branch: 1 branch
BranchTrueFalseTotal
if $saveState & 16 0 0 0
471 if $saveState & sfActive;
472 } #/ if ( $p && !$p->owner(...))
473 } #/ sub insertBefore
474
475 0 ▶sub current { # $view|undef (|$view|undef)
Subroutine current: not called CC=3 SCAR=24.8
Pod documented
476 0 state $sig = signature(
477 method => Object,
478 pos => [
479 Maybe[Object], { optional => 1 },
480 ],
481 );
482 0 my ( $self, $view ) = $sig->( @_ );
483 0 ▶ goto SET if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
484 GET: {
485 0 return $self->{current};
486 }
487 SET: {
488 0 &$unlock_value( $self->{current} ) if STRICT;
489 weaken $self->{current}
490 0 ▶ if $self->{current} = $view;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"current"} = $view 0 0 0
491 0 &$lock_value( $self->{current} ) if STRICT;
492 0 return;
493 }
494 }
495
496 0 ▶sub at { # $view|undef ($index)
Subroutine at: not called CC=2 SCAR=17.9
Pod documented
497 0 state $sig = signature(
498 method => Object,
499 pos => [Int],
500 );
501 0 my ( $self, $index ) = $sig->( @_ );
502 0 my $temp = $self->{last};
503 0 ▶ while ( $index-- > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index-- > 0) 0 0 0
504 0 $temp = $temp->{next};
505 }
506 0 return $temp;
507 } #/ sub at
508
509 0 ▶sub firstMatch { # $view|undef ($aState, $aOptions)
Subroutine firstMatch: not called CC=5 SCAR=30.1
Pod documented
510 0 state $sig = signature(
511 method => Object,
512 pos => [PositiveOrZeroInt, PositiveOrZeroInt],
513 );
514 0 my ( $self, $aState, $aOptions ) = $sig->( @_ );
515 return undef
516 0 ▶ unless $self->{last};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"last"} 0 0 0
517
518 70 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
519 0 my $temp = $self->{last};
520 0 while ( 1 ) {
521 return $temp
522 if ( $temp->{state} & $aState ) == $aState
523 0 ▶ && ( $temp->{options} & $aOptions ) == $aOptions;
Branch: 1 branch
BranchTrueFalseTotal
if ($temp->{"state"} & $aState) == $aState and ($temp->{"options"} & $aOptions) == $aOptions 0 0 0
Condition0%0/3
($temp->{"state"} & $aState) == $aState and ($temp->{"options"} & $aOptions) == $aOptions
!ll&&!rl&&r
000
MC/DC0%0/2
($temp->{"state"} & $aState) == $aState and ($temp->{"options"} & $aOptions) == $aOptions
($temp->{"state"} & $aState) == $aState ($temp->{"options"} & $aOptions) == $aOptions
Truth table0%0/3
A and B
A= ($temp->{"state"} & $aState) == $aStateB= ($temp->{"options"} & $aOptions) == $aOptions
ABresult
0X0
100
111
524 0 $temp = $temp->{next};
525 return undef
526 0 ▶ if $temp == $self->{last};
Branch: 1 branch
BranchTrueFalseTotal
if $temp == $self->{"last"} 0 0 0
527 }
528 } #/ sub firstMatch
529
530 0 ▶sub indexOf { # $int ($p)
Subroutine indexOf: not called CC=5 SCAR=30.3
Pod documented
531 0 state $sig = signature(
532 method => Object,
533 pos => [Object],
534 );
535 0 my ( $self, $p ) = $sig->( @_ );
536 return 0
537 0 ▶ unless $self->{last};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"last"} 0 0 0
538
539 70 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
540 0 my $index = 0;
541 0 my $temp = $self->{last};
542 do {
543 0 $index++;
544 0 $temp = $temp->{next};
545 0 ▶ } while ( $temp != $p && $temp != $self->{last} );
Branch: 1 branch
BranchTrueFalseTotal
$temp != $p and $temp != $self->{"last"} and do { do { ++$index; $temp = $temp->{"next"} } } 0 0 0
Condition0%0/3
$temp != $p and $temp != $self->{"last"}
!ll&&!rl&&r
000
MC/DC0%0/2
$temp != $p and $temp != $self->{"last"}
$temp != $p $temp != $self->{"last"}
Truth table0%0/3
A and B
A= $temp != $pB= $temp != $self->{"last"}
ABresult
0X0
100
111
546 0 ▶ return $temp == $p ? $index : 0;
Branch: 1 branch
BranchTrueFalseTotal
$temp == $p ? : 0 0 0
547 } #/ sub indexOf
548
549 0 ▶sub matches { # $bool ($p)
Subroutine matches: not called CC=1 SCAR=6.9
Pod documented
550 0 state $sig = signature(
551 method => Object,
552 pos => [Object],
553 );
554 0 $sig->( @_ );
555 ...
556 0 }
557
558 0 ▶sub first { # $view|undef ()
Subroutine first: not called CC=2 SCAR=17.9
Pod documented
559 0 state $sig = signature(
560 method => Object,
561 pos => [],
562 );
563 0 my ( $self ) = $sig->( @_ );
564 0 ▶ return $self->{last} ? $self->{last}{next} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'last'} ? : 0 0 0
565 }
566
567 0 ▶my $doExpose = sub { # void ($p, \$enable)
Subroutine __ANON__: not called CC=5 SCAR=34.0
568 0 my ( $p, $enable ) = @_;
569 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
570 0 ▶ assert ( is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($p) 0 0 0
571 0 ▶ assert ( is_ScalarRef $enable );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_ScalarRef($enable) 0 0 0
572 0 ▶ $p->setState( sfExposed, $$enable )
Branch: 1 branch
BranchTrueFalseTotal
if $p->state & 1 0 0 0
573 if $p->state & sfVisible;
574 0 return;
575 70 };
576
577 0 ▶my $doSetState = sub { # void ($p, \%b)
Subroutine __ANON__: not called CC=4 SCAR=30.0
578 0 my ( $p, $b ) = @_;
579 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
580 0 ▶ assert ( is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($p) 0 0 0
581 0 ▶ assert ( is_HashLike $b );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_HashLike($b) 0 0 0
582 0 $p->setState( $b->{st}, $b->{en} );
583 0 return;
584 70 };
585
586 0 ▶sub setState { # void ($aState, $enable)
Subroutine setState: not called CC=6 SCAR=37.4
Pod documented
587 0 state $sig = signature(
588 method => Object,
589 pos => [PositiveOrZeroInt, Bool],
590 );
591 0 my ( $self, $aState, $enable ) = $sig->( @_ );
592 0 my $sb = {
593 st => $aState,
594 en => $enable,
595 };
596
597 0 $self->SUPER::setState( $aState, $enable );
598
599 0 ▶ if ( $aState & ( sfActive | sfDragging ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aState & 144) 0 0 0
600 0 $self->lock();
601 0 $self->forEach( $doSetState, $sb );
602 0 $self->unlock();
603 }
604
605 0 ▶ if ( $aState & sfFocused ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aState & 64) 0 0 0
606 $self->{current}->setState( sfFocused, $enable )
607 0 ▶ if $self->{current};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"current"} 0 0 0
608 }
609
610 0 ▶ if ( $aState & sfExposed ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aState & 2048) 0 0 0
611 0 $self->forEach( $doExpose, \$enable );
612 0 ▶ $self->freeBuffer()
Branch: 1 branch
BranchTrueFalseTotal
unless $enable 0 0 0
613 unless $enable;
614 }
615 0 return;
616 } #/ sub setState
617
618 0 ▶my $doHandleEvent = sub { # void ($p|undef, \%s)
Subroutine __ANON__: not called CC=14 SCAR=53.5
619 0 my ( $p, $s ) = @_;
620 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
621 0 ▶ assert ( !defined $p or is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless not defined $p or &is_Object($p) 0 0 0
Condition0%0/3
not defined $p or &is_Object($p)
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $p or &is_Object($p)
not defined $p &is_Object($p)
Truth table0%0/3
not(A) or B
A= not defined $pB= &is_Object($p)
ABresult
1X1
011
000
622 0 ▶ assert ( is_HashLike $s );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_HashLike($s) 0 0 0
623 0 ▶ return unless $p;
Branch: 1 branch
BranchTrueFalseTotal
unless $p 0 0 0
624 return
625 if ( $p->{state} & sfDisabled )
626 0 ▶ && ( $s->{event}{what} & ( positionalEvents | focusedEvents ) );
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"state"} & 256 and $s->{"event"}{"what"} & 287 0 0 0
Condition0%0/3
$p->{"state"} & 256 and $s->{"event"}{"what"} & 287
!ll&&!rl&&r
000
MC/DC0%0/2
$p->{"state"} & 256 and $s->{"event"}{"what"} & 287
$p->{"state"} & 256 $s->{"event"}{"what"} & 287
Truth table0%0/3
A and B
A= $p->{"state"} & 256B= $s->{"event"}{"what"} & 287
ABresult
0X0
100
111
627
628 0 SWITCH: for ( $s->{grp}{phase} ) {
629 0 ▶ $_ == phPreProcess and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 1 and do { return unless $p->{"options"} & 16; last } 0 0 0
630 return
631 0 ▶ unless $p->{options} & ofPreProcess;
Branch: 1 branch
BranchTrueFalseTotal
unless $p->{"options"} & 16 0 0 0
632 0 last;
633 };
634 0 ▶ $_ == phPostProcess and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 2 and do { return unless $p->{"options"} & 32; last } 0 0 0
635 return
636 0 ▶ unless $p->{options} & ofPostProcess;
Branch: 1 branch
BranchTrueFalseTotal
unless $p->{"options"} & 32 0 0 0
637 0 last;
638 };
639 }
640 $p->handleEvent( $s->{event} )
641 0 ▶ if $s->{event}{what} & $p->{eventMask};
Branch: 1 branch
BranchTrueFalseTotal
if $s->{"event"}{"what"} & $p->{"eventMask"} 0 0 0
642 0 return;
643 70 };
644
645 0 ▶my $hasMouse = sub { # $bool ($p, $s)
Subroutine __ANON__: not called CC=4 SCAR=30.0
646 0 my ( $p, $s ) = @_;
647 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
648 0 ▶ assert ( is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($p) 0 0 0
649 0 ▶ assert ( is_HashLike $s );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_HashLike($s) 0 0 0
650 0 return $p->containsMouse( $s );
651 70 };
652
653 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=6 SCAR=37.4
Pod documented
654 0 state $sig = signature(
655 method => Object,
656 pos => [Object],
657 );
658 0 my ( $self, $event ) = $sig->( @_ );
659 0 $self->SUPER::handleEvent( $event );
660
661 0 my $hs = {
662 event => $event,
663 grp => $self
664 };
665
666 0 ▶ if ( $event->{what} & focusedEvents ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{'what'} & 272) { } 0 0 0
667 0 $self->{phase} = phPreProcess;
668 0 $self->forEach( $doHandleEvent, $hs );
669
670 0 $self->{phase} = phFocused;
671 0 &$doHandleEvent( $self->{current}, $hs );
672
673 0 $self->{phase} = phPostProcess;
674 0 $self->forEach( $doHandleEvent, $hs );
675 } #/ if ( $event->{what} & ...)
676 else {
677 0 $self->{phase} = phFocused;
678 0 ▶ if ( $event->{what} & positionalEvents ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{'what'} & 15) { } 0 0 0
679 # get pointer to topmost view holding mouse
680 0 my $p = $self->firstThat( $hasMouse, $event );
681 0 ▶ if ( $p ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($p) { } 0 0 0
elsif ($event->{'what'} == 1) { } 0 0 0
682 # we have a view; send event to it
683 0 &$doHandleEvent( $p, $hs );
684 }
685 elsif ( $event->{what} == evMouseDown ) {
686 # it was a mouse click and we don't have a view,
687 # so sound a beep.
688 0 ▶ if ( eval { require Win32::Sound } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Win32::Sound } }) { } 0 0 0
689 0 Win32::Sound::Play("SystemDefault");
690 }
691 else {
692 # May not work, depending on the nature of the terminal.
693 0 print "\a";
694 }
695 }
696 } #/ if ( $event->{what} & ...)
697 else {
698 0 $self->forEach( $doHandleEvent, $hs );
699 }
700 } #/ else [ if ( $event->{what} & ...)]
701 0 return;
702 } #/ sub handleEvent
703
704 0 ▶sub drawSubViews { # void ($p|undef, $bottom|undef)
Subroutine drawSubViews: not called CC=2 SCAR=12.6
Pod documented
705 0 state $sig = signature(
706 method => Object,
707 pos => [Maybe[Object], Maybe[Object]],
708 );
709 0 my ( $self, $p, $bottom ) = $sig->( @_ );
710 70 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
711 0 ▶ while ( $p != $bottom ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p != $bottom) 0 0 0
712 0 $p->drawView();
713 0 $p = $p->nextView();
714 }
715 0 return;
716 }
717
718 0 ▶my $doCalcChange = sub { # void ($p, $d)
Subroutine __ANON__: not called CC=4 SCAR=30.0
719 0 my ( $p, $d ) = @_;
720 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
721 0 ▶ assert ( is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($p) 0 0 0
722 0 ▶ assert ( is_Object $d );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($d) 0 0 0
723 0 my $r = TRect->new();
724 0 $p->calcBounds( $r, $d );
725 0 $p->changeBounds( $r );
726 0 return;
727 70 };
728
729 0 ▶sub changeBounds { # void ($self, $bounds)
Subroutine changeBounds: not called CC=3 SCAR=24.8
Pod documented
730 0 state $sig = signature(
731 method => Object,
732 pos => [Object],
733 );
734 0 my ( $self, $bounds ) = $sig->( @_ );
735 my $d = TPoint->new(
736 x => ( $bounds->{b}{x} - $bounds->{a}{x} ) - $self->{size}{x},
737 y => ( $bounds->{b}{y} - $bounds->{a}{y} ) - $self->{size}{y},
738 0 );
739 0 ▶ if ( $d->{x} == 0 && $d->{y} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d->{'x'} == 0 and $d->{'y'} == 0) { } 0 0 0
Condition0%0/3
$d->{"x"} == 0 and $d->{"y"} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$d->{"x"} == 0 and $d->{"y"} == 0
$d->{"x"} == 0 $d->{"y"} == 0
Truth table0%0/3
A and B
A= $d->{"x"} == 0B= $d->{"y"} == 0
ABresult
0X0
100
111
740 0 $self->setBounds( $bounds );
741 0 $self->drawView();
742 }
743 else {
744 0 $self->freeBuffer();
745 0 $self->setBounds( $bounds );
746 0 $self->{clip} = $self->getExtent();
747 0 $self->getBuffer();
748 0 $self->lock();
749 0 $self->forEach( $doCalcChange, $d );
750 0 $self->unlock();
751 }
752 0 return;
753 } #/ sub changeBounds
754
755 0 ▶my $addSubviewDataSize = sub { # void ($p, \$T)
Subroutine __ANON__: not called CC=4 SCAR=30.0
756 0 my ( $p, $T ) = @_;
757 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
758 0 ▶ assert ( is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($p) 0 0 0
759 0 ▶ assert ( is_ScalarRef $T );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_ScalarRef($T) 0 0 0
760 0 $$T += $p->dataSize();
761 70 };
762
763 0 ▶sub dataSize { # $int ()
Subroutine dataSize: not called CC=1 SCAR=6.9
Pod documented
764 0 state $sig = signature(
765 method => Object,
766 pos => [],
767 );
768 0 my ( $self ) = $sig->( @_ );
769 0 my $T = 0;
770 0 $self->forEach( $addSubviewDataSize, \$T );
771 0 return $T;
772 }
773
774 0 ▶sub getData { # void (\@rec)
Subroutine getData: not called CC=4 SCAR=30.0
Pod documented
775 0 state $sig = signature(
776 method => Object,
777 pos => [ArrayLike],
778 );
779 0 my ( $self, $rec ) = $sig->( @_ );
780 0 my $i = 0;
781 0 ▶ if ( $self->{last} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"last"}) 0 0 0
782 0 my $v = $self->{last};
783 do {
784 0 my $size = $v->dataSize();
785 0 ▶ $v->getData( sub { \@_ }->( @$rec[ $i .. $i + $size - 1 ] ) )
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $size 0 0 0
786 if $size;
787 0 $i += $size;
788 0 $v = $v->prev();
789 0 ▶ } while ( $v != $self->{last} );
Branch: 1 branch
BranchTrueFalseTotal
$v != $self->{"last"} and do { do { my $size = $v->dataSize; $v->getData(sub { \@_; } ->(@$rec[$i .. $i + $size - 1])) if $size; $i += $size; $v = $v->prev } } 0 0 0
790 }
791 0 return;
792 } #/ sub getData
793
794 0 ▶sub setData { # void (\@rec)
Subroutine setData: not called CC=4 SCAR=30.0
Pod documented
795 0 state $sig = signature(
796 method => Object,
797 pos => [ArrayLike],
798 );
799 0 my ( $self, $rec ) = $sig->( @_ );
800 0 my $i = 0;
801 0 ▶ if ( $self->{last} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"last"}) 0 0 0
802 0 my $v = $self->{last};
803 do {
804 0 my $size = $v->dataSize();
805 0 ▶ $v->setData( sub { \@_ }->( @$rec[ $i .. $i + $size - 1 ] ) )
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $size 0 0 0
806 if $size;
807 0 $i += $size;
808 0 $v = $v->prev();
809 0 ▶ } while ( $v != $self->{last} );
Branch: 1 branch
BranchTrueFalseTotal
$v != $self->{"last"} and do { do { my $size = $v->dataSize; $v->setData(sub { \@_; } ->(@$rec[$i .. $i + $size - 1])) if $size; $i += $size; $v = $v->prev } } 0 0 0
810 }
811 0 return;
812 }
813
814 0 ▶sub draw { # void ()
Subroutine draw: not called CC=4 SCAR=30.0
Pod documented
815 0 state $sig = signature(
816 method => Object,
817 pos => [],
818 );
819 0 my ( $self ) = $sig->( @_ );
820 0 ▶ if ( !$self->{buffer} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"buffer"}) 0 0 0
821 0 $self->getBuffer();
822 0 ▶ if ( $self->{buffer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"buffer"}) 0 0 0
823 0 $self->{lockFlag}++;
824 0 $self->redraw();
825 0 $self->{lockFlag}--;
826 }
827 }
828 0 ▶ if ( $self->{buffer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'buffer'}) { } 0 0 0
829 0 $self->writeBuf( 0, 0, $self->{size}{x}, $self->{size}{y}, $self->{buffer} );
830 }
831 else {
832 0 $self->{clip} = $self->getClipRect();
833 0 $self->redraw();
834 0 $self->{clip} = $self->getExtent();
835 }
836 0 return;
837 } #/ sub draw
838
839 0 ▶sub redraw { # void ()
Subroutine redraw: not called CC=1 SCAR=6.9
Pod documented
840 0 state $sig = signature(
841 method => Object,
842 pos => [],
843 );
844 0 my ( $self ) = $sig->( @_ );
845 0 $self->drawSubViews( $self->first(), undef );
846 0 return;
847 }
848
849 0 ▶sub lock { # void ()
Subroutine lock: not called CC=3 SCAR=24.8
Pod documented
850 0 state $sig = signature(
851 method => Object,
852 pos => [],
853 );
854 0 my ( $self ) = $sig->( @_ );
855 $self->{lockFlag}++
856 0 ▶ if $self->{buffer} || $self->{lockFlag};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"buffer"} or $self->{"lockFlag"} 0 0 0
Condition0%0/3
$self->{"buffer"} or $self->{"lockFlag"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"buffer"} or $self->{"lockFlag"}
$self->{"buffer"} $self->{"lockFlag"}
Truth table0%0/3
A or B
A= $self->{"buffer"}B= $self->{"lockFlag"}
ABresult
1X1
011
000
857 0 return;
858 }
859
860 0 ▶sub unlock { # void ()
Subroutine unlock: not called CC=3 SCAR=24.8
Pod documented
861 0 state $sig = signature(
862 method => Object,
863 pos => [],
864 );
865 0 my ( $self ) = $sig->( @_ );
866 $self->drawView()
867 0 ▶ if $self->{lockFlag} && --$self->{lockFlag} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"lockFlag"} and --$self->{"lockFlag"} == 0 0 0 0
Condition0%0/3
$self->{"lockFlag"} and --$self->{"lockFlag"} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"lockFlag"} and --$self->{"lockFlag"} == 0
$self->{"lockFlag"} --$self->{"lockFlag"} == 0
Truth table0%0/3
A and B
A= $self->{"lockFlag"}B= --$self->{"lockFlag"} == 0
ABresult
0X0
100
111
868 0 return;
869 }
870
871 0 ▶sub resetCursor { # void ()
Subroutine resetCursor: not called CC=2 SCAR=17.9
Pod documented
872 0 state $sig = signature(
873 method => Object,
874 pos => [],
875 );
876 0 my ( $self ) = $sig->( @_ );
877 $self->{current}->resetCursor()
878 0 ▶ if $self->{current};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"current"} 0 0 0
879 0 return;
880 }
881
882 0 ▶sub endModal { # void ($command)
Subroutine endModal: not called CC=2 SCAR=17.9
Pod documented
883 0 state $sig = signature(
884 method => Object,
885 pos => [PositiveOrZeroInt],
886 );
887 0 my ( $self, $command ) = $sig->( @_ );
888 0 ▶ if ( $self->{state} & sfModal ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'state'} & 512) { } 0 0 0
889 0 $self->{endState} = $command;
890 }
891 else {
892 0 $self->SUPER::endModal( $command );
893 }
894 0 return;
895 }
896
897 0 ▶sub eventError { # void ($event)
Subroutine eventError: not called CC=2 SCAR=17.9
Pod documented
898 0 state $sig = signature(
899 method => Object,
900 pos => [Object],
901 );
902 0 my ( $self, $event ) = $sig->( @_ );
903 0 ▶ if ( $self->{owner} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"owner"}) 0 0 0
904 0 $self->{owner}->eventError( $event );
905 }
906 0 return;
907 }
908
909 0 ▶sub getHelpCtx { # $int ()
Subroutine getHelpCtx: not called CC=3 SCAR=24.8
Pod documented
910 0 state $sig = signature(
911 method => Object,
912 pos => [],
913 );
914 0 my ( $self ) = $sig->( @_ );
915 0 my $h = hcNoContext;
916 $h = $self->{current}->getHelpCtx()
917 0 ▶ if $self->{current};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"current"} 0 0 0
918 0 ▶ $h = $self->SUPER::getHelpCtx()
Branch: 1 branch
BranchTrueFalseTotal
if $h == 0 0 0 0
919 if $h == hcNoContext;
920 0 return $h;
921 }
922
923 0 ▶my $isInvalid = sub { # $bool ($p, \$command)
Subroutine __ANON__: not called CC=4 SCAR=30.0
924 0 my ( $p, $command ) = @_;
925 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
926 0 ▶ assert ( is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($p) 0 0 0
927 0 ▶ assert ( is_ScalarRef $command );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_ScalarRef($command) 0 0 0
928 0 return !$p->valid( $$command );
929 70 };
930
931 0 ▶sub valid { # $bool ($command)
Subroutine valid: not called CC=4 SCAR=30.0
Pod documented
932 0 state $sig = signature(
933 method => Object,
934 pos => [PositiveOrZeroInt],
935 );
936 0 my ( $self, $command ) = $sig->( @_ );
937 0 ▶ if ( $command == cmReleasedFocus ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command == 51) 0 0 0
938 0 ▶ if ( $self->{current}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'current'} and $self->{'current'}{'options'} & 1024) { } 0 0 0
Condition0%0/3
$self->{"current"} and $self->{"current"}{"options"} & 1024
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"current"} and $self->{"current"}{"options"} & 1024
$self->{"current"} $self->{"current"}{"options"} & 1024
Truth table0%0/3
A and B
A= $self->{"current"}B= $self->{"current"}{"options"} & 1024
ABresult
0X0
100
111
939 && ( $self->{current}{options} & ofValidate )
940 ) {
941 0 return $self->{current}->valid( $command );
942 }
943 else {
944 0 return true;
945 }
946 }
947 0 return !$self->firstThat( $isInvalid, \$command );
948 }
949
950 0 ▶sub freeBuffer { # void ()
Subroutine freeBuffer: not called CC=3 SCAR=24.8
Pod documented
951 0 state $sig = signature(
952 method => Object,
953 pos => [],
954 );
955 0 my ( $self ) = $sig->( @_ );
956 0 ▶ if ( ( $self->{options} & ofBuffered ) && $self->{buffer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"options"} & 64 and $self->{"buffer"}) 0 0 0
Condition0%0/3
$self->{"options"} & 64 and $self->{"buffer"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"options"} & 64 and $self->{"buffer"}
$self->{"options"} & 64 $self->{"buffer"}
Truth table0%0/3
A and B
A= $self->{"options"} & 64B= $self->{"buffer"}
ABresult
0X0
100
111
957 0 $self->{buffer} = undef;
958 }
959 0 return;
960 }
961
962 0 ▶sub getBuffer { # void ()
Subroutine getBuffer: not called CC=4 SCAR=30.0
Pod documented
963 0 state $sig = signature(
964 method => Object,
965 pos => [],
966 );
967 0 my ( $self ) = $sig->( @_ );
968 # An uninitialized screen buffer is harmless in MS-DOS, since the worst
969 # you will see are random characters and colors. But in non-Borland mode,
970 # it may result in control characters being printed to screen, which will
971 # severely mess up the display. Do not allow this to happen.
972 0 ▶ if ( ( $self->{state} & sfExposed )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"} & 2048 and $self->{"options"} & 64 and not $self->{"buffer"}) 0 0 0
Condition0%0/6
$self->{"state"} & 2048 and $self->{"options"} & 64 and not $self->{"buffer"}
!ll&&!rl&&r
000
$self->{"state"} & 2048 and $self->{"options"} & 64
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"state"} & 2048 and $self->{"options"} & 64 and not $self->{"buffer"}
$self->{"state"} & 2048 $self->{"options"} & 64 not $self->{"buffer"}
Truth table0%0/4
A and B and not(C)
A= $self->{"state"} & 2048B= $self->{"options"} & 64C= not $self->{"buffer"}
ABCresult
0XX0
10X0
1100
1111
973 && ( $self->{options} & ofBuffered )
974 && !$self->{buffer}
975 ) {
976 $self->{buffer} = [
977 0 map { TScreenCell->new() } 1 .. ( $self->{size}{x} * $self->{size}{y} )
978 0 ];
979 }
980 0 return;
981 }
982
983 0 ▶$focusView = sub { # void ($p|undef, $enable)
Subroutine __ANON__: not called CC=7 SCAR=40.3
984 0 my ( $self, $p, $enable ) = @_;
985 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
986 0 ▶ assert ( !defined $p or is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless not defined $p or &is_Object($p) 0 0 0
Condition0%0/3
not defined $p or &is_Object($p)
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $p or &is_Object($p)
not defined $p &is_Object($p)
Truth table0%0/3
not(A) or B
A= not defined $pB= &is_Object($p)
ABresult
1X1
011
000
987 0 ▶ assert ( is_Bool $enable );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($enable) 0 0 0
988 $p->setState( sfFocused, $enable )
989 0 ▶ if ( $self->{state} & sfFocused ) && $p;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"} & 64 and $p 0 0 0
Condition0%0/3
$self->{"state"} & 64 and $p
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"state"} & 64 and $p
$self->{"state"} & 64 $p
Truth table0%0/3
A and B
A= $self->{"state"} & 64B= $p
ABresult
0X0
100
111
990 0 return;
991 70 };
992
993 0 ▶$selectView = sub { # void ($p, $enable)
Subroutine __ANON__: not called CC=5 SCAR=34.0
994 0 my ( $self, $p, $enable ) = @_;
995 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
996 0 ▶ assert ( is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($p) 0 0 0
997 0 ▶ assert ( is_Bool $enable );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($enable) 0 0 0
998 0 ▶ $p->setState( sfSelected, $enable )
Branch: 1 branch
BranchTrueFalseTotal
if $p 0 0 0
999 if $p;
1000 0 return;
1001 70 };
1002
1003 0 ▶$findNext = sub {
Subroutine __ANON__: not called CC=10 SCAR=47.0
1004 0 my ( $self, $forwards ) = @_;
1005 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
1006 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
1007 0 ▶ assert ( is_Bool $forwards );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($forwards) 0 0 0
1008 0 my $p = $self->{current};
1009 0 my $result = undef;
1010 0 ▶ if ( $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p) 0 0 0
1011 do {
1012 0 ▶ $p = $forwards ? $p->{next} : $p->prev();
Branch: 1 branch
BranchTrueFalseTotal
$forwards ? : 0 0 0
1013 } while (
1014 !(
1015 ( ( $p->{state} & ( sfVisible | sfDisabled ) ) == sfVisible )
1016 && ( $p->{options} & ofSelectable )
1017 )
1018 && ( $p != $self->{current} )
1019 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
not +($p->{"state"} & 257) == 1 && $p->{"options"} & 1 and $p != $self->{"current"} and do { do { $p = $forwards ? $p->{"next"} : $p->prev } } 0 0 0
Condition0%0/6
not +($p->{"state"} & 257) == 1 && $p->{"options"} & 1 and $p != $self->{"current"}
!ll&&!rl&&r
000
($p->{'state'} & 257) == 1 && $p->{'options'} & 1
!ll&&!rl&&r
000
MC/DC0%0/3
not +($p->{"state"} & 257) == 1 && $p->{"options"} & 1 and $p != $self->{"current"}
($p->{'state'} & 257) == 1 $p->{'options'} & 1 $p != $self->{"current"}
Truth table0%0/5
not(A && B) and C
A= ($p->{'state'} & 257) == 1B= $p->{'options'} & 1C= $p != $self->{"current"}
ABCresult
11X0
0X00
1000
0X11
1011
1020 $result = $p
1021 0 ▶ if $p != $self->{current};
Branch: 1 branch
BranchTrueFalseTotal
if $p != $self->{"current"} 0 0 0
1022 } #/ if ( $p )
1023 0 return $result;
1024 70 };
1025
1026 0 ▶$doPut = sub { # void ($p, $osp)
Subroutine __ANON__: not called CC=4 SCAR=30.0
1027 0 my ( $p, $osp ) = @_;
1028 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
1029 0 ▶ assert ( is_Object $p );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($p) 0 0 0
1030 0 ▶ assert ( is_Object $osp );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($osp) 0 0 0
1031 0 $osp->put( $p );
1032 0 return;
1033 70 };
1034
1035 0 ▶sub write :method { # void ($os)
Subroutine write: not called CC=2 SCAR=17.9
Pod undocumented
1036 0 state $sig = signature(
1037 method => Object,
1038 pos => [Object],
1039 );
1040 0 my ( $self, $os ) = $sig->( @_ );
1041 0 $self->SUPER::write( $os );
1042 0 my $ownerSave = $self->{owner};
1043 0 $self->owner( $self );
1044 0 my $count = $self->indexOf( $self->{last} );
1045 0 $os->put( $count );
1046 0 $self->forEach( $doPut, $os );
1047 0 my $index;
1048 0 ▶ if ( !defined $self->{current} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{'current'}) { } 0 0 0
1049 0 $index = 0;
1050 }
1051 else {
1052 0 $index = $self->indexOf( $self->{current} );
1053 }
1054 0 $os->put( $index );
1055 0 $self->owner( $ownerSave );
1056 0 return;
1057 }
1058
1059 0 ▶sub read :method { # $self ($is)
Subroutine read: not called CC=4 SCAR=30.0
Pod undocumented
1060 0 state $sig = signature(
1061 method => Object,
1062 pos => [Object],
1063 );
1064 0 my ( $self, $is ) = $sig->( @_ );
1065 0 $self->SUPER::read( $is );
1066 0 $self->{clip} = $self->getExtent();
1067 0 my $ownerSave = $self->{owner};
1068 0 $self->owner( $self );
1069 0 $self->{last} = undef;
1070 0 $self->{phase} = phFocused;
1071 0 $self->current( undef );
1072 0 $self->{buffer} = undef;
1073 0 $self->{lockFlag} = 0;
1074 0 $self->{endState} = 0;
1075 0 my $count = $is->get();
1076 0 ▶ for ( my $i = 0; $i < $count; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $count) 0 0 0
1077 0 my $tv = $is->get();
1078 0 ▶ $self->insertView( $tv, undef )
Branch: 1 branch
BranchTrueFalseTotal
if defined $tv 0 0 0
1079 if defined $tv;
1080 }
1081 0 $self->owner( $ownerSave );
1082 0 my $index = $is->get();
1083 0 my $current = $self->at( $index );
1084 0 $self->setCurrent( $current, normalSelect );
1085 0 ▶ $self->awaken()
Branch: 1 branch
BranchTrueFalseTotal
unless defined $TUI::Views::Group::ownerGroup 0 0 0
1086 unless defined $ownerGroup;
1087 0 return $self;
1088 }
1089
1090 70 1
1091
1092 __END__
« lib/TUI/Menus/SubMenu.pm ↑ Summary lib/TUI/Dialogs/History.pm »