lib/TUI/Dialogs/Dialog.pm

filter: Statementstmt 41.5% 44 / 106 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 65.0% 13 / 20 Podpod 85.7% 6 / 7 totaltotal 37.0% 63 / 170 CC 20 SCAR 40.5
CC
20
Cov
32%
handleEvent
156.3
getPalette
30.0
BUILD
12.0
CRAP 57.7
« lib/TUI/StdDlg/FileList.pm ↑ Summary lib/TUI/Views/View/Cursor.pm »
1 package TUI::Dialogs::Dialog;
2 # ABSTRACT: Base dialog window class for dialog boxes
3
4 26 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 26 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 26 our $VERSION = '2.000002';
9 26 $VERSION =~ tr/_//d;
10 26 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 26 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 26 our @EXPORT = qw(
14 TDialog
15 new_TDialog
16 );
17
18 26 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 26 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 26 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 is_Object
22 :types
23 26 );
24
25 26 ▶use TUI::Dialogs::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
26 :cpXXXX
27 :dpXXXX
28 26 );
29 26 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
30 :evXXXX
31 kbEsc
32 kbEnter
33 26 );
34 26 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
35 cmCancel
36 cmDefault
37 cmNo
38 cmOK
39 cmYes
40 sfModal
41 wfMove
42 wfClose
43 wnNoNumber
44 26 );
45 26 ▶use TUI::Views::Palette;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 26 ▶use TUI::Views::Window;
Subroutine BEGIN: called CC=1 SCAR=0.0
47
48 sub TDialog() { __PACKAGE__ }
49 sub name() { 'TDialog' }
50 0 ▶sub new_TDialog { __PACKAGE__->from(@_) }
Subroutine new_TDialog: not called CC=1 SCAR=6.9
Pod documented
51
52 26 extends TWindow;
53
54 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
55 0 state $sig = signature(
56 method => 1,
57 named => [
58 bounds => Object,
59 title => Str, { alias => 'aTitle' },
60 ],
61 caller_level => +1,
62 );
63 0 my ( $class, $args ) = $sig->( @_ );
64 0 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
65 return $class->SUPER::BUILDARGS(
66 bounds => $args->{bounds},
67 title => $args->{title},
68 0 number => wnNoNumber,
69 );
70 }
71
72 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod documented
73 0 my ( $self, $args ) = @_;
74 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
75 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
76 0 $self->{growMode} = 0;
77 0 $self->{flags} = wfMove | wfClose;
78 0 $self->{palette} = dpGrayDialog;
79 0 return;
80 }
81
82 0 ▶sub from { # $obj ($bounds, $aTitle)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
83 0 state $sig = signature(
84 method => 1,
85 pos => [Object, Str],
86 );
87 0 my ( $class, @args ) = $sig->( @_ );
88 0 return $class->new( bounds => $args[0], title => $args[1] );
89 }
90
91 0 ▶sub getPalette { # $palette ()
Subroutine getPalette: not called CC=5 SCAR=34.0
Pod documented
92 0 state $sig = signature(
93 method => Object,
94 pos => [],
95 );
96 0 my ( $self ) = $sig->( @_ );
97
98 0 state $paletteGray = TPalette->new(
99 data => cpGrayDialog,
100 size => length( cpGrayDialog )
101 );
102 0 state $paletteBlue = TPalette->new(
103 data => cpBlueDialog,
104 size => length( cpBlueDialog )
105 );
106 0 state $paletteCyan = TPalette->new(
107 data => cpCyanDialog,
108 size => length( cpCyanDialog )
109 );
110
111 0 SWITCH: for ( $self->{palette} ) {
112 0 ▶ dpGrayDialog == $_ and return $paletteGray->clone();
Branch: 1 branch
BranchTrueFalseTotal
2 == $_ and return $paletteGray->clone 0 0 0
113 0 ▶ dpBlueDialog == $_ and return $paletteBlue->clone();
Branch: 1 branch
BranchTrueFalseTotal
0 == $_ and return $paletteBlue->clone 0 0 0
114 0 ▶ dpCyanDialog == $_ and return $paletteCyan->clone();
Branch: 1 branch
BranchTrueFalseTotal
1 == $_ and return $paletteCyan->clone 0 0 0
115 }
116 0 return $paletteGray->clone();
117 } #/ sub getPalette
118
119 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=13 SCAR=50.5
Pod documented
120 26 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
121 0 state $sig = signature(
122 method => Object,
123 pos => [Object],
124 );
125 0 my ( $self, $event ) = $sig->( @_ );
126
127 0 $self->SUPER::handleEvent( $event );
128 0 SWITCH: for ( $event->{what} ) {
129 0 ▶ evKeyDown == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
16 == $_ and do { local $_; SWITCH: foreach $_ ($event->{"keyDown"}{"keyCode"}) { 283 == $_ and do { $event->{"what"} = 256; $event->{"message"}{"command"} = 11; $event->{"message"}{"infoPtr"} = undef; $self->putEvent($event); $self->clearEvent($event); last }; 7181 == $_ and do { $event->{"what"} = 512; $event->{"message"}{"command"} = 14; $event->{"message"}{"infoPtr"} = undef; $self->putEvent($event); $self->clearEvent($event); last }; } ; last } 0 0 0
130 0 local $_;
131 0 SWITCH: for ( $event->{keyDown}{keyCode} ) {
132 0 ▶ kbEsc == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
283 == $_ and do { $event->{"what"} = 256; $event->{"message"}{"command"} = 11; $event->{"message"}{"infoPtr"} = undef; $self->putEvent($event); $self->clearEvent($event); last } 0 0 0
133 0 $event->{what} = evCommand;
134 0 $event->{message}{command} = cmCancel;
135 0 $event->{message}{infoPtr} = undef;
136 0 $self->putEvent( $event );
137 0 $self->clearEvent( $event );
138 0 last;
139 };
140 0 ▶ kbEnter == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
7181 == $_ and do { $event->{"what"} = 512; $event->{"message"}{"command"} = 14; $event->{"message"}{"infoPtr"} = undef; $self->putEvent($event); $self->clearEvent($event); last } 0 0 0
141 0 $event->{what} = evBroadcast;
142 0 $event->{message}{command} = cmDefault;
143 0 $event->{message}{infoPtr} = undef;
144 0 $self->putEvent( $event );
145 0 $self->clearEvent( $event );
146 0 last;
147 };
148 } #/ SWITCH: for ( $event->{keyDown}...)
149 0 last;
150 };
151
152 0 ▶ evCommand == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
256 == $_ and do { local $_; SWITCH: foreach $_ ($event->{"message"}{"command"}) { 10 == $_ || 11 == $_ || 12 == $_ || 13 == $_ and do { if ($self->{"state"} & 512) { $self->endModal($event->{"message"}{"command"}); $self->clearEvent($event); } ; last }; } ; last } 0 0 0
153 0 local $_;
154 0 SWITCH: for ( $event->{message}{command} ) {
155 cmOK == $_ ||
156 cmCancel == $_ ||
157 cmYes == $_ ||
158 0 ▶ cmNo == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
10 == $_ || 11 == $_ || 12 == $_ || 13 == $_ and do { if ($self->{"state"} & 512) { $self->endModal($event->{"message"}{"command"}); $self->clearEvent($event); } ; last } 0 0 0
Condition0%0/9
10 == $_ or 11 == $_ or 12 == $_ or 13 == $_
l!l&&r!l&&!r
000
10 == $_ or 11 == $_ or 12 == $_
l!l&&r!l&&!r
000
10 == $_ or 11 == $_
l!l&&r!l&&!r
000
MC/DC0%0/4
10 == $_ or 11 == $_ or 12 == $_ or 13 == $_
10 == $_ 11 == $_ 12 == $_ 13 == $_
Truth table0%0/5
A or B or C or D
A= 10 == $_B= 11 == $_C= 12 == $_D= 13 == $_
ABCDresult
1XXX1
01XX1
001X1
00011
00000
159 0 ▶ if ( $self->{state} & sfModal ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"} & 512) 0 0 0
160 0 $self->endModal( $event->{message}{command} );
161 0 $self->clearEvent( $event );
162 }
163 0 last;
164 };
165 } #/ SWITCH: for ( $event->{message}...)
166 0 last;
167 };
168 } #/ SWITCH: for ( $event->{what} )
169 0 return;
170 } #/ sub handleEvent
171
172 0 ▶sub valid { # $bool ($command)
Subroutine valid: not called CC=2 SCAR=17.9
Pod documented
173 0 state $sig = signature(
174 method => Object,
175 pos => [PositiveOrZeroInt],
176 );
177 0 my ( $self, $command ) = $sig->( @_ );
178 0 ▶ return $command == cmCancel
Branch: 1 branch
BranchTrueFalseTotal
$command == 11 ? : 0 0 0
179 ? true
180 : $self->SUPER::valid( $command );
181 }
182
183 26 1
184
185 __END__
« lib/TUI/StdDlg/FileList.pm ↑ Summary lib/TUI/Views/View/Cursor.pm »