Completion/_termsize.pm

filter: Statementstmt 61.2% 19 / 31 Branchbran 41.6% 5 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 60.0% 3 / 5 Podpod 100% 1 / 1 totaltotal 53.7% 29 / 54 CC 5 SCAR 13.4
CC
5
Cov
54%
__ANON__
6.0
get_term_size
4.6
__ANON__
2.0
CRAP 3.8
« Completion/_POSIX.pm ↑ Summary Completion/Path.pm »
1 package Term::Completion::_termsize;
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 1 my $get_term_size;
6
7 # try to load Term::Size
8 1 ▶if( eval { require Term::Size; 1; } && !$@) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Term::Size; 1 } } and not $@) { } 0 1 1
Condition33%1/3
eval { do { require Term::Size; 1 } } and not $@
!ll&&!rl&&r
100
MC/DC0%0/2
eval { do { require Term::Size; 1 } } and not $@
eval { do { require Term::Size; 1 } } not $@
Truth table33%1/3
A and not(B)
A= eval { do { require Term::Size; 1 } }B= not $@
ABresult
0X0
100
111
9 $get_term_size = sub {
10 0 ▶ return Term::Size::chars($_[0]);
Subroutine __ANON__: not called CC=1 SCAR=6.9
11 0 };
12 }
13 # we try poor man's ioctl - stolen from perlfaq8
14 else {
15 1 eval { require 'sys/ioctl.ph'; 1; };
16 1 eval { require 'sys/termios.ph'; 1; };
17 1 ▶ if(defined &TIOCGWINSZ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined &Term::Completion::_termsize::TIOCGWINSZ) { } 0 1 1
18 $get_term_size = sub {
19 0 ▶ my $winsize = '';
Subroutine __ANON__: not called CC=2 SCAR=17.9
20 0 ▶ unless(ioctl($_[0], &TIOCGWINSZ, $winsize) =~ /^0/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ioctl($_[0], &TIOCGWINSZ, $winsize) =~ /^0/) 0 0 0
21 0 return;
22 }
23 0 my ($row, $col, $xpixel, $ypixel) = unpack('S4', $winsize);
24 0 return($col,$row);
25 0 };
26 } else {
27 # we don't have a way to get the terminal size
28 $get_term_size = sub {
29 1 ▶ return (undef, undef);
Subroutine __ANON__: called CC=1 SCAR=0.0
30 }
31 1 }
32 }
33
34 sub get_term_size
35 {
36 1 ▶ my __PACKAGE__ $this = shift;
Subroutine get_term_size: called CC=4 SCAR=15.2
Pod documented
37 1 my ($c,$r);
38 1 ▶ if(defined $get_term_size) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $get_term_size) { } 1 0 1
39 1 ($c,$r) = &$get_term_size($this->{out});
40 } else {
41 ($c,$r) = ($Term::Completion::DEFAULTS{columns},
42 0 $Term::Completion::DEFAULTS{rows});
43 }
44 return (
45 (defined $this->{columns} ? $this->{columns} : $c),
46 1 ▶ (defined $this->{rows} ? $this->{rows} : $r)
Branch: 2 branches
BranchTrueFalseTotal
defined $this->{'columns'} ? : 0 1 1
defined $this->{'rows'} ? : 0 1 1
47 );
48 }
49
50 1 1;
51
52 __END__
« Completion/_POSIX.pm ↑ Summary Completion/Path.pm »