lib/TUI/Views/Group.pm

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