lib/TUI/Menus/MenuView.pm

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