Choose/Screen.pm

filter: Statementstmt 41.9% 34 / 81 Branchbran 5.0% 1 / 20 Conditioncond 11.1% 2 / 18 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 30.0% 6 / 20 Podpod 0.0% 0 / 14 totaltotal 26.2% 43 / 164 CC 17 SCAR 44.2
CC
17
Cov
31%
get_term_size
210.0
BEGIN
6.2
down
2.0
CRAP 83.2
« Choose/Opt/Mouse.pm ↑ Summary Choose/Opt/Search.pm »
1 package Term::Choose::Screen;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use 5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '1.783';
8  
9 3 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our @EXPORT_OK = qw(
12 down up left right clear_screen clear_to_end_of_screen clear_to_end_of_line reverse_video bold underline
13 bold_underline normal show_cursor hide_cursor bell get_term_size
14 );
15  
16 3 our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
17  
18 3 ▶use Term::Choose::Constants qw( WIDTH_CURSOR TERM_READKEY );
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 my (
22 3 @up, @down, @right, @left,
23 $reverse, $bold, $underline, $bold_underline, $normal,
24 $bell,
25 $clear_screen, $clr_to_bot, $clr_to_eol,
26 $show_cursor, $hide_cursor,
27 );
28  
29  
30 3 ▶BEGIN {
Subroutine BEGIN: called CC=4 SCAR=18.2
31 3 ▶ if ( $^O eq 'MSWin32' || $ENV{TC_ANSI_ESCAPES} || ! qx(tput cuu 2>/dev/null) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32' or $ENV{'TC_ANSI_ESCAPES'} or not `tput cuu 2>/dev/null`) { } 0 3 3
Condition33%2/6
$^O eq "MSWin32" or $ENV{"TC_ANSI_ESCAPES"} or not `tput cuu 2>/dev/null`
l!l&&r!l&&!r
003
$^O eq "MSWin32" or $ENV{"TC_ANSI_ESCAPES"}
l!l&&r!l&&!r
003
MC/DC0%0/3
$^O eq "MSWin32" or $ENV{"TC_ANSI_ESCAPES"} or not `tput cuu 2>/dev/null`
$^O eq "MSWin32" $ENV{"TC_ANSI_ESCAPES"} not `tput cuu 2>/dev/null`
Truth table25%1/4
A or B or not(C)
A= $^O eq "MSWin32"B= $ENV{"TC_ANSI_ESCAPES"}C= not `tput cuu 2>/dev/null`
ABCresult
1XX1
01X1
0011
0000
32 0 @up = ( "\e[", "A" );
33 0 @down = ( "\e[", "B" );
34 0 @right = ( "\e[", "C" );
35 0 @left = ( "\e[", "D" );
36  
37 0 $reverse = "\e[7m";
38 0 $bold = "\e[1m";
39 0 $underline = "\e[4m";
40 0 $normal = "\e[0m";
41  
42 0 $bell = "\a";
43  
44 0 $clear_screen = "\e[H\e[J";
45 0 $clr_to_bot = "\e[0J";
46 0 $clr_to_eol = "\e[K";
47  
48 0 $show_cursor = "\e[?25h";
49 0 $hide_cursor = "\e[?25l";
50 }
51 else {
52 3 @up = split( '107', qx(tput cuu 107) );
53 3 @down = split( '107', qx(tput cud 107) );
54 3 @right = split( '107', qx(tput cuf 107) );
55 3 @left = split( '107', qx(tput cub 107) );
56  
57 3 $reverse = qx(tput rev);
58 3 $bold = qx(tput bold);
59 3 $underline = qx(tput smul);
60 3 $normal = qx(tput sgr0);
61  
62 3 $bell = qx(tput bel);
63  
64 3 $clear_screen = qx(tput clear);
65 3 $clr_to_bot = qx(tput ed);
66 3 $clr_to_eol = qx(tput el);
67  
68 3 $show_cursor = qx(tput cnorm);
69 3 $hide_cursor = qx(tput civis);
70 }
71 }
72  
73  
74 0 ▶sub down { return $down[0] . $_[0] . $down[1] }
Subroutine down: not called CC=1 SCAR=6.9
Pod undocumented
75 0 ▶sub up { return $up[0] . $_[0] . $up[1] }
Subroutine up: not called CC=1 SCAR=6.9
Pod undocumented
76 0 ▶sub left { return $left[0] . $_[0] . $left[1] }
Subroutine left: not called CC=1 SCAR=6.9
Pod undocumented
77 0 ▶sub right { return $right[0] . $_[0] . $right[1] }
Subroutine right: not called CC=1 SCAR=6.9
Pod undocumented
78  
79 0 ▶sub clear_screen { return $clear_screen }
Subroutine clear_screen: not called CC=1 SCAR=6.9
Pod undocumented
80 0 ▶sub clear_to_end_of_screen { return $clr_to_bot }
Subroutine clear_to_end_of_screen: not called CC=1 SCAR=6.9
Pod undocumented
81 0 ▶sub clear_to_end_of_line { return $clr_to_eol }
Subroutine clear_to_end_of_line: not called CC=1 SCAR=6.9
Pod undocumented
82  
83 0 ▶sub reverse_video { return $reverse }
Subroutine reverse_video: not called CC=1 SCAR=6.9
Pod undocumented
84 #sub bold { return $bold }
85 #sub underline { return $underline }
86 0 ▶sub bold_underline { return $bold . $underline }
Subroutine bold_underline: not called CC=1 SCAR=6.9
Pod undocumented
87 0 ▶sub normal { return $normal }
Subroutine normal: not called CC=1 SCAR=6.9
Pod undocumented
88  
89 0 ▶sub show_cursor { return $show_cursor }
Subroutine show_cursor: not called CC=1 SCAR=6.9
Pod undocumented
90 0 ▶sub hide_cursor { return $hide_cursor }
Subroutine hide_cursor: not called CC=1 SCAR=6.9
Pod undocumented
91  
92 0 ▶sub bell { return $bell }
Subroutine bell: not called CC=1 SCAR=6.9
Pod undocumented
93  
94  
95 0 ▶sub get_term_size {
Subroutine get_term_size: not called CC=14 SCAR=53.5
Pod undocumented
96 0 my ( $width, $height, $error );
97 0 ▶ if ( TERM_READKEY ) {
Branch: 2 branches
BranchTrueFalseTotal
if (&TERM_READKEY()) { } 0 0 0
elsif ($^O eq 'MSWin32') { } 0 0 0
98 0 ( $width, $height ) = ( Term::ReadKey::GetTerminalSize() )[ 0, 1 ];
99 0 ▶ if ( ! $width || ! $height ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($width and $height) 0 0 0
Condition0%0/3
$width and $height
!ll&&!rl&&r
000
MC/DC0%0/2
$width and $height
$width $height
Truth table0%0/3
A and B
A= $widthB= $height
ABresult
0X0
100
111
100 0 $error = "get_term_size - Term::ReadKey::GetTerminalSize:";
101 }
102 }
103 elsif( $^O eq 'MSWin32' ) {
104 0 require Win32::Console;
105 0 ( $width, $height ) = Win32::Console->new()->Size();
106 0 ▶ if ( ! $width || ! $height ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($width and $height) 0 0 0
Condition0%0/3
$width and $height
!ll&&!rl&&r
000
MC/DC0%0/2
$width and $height
$width $height
Truth table0%0/3
A and B
A= $widthB= $height
ABresult
0X0
100
111
107 0 $error = "get_term_size - Win32::Console Size:";
108 }
109 }
110 else {
111 0 my $size = qx(stty size);
112 0 ▶ if ( defined $size && $size =~ /(\d+)\s(\d+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $size and $size =~ /(\d+)\s(\d+)/) 0 0 0
Condition0%0/3
defined $size and $size =~ /(\d+)\s(\d+)/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $size and $size =~ /(\d+)\s(\d+)/
defined $size $size =~ /(\d+)\s(\d+)/
Truth table0%0/3
A and B
A= defined $sizeB= $size =~ /(\d+)\s(\d+)/
ABresult
0X0
100
111
113 0 $width = $2;
114 0 $height = $1;
115 }
116 0 ▶ if ( ! $width || ! $height ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($width and $height) 0 0 0
Condition0%0/3
$width and $height
!ll&&!rl&&r
000
MC/DC0%0/2
$width and $height
$width $height
Truth table0%0/3
A and B
A= $widthB= $height
ABresult
0X0
100
111
117 0 $error = "get_term_size - stty size:";
118 }
119 }
120 0 ▶ if ( $error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
121 0 ▶ $error .= " No term width!" if ! $width;
Branch: 1 branch
BranchTrueFalseTotal
unless $width 0 0 0
122 0 ▶ $error .= " No term height!" if ! $height;
Branch: 1 branch
BranchTrueFalseTotal
unless $height 0 0 0
123 0 die $error;
124 }
125 0 return $width - WIDTH_CURSOR, $height;
126 }
127  
128  
129  
130  
131  
132 3 1;
« Choose/Opt/Mouse.pm ↑ Summary Choose/Opt/Search.pm »