lib/TUI/Menus/MenuView.pm

filter: Statementstmt 18.4% 84 / 455 Branchbran 0.0% 0 / 268 Conditioncond 0.0% 0 / 105 MC/DCmcdc 0.0% 0 / 62 Subroutinesub 43.7% 21 / 48 Podpod 93.3% 14 / 15 totaltotal 12.4% 119 / 953 CC 174 SCAR 74.2
CC
174
Cov
10%
execute
4930.5
handleEvent
182.0
__ANON__
182.0
CRAP 1670.4
↑ Summary lib/TUI/Views/ListViewer.pm »
1 package TUI::Menus::MenuView;
2 # ABSTRACT: Abstract class for menu bars and menu boxes
3
4 42 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 42 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 42 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 42 our $VERSION = '2.000002';
9 42 $VERSION =~ tr/_//d;
10 42 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 42 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 42 our @EXPORT = qw(
14 TMenuView
15 new_TMenuView
16 );
17
18 42 ▶use Devel::StrictMode;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 42 ▶use Scalar::Util qw( weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 42 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 42 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
22 Maybe
23 :is
24 :types
25 42 );
26
27 42 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
28 :evXXXX
29 :kbXXXX
30 42 );
31 42 ▶use TUI::Drivers::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
32 ctrlToArrow
33 getAltChar
34 42 );
35 42 ▶use TUI::Drivers::Event;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 42 ▶use TUI::Objects::Rect;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 42 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
38 :cmXXXX
39 hcNoContext
40 42 );
41 42 ▶use TUI::Views::Palette;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 42 ▶use TUI::Views::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 42 ▶use TUI::Menus::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
44 :menuAction
45 cpMenuView
46 42 );
47
48 sub TMenuView() { __PACKAGE__ }
49 sub name() { 'TMenuView' }
50 0 ▶sub new_TMenuView { __PACKAGE__->from(@_) }
Subroutine new_TMenuView: not called CC=1 SCAR=6.9
Pod documented
51
52 42 extends TView;
53
54 # protected attributes
55 42 has parentMenu => ( is => 'bare' );
56 42 has menu => ( is => 'ro' );
57 42 has current => ( is => 'bare' );
58
59 # predeclare private methods
60 my (
61 42 $nextItem,
62 $prevItem,
63 $trackKey,
64 $mouseInOwner,
65 $mouseInMenus,
66 $trackMouse,
67 $topMenu,
68 $updateMenu,
69 $do_a_select,
70 $findHotKey,
71 );
72
73 0 ▶my $lock_value = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
74 0 ▶ Internals::SvREADONLY( $_[0] => 1 )
Branch: 1 branch
BranchTrueFalseTotal
if exists &Internals::SvREADONLY 0 0 0
75 if exists &Internals::SvREADONLY;
76 42 };
77
78 0 ▶my $unlock_value = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
79 0 ▶ Internals::SvREADONLY( $_[0] => 0 )
Branch: 1 branch
BranchTrueFalseTotal
if exists &Internals::SvREADONLY 0 0 0
80 if exists &Internals::SvREADONLY;
81 42 };
82
83 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=3 SCAR=24.8
Pod documented
84 0 state $sig = signature(
85 method => 1,
86 named => [
87 bounds => Object,
88 menu => Object, { optional => 1, alias => 'aMenu' },
89 parentMenu => Object, { optional => 1, alias => 'aParent' },
90 ],
91 caller_level => +1,
92 );
93 0 my ( $class, $args ) = $sig->( @_ );
94 0 ▶ assert ( !exists $args->{parentMenu} or exists $args->{menu} );
Branch: 1 branch
BranchTrueFalseTotal
unless not exists $args->{"parentMenu"} or exists $args->{"menu"} 0 0 0
Condition0%0/3
not exists $args->{"parentMenu"} or exists $args->{"menu"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not exists $args->{"parentMenu"} or exists $args->{"menu"}
not exists $args->{"parentMenu"} exists $args->{"menu"}
Truth table0%0/3
not(A) or B
A= not exists $args->{"parentMenu"}B= exists $args->{"menu"}
ABresult
1X1
011
000
95 0 return { %$args };
96 }
97
98 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=5 SCAR=34.0
Pod documented
99 0 my ( $self, $args ) = @_;
100 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
101 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
102 0 $self->{eventMask} |= evBroadcast;
103 0 ▶ weaken( $self->{parentMenu} ) if $self->{parentMenu};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parentMenu"} 0 0 0
104 0 ▶ weaken( $self->{current} ) if $self->{current};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"current"} 0 0 0
105 0 &$lock_value( $self->{parentMenu} ) if STRICT;
106 0 &$lock_value( $self->{current} ) if STRICT;
107 0 return;
108 }
109
110 0 ▶sub from { # $obj ($bounds, |$aMenu, |$aParent);
Subroutine from: not called CC=5 SCAR=34.0
Pod undocumented
111 0 state $sig = signature(
112 method => 1,
113 pos => [
114 Object,
115 Object, { optional => 1 },
116 Object, { optional => 1 },
117 ],
118 );
119 0 my ( $class, @args ) = $sig->( @_ );
120 0 SWITCH: for ( scalar @args ) {
121 0 ▶ $_ == 1 and return $class->new( bounds => $args[0] );
Branch: 1 branch
BranchTrueFalseTotal
$_ == 1 and return $class->new("bounds", $args[0]) 0 0 0
122 0 ▶ $_ == 2 and return $class->new( bounds => $args[0], menu => $args[1] );
Branch: 1 branch
BranchTrueFalseTotal
$_ == 2 and return $class->new("bounds", $args[0], "menu", $args[1]) 0 0 0
123 0 ▶ $_ == 3 and return $class->new( bounds => $args[0], menu => $args[1],
Branch: 1 branch
BranchTrueFalseTotal
$_ == 3 and return $class->new("bounds", $args[0], "menu", $args[1], "parentMenu", $args[2]) 0 0 0
124 parentMenu => $args[2] );
125 }
126 0 return;
127 }
128
129 0 ▶sub DEMOLISH { # void ($in_global_destruction)
Subroutine DEMOLISH: not called CC=3 SCAR=24.8
Pod documented
130 0 my ( $self, $in_global_destruction ) = @_;
131 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
132 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
133 0 &$unlock_value( $self->{parentMenu} ) if STRICT;
134 0 &$unlock_value( $self->{current} ) if STRICT;
135 0 return;
136 }
137
138 # The following subroutine was ported from the framework
139 # "A modern port of Turbo Vision 2.0", which is licensed under MIT licence.
140 #
141 # Copyright 2019-2021 by magiblot <magiblot@hotmail.com>
142 #
143 # I<tmnuview.cpp>
144 0 ▶sub execute { # $int ()
Subroutine execute: not called CC=73 SCAR=85.0
Pod documented
145 0 state $sig = signature(
146 method => Object,
147 pos => [],
148 );
149 0 my ( $self ) = $sig->( @_ );
150 0 my $autoSelect = false;
151 0 my $firstEvent = true;
152 0 my $action = 0;
153 0 my $result = 0;
154 0 my $itemShown = undef;
155 0 my $target = undef;
156 0 my $lastTargetItem = undef;
157 0 my $r = TRect->new();
158 0 my $e = TEvent->new();
159 0 my $mouseActive = false;
160
161 0 $self->current( $self->{menu}{deflt} );
162 0 $mouseActive = 0;
163 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$action != 2 and 0 0 0
164 0 $action = doNothing;
165 0 $self->getEvent( $e );
166 0 SWITCH: for ( $e->{what} ) {
167 0 ▶ $_ == evMouseDown and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 1 and do { if ($self->mouseInView($e->{"mouse"}{"where"}) or $self->$mouseInOwner($e)) { $self->$trackMouse($e, \$mouseActive); if ($self->{"size"}{"y"} == 1) { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x51\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $autoSelect = !$self->{"current"} || $lastTargetItem != $self->{"current"}; } elsif (not $firstEvent and $self->$mouseInOwner($e)) { $action = 2; } ; } else { $action = 2; } ; last } 0 0 0
168 0 ▶ if ( $self->mouseInView( $e->{mouse}{where} )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mouseInView($e->{'mouse'}{'where'}) or $self->$mouseInOwner($e)) { } 0 0 0
Condition0%0/3
$self->mouseInView($e->{"mouse"}{"where"}) or $self->$mouseInOwner($e)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->mouseInView($e->{"mouse"}{"where"}) or $self->$mouseInOwner($e)
$self->mouseInView($e->{"mouse"}{"where"}) $self->$mouseInOwner($e)
Truth table0%0/3
A or B
A= $self->mouseInView($e->{"mouse"}{"where"})B= $self->$mouseInOwner($e)
ABresult
1X1
011
000
169 || $self->$mouseInOwner( $e )
170 ) {
171 0 $self->$trackMouse( $e, \$mouseActive );
172 # autoSelect makes it possible to open the selected submenu directly
173 # on a MouseDown event. This should be avoided, however, when said
174 # submenu was just closed by clicking on its name, or when this is
175 # not a menu bar.
176 0 ▶ if ( $self->{size}{y} == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'size'}{'y'} == 1) { } 0 0 0
elsif (not $firstEvent and $self->$mouseInOwner($e)) { } 0 0 0
177 42 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
178 $autoSelect = !$self->{current}
179 0 ▶ || $lastTargetItem != $self->{current};
Condition0%0/3
!$self->{'current'} || $lastTargetItem != $self->{'current'}
l!l&&r!l&&!r
000
MC/DC0%0/2
!$self->{'current'} || $lastTargetItem != $self->{'current'}
!$self->{'current'} $lastTargetItem != $self->{'current'}
Truth table0%0/3
not(A) || B
A= !$self->{'current'}B= $lastTargetItem != $self->{'current'}
ABresult
1X1
011
000
180 }
181 # A submenu will close if the MouseDown event takes place on the
182 # parent menu, except when this submenu has just been opened.
183 ▶ elsif ( !$firstEvent && $self->$mouseInOwner( $e ) ) {
Condition0%0/3
not $firstEvent and $self->$mouseInOwner($e)
!ll&&!rl&&r
000
MC/DC0%0/2
not $firstEvent and $self->$mouseInOwner($e)
not $firstEvent $self->$mouseInOwner($e)
Truth table0%0/3
not(A) and B
A= not $firstEventB= $self->$mouseInOwner($e)
ABresult
0X0
100
111
184 0 $action = doReturn;
185 }
186 }
187 else {
188 0 $action = doReturn;
189 }
190 0 last;
191 };
192 0 ▶ $_ == evMouseUp and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 2 and do { $self->$trackMouse($e, \$mouseActive); if ($self->$mouseInOwner($e)) { $self->current($self->{"menu"}{"deflt"}); } elsif ($self->{"current"}) { if ($self->{"current"}{"name"}) { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x51\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} if ($self->{"current"} != $lastTargetItem) { $action = 1; } elsif ($self->{"size"}{"y"} == 1) { $action = 2; } else { $action = 0; $lastTargetItem = undef; } ; } ; } elsif ($mouseActive and not $self->mouseInView($e->{"mouse"}{"where"})) { $action = 2; } elsif ($self->{"size"}{"y"} == 1) { $self->current($self->{"menu"}{"deflt"} ? $self->{"menu"}{"deflt"} : $self->{"menu"}{"items"}); $action = 0; } ; last } 0 0 0
193 0 $self->$trackMouse( $e, \$mouseActive );
194 0 ▶ if ( $self->$mouseInOwner( $e ) ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->$mouseInOwner($e)) { } 0 0 0
elsif ($self->{'current'}) { } 0 0 0
elsif ($mouseActive and not $self->mouseInView($e->{'mouse'}{'where'})) { } 0 0 0
elsif ($self->{'size'}{'y'} == 1) { } 0 0 0
195 0 $self->current( $self->{menu}{deflt} );
196 }
197 elsif ( $self->{current} ) {
198 0 ▶ if ( $self->{current}{name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"current"}{"name"}) 0 0 0
199 42 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
200 0 ▶ if ( $self->{current} != $lastTargetItem ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'current'} != $lastTargetItem) { } 0 0 0
elsif ($self->{'size'}{'y'} == 1) { } 0 0 0
201 0 $action = doSelect;
202 }
203 elsif ( $self->{size}{y} == 1 ) {
204 # If a menu bar entry was closed, exit and stop listening
205 # for events.
206 0 $action = doReturn;
207 }
208 else {
209 # MouseUp won't open up a submenu that was just closed by
210 # clicking on its name.
211 0 $action = doNothing;
212 # But the next one will.
213 0 $lastTargetItem = undef;
214 }
215 } #/ if ( $self->{current}{...})
216 } #/ elsif ( $self->{current} )
217 ▶ elsif ( $mouseActive && !$self->mouseInView( $e->{mouse}{where} ) ) {
Condition0%0/3
$mouseActive and not $self->mouseInView($e->{"mouse"}{"where"})
!ll&&!rl&&r
000
MC/DC0%0/2
$mouseActive and not $self->mouseInView($e->{"mouse"}{"where"})
$mouseActive not $self->mouseInView($e->{"mouse"}{"where"})
Truth table0%0/3
A and not(B)
A= $mouseActiveB= not $self->mouseInView($e->{"mouse"}{"where"})
ABresult
0X0
100
111
218 0 $action = doReturn;
219 }
220 elsif ( $self->{size}{y} == 1 ) {
221 # When MouseUp happens inside the Box but not on a highlightable
222 # entry (e.g. on a margin, or a separator), either the default or the
223 # first entry will be automatically highlighted. This was added in
224 # Turbo Vision 2.0. But this doesn't make sense in a menu bar, which
225 # was the original behavior.
226 $self->current(
227 $self->{menu}{deflt}
228 ? $self->{menu}{deflt}
229 : $self->{menu}{items}
230 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'menu'}{'deflt'} ? : 0 0 0
231 0 $action = doNothing;
232 } #/ elsif ( $self->{size}{y} ...)
233 0 last;
234 };
235 0 ▶ $_ == evMouseMove and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 4 and do { if ($e->{"mouse"}{"buttons"}) { $self->$trackMouse($e, \$mouseActive); if (not $self->mouseInView($e->{"mouse"}{"where"}) || $self->$mouseInOwner($e) and $self->$mouseInMenus($e)) { $action = 2; } ; } ; last } 0 0 0
236 0 ▶ if ( $e->{mouse}{buttons} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{"mouse"}{"buttons"}) 0 0 0
237 0 $self->$trackMouse( $e, \$mouseActive );
238 0 ▶ if ( !( $self->mouseInView( $e->{mouse}{where} )
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->mouseInView($e->{"mouse"}{"where"}) || $self->$mouseInOwner($e) and $self->$mouseInMenus($e)) 0 0 0
Condition0%0/6
not $self->mouseInView($e->{"mouse"}{"where"}) || $self->$mouseInOwner($e) and $self->$mouseInMenus($e)
!ll&&!rl&&r
000
$self->mouseInView($e->{'mouse'}{'where'}) || $self->$mouseInOwner($e)
l!l&&r!l&&!r
000
MC/DC0%0/3
not $self->mouseInView($e->{"mouse"}{"where"}) || $self->$mouseInOwner($e) and $self->$mouseInMenus($e)
$self->mouseInView($e->{'mouse'}{'where'}) $self->$mouseInOwner($e) $self->$mouseInMenus($e)
Truth table0%0/4
not(A || B) and C
A= $self->mouseInView($e->{'mouse'}{'where'})B= $self->$mouseInOwner($e)C= $self->$mouseInMenus($e)
ABCresult
1XX0
01X0
0000
0011
239 || $self->$mouseInOwner( $e )
240 )
241 && $self->$mouseInMenus( $e ) )
242 {
243 0 $action = doReturn;
244 }
245 }
246 0 last;
247 };
248 0 ▶ $_ == evKeyDown and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 16 and 0 0 0
249 0 SWITCH: for my $key ( ctrlToArrow( $e->{keyDown}{keyCode} ) ) {
250 $key == kbUp ||
251 0 ▶ $key == kbDown and do {
Branch: 1 branch
BranchTrueFalseTotal
$key == 18432 || $key == 20480 and 0 0 0
Condition0%0/3
$key == 18432 or $key == 20480
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 18432 or $key == 20480
$key == 18432 $key == 20480
Truth table0%0/3
A or B
A= $key == 18432B= $key == 20480
ABresult
1X1
011
000
252 0 ▶ if ( $self->{size}{y} != 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'size'}{'y'} != 1) { } 0 0 0
elsif ($e->{'keyDown'}{'keyCode'} == 20480) { } 0 0 0
253 0 $self->$trackKey( $key == kbDown );
254 }
255 elsif ( $e->{keyDown}{keyCode} == kbDown ) {
256 0 $autoSelect = true;
257 }
258 0 last;
259 };
260 $key == kbLeft ||
261 0 ▶ $key == kbRight and do {
Branch: 1 branch
BranchTrueFalseTotal
$key == 19200 || $key == 19712 and do { if (not $self->{"parentMenu"}) { $self->$trackKey($key == 19712); } else { $action = 2; } ; last } 0 0 0
Condition0%0/3
$key == 19200 or $key == 19712
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 19200 or $key == 19712
$key == 19200 $key == 19712
Truth table0%0/3
A or B
A= $key == 19200B= $key == 19712
ABresult
1X1
011
000
262 0 ▶ if ( !$self->{parentMenu} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'parentMenu'}) { } 0 0 0
263 0 $self->$trackKey( $key == kbRight );
264 }
265 else {
266 0 $action = doReturn;
267 }
268 0 last;
269 };
270 $key == kbHome ||
271 0 ▶ $key == kbEnd and do {
Branch: 1 branch
BranchTrueFalseTotal
$key == 18176 || $key == 20224 and 0 0 0
Condition0%0/3
$key == 18176 or $key == 20224
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 18176 or $key == 20224
$key == 18176 $key == 20224
Truth table0%0/3
A or B
A= $key == 18176B= $key == 20224
ABresult
1X1
011
000
272 0 ▶ if ( $self->{size}{y} != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"size"}{"y"} != 1) 0 0 0
273 0 $self->current( $self->{menu}{items} );
274 $self->$trackKey( false )
275 0 ▶ if $e->{keyDown}{keyCode} == kbEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $e->{"keyDown"}{"keyCode"} == 20224 0 0 0
276 }
277 0 last;
278 };
279 0 ▶ $key == kbEnter and do {
Branch: 1 branch
BranchTrueFalseTotal
$key == 7181 and 0 0 0
280 $autoSelect = true
281 0 ▶ if $self->{size}{y} == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"size"}{"y"} == 1 0 0 0
282 0 $action = doSelect;
283 0 last;
284 };
285 0 ▶ $key == kbEsc and do {
Branch: 1 branch
BranchTrueFalseTotal
$key == 283 and do { $action = 2; $self->clearEvent($e) if not $self->{"parentMenu"} or $self->{"parentMenu"}{"size"}{"y"} != 1; last } 0 0 0
286 0 $action = doReturn;
287 $self->clearEvent( $e )
288 0 ▶ if !$self->{parentMenu} || $self->{parentMenu}{size}{y} != 1;
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"parentMenu"} or $self->{"parentMenu"}{"size"}{"y"} != 1 0 0 0
Condition0%0/3
not $self->{"parentMenu"} or $self->{"parentMenu"}{"size"}{"y"} != 1
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->{"parentMenu"} or $self->{"parentMenu"}{"size"}{"y"} != 1
not $self->{"parentMenu"} $self->{"parentMenu"}{"size"}{"y"} != 1
Truth table0%0/3
not(A) or B
A= not $self->{"parentMenu"}B= $self->{"parentMenu"}{"size"}{"y"} != 1
ABresult
1X1
011
000
289 0 last;
290 };
291 DEFAULT: {
292 0 $target = $self;
293 0 my $ch = getAltChar( $e->{keyDown}{keyCode} );
294 $ch = $e->{keyDown}{charScan}{charCode}
295 0 ▶ unless $ch;
Branch: 1 branch
BranchTrueFalseTotal
unless $ch 0 0 0
296 0 ▶ $target = $self->$topMenu()
Branch: 1 branch
BranchTrueFalseTotal
if $ch 0 0 0
297 if $ch;
298 0 my $p = $target->findItem( $ch );
299 0 ▶ if ( !$p ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $p) { } 0 0 0
elsif ($target == $self) { } 0 0 0
elsif ($self->{'parentMenu'} != $target or $self->{'parentMenu'}{'current'} != $p) { } 0 0 0
300 0 $p = $self->$topMenu()->hotKey( $e->{keyDown}{keyCode} );
301 0 ▶ if ( $p && TView->commandEnabled( $p->{command} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p and "TUI::Views::View"->commandEnabled($p->{"command"})) 0 0 0
Condition0%0/3
$p and "TUI::Views::View"->commandEnabled($p->{"command"})
!ll&&!rl&&r
000
MC/DC0%0/2
$p and "TUI::Views::View"->commandEnabled($p->{"command"})
$p "TUI::Views::View"->commandEnabled($p->{"command"})
Truth table0%0/3
A and B
A= $pB= "TUI::Views::View"->commandEnabled($p->{"command"})
ABresult
0X0
100
111
302 0 $result = $p->{command};
303 0 $action = doReturn;
304 }
305 }
306 elsif ( $target == $self ) {
307 $autoSelect = true
308 0 ▶ if $self->{size}{y} == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"size"}{"y"} == 1 0 0 0
309 0 $action = doSelect;
310 0 $self->current( $p );
311 }
312 ▶ elsif ( $self->{parentMenu} != $target
Condition0%0/3
$self->{"parentMenu"} != $target or $self->{"parentMenu"}{"current"} != $p
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"parentMenu"} != $target or $self->{"parentMenu"}{"current"} != $p
$self->{"parentMenu"} != $target $self->{"parentMenu"}{"current"} != $p
Truth table0%0/3
A or B
A= $self->{"parentMenu"} != $targetB= $self->{"parentMenu"}{"current"} != $p
ABresult
1X1
011
000
313 || $self->{parentMenu}{current} != $p
314 ) {
315 0 $action = doReturn;
316 }
317 }
318 }
319 0 last;
320 };
321 0 ▶ $_ == evCommand and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 256 and 0 0 0
322 0 ▶ if ( $e->{message}{command} == cmMenu ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{'message'}{'command'} == 3) { } 0 0 0
323 0 $autoSelect = false;
324 0 $lastTargetItem = undef;
325 $action = doReturn
326 0 ▶ if $self->{parentMenu};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parentMenu"} 0 0 0
327 }
328 else {
329 0 $action = doReturn;
330 }
331 0 last;
332 };
333 }
334
335 {
336 0 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.2
337 # If a submenu was closed by clicking on its name, and the mouse is
338 # dragged to another menu entry, then the submenu will be opened the next
339 # time it is hovered over.
340 0 ▶ if ( $lastTargetItem != $self->{current} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastTargetItem != $self->{"current"}) 0 0 0
341 0 $lastTargetItem = undef;
342 }
343
344 0 ▶ if ( $itemShown != $self->{current} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($itemShown != $self->{"current"}) 0 0 0
345 0 $itemShown = $self->{current};
346 0 $self->drawView();
347 }
348 }
349
350 0 ▶ if ( ( $action == doSelect || ( $action == doNothing && $autoSelect ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($action == 1 || $action == 0 && $autoSelect and $self->{"current"} and $self->{"current"}{"name"}) 0 0 0
Condition0%0/12
$action == 1 || $action == 0 && $autoSelect and $self->{"current"} and $self->{"current"}{"name"}
!ll&&!rl&&r
000
$action == 1 || $action == 0 && $autoSelect and $self->{"current"}
!ll&&!rl&&r
000
$action == 1 or $action == 0 and $autoSelect
l!l&&r!l&&!r
000
$action == 0 and $autoSelect
!ll&&!rl&&r
000
MC/DC0%0/5
$action == 1 || $action == 0 && $autoSelect and $self->{"current"} and $self->{"current"}{"name"}
$action == 1 $action == 0 $autoSelect $self->{"current"} $self->{"current"}{"name"}
Truth table0%0/8
A or B and C and D and E
A= $action == 1B= $action == 0C= $autoSelectD= $self->{"current"}E= $self->{"current"}{"name"}
ABCDEresult
00XXX0
010XX0
1XX0X0
0110X0
1XX100
011100
1XX111
011111
351 && $self->{current}
352 && $self->{current}{name}
353 ) {
354 0 ▶ if ( $self->{current}{command} == 0 && !$self->{current}{disabled} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'current'}{'command'} == 0 and not $self->{'current'}{'disabled'}) { } 0 0 0
elsif ($action == 1) { } 0 0 0
Condition0%0/3
$self->{"current"}{"command"} == 0 and not $self->{"current"}{"disabled"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"current"}{"command"} == 0 and not $self->{"current"}{"disabled"}
$self->{"current"}{"command"} == 0 not $self->{"current"}{"disabled"}
Truth table0%0/3
A and not(B)
A= $self->{"current"}{"command"} == 0B= not $self->{"current"}{"disabled"}
ABresult
0X0
100
111
355 0 ▶ if ( $e->{what} & ( evMouseDown | evMouseMove ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{"what"} & 5) 0 0 0
356 0 $self->putEvent( $e );
357 }
358 0 $r = $self->getItemRect( $self->{current} );
359 0 $r->{a}{x} = $r->{a}{x} + $self->{origin}{x};
360 0 $r->{a}{y} = $r->{b}{y} + $self->{origin}{y};
361 0 $r->{b} = $self->{owner}{size};
362 $r->{a}{x}--
363 0 ▶ if $self->{size}{y} == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"size"}{"y"} == 1 0 0 0
364 $target = $self->$topMenu()->newSubView(
365 0 $r, $self->{current}{subMenu}, $self
366 );
367 0 $result = $self->{owner}->execView( $target );
368 0 $self->destroy( $target );
369 0 weaken( $lastTargetItem = $self->{current} );
370 0 $self->{menu}->deflt( $self->{current} );
371 } #/ if ( $self->{current}{...})
372 elsif ( $action == doSelect ) {
373 0 $result = $self->{current}{command};
374 }
375 } #/ if ( ( $action == doSelect...))
376
377 0 ▶ if ( $result && TView->commandEnabled( $result ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result and 'TUI::Views::View'->commandEnabled($result)) { } 0 0 0
Condition0%0/3
$result and "TUI::Views::View"->commandEnabled($result)
!ll&&!rl&&r
000
MC/DC0%0/2
$result and "TUI::Views::View"->commandEnabled($result)
$result "TUI::Views::View"->commandEnabled($result)
Truth table0%0/3
A and B
A= $resultB= "TUI::Views::View"->commandEnabled($result)
ABresult
0X0
100
111
378 0 $action = doReturn;
379 0 $self->clearEvent( $e );
380 }
381 else {
382 0 $result = 0;
383 }
384
385 0 $firstEvent = false;
386 } while ( $action != doReturn );
387
388 0 ▶ if ( $e->{what} != evNothing
Branch: 1 branch
BranchTrueFalseTotal
if ($e->{"what"} != 0 and $self->{"parentMenu"} || $e->{"what"} == 256) 0 0 0
Condition0%0/6
$e->{"what"} != 0 and $self->{"parentMenu"} || $e->{"what"} == 256
!ll&&!rl&&r
000
$self->{"parentMenu"} or $e->{"what"} == 256
l!l&&r!l&&!r
000
MC/DC0%0/3
$e->{"what"} != 0 and $self->{"parentMenu"} || $e->{"what"} == 256
$e->{"what"} != 0 $self->{"parentMenu"} $e->{"what"} == 256
Truth table0%0/4
A and B or C
A= $e->{"what"} != 0B= $self->{"parentMenu"}C= $e->{"what"} == 256
ABCresult
0XX0
1000
11X1
1011
389 && ( $self->{parentMenu} || $e->{what} == evCommand )
390 ) {
391 0 $self->putEvent( $e );
392 }
393 0 ▶ if ( $self->{current} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"current"}) 0 0 0
394 0 $self->{menu}->deflt( $self->{current} );
395 0 $self->current( undef );
396 0 $self->drawView();
397 }
398 0 return $result;
399 } #/ sub execute
400
401 0 ▶sub findItem { # $menuItem|undef ($ch)
Subroutine findItem: not called CC=7 SCAR=40.3
Pod documented
402 0 state $sig = signature(
403 method => Object,
404 pos => [Str],
405 );
406 0 my ( $self, $ch ) = $sig->( @_ );
407 0 ▶ assert ( length $ch == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless length $ch == 1 0 0 0
408 0 $ch = uc( $ch );
409 0 my $p = $self->{menu}{items};
410 0 ▶ while ( $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p) 0 0 0
411 0 ▶ if ( $p->{name} && !$p->{disabled} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"name"} and not $p->{"disabled"}) 0 0 0
Condition0%0/3
$p->{"name"} and not $p->{"disabled"}
!ll&&!rl&&r
000
MC/DC0%0/2
$p->{"name"} and not $p->{"disabled"}
$p->{"name"} not $p->{"disabled"}
Truth table0%0/3
A and not(B)
A= $p->{"name"}B= not $p->{"disabled"}
ABresult
0X0
100
111
412 0 my $loc = index( $p->{name}, '~' );
413 0 ▶ if ( $loc != -1 && uc( substr( $p->{name}, $loc + 1, 1 ) ) eq $ch ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($loc != -1 and uc substr($p->{"name"}, $loc + 1, 1) eq $ch) 0 0 0
Condition0%0/3
$loc != -1 and uc substr($p->{"name"}, $loc + 1, 1) eq $ch
!ll&&!rl&&r
000
MC/DC0%0/2
$loc != -1 and uc substr($p->{"name"}, $loc + 1, 1) eq $ch
$loc != -1 uc substr($p->{"name"}, $loc + 1, 1) eq $ch
Truth table0%0/3
A and B
A= $loc != -1B= uc substr($p->{"name"}, $loc + 1, 1) eq $ch
ABresult
0X0
100
111
414 0 return $p;
415 }
416 }
417 0 $p = $p->{next};
418 }
419 0 return undef;
420 } #/ sub findItem
421
422 0 ▶sub getItemRect { # $rect ($item|undef)
Subroutine getItemRect: not called CC=1 SCAR=6.9
Pod documented
423 0 state $sig = signature(
424 method => Object,
425 pos => [Object],
426 );
427 0 my ( $self, $item ) = $sig->( @_ );
428 0 return TRect->new();
429 }
430
431 0 ▶sub getHelpCtx { # $int ()
Subroutine getHelpCtx: not called CC=6 SCAR=37.4
Pod documented
432 0 state $sig = signature(
433 method => Object,
434 pos => [],
435 );
436 0 my ( $self ) = $sig->( @_ );
437 0 my $c = $self;
438
439 0 ▶ while ( $c
Branch: 1 branch
BranchTrueFalseTotal
if ($c and !$c->{"current"} || $c->{"current"}{"helpCtx"} == 0 || !$c->{"current"}{"name"}) 0 0 0
Condition0%0/9
$c and !$c->{"current"} || $c->{"current"}{"helpCtx"} == 0 || !$c->{"current"}{"name"}
!ll&&!rl&&r
000
not $c->{"current"} or $c->{"current"}{"helpCtx"} == 0 or not $c->{"current"}{"name"}
l!l&&r!l&&!r
000
not $c->{"current"} or $c->{"current"}{"helpCtx"} == 0
l!l&&r!l&&!r
000
MC/DC0%0/4
$c and !$c->{"current"} || $c->{"current"}{"helpCtx"} == 0 || !$c->{"current"}{"name"}
$c not $c->{"current"} $c->{"current"}{"helpCtx"} == 0 not $c->{"current"}{"name"}
Truth table0%0/5
A and not(B) or C or not(D)
A= $cB= not $c->{"current"}C= $c->{"current"}{"helpCtx"} == 0D= not $c->{"current"}{"name"}
ABCDresult
0XXX0
10000
11XX1
101X1
10011
440 && ( !$c->{current}
441 || $c->{current}{helpCtx} == hcNoContext
442 || !$c->{current}{name} )
443 ) {
444 0 $c = $c->{parentMenu};
445 }
446
447 return $c
448 ? $c->{current}{helpCtx}
449 0 ▶ : hcNoContext;
Branch: 1 branch
BranchTrueFalseTotal
$c ? : 0 0 0
450 } #/ sub getHelpCtx
451
452 0 ▶sub getPalette { # $palette ()
Subroutine getPalette: not called CC=1 SCAR=6.9
Pod documented
453 0 state $sig = signature(
454 method => Object,
455 pos => [],
456 );
457 0 my ( $self ) = $sig->( @_ );
458 0 state $palette = TPalette->new(
459 data => cpMenuView,
460 size => length( cpMenuView ),
461 );
462 0 return $palette->clone();
463 }
464
465 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=13 SCAR=52.0
Pod documented
466 0 state $sig = signature(
467 method => Object,
468 pos => [Object],
469 );
470 0 my ( $self, $event ) = $sig->( @_ );
471 0 ▶ if ( $self->{menu} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"menu"}) 0 0 0
472 0 SWITCH: for ( $event->{what} ) {
473 0 ▶ $_ == evMouseDown and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 1 and do { $self->$do_a_select($event); last } 0 0 0
474 0 $self->$do_a_select( $event );
475 0 last;
476 };
477 0 ▶ $_ == evKeyDown and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 16 and do { if ($self->findItem(&getAltChar($event->{"keyDown"}{"keyCode"}))) { $self->$do_a_select($event); } else { my $p = $self->hotKey($event->{"keyDown"}{"keyCode"}); if ($p and "TUI::Views::View"->commandEnabled($p->{"command"})) { $event->{"what"} = 256; $event->{"message"}{"command"} = $p->{"command"}; $event->{"message"}{"infoPtr"} = undef; $self->putEvent($event); $self->clearEvent($event); } ; } ; last } 0 0 0
478 0 ▶ if ( $self->findItem( getAltChar( $event->{keyDown}{keyCode} ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->findItem(&getAltChar($event->{'keyDown'}{'keyCode'}))) { } 0 0 0
479 0 $self->$do_a_select( $event );
480 }
481 else {
482 0 my $p = $self->hotKey( $event->{keyDown}{keyCode} );
483 0 ▶ if ( $p && TView->commandEnabled( $p->{command} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p and "TUI::Views::View"->commandEnabled($p->{"command"})) 0 0 0
Condition0%0/3
$p and "TUI::Views::View"->commandEnabled($p->{"command"})
!ll&&!rl&&r
000
MC/DC0%0/2
$p and "TUI::Views::View"->commandEnabled($p->{"command"})
$p "TUI::Views::View"->commandEnabled($p->{"command"})
Truth table0%0/3
A and B
A= $pB= "TUI::Views::View"->commandEnabled($p->{"command"})
ABresult
0X0
100
111
484 0 $event->{what} = evCommand;
485 0 $event->{message}{command} = $p->{command};
486 0 $event->{message}{infoPtr} = undef;
487 0 $self->putEvent( $event );
488 0 $self->clearEvent( $event );
489 }
490 } #/ else [ if ( $self->findItem( ...))]
491 0 last;
492 };
493 0 ▶ $_ == evCommand and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 256 and do { if ($event->{"message"}{"command"} == 3) { $self->$do_a_select($event); } ; last } 0 0 0
494 0 ▶ if ( $event->{message}{command} == cmMenu ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"message"}{"command"} == 3) 0 0 0
495 0 $self->$do_a_select( $event );
496 }
497 0 last;
498 };
499 0 ▶ $_ == evBroadcast and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 512 and do { if ($event->{"message"}{"command"} == 52) { $self->drawView if $self->$updateMenu($self->{"menu"}); } ; last } 0 0 0
500 0 ▶ if ( $event->{message}{command} == cmCommandSetChanged ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"message"}{"command"} == 52) 0 0 0
501 $self->drawView()
502 0 ▶ if $self->$updateMenu( $self->{menu} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->$updateMenu($self->{"menu"}) 0 0 0
503 }
504 0 last;
505 };
506 }
507 } #/ if ( $self->{menu} )
508 0 return;
509 } #/ sub handleEvent
510
511 0 ▶sub hotKey { # $menuItem ($keyCode)
Subroutine hotKey: not called CC=1 SCAR=6.9
Pod documented
512 0 state $sig = signature(
513 method => Object,
514 pos => [PositiveOrZeroInt],
515 );
516 0 my ( $self, $keyCode ) = $sig->( @_ );
517 0 return $self->$findHotKey( $self->{menu}{items}, $keyCode );
518 }
519
520 0 ▶sub newSubView { # $menuView ($bounds, $aMenu, $aParentMenu)
Subroutine newSubView: not called CC=1 SCAR=6.9
Pod documented
521 0 state $sig = signature(
522 method => Object,
523 pos => [Object, Object, Object],
524 );
525 0 my ( $self, $bounds, $aMenu, $aParentMenu ) = $sig->( @_ );
526 0 require TUI::Menus::MenuBox;
527 0 return TUI::Menus::MenuBox->new(
528 bounds => $bounds,
529 menu => $aMenu,
530 parentMenu => $aParentMenu,
531 );
532 }
533
534 0 ▶sub parentMenu { # $menuView|undef (|$menuView|undef)
Subroutine parentMenu: not called CC=3 SCAR=24.8
Pod documented
535 0 state $sig = signature(
536 method => Object,
537 pos => [
538 Maybe[Object], { optional => 1 },
539 ],
540 );
541 0 my ( $self, $menuView ) = $sig->( @_ );
542 0 ▶ goto SET if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
543 GET: {
544 0 return $self->{parentMenu};
545 }
546 SET: {
547 0 &$unlock_value( $self->{parentMenu} ) if STRICT;
548 weaken $self->{parentMenu}
549 0 ▶ if $self->{parentMenu} = $menuView;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parentMenu"} = $menuView 0 0 0
550 0 &$lock_value( $self->{parentMenu} ) if STRICT;
551 0 return;
552 }
553 }
554
555 0 ▶sub current { # $menuItem|undef (|$menuItem|undef)
Subroutine current: not called CC=3 SCAR=24.8
Pod documented
556 0 state $sig = signature(
557 method => Object,
558 pos => [
559 Maybe[Object], { optional => 1 },
560 ],
561 );
562 0 my ( $self, $menuItem ) = $sig->( @_ );
563 0 ▶ goto SET if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
564 GET: {
565 0 return $self->{current};
566 }
567 SET: {
568 0 &$unlock_value( $self->{current} ) if STRICT;
569 weaken $self->{current}
570 0 ▶ if $self->{current} = $menuItem;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"current"} = $menuItem 0 0 0
571 0 &$lock_value( $self->{current} ) if STRICT;
572 0 return;
573 }
574 }
575
576 0 ▶$nextItem = sub { # void ()
Subroutine __ANON__: not called CC=4 SCAR=30.0
577 0 my ( $self ) = @_;
578 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
579 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
580 $self->current(
581 $self->{current}{next}
582 ? $self->{current}{next}
583 : $self->{menu}{items}
584 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'current'}{'next'} ? : 0 0 0
585 0 return;
586 42 };
587
588 0 ▶$prevItem = sub { # void ()
Subroutine __ANON__: not called CC=5 SCAR=30.5
589 0 my ( $self ) = @_;
590 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
591 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
592 0 my $p;
593
594 42 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
595 0 ▶ if ( ( $p = $self->{current} ) == $self->{menu}{items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($p = $self->{"current"}) == $self->{"menu"}{"items"}) 0 0 0
596 0 $p = undef;
597 }
598
599 do {
600 0 $self->$nextItem();
601 0 ▶ } while ( $self->{current}{next} != $p );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"current"}{"next"} != $p and do { do { $self->$nextItem } } 0 0 0
602 0 return;
603 42 };
604
605 0 ▶$trackKey = sub { # void ($findNext)
Subroutine __ANON__: not called CC=7 SCAR=40.3
606 0 my ( $self, $findNext ) = @_;
607 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
608 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
609 0 ▶ assert ( is_Bool $findNext );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Bool($findNext) 0 0 0
610 return
611 0 ▶ unless $self->{current};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"current"} 0 0 0
612
613 do {
614 0 ▶ if ( $findNext ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($findNext) { } 0 0 0
615 0 $self->$nextItem();
616 }
617 else {
618 0 $self->$prevItem();
619 }
620 0 ▶ } while ( !$self->{current}{name} );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"current"}{"name"} or do { do { if ($findNext) { $self->$nextItem; } else { $self->$prevItem; } } } 0 0 0
621 0 return;
622 42 }; #/ $trackKey = sub
623
624 0 ▶$mouseInOwner = sub { # $bool ($e)
Subroutine __ANON__: not called CC=6 SCAR=37.4
625 0 my ( $self, $e ) = @_;
626 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
627 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
628 0 ▶ assert ( is_Object $e );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($e) 0 0 0
629 0 ▶ if ( !$self->{parentMenu} || $self->{parentMenu}{size}{y} != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'parentMenu'} or $self->{'parentMenu'}{'size'}{'y'} != 1) { } 0 0 0
Condition0%0/3
not $self->{"parentMenu"} or $self->{"parentMenu"}{"size"}{"y"} != 1
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->{"parentMenu"} or $self->{"parentMenu"}{"size"}{"y"} != 1
not $self->{"parentMenu"} $self->{"parentMenu"}{"size"}{"y"} != 1
Truth table0%0/3
not(A) or B
A= not $self->{"parentMenu"}B= $self->{"parentMenu"}{"size"}{"y"} != 1
ABresult
1X1
011
000
630 0 return false;
631 }
632 else {
633 0 my $mouse = $self->{parentMenu}->makeLocal( $e->{mouse}{where} );
634 0 my $r = $self->{parentMenu}->getItemRect( $self->{parentMenu}{current} );
635 0 return $r->contains( $mouse );
636 }
637 42 }; #/ $mouseInOwner = sub
638
639 0 ▶$mouseInMenus = sub { # $bool ($e)
Subroutine __ANON__: not called CC=6 SCAR=37.4
640 0 my ( $self, $e ) = @_;
641 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
642 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
643 0 ▶ assert ( is_Object $e );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($e) 0 0 0
644 0 my $p = $self->{parentMenu};
645 0 ▶ while ( $p && !$p->mouseInView( $e->{mouse}{where} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p and not $p->mouseInView($e->{"mouse"}{"where"})) 0 0 0
Condition0%0/3
$p and not $p->mouseInView($e->{"mouse"}{"where"})
!ll&&!rl&&r
000
MC/DC0%0/2
$p and not $p->mouseInView($e->{"mouse"}{"where"})
$p not $p->mouseInView($e->{"mouse"}{"where"})
Truth table0%0/3
A and not(B)
A= $pB= not $p->mouseInView($e->{"mouse"}{"where"})
ABresult
0X0
100
111
646 0 $p = $p->{parentMenu};
647 }
648 0 return defined $p;
649 42 };
650
651 0 ▶$trackMouse = sub { # void ($e, \$mouseActive)
Subroutine __ANON__: not called CC=7 SCAR=40.3
652 0 my ( $self, $e, $mouseActive ) = @_;
653 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
654 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
655 0 ▶ assert ( is_Object $e );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($e) 0 0 0
656 0 ▶ assert ( is_ScalarRef $mouseActive );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_ScalarRef($mouseActive) 0 0 0
657 0 my $mouse = $self->makeLocal( $e->{mouse}{where} );
658 0 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"current"}) 0 0 0
659 $self->current( $self->{menu}{items} );
660 $self->{current};
661 $self->current( $self->{current}{next} )
662 ) {
663 0 my $r = $self->getItemRect( $self->{current} );
664 0 ▶ if ( $r->contains( $mouse ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r->contains($mouse)) 0 0 0
665 0 $$mouseActive = true;
666 0 return;
667 }
668 } #/ for ( $self->{current} ...)
669 0 return;
670 42 }; #/ sub
671
672 0 ▶$topMenu = sub { # $menuView ()
Subroutine __ANON__: not called CC=4 SCAR=30.0
673 0 my ( $self ) = @_;
674 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
675 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
676 0 my $p = $self;
677 0 ▶ while ( $p->{parentMenu} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"parentMenu"}) 0 0 0
678 0 $p = $p->{parentMenu};
679 }
680 0 return $p;
681 42 };
682
683 0 ▶$updateMenu = sub { # $bool ($menu|undef)
Subroutine __ANON__: not called CC=12 SCAR=48.6
684 0 my ( $self, $menu ) = @_;
685 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
686 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
687 0 ▶ assert ( !defined $menu or is_Object $menu );
Branch: 1 branch
BranchTrueFalseTotal
unless not defined $menu or &is_Object($menu) 0 0 0
Condition0%0/3
not defined $menu or &is_Object($menu)
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $menu or &is_Object($menu)
not defined $menu &is_Object($menu)
Truth table0%0/3
not(A) or B
A= not defined $menuB= &is_Object($menu)
ABresult
1X1
011
000
688 0 my $res = false;
689 0 ▶ if ( $menu ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($menu) 0 0 0
690 0 ▶ for ( my $p = $menu->{items} ; $p ; $p = $p->{next} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p) 0 0 0
691 0 ▶ if ( $p->{name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"name"}) 0 0 0
692 0 ▶ if ( $p->{command} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{'command'} == 0) { } 0 0 0
693 $res = true
694 if $p->{subMenu}
695 0 ▶ && $self->$updateMenu( $p->{subMenu} );
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"subMenu"} and $self->$updateMenu($p->{"subMenu"}) 0 0 0
Condition0%0/3
$p->{"subMenu"} and $self->$updateMenu($p->{"subMenu"})
!ll&&!rl&&r
000
MC/DC0%0/2
$p->{"subMenu"} and $self->$updateMenu($p->{"subMenu"})
$p->{"subMenu"} $self->$updateMenu($p->{"subMenu"})
Truth table0%0/3
A and B
A= $p->{"subMenu"}B= $self->$updateMenu($p->{"subMenu"})
ABresult
0X0
100
111
696 }
697 else {
698 0 my $commandState = TView->commandEnabled( $p->{command} );
699 42 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
700 0 ▶ if ( $p->{disabled} == $commandState ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"disabled"} == $commandState) 0 0 0
701 0 $p->{disabled} = !$commandState;
702 0 $res = true;
703 }
704 }
705 } #/ if ( $p->{name} )
706 } #/ for ( my $p = $menu->{items...})
707 } #/ if ( $menu )
708 0 return $res;
709 42 }; #/ $updateMenu = sub
710
711 0 ▶$do_a_select = sub { # void ($event)
Subroutine __ANON__: not called CC=6 SCAR=37.4
712 0 my ( $self, $event ) = @_;
713 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
714 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
715 0 ▶ assert ( is_Object $event );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($event) 0 0 0
716 0 $self->putEvent( $event );
717 0 my $cmd = $self->{owner}->execView( $self );
718 0 ▶ if ( $cmd && TView->commandEnabled( $cmd ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd and "TUI::Views::View"->commandEnabled($cmd)) 0 0 0
Condition0%0/3
$cmd and "TUI::Views::View"->commandEnabled($cmd)
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd and "TUI::Views::View"->commandEnabled($cmd)
$cmd "TUI::Views::View"->commandEnabled($cmd)
Truth table0%0/3
A and B
A= $cmdB= "TUI::Views::View"->commandEnabled($cmd)
ABresult
0X0
100
111
719 0 $event->{what} = evCommand;
720 0 $event->{message}{command} = $cmd;
721 0 $event->{message}{infoPtr} = undef;
722 0 $self->putEvent( $event );
723 }
724 0 $self->clearEvent( $event );
725 0 return;
726 42 }; #/ $do_a_select = sub
727
728 0 ▶$findHotKey = sub { # $menuItem|undef ($p|undef, $keyCode)
Subroutine __ANON__: not called CC=13 SCAR=52.0
729 0 my ( $self, $p, $keyCode ) = @_;
730 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
731 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
732 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
733 0 ▶ assert ( is_Int $keyCode );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($keyCode) 0 0 0
734 0 ▶ while ( $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p) 0 0 0
735 0 ▶ if ( $p->{name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"name"}) 0 0 0
736 0 ▶ if ( $p->{command} == 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($p->{'command'} == 0) { } 0 0 0
elsif (not $p->{'disabled'} and $p->{'keyCode'} != 0 and $p->{'keyCode'} == $keyCode) { } 0 0 0
737 0 my $T = $self->$findHotKey( $p->{subMenu}{items}, $keyCode );
738 0 ▶ return $T
Branch: 1 branch
BranchTrueFalseTotal
if $T 0 0 0
739 if $T;
740 }
741 ▶ elsif ( !$p->{disabled}
Condition0%0/6
not $p->{"disabled"} and $p->{"keyCode"} != 0 and $p->{"keyCode"} == $keyCode
!ll&&!rl&&r
000
not $p->{"disabled"} and $p->{"keyCode"} != 0
!ll&&!rl&&r
000
MC/DC0%0/3
not $p->{"disabled"} and $p->{"keyCode"} != 0 and $p->{"keyCode"} == $keyCode
not $p->{"disabled"} $p->{"keyCode"} != 0 $p->{"keyCode"} == $keyCode
Truth table0%0/4
not(A) and B and C
A= not $p->{"disabled"}B= $p->{"keyCode"} != 0C= $p->{"keyCode"} == $keyCode
ABCresult
0XX0
10X0
1100
1111
742 && $p->{keyCode} != kbNoKey
743 && $p->{keyCode} == $keyCode
744 ) {
745 0 return $p;
746 }
747 } #/ if ( $p->{name} )
748 0 $p = $p->{next};
749 } #/ while ( $p )
750 0 return undef;
751 42 }; #/ sub $findHotKey
752
753 42 1
754
755 __END__
↑ Summary lib/TUI/Views/ListViewer.pm »