lib/TUI/Dialogs/Dialog.pm

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