lib/TUI/StdDlg/FileList.pm

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