lib/TUI/Menus/MenuPopup.pm

filter: Statementstmt 56.1% 41 / 73 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 12 / 18 Podpod 50.0% 3 / 6 totaltotal 48.2% 56 / 116 CC 9 SCAR 26.1
CC
9
Cov
46%
handleEvent
42.0
build
20.0
name
2.0
CRAP 13.5
« lib/TUI/Drivers/Util.pm ↑ Summary lib/TUI/ColorSel/ColorItemList.pm »
1 package TUI::Menus::MenuPopup;
2 # ABSTRACT: Pop-up menu with keyboard shortcut handling
3
4 5 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 5 our $VERSION = '2.000003';
9 5 $VERSION =~ tr/_//d;
10 5 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 5 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 our @EXPORT = qw(
14 TMenuPopup
15 new_TMenuPopup
16 );
17
18 5 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 Maybe
22 :is
23 :types
24 5 );
25
26 5 ▶use TUI::Drivers::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 getAltChar
28 getCtrlChar
29 5 );
30 5 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
31 evKeyDown
32 evCommand
33 5 );
34 5 ▶use TUI::Menus::MenuBox;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 5 ▶use TUI::Objects::Rect;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 5 ▶use TUI::Views::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
37
38 sub TMenuPopup() { __PACKAGE__ }
39 0 ▶sub name { 'TMenuPopup' }
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
40 0 ▶sub new_TMenuPopup { __PACKAGE__->from(@_) }
Subroutine new_TMenuPopup: not called CC=1 SCAR=6.9
Pod documented
41
42 5 extends TMenuBox;
43
44 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
45 0 state $sig = signature(
46 method => 1,
47 named => [
48 bounds => Object,
49 menu => Maybe[Object],
50 ],
51 caller_level => +1,
52 );
53 0 my ( $class, $args1 ) = $sig->( @_ );
54 my $args2 = $class->SUPER::BUILDARGS(
55 bounds => $args1->{bounds},
56 menu => $args1->{menu},
57 0 parentMenu => undef,
58 );
59 0 return { %$args1, %$args2 };
60 }
61
62 0 ▶sub from { # $obj ($bounds, $menu)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
63 0 state $sig = signature(
64 method => 1,
65 pos => [Object, Maybe[Object]],
66 );
67 0 my ( $class, @args ) = $sig->( @_ );
68 0 return $class->new( bounds => $args[0], menu => $args[1] );
69 }
70
71 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=6 SCAR=37.4
Pod documented
72 0 state $sig = signature(
73 method => Object,
74 pos => [Object],
75 );
76 0 my ( $self, $event ) = $sig->( @_ );
77 0 ▶ if ( $event->{what} == evKeyDown ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"what"} == 16) 0 0 0
78 0 my $keyCode = $event->{keyDown}{keyCode};
79 0 my $item = $self->findItem( getCtrlChar( $keyCode ) );
80 0 ▶ $item = $self->hotKey( $keyCode )
Branch: 1 branch
BranchTrueFalseTotal
unless $item 0 0 0
81 if !$item;
82 0 ▶ if ( $item && TView->commandEnabled( $item->{command} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($item and 'TUI::Views::View'->commandEnabled($item->{'command'})) { } 0 0 0
elsif (&getAltChar($keyCode) ne "\000") { } 0 0 0
Condition0%0/3
$item and "TUI::Views::View"->commandEnabled($item->{"command"})
!ll&&!rl&&r
000
MC/DC0%0/2
$item and "TUI::Views::View"->commandEnabled($item->{"command"})
$item "TUI::Views::View"->commandEnabled($item->{"command"})
Truth table0%0/3
A and B
A= $itemB= "TUI::Views::View"->commandEnabled($item->{"command"})
ABresult
0X0
100
111
83 0 $event->{what} = evCommand;
84 0 $event->{message}{command} = $item->{command};
85 0 $event->{message}{infoPtr} = undef;
86 0 $self->putEvent( $event );
87 0 $self->clearEvent( $event );
88 }
89 elsif ( getAltChar( $keyCode ) ne "\0" ) {
90 0 $self->clearEvent( $event );
91 }
92 }
93 0 $self->SUPER::handleEvent( $event );
94 0 return;
95 }
96
97 0 ▶sub build { # $obj ()
Subroutine build: not called CC=4 SCAR=30.0
Pod undocumented
98 0 my ( $class ) = @_;
99 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
100 0 ▶ assert ( is_Str $class );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($class) 0 0 0
101 0 ▶ assert ( Storable::is_retrieving );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_retrieving() 0 0 0
102 0 return $class->new(
103 bounds => TRect->new(),
104 menu => undef,
105 );
106 }
107
108 5 1
109
110 __END__
« lib/TUI/Drivers/Util.pm ↑ Summary lib/TUI/ColorSel/ColorItemList.pm »