lib/TUI/StdDlg/FileList.pm

filter: Statementstmt 35.5% 58 / 163 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 53.1% 17 / 32 Podpod 92.8% 13 / 14 totaltotal 33.7% 88 / 261 CC 24 SCAR 40.7
CC
24
Cov
28%
readDirectory
210.0
DEMOLISH
20.0
readFf_blk
20.0
CRAP 58.3
« lib/TUI/Menus/MenuBox.pm ↑ Summary lib/TUI/Dialogs/Dialog.pm »
1 package TUI::StdDlg::FileList;
2 # ABSTRACT: TListBox subclass for file lists in TFileList
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.000002';
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
14 5 our @EXPORT = qw(
15 TFileList
16 new_TFileList
17 );
18
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_Object
23 :types
24 5 );
25
26 5 ▶use TUI::Const qw( EOS );
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
28 evBroadcast
29 kbShift
30 5 );
31 5 ▶use TUI::MsgBox::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
32 mfOKButton
33 mfWarning
34 5 );
35 5 ▶use TUI::MsgBox::MsgBoxText qw( messageBox );
Subroutine BEGIN: called CC=1 SCAR=0.0
36 5 ▶use TUI::Objects::Const qw( maxCollectionSize );
Subroutine BEGIN: called CC=1 SCAR=0.0
37 5 ▶use TUI::StdDlg::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
38 cmFileDoubleClicked
39 cmFileFocused
40 :FA_
41 5 );
42 5 ▶use TUI::StdDlg::FileCollection;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 5 ▶use TUI::StdDlg::SortedListBox;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 5 ▶use TUI::StdDlg::Dir qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
45 findfirst
46 findnext
47 fnmerge
48 fnsplit
49 5 );
50 5 ▶use TUI::StdDlg::Util qw( fexpand );
Subroutine BEGIN: called CC=1 SCAR=0.0
51 5 ▶use TUI::Views::Util qw( message );
Subroutine BEGIN: called CC=1 SCAR=0.0
52
53 sub TFileList() { __PACKAGE__ }
54 sub name() { 'TFileList' }
55 0 ▶sub new_TFileList { __PACKAGE__->from( @_ ) }
Subroutine new_TFileList: not called CC=1 SCAR=6.9
Pod documented
56
57 5 extends TSortedListBox;
58
59 # declare global variables
60 5 our $tooManyFiles = "Too many files.";
61
62 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
63 0 state $sig = signature(
64 method => 1,
65 named => [
66 bounds => Object,
67 vScrollBar => Maybe[Object], { alias => 'aScrollBar' },
68 ],
69 caller_level => +1,
70 );
71 0 my ( $class, $args ) = $sig->( @_ );
72 0 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
73 return $class->SUPER::BUILDARGS(
74 bounds => $args->{bounds},
75 numCols => 2,
76 vScrollBar => $args->{vScrollBar},
77 0 );
78 }
79
80 0 ▶sub from { # $obj ($bounds, $aVScrollBar|undef)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
81 0 state $sig = signature(
82 method => 1,
83 pos => [Object, Maybe[Object]],
84 );
85 0 my ( $class, @args ) = $sig->( @_ );
86 0 return $class->new( bounds => $args[0], vScrollBar => $args[2] );
87 }
88
89 0 ▶sub DEMOLISH { # void ($in_global_destruction)
Subroutine DEMOLISH: not called CC=4 SCAR=30.0
Pod documented
90 0 my ( $self, $in_global_destruction ) = @_;
91 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
92 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
93 0 alias: for my $list ( $self->{items} ) {
94 0 $self->destroy( $list );
95 0 return;
96 } #/ alias:
97 }
98
99 0 ▶sub focusItem { # void ($item)
Subroutine focusItem: not called CC=1 SCAR=6.9
Pod documented
100 0 state $sig = signature(
101 method => Object,
102 pos => [PositiveOrZeroInt],
103 );
104 0 my ( $self, $item ) = $sig->( @_ );
105 0 $self->SUPER::focusItem( $item );
106 0 message( $self->{owner}, evBroadcast, cmFileFocused,
107 $self->list()->at( $item ) );
108 0 return;
109 }
110
111 0 ▶sub selectItem { # void ($item)
Subroutine selectItem: not called CC=1 SCAR=6.9
Pod documented
112 0 state $sig = signature(
113 method => Object,
114 pos => [PositiveOrZeroInt],
115 );
116 0 my ( $self, $item ) = $sig->( @_ );
117 0 message( $self->{owner}, evBroadcast, cmFileDoubleClicked,
118 $self->list()->at( $item ) );
119 0 return;
120 }
121
122 0 ▶sub getText { # void (\$dest, $item, $maxChars)
Subroutine getText: not called CC=3 SCAR=24.8
Pod documented
123 0 state $sig = signature(
124 method => Object,
125 pos => [ScalarRef, Int, Int],
126 );
127 0 my ( $self, $dest, $item, $maxChars ) = $sig->( @_ );
128 0 my $f = $self->list()->at( $item );
129 0 ▶ assert ( is_Object $f );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($f) 0 0 0
130 0 $$dest = substr( $f->name(), 0, $maxChars );
131 0 ▶ $$dest .= "\\"
Branch: 1 branch
BranchTrueFalseTotal
if $f->attr & 16 0 0 0
132 if $f->attr() & FA_DIREC;
133 0 return;
134 }
135
136 0 ▶sub newList { # void ($aList)
Subroutine newList: not called CC=1 SCAR=6.9
Pod documented
137 0 goto &TUI::StdDlg::SortedListBox::newList;
138 }
139
140 5 @DirSearchRec::ISA = ( 'TSearchRec' );
141
142 0 ▶sub DirSearchRec::readFf_blk { # void ($f)
Subroutine readFf_blk: not called CC=4 SCAR=30.0
143 0 my ( $self, $f ) = @_;
144 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
145 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
146 0 ▶ assert ( is_Object $f );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($f) 0 0 0
147 0 $self->attr( $f->ff_attrib );
148 0 $self->time( ( $f->ff_fdate() << 16 ) | $f->ff_ftime );
149 0 $self->size( $f->ff_fsize );
150 0 $self->name( $f->ff_name );
151 }
152
153 0 ▶sub readDirectory { # void (|$dir, $wildCard)
Subroutine readDirectory: not called CC=14 SCAR=53.5
Pod documented
154 0 state $sig = signature(
155 method => Object,
156 pos => [
157 Str,
158 Str, { default => '' },
159 ],
160 );
161 0 my ( $self, @args ) = $sig->( @_ );
162 0 my $aWildCard = join '' => @args;
163
164 0 my $s = ffblk->new();
165 0 my $path = $aWildCard;
166 0 fexpand( $path );
167 0 my ( $drive, $dir, $file, $ext );
168 0 fnsplit( $path, $drive, $dir, $file, $ext );
169
170 0 my $fileList = TFileCollection->new( limit => 5, delta => 5 );
171
172 0 my $res = findfirst( $aWildCard, $s, FA_RDONLY | FA_ARCH );
173 0 ▶ for ( ; $res == 0; $res = findnext( $s ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res == 0) 0 0 0
174 0 ▶ next if $s->ff_attrib() & FA_DIREC;
Branch: 1 branch
BranchTrueFalseTotal
if $s->ff_attrib & 16 0 0 0
175 0 ▶ last if $fileList->getCount() >= maxCollectionSize;
Branch: 1 branch
BranchTrueFalseTotal
if $fileList->getCount >= '2305843009213693952' 0 0 0
176
177 0 my $p = DirSearchRec->new();
178 0 $p->readFf_blk( $s );
179 0 $fileList->insert( $p );
180 }
181
182 0 fnmerge( $path, $drive, $dir, "*", ".*" );
183
184 0 $res = findfirst( $path, $s, FA_DIREC );
185 0 ▶ for ( ; $res == 0; $res = findnext( $s ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res == 0) 0 0 0
186 0 ▶ next unless $s->ff_attrib() & FA_DIREC;
Branch: 1 branch
BranchTrueFalseTotal
unless $s->ff_attrib & 16 0 0 0
187 0 ▶ next if substr( $s->ff_name, 0, 1 ) eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if substr($s->ff_name, 0, 1) eq "." 0 0 0
188 0 ▶ last if $fileList->getCount() >= maxCollectionSize;
Branch: 1 branch
BranchTrueFalseTotal
if $fileList->getCount >= '2305843009213693952' 0 0 0
189
190 0 my $p = DirSearchRec->new();
191 0 $p->readFf_blk( $s );
192 0 $fileList->insert( $p );
193 }
194
195 0 ▶ if ( length $dir > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $dir > 1) 0 0 0
196 0 my $p = DirSearchRec->new();
197 0 ▶ if ( findfirst( $path, $s, FA_DIREC ) == 0
Branch: 1 branch
BranchTrueFalseTotal
if (findfirst($path, $s, 16) == 0 and findnext($s) == 0 and $s->ff_name eq '..') { } 0 0 0
Condition0%0/6
findfirst($path, $s, 16) == 0 and findnext($s) == 0 and $s->ff_name eq ".."
!ll&&!rl&&r
000
findfirst($path, $s, 16) == 0 and findnext($s) == 0
!ll&&!rl&&r
000
MC/DC0%0/3
findfirst($path, $s, 16) == 0 and findnext($s) == 0 and $s->ff_name eq ".."
findfirst($path, $s, 16) == 0 findnext($s) == 0 $s->ff_name eq ".."
Truth table0%0/4
A and B and C
A= findfirst($path, $s, 16) == 0B= findnext($s) == 0C= $s->ff_name eq ".."
ABCresult
0XX0
10X0
1100
1111
198 && findnext( $s ) == 0
199 && $s->ff_name eq '..'
200 ) {
201 0 $p->readFf_blk( $s );
202 }
203 else {
204 0 $p->name( '..' );
205 0 $p->size( 0 );
206 0 $p->time( 0x210000 );
207 0 $p->attr( FA_DIREC );
208 }
209 0 $fileList->insert( $p );
210 } #/ if ( length( $dir ) > ...)
211
212 0 ▶ if ( $fileList->getCount() >= maxCollectionSize ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fileList->getCount >= '2305843009213693952') 0 0 0
213 0 messageBox( $tooManyFiles, mfOKButton | mfWarning );
214 }
215 0 $self->newList( $fileList );
216 0 ▶ if ( $self->list()->getCount() > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->list->getCount > 0) { } 0 0 0
217 0 message( $self->{owner}, evBroadcast, cmFileFocused,
218 $self->list()->at( 0 ) );
219 }
220 else {
221 0 state $noFile = DirSearchRec->new();
222 0 message( $self->{owner}, evBroadcast, cmFileFocused, $noFile );
223 }
224 0 return;
225 }
226
227 0 ▶sub dataSize { # $size ()
Subroutine dataSize: not called CC=1 SCAR=6.9
Pod documented
228 0 state $sig = signature(
229 method => Object,
230 pos => [],
231 );
232 0 $sig->( @_ );
233 0 return 0;
234 }
235
236 0 ▶sub getData { # void (\@rec)
Subroutine getData: not called CC=1 SCAR=6.9
Pod documented
237 0 state $sig = signature(
238 method => Object,
239 pos => [ArrayLike],
240 );
241 0 $sig->( @_ );
242 0 return;
243 }
244
245 0 ▶sub setData { # void (\@rec)
Subroutine setData: not called CC=1 SCAR=6.9
Pod documented
246 0 state $sig = signature(
247 method => Object,
248 pos => [ArrayLike],
249 );
250 0 $sig->( @_ );
251 0 return;
252 }
253
254 0 ▶sub list { # $fileCollection ()
Subroutine list: not called CC=1 SCAR=6.9
Pod documented
255 0 goto &TUI::StdDlg::SortedListBox::list;
256 }
257
258 0 ▶sub getKey { # $key ($s)
Subroutine getKey: not called CC=3 SCAR=24.8
Pod documented
259 0 state $sig = signature(
260 method => Object,
261 pos => [Str],
262 );
263 0 my ( $self, $s ) = $sig->( @_ );
264 0 state $sR = TSearchRec->new();
265 0 ▶ if ( ( $self->{shiftState} & kbShift ) || $s eq '.' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'shiftState'} & 3 or $s eq '.') { } 0 0 0
Condition0%0/3
$self->{"shiftState"} & 3 or $s eq "."
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"shiftState"} & 3 or $s eq "."
$self->{"shiftState"} & 3 $s eq "."
Truth table0%0/3
A or B
A= $self->{"shiftState"} & 3B= $s eq "."
ABresult
1X1
011
000
266 0 $sR->attr( FA_DIREC );
267 }
268 else {
269 0 $sR->attr( 0 );
270 }
271 0 $sR->name( uc $s );
272 0 return $sR;
273 }
274
275 5 1
276
277 __END__
« lib/TUI/Menus/MenuBox.pm ↑ Summary lib/TUI/Dialogs/Dialog.pm »