blib/lib/Tk/Getopt.pm

filter: Statementstmt 21.0% 170 / 808 Branchbran 16.4% 73 / 444 Conditioncond 13.5% 22 / 163 MC/DCmcdc 8.4% 8 / 95 Subroutinesub 21.6% 16 / 74 Podpod 84.6% 11 / 13 totaltotal 18.7% 300 / 1597 CC 298 SCAR 68.5
CC
298
Cov
19%
option_editor
4422.0
_create_page
1190.0
__ANON__
380.0
CRAP 940.6
↑ Summary
1 # -*- perl -*-
2  
3 #
4 # Author: Slaven Rezic
5 #
6 # Copyright (C) 1997,1998,1999,2000,2003,2007,2008,2012,2014,2017 Slaven Rezic. All rights reserved.
7 # This package is free software; you can redistribute it and/or
8 # modify it under the same terms as Perl itself.
9 #
10 # Mail: srezic@cpan.org
11 # WWW: http://www.rezic.de/eserte/
12 #
13  
14 package Tk::Getopt;
15 5 require 5.005; # calling CODE refs
16 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use vars qw($loadoptions $VERSION $x11_pass_through
Subroutine BEGIN: called CC=1 SCAR=0.0
18 $CHECKMARK_OFF $CHECKMARK_ON
19 $FILE_IMAGE $CURR_GEOMETRY_IMAGE $DEBUG
20 5 );
21 5 ▶use constant OPTNAME => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use constant OPTTYPE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use constant DEFVAL => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 5 ▶use constant OPTEXTRA => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 5 ▶use Carp qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 5 $VERSION = '0.52';
29 5 $VERSION =~ s{_}{};
30  
31 5 $DEBUG = 0;
32 5 $x11_pass_through = 0;
33  
34 10 ▶sub new {
Subroutine new: called CC=27 SCAR=34.1
Pod documented
35 10 my($pkg, %a) = @_;
36 10 my $self = {};
37  
38 10 ▶ $self->{'options'} = delete $a{'-options'} if exists $a{'-options'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $a{"-options"} 0 10 10
39  
40 10 ▶ if (exists $a{'-opttable'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $a{'-opttable'}) { } 3 7 10
elsif (exists $a{'-getopt'}) { } 7 0 7
41 3 $self->{'opttable'} = delete $a{'-opttable'};
42 3 foreach (@{$self->{'opttable'}}) {
43 # Convert from new style without hash for extra options for
44 # internal operation.
45 # ['opt', '=s', 'defval', 'x' => 'y', 'z' => 'a', ...] into
46 # ['opt', '=s', 'defval', {'x' => 'y', 'z' => 'a', ...}]
47 7 ▶ if (ref $_ eq 'ARRAY' and
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ eq "ARRAY" and defined $_->[3] and ref $_->[3] ne "HASH") 1 6 7
Condition83%5/6
ref $_ eq "ARRAY" and defined $_->[3] and ref $_->[3] ne "HASH"
!ll&&!rl&&r
511
ref $_ eq "ARRAY" and defined $_->[3]
!ll&&!rl&&r
052
MC/DC66%2/3
ref $_ eq "ARRAY" and defined $_->[3] and ref $_->[3] ne "HASH"
ref $_ eq "ARRAY" defined $_->[3] ref $_->[3] ne "HASH"
Truth table75%3/4
A and B and C
A= ref $_ eq "ARRAY"B= defined $_->[3]C= ref $_->[3] ne "HASH"
ABCresult
0XX0
10X0
1100
1111
48 defined $_->[OPTEXTRA] and
49 ref $_->[OPTEXTRA] ne 'HASH') {
50 1 ▶ if ((@$_ - OPTEXTRA) % 2 != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ((@$_ - 3) % 2 != 0) 0 1 1
51 0 warn "Odd number of elements in definition for " . $_->[OPTNAME];
52 }
53 1 my %h = splice @$_, OPTEXTRA;
54 1 $_->[OPTEXTRA] = \%h;
55 }
56 # Handle aliases
57 7 ▶ if (ref $_ eq 'ARRAY' && $_->[OPTNAME] =~ /\|/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ eq "ARRAY" and $_->[0] =~ /\|/) 0 7 7
Condition33%1/3
ref $_ eq "ARRAY" and $_->[0] =~ /\|/
!ll&&!rl&&r
070
MC/DC0%0/2
ref $_ eq "ARRAY" and $_->[0] =~ /\|/
ref $_ eq "ARRAY" $_->[0] =~ /\|/
Truth table33%1/3
A and B
A= ref $_ eq "ARRAY"B= $_->[0] =~ /\|/
ABresult
0X0
100
111
58 0 my($opt, @aliases) = split(/\|/, $_->[OPTNAME]);
59 0 $_->[OPTNAME] = $opt;
60 0 push(@{$_->[OPTEXTRA]{'aliases'}}, @aliases);
61 }
62 }
63 } elsif (exists $a{'-getopt'}) {
64 # build opttable from -getopt argument
65 7 my @optionlist;
66 7 my $genprefix = "(--|-|\\+)";
67 7 ▶ if (ref $a{'-getopt'} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $a{'-getopt'} eq 'HASH') { } 4 3 7
68 # convert hash to array
69 @optionlist
70 4 = map { ($_, $a{'-getopt'}->{$_}) } keys %{$a{'-getopt'}};
71 } else {
72 3 @optionlist = @{$a{'-getopt'}};
73 }
74 7 delete $a{'-getopt'};
75 # check if first argument is hash reference
76 7 ▶ if (ref $optionlist[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $optionlist[0] eq "HASH") 2 5 7
77 2 $self->{'options'} = shift @optionlist;
78 }
79 7 ▶ while (@optionlist > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@optionlist > 0) 45 7 52
80 45 my $opt = shift @optionlist;
81 # Strip leading prefix so people can specify "--foo=i"
82 # if they like.
83 45 ▶ $opt = $2 if $opt =~ /^($genprefix)+(.*)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $opt =~ /^($genprefix)+(.*)$/ 0 45 45
84  
85 45 ▶ if ($opt !~ /^(\w+[-\w|]*)?(!|[=:][infse][@%]?)?$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /^(\w+[-\w|]*)?(!|[=:][infse][\@%]?)?$/) 0 45 45
86 0 warn "Error in option spec: \"", $opt, "\"\n";
87 0 next;
88 }
89 45 my($o, $c) = ($1, $2);
90 45 ▶ $c = '' unless defined $c;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $c 8 37 45
91 45 my @aliases;
92 45 ▶ if ($o =~ /\|/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o =~ /\|/) 1 44 45
93 # Handle alias names
94 1 @aliases = split(/\|/, $o);
95 1 $o = shift @aliases;
96 }
97 45 my $varref;
98 # If no linkage is supplied in the @optionlist, copy it from
99 # the userlinkage ($self->{'options'}) if available.
100 45 ▶ if (defined $self->{'options'} && !ref $optionlist[0]) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'options'} and not ref $optionlist[0]) { } 5 40 45
elsif (ref $optionlist[0]) { } 39 1 40
Condition100%3/3
defined $self->{"options"} and not ref $optionlist[0]
!ll&&!rl&&r
27135
MC/DC100%2/2
defined $self->{"options"} and not ref $optionlist[0]
defined $self->{"options"} not ref $optionlist[0]
Truth table100%3/3
A and not(B)
A= defined $self->{"options"}B= not ref $optionlist[0]
ABresult
0X0
100
111
101 $varref = (exists $self->{'options'}{$o} ?
102 $self->{'options'}{$o} :
103 5 ▶ \$self->{'options'}{$o});
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'options'}{$o} ? : 3 2 5
104 } elsif (ref $optionlist[0]) {
105 # link to global variable
106 39 $varref = shift @optionlist;
107 }
108 45 my %a;
109 45 ▶ if (defined $varref) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $varref) 44 1 45
110 44 ▶ if (ref $varref eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $varref eq "CODE") 2 42 44
111 2 my $code = $varref;
112 2 ▶ $a{'callback'} = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
113 2 ▶ if ($self->{'options'}{$o}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"options"}{$o}) 1 1 2
114 1 &$code;
115 }
116 2 };
117 2 $varref = \$self->{'options'}{$o};
118 }
119 44 ▶ if (ref($varref) =~ /^(SCALAR|HASH|ARRAY)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($varref) =~ /^(SCALAR|HASH|ARRAY)$/) { } 44 0 44
120 44 $a{'var'} = $varref;
121 } else {
122 0 die "Can't handle variable reference of type "
123 . ref $varref;
124 }
125 }
126 45 ▶ if (@aliases) {
Branch: 1 branch
BranchTrueFalseTotal
if (@aliases) 1 44 45
127 1 $a{'alias'} = \@aliases;
128 }
129 45 push(@{$self->{'opttable'}}, [$o, $c, undef, \%a]);
130 }
131 } else {
132 0 die "No opttable array ref or getopt hash ref";
133 }
134  
135 10 $self->{'caller'} = (caller)[0];
136 10 $self->{'filename'} = delete $a{'-filename'};
137 10 $self->{'nosafe'} = delete $a{'-nosafe'};
138 10 $self->{'useerrordialog'} = delete $a{'-useerrordialog'};
139  
140 10 ▶ die "Unrecognized arguments: " . join(" ", %a) if %a;
Branch: 1 branch
BranchTrueFalseTotal
if %a 0 10 10
141  
142 10 bless $self, $pkg;
143 }
144  
145 # Return a list with all option names, that is, section labels and
146 # descriptions are ignored.
147 12 ▶sub _opt_array {
Subroutine _opt_array: called CC=4 SCAR=14.6
148 12 my $self = shift;
149 12 my @res;
150 12 foreach (@{$self->{'opttable'}}) {
151 80 ▶ push @res, $_
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "ARRAY" and $_->[0] ne "" 80 0 80
Condition33%1/3
ref $_ eq "ARRAY" and $_->[0] ne ""
!ll&&!rl&&r
0080
MC/DC0%0/2
ref $_ eq "ARRAY" and $_->[0] ne ""
ref $_ eq "ARRAY" $_->[0] ne ""
Truth table33%1/3
A and B
A= ref $_ eq "ARRAY"B= $_->[0] ne ""
ABresult
0X0
100
111
152 if ref $_ eq 'ARRAY' and
153 $_->[OPTNAME] ne '';
154 }
155 12 @res;
156 }
157  
158 # Return a reference to the option variable given by $opt
159 86 ▶sub varref {
Subroutine varref: called CC=3 SCAR=11.2
Pod documented
160 86 my($self, $opt) = @_;
161 86 ▶ if($opt->[OPTEXTRA]{'var'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opt->[3]{'var'}) { } 77 9 86
elsif ($self->{'options'}) { } 0 9 9
162 77 $opt->[OPTEXTRA]{'var'};
163 } elsif ($self->{'options'}) {
164 0 \$self->{'options'}{$opt->[OPTNAME]};
165 } else {
166 # Link to global $opt_XXX variable.
167 # Make sure a valid perl identifier results.
168 9 my $v;
169 9 ($v = $opt->[OPTNAME]) =~ s/\W/_/g;
170 9 eval q{\$} . $self->{'caller'} . q{::opt_} . $v; # XXX @, %
171 }
172 }
173 # Formerly the varref method was private:
174 0 ▶sub _varref { shift->varref(@_) }
Subroutine _varref: not called CC=1 SCAR=6.9
175  
176 0 ▶sub optextra {
Subroutine optextra: not called CC=1 SCAR=6.9
Pod documented
177 0 my($self, $opt, $arg) = @_;
178 0 $opt->[OPTEXTRA]{$arg};
179 }
180  
181 0 ▶sub _is_separator {
Subroutine _is_separator: not called CC=4 SCAR=30.0
182 0 my $opt = shift;
183 0 ▶ defined $opt->[OPTNAME] && $opt->[OPTNAME] eq '' &&
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->[0] and $opt->[0] eq "" and defined $opt->[2] and $opt->[2] eq "-" 0 0 0
Condition0%0/6
defined $opt->[0] and $opt->[0] eq "" and defined $opt->[2]
!ll&&!rl&&r
000
defined $opt->[0] and $opt->[0] eq ""
!ll&&!rl&&r
000
MC/DC0%0/3
defined $opt->[0] and $opt->[0] eq "" and defined $opt->[2]
defined $opt->[0] $opt->[0] eq "" defined $opt->[2]
Truth table0%0/4
A and B and C
A= defined $opt->[0]B= $opt->[0] eq ""C= defined $opt->[2]
ABCresult
0XX0
10X0
1100
1111
184 defined $opt->[DEFVAL] && $opt->[DEFVAL] eq '-';
185 }
186  
187 0 ▶sub set_defaults {
Subroutine set_defaults: not called CC=6 SCAR=37.4
Pod documented
188 0 my $self = shift;
189 0 my $opt;
190 0 foreach $opt ($self->_opt_array) {
191 0 ▶ if (defined $opt->[DEFVAL]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt->[2]) 0 0 0
192 0 my $ref = ref $self->varref($opt);
193 0 ▶ if ($ref eq 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if ($ref eq 'ARRAY') { } 0 0 0
elsif ($ref eq 'HASH') { } 0 0 0
elsif ($ref eq 'SCALAR') { } 0 0 0
194 0 @ {$self->varref($opt)} = @{ $opt->[DEFVAL] };
195 } elsif ($ref eq 'HASH') {
196 0 % {$self->varref($opt)} = %{ $opt->[DEFVAL] };
197 } elsif ($ref eq 'SCALAR') {
198 0 $ {$self->varref($opt)} = $opt->[DEFVAL];
199 } else {
200 0 die "Invalid reference type for option $opt->[OPTNAME] while setting the default value (maybe you should specify <undef> as the default value)";
201 }
202 }
203 }
204 }
205  
206 1 ▶sub load_options {
Subroutine load_options: called CC=16 SCAR=34.8
Pod documented
207 1 my($self, $filename) = @_;
208 1 ▶ $filename = $self->{'filename'} if !$filename;
Branch: 1 branch
BranchTrueFalseTotal
unless $filename 0 1 1
209 1 ▶ return if !$filename;
Branch: 1 branch
BranchTrueFalseTotal
unless $filename 0 1 1
210 1 require File::Spec;
211 1 ▶ if (!-e $filename) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $filename) 0 1 1
212 0 warn "File $filename does not exist";
213 0 return undef;
214 }
215 1 ▶ if (!File::Spec->file_name_is_absolute($filename)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("File::Spec"->file_name_is_absolute($filename)) 0 1 1
216 # required for do operation with PERL_USE_UNSAFE_INC=0
217 0 $filename = File::Spec->rel2abs($filename);
218 }
219 1 ▶ if ($self->{'nosafe'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'nosafe'}) { } 0 1 1
220 0 require Safe;
221 0 my $c = new Safe;
222 0 $c->share('$loadoptions');
223 0 ▶ if (!$c->rdo($filename)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($c->rdo($filename)) 0 0 0
224 0 warn "Can't load $filename";
225 0 return undef;
226 }
227 } else {
228 1 eval {do $filename};
229 1 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
230 0 warn $@;
231 0 return undef;
232 }
233 }
234  
235 1 my $opt;
236 1 foreach $opt ($self->_opt_array) {
237 7 ▶ if (exists $loadoptions->{$opt->[OPTNAME]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$Tk::Getopt::loadoptions{$opt->[0]}) 7 0 7
238 7 ▶ if (ref $self->varref($opt) eq 'CODE') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $self->varref($opt) eq 'CODE') { } 0 7 7
elsif (ref $self->varref($opt) eq 'ARRAY' and ref $$Tk::Getopt::loadoptions{$opt->[0]} eq 'ARRAY') { } 1 6 7
elsif (ref $self->varref($opt) eq 'HASH' and ref $$Tk::Getopt::loadoptions{$opt->[0]} eq 'HASH') { } 1 5 6
239 0 ▶ $self->varref($opt)->($opt, $loadoptions->{$opt->[OPTNAME]}) if $loadoptions->{$opt->[OPTNAME]};
Branch: 1 branch
BranchTrueFalseTotal
if $$Tk::Getopt::loadoptions{$opt->[0]} 0 0 0
240 ▶ } elsif (ref $self->varref($opt) eq 'ARRAY' &&
Condition66%2/3
ref $self->varref($opt) eq "ARRAY" and ref $$Tk::Getopt::loadoptions{$opt->[0]} eq "ARRAY"
!ll&&!rl&&r
601
MC/DC50%1/2
ref $self->varref($opt) eq "ARRAY" and ref $$Tk::Getopt::loadoptions{$opt->[0]} eq "ARRAY"
ref $self->varref($opt) eq "ARRAY" ref $$Tk::Getopt::loadoptions{$opt->[0]} eq "ARRAY"
Truth table66%2/3
A and B
A= ref $self->varref($opt) eq "ARRAY"B= ref $$Tk::Getopt::loadoptions{$opt->[0]} eq "ARRAY"
ABresult
0X0
100
111
241 ref $loadoptions->{$opt->[OPTNAME]} eq 'ARRAY') {
242 1 @{ $self->varref($opt) } = @{ $loadoptions->{$opt->[OPTNAME]} };
243 ▶ } elsif (ref $self->varref($opt) eq 'HASH' &&
Condition66%2/3
ref $self->varref($opt) eq "HASH" and ref $$Tk::Getopt::loadoptions{$opt->[0]} eq "HASH"
!ll&&!rl&&r
501
MC/DC50%1/2
ref $self->varref($opt) eq "HASH" and ref $$Tk::Getopt::loadoptions{$opt->[0]} eq "HASH"
ref $self->varref($opt) eq "HASH" ref $$Tk::Getopt::loadoptions{$opt->[0]} eq "HASH"
Truth table66%2/3
A and B
A= ref $self->varref($opt) eq "HASH"B= ref $$Tk::Getopt::loadoptions{$opt->[0]} eq "HASH"
ABresult
0X0
100
111
244 ref $loadoptions->{$opt->[OPTNAME]} eq 'HASH') {
245 1 %{ $self->varref($opt) } = %{ $loadoptions->{$opt->[OPTNAME]} };
246 } else {
247 5 $ {$self->varref($opt)} = $loadoptions->{$opt->[OPTNAME]};
248 }
249 }
250 }
251 1 1;
252 }
253  
254 1 ▶sub save_options {
Subroutine save_options: called CC=12 SCAR=28.0
Pod documented
255 1 my($self, $filename) = @_;
256 1 ▶ $filename = $self->{'filename'} if !$filename;
Branch: 1 branch
BranchTrueFalseTotal
unless $filename 0 1 1
257 1 ▶ die "Saving disabled" if !$filename;
Branch: 1 branch
BranchTrueFalseTotal
unless $filename 0 1 1
258 1 eval "require Data::Dumper";
259 1 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 1 1
260 0 warn $@;
261 0 $self->my_die("No Data::Dumper available, cannot save options.\n");
262 } else {
263 1 ▶ if (open(OPT, ">$filename")) {
Branch: 1 branch
BranchTrueFalseTotal
if (open OPT, ">$filename") { } 1 0 1
264 1 my %saveoptions;
265 my $opt;
266 1 foreach $opt ($self->_opt_array) {
267 11 ▶ if (!$opt->[OPTEXTRA]{'nosave'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt->[3]{"nosave"}) 11 0 11
268 11 my $ref;
269 11 ▶ if ($opt->[OPTEXTRA]{'savevar'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->[3]{'savevar'}) { } 0 11 11
270 0 $ref = $opt->[OPTEXTRA]{'savevar'};
271 } else {
272 11 $ref = $self->varref($opt);
273 }
274 11 ▶ if (ref($ref) eq 'SCALAR') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $ref eq 'SCALAR') { } 9 2 11
elsif (ref($ref) =~ /^(HASH|ARRAY)$/) { } 2 0 2
275 9 $saveoptions{$opt->[OPTNAME]} = $$ref;
276 } elsif (ref($ref) =~ /^(HASH|ARRAY)$/) {
277 2 $saveoptions{$opt->[OPTNAME]} = $ref;
278 }
279 }
280 }
281 1 local $Data::Dumper::Sortkeys = $Data::Dumper::Sortkeys = 1;
282 1 local $Data::Dumper::Indent = $Data::Dumper::Indent = 1;
283 1 ▶ if (Data::Dumper->can('Dumpxs')) {
Branch: 1 branch
BranchTrueFalseTotal
if ('Data::Dumper'->can('Dumpxs')) { } 1 0 1
284 # use faster version of Dump
285 1 print OPT
286 Data::Dumper->Dumpxs([\%saveoptions], ['loadoptions']);
287 } else {
288 0 print OPT
289 Data::Dumper->Dump([\%saveoptions], ['loadoptions']);
290 }
291 1 close OPT;
292 1 ▶ warn "Options written to $filename" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $Tk::Getopt::DEBUG 0 1 1
293 1 1;
294 } else {
295 0 $self->my_die("Writing to config file <$filename> failed: $!\n");
296 0 undef;
297 }
298 }
299 }
300  
301 9 ▶sub get_options {
Subroutine get_options: called CC=15 SCAR=47.4
Pod documented
302 9 my $self = shift;
303 9 my %getopt;
304 my $opt;
305 9 foreach $opt ($self->_opt_array) {
306 45 $getopt{_getopt_long_string($opt->[OPTNAME], $opt->[OPTTYPE])} =
307 $self->varref($opt);
308 # process aliases
309 45 foreach (@{$opt->[OPTEXTRA]{'alias'}}) {
310 3 $getopt{_getopt_long_string($_, $opt->[OPTTYPE])} =
311 $self->varref($opt);
312 }
313 }
314 9 require Getopt::Long;
315 # XXX anders implementieren ... vielleicht die X11-Optionen zusätzlich
316 # in die %getopt-Liste reinschreiben?
317 9 ▶ if ($x11_pass_through) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Tk::Getopt::x11_pass_through) 0 9 9
318 0 Getopt::Long::config('pass_through');
319 }
320 9 my $res = Getopt::Long::GetOptions(%getopt);
321 # Hack to pass standard X11 options (as defined in Tk::CmdLine)
322 9 ▶ if ($x11_pass_through) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Tk::Getopt::x11_pass_through) 0 9 9
323 0 eval {
324 0 require Tk::CmdLine;
325 0 ▶ if ($Tk::CmdLine::VERSION >= 3.012) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Tk::CmdLine::VERSION >= 3.012) { } 0 0 0
326 # XXX nicht ausgetestet
327 0 my @args = @ARGV;
328 0 ▶ while (@args && $args[0] =~ /^-(\w+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and $args[0] =~ /^-(\w+)$/) 0 0 0
Condition0%0/3
@args and $args[0] =~ /^-(\w+)$/
!ll&&!rl&&r
000
MC/DC0%0/2
@args and $args[0] =~ /^-(\w+)$/
@args $args[0] =~ /^-(\w+)$/
Truth table0%0/3
A and B
A= @argsB= $args[0] =~ /^-(\w+)$/
ABresult
0X0
100
111
329 0 my $sw = $1;
330 0 ▶ return 0 if !$Tk::CmdLine::Method{$sw};
Branch: 1 branch
BranchTrueFalseTotal
unless $Tk::CmdLine::Method{$sw} 0 0 0
331 0 ▶ if ($Tk::CmdLine::Method{$sw} ne 'Flag_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Tk::CmdLine::Method{$sw} ne "Flag_") 0 0 0
332 0 shift @args;
333 }
334 0 shift @args;
335 }
336 } else {
337 0 my $flag_ref = \&Tk::CmdLine::flag;
338 0 my @args = @ARGV;
339 0 ▶ while (@args && $args[0] =~ /^-(\w+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and $args[0] =~ /^-(\w+)$/) 0 0 0
Condition0%0/3
@args and $args[0] =~ /^-(\w+)$/
!ll&&!rl&&r
000
MC/DC0%0/2
@args and $args[0] =~ /^-(\w+)$/
@args $args[0] =~ /^-(\w+)$/
Truth table0%0/3
A and B
A= @argsB= $args[0] =~ /^-(\w+)$/
ABresult
0X0
100
111
340 0 my $sw = $1;
341 0 ▶ return 0 if !$Tk::CmdLine::switch{$sw};
Branch: 1 branch
BranchTrueFalseTotal
unless $Tk::CmdLine::switch{$sw} 0 0 0
342 0 ▶ if ($Tk::CmdLine::switch{$sw} ne $flag_ref) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Tk::CmdLine::switch{$sw} ne $flag_ref) 0 0 0
343 0 shift @args;
344 }
345 0 shift @args;
346 }
347 }
348 0 $res = 1;
349 };
350 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
351 }
352 9 $res;
353 }
354  
355 # Builds a string for Getopt::Long. Arguments are option name and option
356 # type (e.g. '!' or '=s').
357 48 ▶sub _getopt_long_string {
Subroutine _getopt_long_string: called CC=5 SCAR=16.7
358 48 my($option, $type) = @_;
359 48 ▶ $option . (length($option) == 1 &&
Branch: 1 branch
BranchTrueFalseTotal
length $option == 1 && (!defined($type) || $type eq '' || $type eq '!') ? : 1 47 48
Condition66%6/9
length $option == 1 and !defined($type) || $type eq "" || $type eq "!"
!ll&&!rl&&r
4521
not defined $type or $type eq "" or $type eq "!"
l!l&&r!l&&!r
012
not defined $type or $type eq ""
l!l&&r!l&&!r
003
MC/DC50%2/4
length $option == 1 and !defined($type) || $type eq "" || $type eq "!"
length $option == 1 not defined $type $type eq "" $type eq "!"
Truth table60%3/5
A and not(B) or C or D
A= length $option == 1B= not defined $typeC= $type eq ""D= $type eq "!"
ABCDresult
0XXX0
10000
11XX1
101X1
10011
360 (!defined $type || $type eq '' || $type eq '!')
361 ? '' : $type);
362 }
363  
364 # Prints option name with one or two dashes
365 0 ▶sub _getopt_long_dash {
Subroutine _getopt_long_dash: not called CC=2 SCAR=17.9
366 0 my $option = shift;
367 0 ▶ (length($option) == 1 ? '' : '-') . "-$option";
Branch: 1 branch
BranchTrueFalseTotal
length $option == 1 ? : 0 0 0
368 }
369  
370 0 ▶sub usage {
Subroutine usage: not called CC=5 SCAR=34.0
Pod documented
371 0 my $self = shift;
372 0 my $usage = "Usage: $0 [options]\n";
373 0 my $opt;
374 0 foreach $opt ($self->_opt_array) {
375 # The following prints all options as a comma-seperated list
376 # with one or two dashes, depending on the length of the option.
377 # Options are sorted by length.
378 $usage .= join(', ',
379 0 sort { length $a <=> length $b }
380 0 map { _getopt_long_dash($_) }
381 0 ▶ map { ($opt->[OPTTYPE] eq '!' ? "[no]" : "") . $_ }
Branch: 1 branch
BranchTrueFalseTotal
$opt->[1] eq '!' ? : 0 0 0
382 0 ($opt->[OPTNAME], @{$opt->[OPTEXTRA]{'alias'}}));
383 0 $usage .= "\t";
384 0 ▶ $usage .= $opt->[OPTEXTRA]{'help'} if $opt->[OPTEXTRA]{'help'};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->[3]{"help"} 0 0 0
385 0 ▶ $usage .= " (default: " . $opt->[DEFVAL] . ") " if $opt->[DEFVAL];
Branch: 1 branch
BranchTrueFalseTotal
if $opt->[2] 0 0 0
386 0 $usage .= "\n";
387 }
388 0 $usage;
389 }
390  
391 1 ▶sub process_options {
Subroutine process_options: called CC=16 SCAR=44.4
Pod documented
392 1 my($self, $former, $fromgui) = @_;
393 1 my $bag = {};
394 1 foreach my $optdef ($self->_opt_array) {
395 17 my $opt = $optdef->[OPTNAME];
396  
397 17 my $callback;
398 17 ▶ if ($fromgui) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fromgui) 0 17 17
399 0 $callback = $optdef->[OPTEXTRA]{'callback-interactive'};
400 }
401 17 ▶ if (!$callback) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($callback) 17 0 17
402 17 $callback = $optdef->[OPTEXTRA]{'callback'};
403 }
404 17 ▶ if ($callback) {
Branch: 1 branch
BranchTrueFalseTotal
if ($callback) 2 15 17
405 # no warnings here ... it would be too complicated to catch
406 # all undefined values
407 2 my $old_w = $^W;
408 2 local($^W) = 0;
409 # execute callback if value has changed
410 2 ▶ if (!(defined $former
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $former and !exists $former->{$opt} || ${$self->varref($optdef);} eq $former->{$opt}) 2 0 2
Condition16%1/6
defined $former and !exists $former->{$opt} || ${$self->varref($optdef);} eq $former->{$opt}
!ll&&!rl&&r
200
not exists $former->{$opt} or ${$self->varref($optdef);} eq $former->{$opt}
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $former and !exists $former->{$opt} || ${$self->varref($optdef);} eq $former->{$opt}
defined $former not exists $former->{$opt} ${$self->varref($optdef);} eq $former->{$opt}
Truth table25%1/4
A and not(B) or C
A= defined $formerB= not exists $former->{$opt}C= ${$self->varref($optdef);} eq $former->{$opt}
ABCresult
0XX0
1000
11X1
1011
411 && (!exists $former->{$opt}
412 0 || $ {$self->varref($optdef)} eq $former->{$opt}))) {
413 2 local($^W) = $old_w; # fall back to original value
414 2 &$callback(optdef => $optdef, bag => $bag);
415 }
416 }
417 17 ▶ if ($optdef->[OPTEXTRA]{'strict'} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($optdef->[3]{"strict"} and UNIVERSAL::isa($optdef->[3]{"choices"}, "ARRAY")) 0 17 17
Condition33%1/3
$optdef->[3]{"strict"} and UNIVERSAL::isa($optdef->[3]{"choices"}, "ARRAY")
!ll&&!rl&&r
1700
MC/DC0%0/2
$optdef->[3]{"strict"} and UNIVERSAL::isa($optdef->[3]{"choices"}, "ARRAY")
$optdef->[3]{"strict"} UNIVERSAL::isa($optdef->[3]{"choices"}, "ARRAY")
Truth table33%1/3
A and B
A= $optdef->[3]{"strict"}B= UNIVERSAL::isa($optdef->[3]{"choices"}, "ARRAY")
ABresult
0X0
100
111
418 UNIVERSAL::isa($optdef->[OPTEXTRA]{'choices'},'ARRAY')) {
419 # check for valid values (valid are: choices and default value)
420 0 my $v = $ {$self->varref($optdef)};
421 0 my @choices = @{$optdef->[OPTEXTRA]{'choices'}};
422 0 ▶ push(@choices, $optdef->[DEFVAL]) if defined $optdef->[DEFVAL];
Branch: 1 branch
BranchTrueFalseTotal
if defined $optdef->[2] 0 0 0
423 0 my $seen;
424 0 for my $choice (@choices) {
425 0 ▶ my $value = (ref $choice eq 'ARRAY' ? $choice->[1] : $choice);
Branch: 1 branch
BranchTrueFalseTotal
ref $choice eq 'ARRAY' ? : 0 0 0
426 0 ▶ if ($value eq $v) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq $v) 0 0 0
427 0 $seen = 1;
428 0 last;
429 }
430 }
431 0 ▶ if (!$seen) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen) 0 0 0
432 0 ▶ if (defined $former) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $former) { } 0 0 0
433 0 warn "Not allowed: " . $ {$self->varref($optdef)}
434 . " for -$opt. Using old value $former->{$opt}";
435 0 $ {$self->varref($optdef)} = $former->{$opt};
436 } else {
437 die "Not allowed: "
438 0 . $ {$self->varref($optdef)} . " for -$opt\n"
439 . "Allowed is only: " . join(", ", @choices);
440 }
441 }
442 }
443 }
444 }
445  
446 0 ▶sub my_die {
Subroutine my_die: not called CC=12 SCAR=50.5
Pod undocumented
447 0 my($self, $msg, $is_safe) = @_;
448 0 my $use_tk;
449 0 ▶ if ($self->{'useerrordialog'} && defined &Tk::MainWindow::Existing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"useerrordialog"} and defined &Tk::MainWindow::Existing) 0 0 0
Condition0%0/3
$self->{"useerrordialog"} and defined &Tk::MainWindow::Existing
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"useerrordialog"} and defined &Tk::MainWindow::Existing
$self->{"useerrordialog"} defined &Tk::MainWindow::Existing
Truth table0%0/3
A and B
A= $self->{"useerrordialog"}B= defined &Tk::MainWindow::Existing
ABresult
0X0
100
111
450 0 for my $mw (Tk::MainWindow::Existing()) {
451 0 ▶ if (Tk::Exists($mw)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Tk::Exists($mw)) 0 0 0
452 0 $use_tk = $mw;
453 0 last;
454 }
455 }
456 0 ▶ if ($use_tk && !defined $is_safe) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_tk and not defined $is_safe) 0 0 0
Condition0%0/3
$use_tk and not defined $is_safe
!ll&&!rl&&r
000
MC/DC0%0/2
$use_tk and not defined $is_safe
$use_tk not defined $is_safe
Truth table0%0/3
A and not(B)
A= $use_tkB= not defined $is_safe
ABresult
0X0
100
111
457 0 ▶ for(my $i=0; $i<100; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 100) 0 0 0
458 0 my(undef,undef,undef,$subroutine) = caller($i);
459 0 ▶ last if !defined $subroutine;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $subroutine 0 0 0
460 0 ▶ if ($subroutine eq '(eval)') {
Branch: 1 branch
BranchTrueFalseTotal
if ($subroutine eq "(eval)") 0 0 0
461 0 $use_tk = 0;
462 0 last;
463 }
464 }
465 }
466 }
467 0 ▶ if ($use_tk) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_tk) { } 0 0 0
468 0 eval {
469 0 $use_tk->messageBox(-icon => "error",
470 -message => $msg,
471 -title => "Error",
472 );
473 };
474 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
475 0 Carp::croak($msg);
476 }
477 } else {
478 0 Carp::croak($msg);
479 }
480 }
481  
482 # try to work around weird browse entry
483 0 ▶sub _fix_layout {
Subroutine _fix_layout: not called CC=2 SCAR=17.9
484 0 my($self, $frame, $widget, %args) = @_;
485 0 my($w, $real_w);
486 0 ▶ if ($Tk::VERSION < 804) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Tk::VERSION < 804) { } 0 0 0
487 0 my $f = $frame->Frame;
488 0 $f->Label->pack(-side => "left"); # dummy
489 0 $real_w = $f->$widget(%args)->pack(-side => "left", -padx => 1);
490 0 $w = $f;
491 } else {
492 0 $w = $real_w = $frame->$widget(%args);
493 }
494 0 ($w, $real_w);
495 }
496  
497 0 ▶sub _boolean_widget {
Subroutine _boolean_widget: not called CC=1 SCAR=6.9
498 0 my($self, $frame, $opt) = @_;
499 0 ($self->_fix_layout($frame, "Checkbutton",
500 -variable => $self->varref($opt)))[0];
501 }
502  
503 0 ▶sub _boolean_checkmark_widget {
Subroutine _boolean_checkmark_widget: not called CC=1 SCAR=6.9
504 # XXX hangs with Tk800.014?!
505 0 my($self, $frame, $opt) = @_;
506 0 _create_checkmarks($frame);
507 0 ($self->_fix_layout($frame, "Checkbutton",
508 -variable => $self->varref($opt),
509 -image => $CHECKMARK_OFF,
510 -selectimage => $CHECKMARK_ON,
511 -indicatoron => 0,
512 ))[0];
513 }
514  
515 0 ▶sub _number_widget {
Subroutine _number_widget: not called CC=2 SCAR=17.9
516 0 my($self, $frame, $opt) = @_;
517 ($self->_fix_layout($frame, "Scale",
518 -orient => 'horizontal',
519 -from => $opt->[OPTEXTRA]{'range'}[0],
520 0 ▶ -to => $opt->[OPTEXTRA]{'range'}[1],
Branch: 1 branch
BranchTrueFalseTotal
$opt->[1] =~ /f/ ? : 0 0 0
521 -showvalue => 1,
522 -resolution => ($opt->[OPTTYPE] =~ /f/ ? 0 : 1),
523 -variable => $self->varref($opt)
524 ))[0];
525 }
526  
527 0 ▶sub _integer_widget {
Subroutine _integer_widget: not called CC=2 SCAR=17.9
528 0 my($self, $frame, $opt) = @_;
529 0 ▶ if (exists $opt->[OPTEXTRA]{'range'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt->[3]{'range'}) { } 0 0 0
530 0 $self->_number_widget($frame, $opt);
531 } else {
532 0 $self->_string_widget($frame, $opt, -restrict => "=i");
533 }
534 }
535  
536 0 ▶sub _float_widget {
Subroutine _float_widget: not called CC=2 SCAR=17.9
537 0 my($self, $frame, $opt) = @_;
538 0 ▶ if (exists $opt->[OPTEXTRA]{'range'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt->[3]{'range'}) { } 0 0 0
539 0 $self->_number_widget($frame, $opt);
540 } else {
541 0 $self->_string_widget($frame, $opt, -restrict => "=f");
542 }
543 }
544  
545 0 ▶sub _list_widget {
Subroutine _list_widget: not called CC=3 SCAR=24.8
546 0 my($self, $frame, $opt) = @_;
547 0 ▶ if ($opt->[OPTEXTRA]{'strict'} && grep { ref $_ eq 'ARRAY' } @{$opt->[OPTEXTRA]{'choices'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->[3]{'strict'} and grep {ref $_ eq 'ARRAY';} @{$$opt[3]{'choices'};}) { } 0 0 0
Condition0%0/3
$opt->[3]{"strict"} and grep {ref $_ eq "ARRAY";} @{$$opt[3]{"choices"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$opt->[3]{"strict"} and grep {ref $_ eq "ARRAY";} @{$$opt[3]{"choices"};}
$opt->[3]{"strict"} grep {ref $_ eq "ARRAY";} @{$$opt[3]{"choices"};}
Truth table0%0/3
A and B
A= $opt->[3]{"strict"}B= grep {ref $_ eq "ARRAY";} @{$$opt[3]{"choices"};}
ABresult
0X0
100
111
548 0 $self->_optionmenu_widget($frame, $opt);
549 } else {
550 0 $self->_browseentry_widget($frame, $opt);
551 }
552 }
553  
554 0 ▶sub _browseentry_widget {
Subroutine _browseentry_widget: not called CC=5 SCAR=34.0
555 0 my($self, $frame, $opt) = @_;
556 0 require Tk::BrowseEntry;
557 0 my %args = (-variable => $self->varref($opt));
558 0 ▶ if ($opt->[OPTEXTRA]{'strict'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->[3]{"strict"}) 0 0 0
559 0 $args{-state} = "readonly";
560 }
561 0 my $w = $frame->BrowseEntry(%args);
562 0 my %mapping;
563 0 my @optlist = @{$opt->[OPTEXTRA]{'choices'}};
564 0 ▶ unshift @optlist, $opt->[DEFVAL] if defined $opt->[DEFVAL];
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt->[2] 0 0 0
565 0 my $o;
566 my %seen;
567 0 foreach $o (@optlist) {
568 0 ▶ if (!$seen{$o}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen{$o}) 0 0 0
569 0 $w->insert("end", $o);
570 0 $seen{$o}++;
571 }
572 }
573 0 $w;
574 }
575  
576 0 ▶sub _optionmenu_widget {
Subroutine _optionmenu_widget: not called CC=5 SCAR=34.0
577 0 my($self, $frame, $opt) = @_;
578 0 require Tk::Optionmenu;
579 0 my $varref = $self->varref($opt);
580 # Have to remember value, otherwise Optionmenu would overwrite it...
581 0 my $value = $$varref;
582 my %args = (-variable => $varref,
583 0 -options => $opt->[OPTEXTRA]{'choices'},
584 );
585 0 my $w = $frame->Optionmenu(%args);
586 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
587 0 my $label = $value;
588 0 for my $choice (@{ $opt->[OPTEXTRA]{'choices'} }) {
589 0 ▶ if (ref $choice eq 'ARRAY' && $choice->[1] eq $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $choice eq "ARRAY" and $choice->[1] eq $value) 0 0 0
Condition0%0/3
ref $choice eq "ARRAY" and $choice->[1] eq $value
!ll&&!rl&&r
000
MC/DC0%0/2
ref $choice eq "ARRAY" and $choice->[1] eq $value
ref $choice eq "ARRAY" $choice->[1] eq $value
Truth table0%0/3
A and B
A= ref $choice eq "ARRAY"B= $choice->[1] eq $value
ABresult
0X0
100
111
590 0 $label = $choice->[0];
591 }
592 }
593 0 $w->setOption($label, $value);
594 }
595 0 $w;
596 }
597  
598 0 ▶sub _string_widget {
Subroutine _string_widget: not called CC=6 SCAR=37.4
599 0 my($self, $frame, $opt, %args) = @_;
600 0 ▶ if (exists $opt->[OPTEXTRA]{'choices'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt->[3]{'choices'}) { } 0 0 0
601 0 $self->_list_widget($frame, $opt);
602 } else {
603 my($e, $ee) = $self->_fix_layout
604 ($frame, "Entry",
605 (defined $opt->[OPTEXTRA]{'length'}
606 0 ▶ ? (-width => $opt->[OPTEXTRA]{'length'}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->[3]{'length'} ? : 0 0 0
607 -textvariable => $self->varref($opt));
608 0 ▶ if ($args{-restrict} || defined $opt->[OPTEXTRA]{'maxsize'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"-restrict"} or defined $opt->[3]{"maxsize"}) 0 0 0
Condition0%0/3
$args{"-restrict"} or defined $opt->[3]{"maxsize"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"-restrict"} or defined $opt->[3]{"maxsize"}
$args{"-restrict"} defined $opt->[3]{"maxsize"}
Truth table0%0/3
A or B
A= $args{"-restrict"}B= defined $opt->[3]{"maxsize"}
ABresult
1X1
011
000
609 0 ▶ my $restrict_int = sub { $_[0] =~ /^([+-]?\d+|)$/ };
Subroutine __ANON__: not called CC=1 SCAR=6.9
610 0 ▶ my $restrict_float = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
611 0 $_[0] =~ /^(|([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?)$/
612 0 };
613 0 ▶ my $restrict_len = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
614 0 length $_[0] <= $opt->[OPTEXTRA]{'maxsize'}
615 0 };
616 0 eval {
617 $ee->configure
618 (-validate => "all",
619 0 ▶ -vcmd => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
620 ($args{-restrict} ne "=i" || $restrict_int->($_[0]))
621 &&
622 ($args{-restrict} ne "=f" || $restrict_float->($_[0]))
623 &&
624 0 ▶ (!defined $opt->[OPTEXTRA]{'maxsize'} || $restrict_len->($_[0]))
Branch: 1 branch
BranchTrueFalseTotal
$args{"-restrict"} ne "=i" || &$restrict_int($_[0]) and $args{"-restrict"} ne "=f" || &$restrict_float($_[0]) and !defined($opt->[3]{"maxsize"}) || &$restrict_len($_[0]) 0 0 0
Condition0%0/15
($args{'-restrict'} ne '=i' || &$restrict_int($_[0])) && ($args{'-restrict'} ne '=f' || &$restrict_float($_[0])) && (!defined($opt->[3]{'maxsize'}) || &$restrict_len($_[0]))
!ll&&!rl&&r
000
$args{"-restrict"} ne "=i" || &$restrict_int($_[0]) and $args{"-restrict"} ne "=f" || &$restrict_float($_[0])
!ll&&!rl&&r
000
$args{"-restrict"} ne "=i" or &$restrict_int($_[0])
l!l&&r!l&&!r
000
$args{"-restrict"} ne "=f" or &$restrict_float($_[0])
l!l&&r!l&&!r
000
not defined $opt->[3]{"maxsize"} or &$restrict_len($_[0])
l!l&&r!l&&!r
000
MC/DC0%0/6
($args{'-restrict'} ne '=i' || &$restrict_int($_[0])) && ($args{'-restrict'} ne '=f' || &$restrict_float($_[0])) && (!defined($opt->[3]{'maxsize'}) || &$restrict_len($_[0]))
$args{"-restrict"} ne "=i" &$restrict_int($_[0]) $args{"-restrict"} ne "=f" &$restrict_float($_[0]) not defined $opt->[3]{"maxsize"} &$restrict_len($_[0])
Truth table0%0/15
A or B and C or D && not(E) or F
A= $args{"-restrict"} ne "=i"B= &$restrict_int($_[0])C= $args{"-restrict"} ne "=f"D= &$restrict_float($_[0])E= not defined $opt->[3]{"maxsize"}F= &$restrict_len($_[0])
ABCDEFresult
00XXXX0
1X00XX0
0100XX0
1X1X000
1X01000
011X000
0101000
1X1X1X1
1X1X011
1X011X1
1X01011
011X1X1
011X011
01011X1
0101011
625 0 });
626 };
627 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
628 }
629 0 $e;
630 }
631 }
632  
633 0 ▶sub _dir_select {
Subroutine _dir_select: not called CC=5 SCAR=34.0
634 0 my($top, $curr_dir) = @_;
635  
636 0 ▶ if ($top->can("chooseDirectory")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($top->can("chooseDirectory")) 0 0 0
637 0 return $top->chooseDirectory(-initialdir => $curr_dir);
638 }
639  
640 0 ▶ if (eval { require Tk::DirSelect; Tk::DirSelect->VERSION("1.03"); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Tk::DirSelect; "Tk::DirSelect"->VERSION("1.03"); 1 } }) 0 0 0
641 0 return $top->DirSelect(-directory => $curr_dir)->Show;
642 }
643  
644 0 require Tk::DirTree;
645 0 my $t = $top->Toplevel;
646 0 $t->title("Choose directory:");
647 0 my $ok = 0; # flag: "1" means OK, "-1" means cancelled
648  
649 # Create Frame widget before the DirTree widget, so it's always visible
650 # if the window gets resized.
651 0 my $f = $t->Frame->pack(-fill => "x", -side => "bottom");
652  
653 0 my $d;
654 $d = $t->Scrolled('DirTree',
655 -scrollbars => 'osoe',
656 -width => 35,
657 -height => 20,
658 -selectmode => 'browse',
659 -exportselection => 1,
660 0 ▶ -browsecmd => sub { $curr_dir = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
661 0 ▶ if ($^O ne 'MSWin32') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O ne "MSWin32") 0 0 0
662 0 $curr_dir =~ s|^//|/|; # bugfix
663 }
664 },
665  
666 # With this version of -command a double-click will
667 # select the directory
668 0 ▶ -command => sub { $ok = 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
669  
670 # With this version of -command a double-click will
671 # open a directory. Selection is only possible with
672 # the Ok button.
673 #-command => sub { $d->opencmd($_[0]) },
674 0 )->pack(-fill => "both", -expand => 1);
675 # Set the initial directory
676 0 $d->chdir($curr_dir);
677  
678 $f->Button(-text => 'Ok',
679 0 ▶ -command => sub { $ok = 1 })->pack(-side => 'left');
Subroutine __ANON__: not called CC=1 SCAR=6.9
680 $f->Button(-text => 'Cancel',
681 0 ▶ -command => sub { $ok = -1 })->pack(-side => 'left');
Subroutine __ANON__: not called CC=1 SCAR=6.9
682 0 ▶ $t->OnDestroy(sub { $ok = -1 });
Subroutine __ANON__: not called CC=1 SCAR=6.9
683 0 $f->waitVariable(\$ok);
684 0 ▶ $t->destroy if Tk::Exists($t);
Branch: 1 branch
BranchTrueFalseTotal
if Tk::Exists($t) 0 0 0
685 0 ▶ if ($ok == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ok == 1) { } 0 0 0
686 0 $curr_dir;
687 } else {
688 0 undef;
689 }
690 }
691  
692 0 ▶sub _filedialog_widget {
Subroutine _filedialog_widget: not called CC=6 SCAR=37.4
693 0 my($self, $frame, $opt, %args) = @_;
694 0 ▶ my $subtype = (exists $args{'-subtype'} ? $args{'-subtype'} : 'file');
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'-subtype'} ? : 0 0 0
695 0 my $topframe = $frame->Frame;
696 0 my $e;
697 0 ▶ if (exists $opt->[OPTEXTRA]{'choices'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt->[3]{'choices'}) { } 0 0 0
698 0 require Tk::BrowseEntry;
699 0 $e = $topframe->BrowseEntry(-variable => $self->varref($opt));
700 0 my @optlist = @{$opt->[OPTEXTRA]{'choices'}};
701 0 ▶ unshift(@optlist, $opt->[DEFVAL]) if defined $opt->[DEFVAL];
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt->[2] 0 0 0
702 0 my $o;
703 0 foreach $o (@optlist) {
704 0 $e->insert("end", $o);
705 }
706 } else {
707 0 ▶ if (!eval '
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "\n use Tk::PathEntry;\n my \$real_e;\n (\$e, \$real_e) = \$self->_fix_layout(\$topframe, \"PathEntry\",\n -textvariable => \$self->varref(\$opt));\n # XXX Escape is already used for cancelling Tk::Getopt\n \$real_e->bind(\"<\$_>\" => sub { \$real_e->Finish }) for (qw/Return/);\n 1;\n ") 0 0 0
708 use Tk::PathEntry;
709 my $real_e;
710 ($e, $real_e) = $self->_fix_layout($topframe, "PathEntry",
711 -textvariable => $self->varref($opt));
712 # XXX Escape is already used for cancelling Tk::Getopt
713 $real_e->bind("<$_>" => sub { $real_e->Finish }) for (qw/Return/);
714 1;
715 ') {
716 0 ($e) = $self->_fix_layout($topframe, "Entry",
717 -textvariable => $self->varref($opt));
718 }
719 }
720 0 $e->pack(-side => 'left');
721  
722 my $b = $topframe->Button
723 (_get_browse_args($topframe),
724 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=19 SCAR=59.4
725 0 require File::Basename;
726 0 my($fd, $filedialog);
727 0 ▶ if ($Tk::VERSION >= 800) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Tk::VERSION >= 800) { } 0 0 0
728 0 ▶ if ($subtype eq 'dir') {
Branch: 3 branches
BranchTrueFalseTotal
if ($subtype eq 'dir') { } 0 0 0
elsif ($subtype eq 'savefile') { } 0 0 0
elsif ($subtype eq 'file') { } 0 0 0
729 0 $fd = '_dir_select';
730 } elsif ($subtype eq 'savefile') {
731 0 $fd = 'getSaveFile';
732 } elsif ($subtype eq 'file') {
733 0 $fd = 'getOpenFile';
734 } else {
735 0 die "Unknown subtype <$subtype>";
736 }
737 } else {
738 0 $fd = 'FileDialog';
739 0 eval {
740 0 ▶ die "nope" if $subtype eq 'dir';
Branch: 1 branch
BranchTrueFalseTotal
if $subtype eq "dir" 0 0 0
741 0 require Tk::FileDialog;
742 };
743 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
744 0 require Tk::FileSelect;
745 0 $fd = 'FileSelect';
746 }
747 # XXX set FileDialog options via $opt->[3]{'filedialog_opt'}
748 0 ▶ if ($fd eq 'FileDialog') {
Branch: 1 branch
BranchTrueFalseTotal
if ($fd eq 'FileDialog') { } 0 0 0
749 0 $filedialog = $topframe->FileDialog
750 (-Title => 'Select file');
751 } else {
752 0 $filedialog = $topframe->FileSelect;
753 }
754 }
755 0 my($dir, $base, $file);
756 0 my $act_val = $ {$self->varref($opt)};
757 0 ▶ if ($act_val) {
Branch: 1 branch
BranchTrueFalseTotal
if ($act_val) { } 0 0 0
758 0 $dir = File::Basename::dirname($act_val);
759 0 $base = File::Basename::basename($act_val);
760 0 ▶ $dir = '.' if (!-d $dir);
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 0 0
761  
762 0 ▶ if ($fd =~ /^get(Open|Save)File$/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($fd =~ /^get(Open|Save)File$/) { } 0 0 0
elsif ($fd eq '_dir_select') { } 0 0 0
elsif ($fd eq 'FileDialog') { } 0 0 0
763 0 $file = $topframe->$fd(-initialdir => $dir,
764 -initialfile => $base,
765 -title => 'Select file',
766 # XXX erst ab 800.013 (?)
767 # -force => 1,
768 );
769 } elsif ($fd eq '_dir_select') {
770 0 $file = _dir_select($topframe, $dir);
771 } elsif ($fd eq 'FileDialog') {
772 0 $file = $filedialog->Show(-Path => $dir,
773 -File => $base);
774 } else {
775 0 ▶ if ($subtype eq 'dir') {
Branch: 1 branch
BranchTrueFalseTotal
if ($subtype eq 'dir') { } 0 0 0
776 0 $file = $filedialog->Show(-directory => $dir,
777 -verify => [qw(-d)],
778 );
779 } else {
780 0 $file = $filedialog->Show(-directory => $dir);
781 }
782 }
783 } else {
784 0 ▶ if ($fd =~ /^get(Open|Save)File$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($fd =~ /^get(Open|Save)File$/) { } 0 0 0
elsif ($fd eq '_dir_select') { } 0 0 0
785 0 $file = $topframe->$fd(-title => 'Select file');
786 } elsif ($fd eq '_dir_select') {
787 0 require Cwd;
788 0 $file = _dir_select($topframe, Cwd::getcwd());
789 } else {
790 0 ▶ if ($subtype eq 'dir') {
Branch: 1 branch
BranchTrueFalseTotal
if ($subtype eq 'dir') { } 0 0 0
791 0 $file = $filedialog->Show(-verify => [qw(-d)]);
792 } else {
793 0 $file = $filedialog->Show;
794 }
795 }
796 }
797 0 ▶ if (defined $file && $file ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $file and $file ne "") 0 0 0
Condition0%0/3
defined $file and $file ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $file and $file ne ""
defined $file $file ne ""
Truth table0%0/3
A and B
A= defined $fileB= $file ne ""
ABresult
0X0
100
111
798 0 $ {$self->varref($opt)} = $file;
799 }
800 0 });
801 0 $b->pack(-side => 'left');
802 0 $topframe;
803 }
804  
805 0 ▶sub _geometry_widget {
Subroutine _geometry_widget: not called CC=2 SCAR=17.9
806 0 my($self, $frame, $opt) = @_;
807 my($topframe, $e) = $self->_fix_layout
808 ($frame,
809 'Entry',
810 (defined $opt->[OPTEXTRA]{'length'}
811 0 ▶ ? (-width => $opt->[OPTEXTRA]{'length'}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->[3]{'length'} ? : 0 0 0
812 -textvariable => $self->varref($opt));
813 $topframe->Button(_get_curr_geometry_args($topframe),
814 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
815 0 my $mw = $frame->MainWindow;
816 0 $e->delete(0, "end");
817 0 $e->insert("end", $mw->geometry);
818 },
819 0 )->pack(-side => "left");
820 0 $topframe;
821 }
822  
823 0 ▶sub _color_widget {
Subroutine _color_widget: not called CC=3 SCAR=24.8
824 0 return shift->_string_widget(@_);
825  
826 # XXX funktioniert leider nicht...
827 0 my($self, $frame, $opt) = @_;
828 my($topframe, $e) = $self->_fix_layout
829 ($frame,
830 'Entry',
831 (defined $opt->[OPTEXTRA]{'length'}
832 0 ▶ ? (-width => $opt->[OPTEXTRA]{'length'}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->[3]{'length'} ? : 0 0 0
833 -textvariable => $self->varref($opt));
834 0 ▶ if ($frame->can("chooseColor")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frame->can("chooseColor")) 0 0 0
835 $topframe->Button(-text => "...",
836 -padx => 0, -pady => 0,
837 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
838 0 my $color = $frame->chooseColor;
839 # (-initialcolor => $e->get);
840 0 ▶ return unless defined $color;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $color 0 0 0
841 0 $e->delete(0, "end");
842 0 $e->insert("end", $color);
843 },
844 0 )->pack(-side => "left");
845 }
846 0 $topframe;
847 }
848  
849 0 ▶sub _font_widget {
Subroutine _font_widget: not called CC=3 SCAR=24.8
850 0 my($self, $frame, $opt) = @_;
851 my($topframe, $e) = $self->_fix_layout
852 ($frame,
853 'Entry',
854 (defined $opt->[OPTEXTRA]{'length'}
855 0 ▶ ? (-width => $opt->[OPTEXTRA]{'length'}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->[3]{'length'} ? : 0 0 0
856 -textvariable => $self->varref($opt));
857 0 ▶ if (eval {require Tk::Font; require Tk::FontDialog; 1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Tk::Font; require Tk::FontDialog; 1 } }) 0 0 0
858 $topframe->Button(-text => "...",
859 -padx => 0, -pady => 0,
860 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
861 0 my $font = $frame->FontDialog
862 (-initfont => $e->get)->Show;
863 0 ▶ return unless defined $font;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $font 0 0 0
864 0 $e->delete(0, "end");
865 0 $e->insert("end", $font->Pattern);
866 },
867 0 )->pack(-side => "left");
868 }
869 0 $topframe;
870 }
871  
872 # Creates one page of the Notebook widget
873 # Arguments:
874 # $current_page: Frame for drawing
875 # $optnote: Notebook widget
876 # $current_top: title of Notebook page
877 # $optlist: list of options for this Notebook page
878 # $balloon: Balloon widget
879 # $msglist: (optional) list of messages for this Notebook page
880 0 ▶sub _create_page {
Subroutine _create_page: not called CC=34 SCAR=70.8
881 0 my($self, $current_page,
882 $optnote, $current_top, $optlist,
883 $balloon, $msglist) = @_;
884 0 ▶ $current_page = $optnote->{$current_top} if !defined $current_page;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $current_page 0 0 0
885 0 my $opt;
886 0 my $row = -1;
887  
888 0 my $msgobj;
889 0 ▶ if (ref $msglist and
Branch: 1 branch
BranchTrueFalseTotal
if (ref $msglist and exists $msglist->{$current_top} and $msglist->{$current_top} ne "") 0 0 0
Condition0%0/6
ref $msglist and exists $msglist->{$current_top} and $msglist->{$current_top} ne ""
!ll&&!rl&&r
000
ref $msglist and exists $msglist->{$current_top}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $msglist and exists $msglist->{$current_top} and $msglist->{$current_top} ne ""
ref $msglist exists $msglist->{$current_top} $msglist->{$current_top} ne ""
Truth table0%0/4
A and B and C
A= ref $msglistB= exists $msglist->{$current_top}C= $msglist->{$current_top} ne ""
ABCresult
0XX0
10X0
1100
1111
890 exists $msglist->{$current_top} and
891 $msglist->{$current_top} ne "") {
892 0 $row++;
893 0 $msgobj = $current_page->Label(-text => $msglist->{$current_top},
894 -justify => "left",
895 )->grid(-row => $row, -column => 0,
896 -columnspan => 3);
897 }
898  
899 0 foreach $opt (@{$optlist->{$current_top}}) {
900 0 my $f = $current_page;
901 0 $row++;
902 0 ▶ if (_is_separator($opt)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_separator($opt)) 0 0 0
903 0 my $separator = $f->Frame(-height => 2,
904 )->grid(-row => $row,
905 -column => 0,
906 -columnspan => 3,
907 -pady => 3,
908 -padx => 3,
909 -sticky => "ew");
910 0 $separator->configure
911 (-fg => $separator->cget(-bg),
912 -bg => $separator->Darken($separator->cget(-bg), 60));
913 0 next;
914 }
915  
916 0 my $label;
917 my $w;
918 0 ▶ if (exists $opt->[OPTEXTRA]{'label'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt->[3]{'label'}) { } 0 0 0
919 0 $label = $opt->[OPTEXTRA]{'label'};
920 } else {
921 0 $label = $opt->[OPTNAME];
922 0 ▶ if ($label =~ /^(.*)-(.*)$/ && $1 eq $current_top) {
Branch: 1 branch
BranchTrueFalseTotal
if ($label =~ /^(.*)-(.*)$/ and $1 eq $current_top) 0 0 0
Condition0%0/3
$label =~ /^(.*)-(.*)$/ and $1 eq $current_top
!ll&&!rl&&r
000
MC/DC0%0/2
$label =~ /^(.*)-(.*)$/ and $1 eq $current_top
$label =~ /^(.*)-(.*)$/ $1 eq $current_top
Truth table0%0/3
A and B
A= $label =~ /^(.*)-(.*)$/B= $1 eq $current_top
ABresult
0X0
100
111
923 0 $label = $2;
924 }
925 }
926 0 my $lw = $f->Label(-text => $label)->grid(-row => $row, -column => 0,
927 -sticky => 'w');
928 0 ▶ if (exists $opt->[OPTEXTRA]{'widget'}) {
Branch: 5 branches
BranchTrueFalseTotal
if (exists $opt->[3]{'widget'}) { } 0 0 0
elsif (defined $opt->[1] and $opt->[1] eq '!' or $opt->[1] eq '') { } 0 0 0
elsif (defined $opt->[1] and $opt->[1] =~ /i/) { } 0 0 0
elsif (defined $opt->[1] and $opt->[1] =~ /f/) { } 0 0 0
elsif (defined $opt->[1] and $opt->[1] =~ /s/) { } 0 0 0
929 # own widget
930 0 $w = &{$opt->[OPTEXTRA]{'widget'}}($self, $f, $opt);
931 ▶ } elsif (defined $opt->[OPTTYPE] &&
Condition0%0/6
defined $opt->[1] and $opt->[1] eq "!" or $opt->[1] eq ""
l!l&&r!l&&!r
000
defined $opt->[1] and $opt->[1] eq "!"
!ll&&!rl&&r
000
MC/DC0%0/3
defined $opt->[1] and $opt->[1] eq "!" or $opt->[1] eq ""
defined $opt->[1] $opt->[1] eq "!" $opt->[1] eq ""
Truth table0%0/5
A and B or C
A= defined $opt->[1]B= $opt->[1] eq "!"C= $opt->[1] eq ""
ABCresult
11X1
0X11
1011
0X00
1000
932 $opt->[OPTTYPE] eq '!' or $opt->[OPTTYPE] eq '') {
933 0 $w = $self->_boolean_widget($f, $opt); # XXX _checkmark_
934 ▶ } elsif (defined $opt->[OPTTYPE] && $opt->[OPTTYPE] =~ /i/) {
Condition0%0/3
defined $opt->[1] and $opt->[1] =~ /i/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opt->[1] and $opt->[1] =~ /i/
defined $opt->[1] $opt->[1] =~ /i/
Truth table0%0/3
A and B
A= defined $opt->[1]B= $opt->[1] =~ /i/
ABresult
0X0
100
111
935 0 $w = $self->_integer_widget($f, $opt);
936 ▶ } elsif (defined $opt->[OPTTYPE] && $opt->[OPTTYPE] =~ /f/) {
Condition0%0/3
defined $opt->[1] and $opt->[1] =~ /f/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opt->[1] and $opt->[1] =~ /f/
defined $opt->[1] $opt->[1] =~ /f/
Truth table0%0/3
A and B
A= defined $opt->[1]B= $opt->[1] =~ /f/
ABresult
0X0
100
111
937 0 $w = $self->_float_widget($f, $opt);
938 ▶ } elsif (defined $opt->[OPTTYPE] && $opt->[OPTTYPE] =~ /s/) {
Condition0%0/3
defined $opt->[1] and $opt->[1] =~ /s/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opt->[1] and $opt->[1] =~ /s/
defined $opt->[1] $opt->[1] =~ /s/
Truth table0%0/3
A and B
A= defined $opt->[1]B= $opt->[1] =~ /s/
ABresult
0X0
100
111
939 my $subtype = (defined $opt->[OPTEXTRA] &&
940 exists $opt->[OPTEXTRA]{'subtype'} ?
941 0 ▶ $opt->[OPTEXTRA]{'subtype'} : "");
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->[3] && exists $opt->[3]{'subtype'} ? : 0 0 0
Condition0%0/3
defined $opt->[3] and exists $opt->[3]{"subtype"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opt->[3] and exists $opt->[3]{"subtype"}
defined $opt->[3] exists $opt->[3]{"subtype"}
Truth table0%0/3
A and B
A= defined $opt->[3]B= exists $opt->[3]{"subtype"}
ABresult
0X0
100
111
942 0 ▶ if ($subtype eq 'file' ||
Branch: 4 branches
BranchTrueFalseTotal
if ($subtype eq 'file' or $subtype eq 'savefile' or $subtype eq 'dir') { } 0 0 0
elsif ($subtype eq 'geometry') { } 0 0 0
elsif ($subtype eq 'color') { } 0 0 0
elsif ($subtype eq 'font') { } 0 0 0
Condition0%0/6
$subtype eq "file" or $subtype eq "savefile" or $subtype eq "dir"
l!l&&r!l&&!r
000
$subtype eq "file" or $subtype eq "savefile"
l!l&&r!l&&!r
000
MC/DC0%0/3
$subtype eq "file" or $subtype eq "savefile" or $subtype eq "dir"
$subtype eq "file" $subtype eq "savefile" $subtype eq "dir"
Truth table0%0/4
A or B or C
A= $subtype eq "file"B= $subtype eq "savefile"C= $subtype eq "dir"
ABCresult
1XX1
01X1
0011
0000
943 $subtype eq 'savefile' ||
944 $subtype eq 'dir') {
945 0 $w = $self->_filedialog_widget($f, $opt, -subtype => $subtype);
946 } elsif ($subtype eq 'geometry') {
947 0 $w = $self->_geometry_widget($f, $opt);
948 } elsif ($subtype eq 'color') {
949 0 $w = $self->_color_widget($f, $opt);
950 } elsif ($subtype eq 'font') {
951 0 $w = $self->_font_widget($f, $opt);
952 } else {
953 0 $w = $self->_string_widget($f, $opt);
954 }
955 } else {
956 0 warn "Can't generate option editor entry for $opt->[OPTNAME]";
957 }
958 0 ▶ if (defined $w) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $w) 0 0 0
959 0 $w->grid(-row => $row, -column => 1, -sticky => 'w');
960 }
961 0 ▶ if (exists $opt->[OPTEXTRA]{'help'} && defined $balloon) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt->[3]{"help"} and defined $balloon) 0 0 0
Condition0%0/3
exists $opt->[3]{"help"} and defined $balloon
!ll&&!rl&&r
000
MC/DC0%0/2
exists $opt->[3]{"help"} and defined $balloon
exists $opt->[3]{"help"} defined $balloon
Truth table0%0/3
A and B
A= exists $opt->[3]{"help"}B= defined $balloon
ABresult
0X0
100
111
962 0 ▶ $balloon->attach($w, -msg => $opt->[OPTEXTRA]{'help'})
Branch: 1 branch
BranchTrueFalseTotal
if defined $w 0 0 0
963 if defined $w;
964 0 ▶ $balloon->attach($lw, -msg => $opt->[OPTEXTRA]{'help'})
Branch: 1 branch
BranchTrueFalseTotal
if defined $lw 0 0 0
965 if defined $lw;
966 }
967 0 ▶ if (exists $opt->[OPTEXTRA]{'longhelp'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt->[3]{"longhelp"}) 0 0 0
968 $f->Button(-text => '?',
969 -padx => 1,
970 -pady => 1,
971 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
972 my $t = $f->Toplevel
973 0 (-title => $self->{_string}{"helpfor"}
974 . " $label");
975 0 $t->Message(-text => $opt->[OPTEXTRA]{'longhelp'},
976 -justify => 'left')->pack;
977 $t->Button(-text => 'OK',
978 0 ▶ -command => sub { $t->destroy }
Subroutine __ANON__: not called CC=1 SCAR=6.9
979 0 )->pack;
980 0 $t->Popup(-popover => "cursor");
981 0 })->grid(-row => $row, -column => 2, -sticky => 'w');
982 }
983 }
984 0 $current_page->grid('columnconfigure', 3, -weight => 1);
985 0 $current_page->grid('rowconfigure', ++$row, -weight => 1);
986 }
987  
988 0 ▶sub _do_undo {
Subroutine _do_undo: not called CC=7 SCAR=40.3
989 0 my($self, $undo_options) = @_;
990 0 my $opt;
991 0 foreach $opt ($self->_opt_array) {
992 0 ▶ next if $opt->[OPTEXTRA]{'nogui'};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->[3]{"nogui"} 0 0 0
993 0 ▶ if (exists $undo_options->{$opt->[OPTNAME]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$undo_options{$opt->[0]}) 0 0 0
994 0 my $ref = ref $self->varref($opt);
995 0 ▶ if ($ref eq 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if ($ref eq 'ARRAY') { } 0 0 0
elsif ($ref eq 'HASH') { } 0 0 0
elsif ($ref eq 'SCALAR') { } 0 0 0
996 0 my @swap = @ {$self->varref($opt)};
997 0 @ {$self->varref($opt)} = @{ $undo_options->{$opt->[OPTNAME]} };
998 0 @{ $undo_options->{$opt->[OPTNAME]}} = @swap;
999 } elsif ($ref eq 'HASH') {
1000 0 my %swap = % {$self->varref($opt)};
1001 0 % {$self->varref($opt)} = %{ $undo_options->{$opt->[OPTNAME]} };
1002 0 %{ $undo_options->{$opt->[OPTNAME]}} = %swap;
1003 } elsif ($ref eq 'SCALAR') {
1004 0 my $swap = $ {$self->varref($opt)};
1005 0 $ {$self->varref($opt)} = $undo_options->{$opt->[OPTNAME]};
1006 0 $undo_options->{$opt->[OPTNAME]} = $swap;
1007 } else {
1008 0 die "Invalid reference type for option $opt->[OPTNAME]";
1009 }
1010 }
1011 }
1012 }
1013  
1014 0 ▶sub option_dialog {
Subroutine option_dialog: not called CC=1 SCAR=6.9
Pod documented
1015 0 my($self, $top, %a) = @_;
1016 0 my $button_pressed;
1017 0 $a{'-buttonpressed'} = \$button_pressed;
1018 0 $a{'-wait'} = 1;
1019 0 $self->option_editor($top, %a);
1020 0 $button_pressed;
1021 }
1022  
1023 0 ▶sub option_editor {
Subroutine option_editor: not called CC=66 SCAR=83.9
Pod documented
1024 0 my($self, $top, %a) = @_;
1025 0 my $callback = delete $a{'-callback'};
1026 0 my $nosave = delete $a{'-nosave'};
1027 0 my $buttons = delete $a{'-buttons'};
1028 0 ▶ my $toplevel = delete $a{'-toplevel'} || 'Toplevel';
Condition0%0/2
delete $a{'-toplevel'} || 'Toplevel'
l!l
00
MC/DC0%0/1
delete $a{'-toplevel'} || 'Toplevel'
delete $a{'-toplevel'}
Truth table0%0/2
A
A= delete $a{'-toplevel'}
Aresult
11
00
1029 0 my $pack = delete $a{'-pack'};
1030 0 my $transient = delete $a{'-transient'};
1031 0 my $use_statusbar = delete $a{'-statusbar'};
1032 0 my $wait = delete $a{'-wait'};
1033 0 ▶ my $string = delete $a{'-string'} || {};
Condition0%0/2
delete $a{'-string'} || {}
l!l
00
MC/DC0%0/1
delete $a{'-string'} || {}
delete $a{'-string'}
Truth table0%0/2
A
A= delete $a{'-string'}
Aresult
11
00
1034 my $delay_page_create = (exists $a{'-delaypagecreate'}
1035 0 ▶ ? delete $a{'-delaypagecreate'}
Branch: 1 branch
BranchTrueFalseTotal
exists $a{'-delaypagecreate'} ? : 0 0 0
1036 : 1);
1037 0 my $page = delete $a{'-page'};
1038 0 my $button_pressed;
1039 0 ▶ if (exists $a{'-buttonpressed'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $a{'-buttonpressed'}) { } 0 0 0
1040 0 ▶ if (ref $a{'-buttonpressed'} ne "SCALAR") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $a{"-buttonpressed"} ne "SCALAR") 0 0 0
1041 0 die "The value for the -buttonpressed option has to be a SCALAR reference, not a " . ref($a{'-buttonpressed'}) . "\n";
1042 }
1043 0 $button_pressed = delete $a{'-buttonpressed'};
1044 } else {
1045 # dummy
1046 0 $button_pressed = \do { my $dummy };
1047 }
1048 {
1049 0 my %defaults = ('optedit' => 'Option editor',
1050 'undo' => 'Undo',
1051 'lastsaved' => 'Last saved',
1052 'save' => 'Save',
1053 'defaults' => 'Defaults',
1054 'ok' => 'OK',
1055 'apply' => 'Apply',
1056 'cancel' => 'Cancel',
1057 'helpfor' => 'Help for:',
1058 'oksave' => 'OK',
1059 );
1060 0 for my $key (keys %defaults) {
1061 0 ▶ next if exists $string->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $string->{$key} 0 0 0
1062 0 $string->{$key} = $defaults{$key};
1063 }
1064 }
1065 0 $self->{_string} = $string;
1066  
1067 0 ▶ if (defined $page) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $page) 0 0 0
1068 0 $self->{'raised'} = $page;
1069 }
1070  
1071 # store old values for undo
1072 0 my %undo_options;
1073 my $opt;
1074 0 foreach $opt ($self->_opt_array) {
1075 0 ▶ next if $opt->[OPTEXTRA]{'nogui'};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->[3]{"nogui"} 0 0 0
1076 0 my $ref = ref $self->varref($opt);
1077 0 ▶ if ($ref eq 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if ($ref eq 'ARRAY') { } 0 0 0
elsif ($ref eq 'HASH') { } 0 0 0
elsif ($ref eq 'SCALAR') { } 0 0 0
1078 0 @{ $undo_options{$opt->[OPTNAME]} } = @ {$self->varref($opt)};
1079 } elsif ($ref eq 'HASH') {
1080 0 %{ $undo_options{$opt->[OPTNAME]} } = % {$self->varref($opt)};
1081 } elsif ($ref eq 'SCALAR') {
1082 0 $undo_options{$opt->[OPTNAME]} = $ {$self->varref($opt)};
1083 } else {
1084 0 die "Invalid reference type for option $opt->[OPTNAME]";
1085 }
1086 }
1087  
1088 0 require Tk;
1089  
1090 0 my $dont_use_notebook = 1;
1091 0 foreach $opt (@{$self->{'opttable'}}) {
1092 0 ▶ if (ref $opt ne 'ARRAY') { # found header
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opt ne "ARRAY") 0 0 0
1093 0 undef $dont_use_notebook;
1094 0 last;
1095 }
1096 }
1097 0 ▶ if (!$dont_use_notebook) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dont_use_notebook) 0 0 0
1098 0 eval { require Tk::NoteBook };
1099 0 ▶ $dont_use_notebook = 1 if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1100 }
1101  
1102 0 my $dont_use_balloon;
1103 0 eval { require Tk::Balloon };
1104 0 ▶ $dont_use_balloon = 1 if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1105  
1106 0 my $cmd = '$top->' . $toplevel . '(%a)';
1107 0 my $opt_editor = eval $cmd;
1108 0 ▶ die "$@ while evaling $cmd" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1109 0 ▶ $opt_editor->transient($transient) if $transient;
Branch: 1 branch
BranchTrueFalseTotal
if $transient 0 0 0
1110 0 eval { $opt_editor->configure(-title => $string->{optedit}) };
1111  
1112 0 ▶ my $opt_notebook = ($dont_use_notebook ?
Branch: 1 branch
BranchTrueFalseTotal
$dont_use_notebook ? : 0 0 0
1113 $opt_editor->Frame :
1114 $opt_editor->NoteBook(-ipadx => 6, -ipady => 6));
1115 0 $self->{Frame} = $opt_notebook;
1116  
1117 0 my($statusbar, $balloon);
1118 0 ▶ if (!$dont_use_balloon) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dont_use_balloon) 0 0 0
1119 0 ▶ if ($use_statusbar) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_statusbar) 0 0 0
1120 0 $statusbar = $opt_editor->Label;
1121 }
1122 0 ▶ $balloon = $opt_notebook->Balloon($use_statusbar
Branch: 1 branch
BranchTrueFalseTotal
$use_statusbar ? : 0 0 0
1123 ? (-statusbar => $statusbar)
1124 : ());
1125 }
1126  
1127 0 my $optlist = {};
1128 0 my $msglist = {};
1129 0 my $current_top;
1130 0 ▶ if ($dont_use_notebook) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dont_use_notebook) { } 0 0 0
1131 0 $current_top = $string->{'optedit'};
1132 0 foreach $opt ($self->_opt_array) {
1133 0 push(@{$optlist->{$current_top}}, $opt)
1134 0 ▶ if !$opt->[OPTEXTRA]{'nogui'};
Branch: 1 branch
BranchTrueFalseTotal
unless $opt->[3]{"nogui"} 0 0 0
1135 }
1136 # XXX message missing
1137 0 $self->_create_page($opt_notebook, undef, $current_top,
1138 $optlist, $balloon);
1139 } else {
1140 0 my @opttable = @{$self->{'opttable'}};
1141 0 ▶ unshift(@opttable, $string->{'optedit'})
Branch: 1 branch
BranchTrueFalseTotal
if ref $opttable[0] eq "ARRAY" 0 0 0
1142 if ref $opttable[OPTNAME] eq 'ARRAY'; # put head
1143  
1144 0 my $page_create_page;
1145 0 foreach $opt (@opttable) {
1146 0 ▶ if (ref $opt ne 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $opt ne 'ARRAY') { } 0 0 0
elsif ($opt->[0] eq '' and not _is_separator($opt)) { } 0 0 0
1147 0 ▶ if (!$delay_page_create && $page_create_page) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $delay_page_create and $page_create_page) 0 0 0
Condition0%0/3
not $delay_page_create and $page_create_page
!ll&&!rl&&r
000
MC/DC0%0/2
not $delay_page_create and $page_create_page
not $delay_page_create $page_create_page
Truth table0%0/3
not(A) and B
A= not $delay_page_createB= $page_create_page
ABresult
0X0
100
111
1148 0 $page_create_page->();
1149 0 undef $page_create_page;
1150 }
1151  
1152 0 my $label = $opt;
1153 0 $current_top = lc($label);
1154 0 my $c = $current_top;
1155 0 $optlist->{$c} = [];
1156 0 $msglist->{$c} = "";
1157 0 my $page_f;
1158 0 ▶ $page_create_page = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1159 0 $self->_create_page
1160 ($page_f,
1161 $opt_notebook, $c,
1162 $optlist, $balloon, $msglist);
1163 0 };
1164 0 ▶ $page_f = $opt_notebook->add
Branch: 1 branch
BranchTrueFalseTotal
$delay_page_create ? : 0 0 0
1165 ($c,
1166 -label => $label,
1167 -anchor => 'w',
1168 ($delay_page_create?(-createcmd => $page_create_page):()),
1169 );
1170 ▶ } elsif ($opt->[OPTNAME] eq '' && !_is_separator($opt)) {
Condition0%0/3
$opt->[0] eq "" and not _is_separator($opt)
!ll&&!rl&&r
000
MC/DC0%0/2
$opt->[0] eq "" and not _is_separator($opt)
$opt->[0] eq "" not _is_separator($opt)
Truth table0%0/3
A and not(B)
A= $opt->[0] eq ""B= not _is_separator($opt)
ABresult
0X0
100
111
1171 0 $msglist->{$current_top} = $opt->[DEFVAL];
1172 } else {
1173 0 push @{$optlist->{$current_top}}, $opt
1174 0 ▶ if !$opt->[OPTEXTRA]{'nogui'};
Branch: 1 branch
BranchTrueFalseTotal
unless $opt->[3]{"nogui"} 0 0 0
1175 }
1176 }
1177 0 ▶ if (!$delay_page_create && $page_create_page) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $delay_page_create and $page_create_page) 0 0 0
Condition0%0/3
not $delay_page_create and $page_create_page
!ll&&!rl&&r
000
MC/DC0%0/2
not $delay_page_create and $page_create_page
not $delay_page_create $page_create_page
Truth table0%0/3
not(A) and B
A= not $delay_page_createB= $page_create_page
ABresult
0X0
100
111
1178 0 $page_create_page->();
1179 0 undef $page_create_page;
1180 }
1181  
1182 }
1183  
1184 0 require Tk::Tiler;
1185 0 my $f;
1186 $f = $opt_editor->Tiler
1187 (-rows => 1,
1188 -columns => 1,
1189 0 ▶ -yscrollcommand => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
1190 0 my $bw = $f->cget(-highlightthickness);
1191 0 ▶ return if (!$f->{Sw});
Branch: 1 branch
BranchTrueFalseTotal
unless $f->{"Sw"} 0 0 0
1192 0 my $nenner = int(($f->Width-2*$bw)/$f->{Sw});
1193 0 ▶ return if (!$nenner);
Branch: 1 branch
BranchTrueFalseTotal
unless $nenner 0 0 0
1194 0 my $rows = @{$f->{Slaves}}/$nenner;
1195 0 ▶ return if (!$rows or !int($rows));
Branch: 1 branch
BranchTrueFalseTotal
unless $rows and int $rows 0 0 0
Condition0%0/3
$rows and int $rows
!ll&&!rl&&r
000
MC/DC0%0/2
$rows and int $rows
$rows int $rows
Truth table0%0/3
A and B
A= $rowsB= int $rows
ABresult
0X0
100
111
1196 0 ▶ if ($rows/int($rows) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rows / int($rows) > 0) 0 0 0
1197 0 $rows = int($rows)+1;
1198 }
1199 $f->GeometryRequest($f->Width,
1200 0 2*$bw+$rows*$f->{Sh});
1201 0 });
1202 0 ▶ $f->bind('<Configure>' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1203 0 ▶ if ($f->y + $f->height > $opt_editor->height) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f->y + $f->height > $opt_editor->height) 0 0 0
1204 0 $opt_editor->geometry($opt_editor->width .
1205 "x" .
1206 ($f->height+$f->y));
1207 }
1208 0 });
1209 0 my @tiler_b;
1210  
1211 my %allowed_button;
1212 0 ▶ if ($buttons) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buttons) 0 0 0
1213 0 ▶ if (ref $buttons ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $buttons ne 'ARRAY') { } 0 0 0
1214 0 undef $buttons;
1215 } else {
1216 0 %allowed_button = map { ($_ => 1) } @$buttons;
1217 }
1218 }
1219  
1220 0 ▶ if (!$buttons || $allowed_button{'ok'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $buttons or $allowed_button{"ok"}) 0 0 0
Condition0%0/3
not $buttons or $allowed_button{"ok"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $buttons or $allowed_button{"ok"}
not $buttons $allowed_button{"ok"}
Truth table0%0/3
not(A) or B
A= not $buttonsB= $allowed_button{"ok"}
ABresult
1X1
011
000
1221 my $ok_button
1222 = $f->Button(-text => $string->{'ok'},
1223 -underline => 0,
1224 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1225 0 $self->process_options(\%undo_options, 1);
1226 0 ▶ if (!$dont_use_notebook) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dont_use_notebook) 0 0 0
1227 0 $self->{'raised'} = $opt_notebook->raised();
1228 }
1229 0 $opt_editor->destroy;
1230 0 $$button_pressed = 'ok';
1231 }
1232 0 );
1233 0 push @tiler_b, $ok_button;
1234 }
1235  
1236 0 ▶ if ($allowed_button{'oksave'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($allowed_button{"oksave"}) 0 0 0
1237 my $ok_button
1238 = $f->Button(-text => $string->{'oksave'},
1239 -underline => 0,
1240 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1241 0 $top->Busy;
1242 0 eval {
1243 0 $self->save_options;
1244 0 $self->process_options(\%undo_options, 1);
1245 0 ▶ if (!$dont_use_notebook) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dont_use_notebook) 0 0 0
1246 0 $self->{'raised'} = $opt_notebook->raised();
1247 }
1248 };
1249 0 my $err = $@;
1250 0 $top->Unbusy;
1251 0 ▶ if ($err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err) 0 0 0
1252 0 $self->my_die($err, 'safe');
1253 }
1254 0 $opt_editor->destroy;
1255 0 $$button_pressed = 'ok';
1256 }
1257 0 );
1258 0 push @tiler_b, $ok_button;
1259 }
1260  
1261 0 ▶ if (!$buttons || $allowed_button{'apply'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $buttons or $allowed_button{"apply"}) 0 0 0
Condition0%0/3
not $buttons or $allowed_button{"apply"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $buttons or $allowed_button{"apply"}
not $buttons $allowed_button{"apply"}
Truth table0%0/3
not(A) or B
A= not $buttonsB= $allowed_button{"apply"}
ABresult
1X1
011
000
1262 my $apply_button
1263 = $f->Button(-text => $string->{'apply'},
1264 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1265 0 $self->process_options(\%undo_options, 1);
1266 }
1267 0 );
1268 0 push @tiler_b, $apply_button;
1269 }
1270
1271 0 my $cancel_button;
1272 0 ▶ if (!$buttons || $allowed_button{'cancel'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $buttons or $allowed_button{"cancel"}) 0 0 0
Condition0%0/3
not $buttons or $allowed_button{"cancel"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $buttons or $allowed_button{"cancel"}
not $buttons $allowed_button{"cancel"}
Truth table0%0/3
not(A) or B
A= not $buttonsB= $allowed_button{"cancel"}
ABresult
1X1
011
000
1273 $cancel_button
1274 = $f->Button(-text => $string->{'cancel'},
1275 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1276 0 $self->_do_undo(\%undo_options);
1277 0 ▶ if (!$dont_use_notebook) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dont_use_notebook) 0 0 0
1278 0 $self->{'raised'} = $opt_notebook->raised();
1279 }
1280 0 $opt_editor->destroy;
1281 0 $$button_pressed = 'cancel';
1282 }
1283 0 );
1284 0 push @tiler_b, $cancel_button;
1285 }
1286  
1287 0 ▶ if (!$buttons || $allowed_button{'undo'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $buttons or $allowed_button{"undo"}) 0 0 0
Condition0%0/3
not $buttons or $allowed_button{"undo"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $buttons or $allowed_button{"undo"}
not $buttons $allowed_button{"undo"}
Truth table0%0/3
not(A) or B
A= not $buttonsB= $allowed_button{"undo"}
ABresult
1X1
011
000
1288 my $undo_button
1289 = $f->Button(-text => $string->{'undo'},
1290 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1291 0 $self->_do_undo(\%undo_options);
1292 }
1293 0 );
1294 0 push @tiler_b, $undo_button;
1295 }
1296  
1297 0 ▶ if ($self->{'filename'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"filename"}) 0 0 0
1298 0 ▶ if (!$buttons || $allowed_button{'lastsaved'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $buttons or $allowed_button{"lastsaved"}) 0 0 0
Condition0%0/3
not $buttons or $allowed_button{"lastsaved"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $buttons or $allowed_button{"lastsaved"}
not $buttons $allowed_button{"lastsaved"}
Truth table0%0/3
not(A) or B
A= not $buttonsB= $allowed_button{"lastsaved"}
ABresult
1X1
011
000
1299 my $lastsaved_button
1300 = $f->Button(-text => $string->{'lastsaved'},
1301 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1302 0 $top->Busy;
1303 0 $self->load_options;
1304 0 $top->Unbusy;
1305 }
1306 0 );
1307 0 push @tiler_b, $lastsaved_button;
1308 }
1309  
1310 0 ▶ if (!$nosave && (!$buttons || $allowed_button{'save'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $nosave and !$buttons || $allowed_button{"save"}) 0 0 0
Condition0%0/6
not $nosave and !$buttons || $allowed_button{"save"}
!ll&&!rl&&r
000
not $buttons or $allowed_button{"save"}
l!l&&r!l&&!r
000
MC/DC0%0/3
not $nosave and !$buttons || $allowed_button{"save"}
not $nosave not $buttons $allowed_button{"save"}
Truth table0%0/4
not(A) and not(B) or C
A= not $nosaveB= not $buttonsC= $allowed_button{"save"}
ABCresult
0XX0
1000
11X1
1011
1311 0 my $save_button;
1312 $save_button
1313 = $f->Button(-text => $string->{'save'},
1314 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1315 0 $top->Busy;
1316 0 eval { $self->save_options };
1317 0 ▶ if ($@ =~ /No Data::Dumper/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ =~ /No Data::Dumper/) 0 0 0
1318 0 $save_button->configure(-state => 'disabled');
1319 }
1320 0 $top->Unbusy;
1321 }
1322 0 );
1323 0 push @tiler_b, $save_button;
1324 }
1325 }
1326  
1327 0 ▶ if (!$buttons || $allowed_button{'defaults'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $buttons or $allowed_button{"defaults"}) 0 0 0
Condition0%0/3
not $buttons or $allowed_button{"defaults"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $buttons or $allowed_button{"defaults"}
not $buttons $allowed_button{"defaults"}
Truth table0%0/3
not(A) or B
A= not $buttonsB= $allowed_button{"defaults"}
ABresult
1X1
011
000
1328 my $def_button
1329 = $f->Button(-text => $string->{'defaults'},
1330 0 ▶ -command => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1331 0 $self->set_defaults;
1332 }
1333 0 );
1334 0 push @tiler_b, $def_button;
1335 }
1336  
1337 0 $f->Manage(@tiler_b);
1338  
1339 0 ▶ &$callback($self, $opt_editor) if $callback;
Branch: 1 branch
BranchTrueFalseTotal
if $callback 0 0 0
1340  
1341 0 ▶ if (!$dont_use_notebook && defined $self->{'raised'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $dont_use_notebook and defined $self->{"raised"}) 0 0 0
Condition0%0/3
not $dont_use_notebook and defined $self->{"raised"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $dont_use_notebook and defined $self->{"raised"}
not $dont_use_notebook defined $self->{"raised"}
Truth table0%0/3
not(A) and B
A= not $dont_use_notebookB= defined $self->{"raised"}
ABresult
0X0
100
111
1342 0 $self->raise_page($self->{'raised'});
1343 }
1344  
1345 0 ▶ $opt_editor->bind('<Escape>' => sub { $cancel_button->invoke });
Subroutine __ANON__: not called CC=1 SCAR=6.9
1346  
1347 0 $f->pack(-fill => 'x', -side => "bottom");
1348 0 $opt_notebook->pack(-expand => 1, -fill => 'both');
1349 0 ▶ if (defined $statusbar) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $statusbar) 0 0 0
1350 0 $statusbar->pack(-fill => 'x', -anchor => 'w');
1351 }
1352  
1353 0 ▶ if ($opt_editor->can('Popup')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt_editor->can("Popup")) 0 0 0
1354 0 $opt_editor->withdraw;
1355 0 $opt_editor->Popup;
1356 }
1357 0 ▶ if ($wait) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wait) 0 0 0
1358 0 ▶ if ($pack) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pack) 0 0 0
1359 0 $opt_editor->pack(@$pack);
1360 }
1361 0 my $wait_var = 1;
1362 0 ▶ $opt_editor->OnDestroy(sub { undef $wait_var });
Subroutine __ANON__: not called CC=1 SCAR=6.9
1363 0 ▶ $opt_editor->waitVisibility unless $opt_editor->ismapped;
Branch: 1 branch
BranchTrueFalseTotal
unless $opt_editor->ismapped 0 0 0
1364 0 $opt_editor->grab;
1365 0 $opt_editor->waitVariable(\$wait_var);
1366 }
1367  
1368 0 $opt_editor;
1369 }
1370  
1371 0 ▶sub _create_checkmarks {
Subroutine _create_checkmarks: not called CC=3 SCAR=24.8
1372 0 my $w = shift;
1373  
1374 0 ▶ $CHECKMARK_ON = $w->Photo(-data => <<EOF)
Branch: 1 branch
BranchTrueFalseTotal
unless $Tk::Getopt::CHECKMARK_ON 0 0 0
1375 R0lGODdhDgAOAIAAAP///1FR+ywAAAAADgAOAAACM4SPFplGIXy0yDQK4aNFZAIlhI8QEQkUACKC
1376 4EMERFAI3yg+wb+ICEQjMeGjRWQahfCxAAA7
1377 EOF
1378 unless $CHECKMARK_ON;
1379 0 ▶ $CHECKMARK_OFF = $w->Photo(-data => <<EOF)
Branch: 1 branch
BranchTrueFalseTotal
unless $Tk::Getopt::CHECKMARK_OFF 0 0 0
1380 R0lGODdhDgAOAIAAAAAAAP///ywAAAAADgAOAAACDYyPqcvtD6OctNqrSAEAOw==
1381 EOF
1382 unless $CHECKMARK_OFF;
1383 }
1384  
1385 0 ▶sub _get_browse_args {
Subroutine _get_browse_args: not called CC=4 SCAR=30.0
1386 0 my $w = shift;
1387 0 ▶ if (!defined $FILE_IMAGE) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Tk::Getopt::FILE_IMAGE) 0 0 0
1388 0 require Tk::Pixmap;
1389 0 $FILE_IMAGE = $w->Pixmap(-file => Tk->findINC("openfolder.xpm"));
1390 0 ▶ $FILE_IMAGE = 0 if (!$FILE_IMAGE);
Branch: 1 branch
BranchTrueFalseTotal
unless $Tk::Getopt::FILE_IMAGE 0 0 0
1391 }
1392 0 ▶ if ($FILE_IMAGE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Tk::Getopt::FILE_IMAGE) { } 0 0 0
1393 0 (-image => $FILE_IMAGE);
1394 } else {
1395 0 (-text => "Browse...");
1396 }
1397 }
1398  
1399 0 ▶sub _get_curr_geometry_args {
Subroutine _get_curr_geometry_args: not called CC=4 SCAR=30.0
1400 0 my $w = shift;
1401 0 ▶ if (!defined $CURR_GEOMETRY_IMAGE) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Tk::Getopt::CURR_GEOMETRY_IMAGE) 0 0 0
1402 0 require Tk::Photo;
1403 0 $CURR_GEOMETRY_IMAGE = $w->Photo(-file => Tk->findINC("win.xbm"));
1404 0 ▶ $CURR_GEOMETRY_IMAGE = 0 if (!$CURR_GEOMETRY_IMAGE);
Branch: 1 branch
BranchTrueFalseTotal
unless $Tk::Getopt::CURR_GEOMETRY_IMAGE 0 0 0
1405 }
1406 0 ▶ if ($CURR_GEOMETRY_IMAGE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Tk::Getopt::CURR_GEOMETRY_IMAGE) { } 0 0 0
1407 0 (-image => $CURR_GEOMETRY_IMAGE);
1408 } else {
1409 0 (-text => "Geom.");
1410 }
1411 }
1412  
1413 0 ▶sub raise_page {
Subroutine raise_page: not called CC=1 SCAR=6.9
Pod undocumented
1414 0 my($self, $page) = @_;
1415 0 my $opt_notebook = $self->{Frame};
1416 0 $page = lc $page; # always lowercase in NoteBook internals
1417 0 $opt_notebook->raise($page);
1418 }
1419  
1420 5 1;
1421  
1422 __END__
↑ Summary