lib/TUI/Drivers/Display.pm

filter: Statementstmt 56.8% 58 / 102 Branchbran 20.0% 2 / 10 Conditioncond 33.3% 9 / 27 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 100% 17 / 17 Podpod 100% 8 / 8 totaltotal 51.6% 94 / 182 CC 15 SCAR 23.6
CC
15
Cov
50%
updateIntlChars
40.8
__ANON__
2.5
getCursorType
2.3
CRAP 10.6
« lib/TUI/Outline/Outline.pm ↑ Summary lib/TUI/Validate/StringLookupValidator.pm »
1 package TUI::Drivers::Display;
2 # ABSTRACT: low-level display abstraction
3
4 136 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 136 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 136 our $VERSION = '2.000003';
8 136 $VERSION =~ tr/_//d;
9 136 our $AUTHORITY = 'cpan:BRICKPOOL';
10
11 136 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 136 our @EXPORT = qw(
13 TDisplay
14 );
15
16 136 ▶use Devel::StrictMode;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 136 ▶use PerlX::Assert::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 136 ▶use Scalar::Util qw( looks_like_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
19
20 136 ▶use TUI::Drivers::HardwareInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
21
22 sub TDisplay() { __PACKAGE__ }
23
24 135 ▶my $getCodePage = sub {
Subroutine __ANON__: called CC=2 SCAR=9.2
25 135 ▶ if ( $^O eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 135 135
26 0 require Win32;
27 0 return Win32::GetConsoleOutputCP();
28 }
29 135 return 437;
30 136 };
31
32 135 ▶INIT {
Subroutine INIT: called CC=1 SCAR=0.0
33 135 TDisplay->updateIntlChars()
34 }
35
36 135 ▶sub updateIntlChars { # void ($class)
Subroutine updateIntlChars: called CC=7 SCAR=37.1
Pod documented
37 135 my $class = shift;
38 135 ▶ assert ( $class and !ref $class );
Condition33%1/3
$class && !ref($class)
!ll&&!rl&&r
00135
MC/DC0%0/2
$class && !ref($class)
$class !ref($class)
Truth table33%1/3
A && not(B)
A= $classB= !ref($class)
ABresult
0X0
100
111
39 135 my $cp = &$getCodePage();
40 # Some 8-bit code pages are supported directly and
41 # preserve the original CP437 frame characters when using UTF-8 with
42 # Windows Virtual Terminal (VT) mode (CP65001).
43 return
44 135 ▶ if $cp =~ /^(437|720|737|775|850|852|855|857|858|859|860|861|862|863|865)$/
Branch: 1 branch
BranchTrueFalseTotal
if $cp =~ /^(437|720|737|775|850|852|855|857|858|859|860|861|862|863|865)$/ or $cp =~ /^(866|869|65001)$/ 135 0 135
Condition33%1/3
$cp =~ /^(437|720|737|775|850|852|855|857|858|859|860|861|862|863|865)$/ or $cp =~ /^(866|869|65001)$/
l!l&&r!l&&!r
13500
MC/DC0%0/2
$cp =~ /^(437|720|737|775|850|852|855|857|858|859|860|861|862|863|865)$/ or $cp =~ /^(866|869|65001)$/
$cp =~ /^(437|720|737|775|850|852|855|857|858|859|860|861|862|863|865)$/ $cp =~ /^(866|869|65001)$/
Truth table33%1/3
A or B
A= $cp =~ /^(437|720|737|775|850|852|855|857|858|859|860|861|862|863|865)$/B= $cp =~ /^(866|869|65001)$/
ABresult
1X1
011
000
45 || $cp =~ /^(866|869|65001)$/;
46
47 0 require TUI::Views::Frame;
48 0 require TUI::Views::ScrollBar;
49 0 require TUI::Menus::MenuBox;
50 0 require TUI::App::DeskTop;
51 0 ▶ if ( $cp == 874 ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($cp == 874) { } 0 0 0
elsif ($cp =~ /^(1250|1251|1252|1253|1254|1256|1257|1258)$/) { } 0 0 0
elsif ($cp == 1255) { } 0 0 0
52 0 $TUI::Views::Frame::frameChars = " ' :.+ '\x96+.+++ ' |.+ '\x97+.++ ";
53 0 $TUI::Views::Frame::closeIcon = "[~x~]";
54 0 $TUI::Views::Frame::zoomIcon = "[~+~]";
55 0 $TUI::Views::Frame::unZoomIcon = "[~-~]";
56 0 $TUI::Views::Frame::dragIcon = "~\x97'~";
57 0 $TUI::Views::ScrollBar::vChars = "^v # ";
58 0 $TUI::Views::ScrollBar::hChars = "<> # ";
59 0 $TUI::Menus::MenuBox::frameChars = " .-. '-' | | +-+ ";
60 0 $TUI::App::DeskTop::defaultBkgrnd = ":";
61 }
62 elsif ( $cp =~ /^(1250|1251|1252|1253|1254|1256|1257|1258)$/ ) {
63 0 $TUI::Views::Frame::frameChars = " ' \xA6.+ '\x96+.+++ ' |.+ '\x97+.+"
64 . "+ ";
65 0 $TUI::Views::Frame::closeIcon = "[~\xD7~]";
66 0 $TUI::Views::Frame::zoomIcon = "[~+~]";
67 0 $TUI::Views::Frame::unZoomIcon = "[~\xB1~]";
68 0 $TUI::Views::Frame::dragIcon = "~\x97'~";
69 0 $TUI::Views::ScrollBar::vChars = "^v \xA4 ";
70 0 $TUI::Views::ScrollBar::hChars = "<> \xA4 ";
71 0 $TUI::Menus::MenuBox::frameChars = " .\x97. '\x97' | | +\x97+ ";
72 0 $TUI::App::DeskTop::defaultBkgrnd = ":";
73 }
74 elsif ( $cp == 1255 ) {
75 0 $TUI::Views::Frame::frameChars = " ' :.+ '\x96+.+++ ' |.+ '\x97+.++ ";
76 0 $TUI::Views::Frame::closeIcon = "[~x~]";
77 0 $TUI::Views::Frame::zoomIcon = "[~+~]";
78 0 $TUI::Views::Frame::unZoomIcon = "[~\xB1~]";
79 0 $TUI::Views::Frame::dragIcon = "~\x97'~";
80 0 $TUI::Views::ScrollBar::vChars = "^v # ";
81 0 $TUI::Views::ScrollBar::hChars = "<> # ";
82 0 $TUI::Menus::MenuBox::frameChars = " .\x97. '\x97' | | +\x97+ ";
83 0 $TUI::App::DeskTop::defaultBkgrnd = ":";
84 }
85 else {
86 0 $TUI::Views::Frame::frameChars = " ' :.+ '-+.+++ ' |.+ '=+.++ ";
87 0 $TUI::Views::Frame::closeIcon = "[~x~]";
88 0 $TUI::Views::Frame::zoomIcon = "[~+~]";
89 0 $TUI::Views::Frame::unZoomIcon = "[~-~]";
90 0 $TUI::Views::Frame::dragIcon = "~-'~";
91 0 $TUI::Views::ScrollBar::vChars = "^v # ";
92 0 $TUI::Views::ScrollBar::hChars = "<> # ";
93 0 $TUI::Menus::MenuBox::frameChars = " .-. '-' | | +-+ ";
94 0 $TUI::App::DeskTop::defaultBkgrnd = ":";
95 }
96 0 return;
97 } #/ sub updateIntlChars
98
99 7 ▶sub getCursorType { # $size ($class)
Subroutine getCursorType: called CC=2 SCAR=8.1
Pod documented
100 7 ▶ assert ( $_[0] and !ref $_[0] );
Condition33%1/3
$_[0] && !ref($_[0])
!ll&&!rl&&r
007
MC/DC0%0/2
$_[0] && !ref($_[0])
$_[0] !ref($_[0])
Truth table33%1/3
A && not(B)
A= $_[0]B= !ref($_[0])
ABresult
0X0
100
111
101 7 return THardwareInfo->getCaretSize();
102 }
103
104 7 ▶sub setCursorType { # void ($class, $ct)
Subroutine setCursorType: called CC=2 SCAR=7.2
Pod documented
105 7 my ( $class, $ct ) = @_;
106 7 ▶ assert ( $class and !ref $class );
Condition33%1/3
$class && !ref($class)
!ll&&!rl&&r
007
MC/DC0%0/2
$class && !ref($class)
$class !ref($class)
Truth table33%1/3
A && not(B)
A= $classB= !ref($class)
ABresult
0X0
100
111
107 7 assert ( looks_like_number $ct );
108 7 THardwareInfo->setCaretSize( $ct & 0xff );
109 7 return;
110 }
111
112 4 ▶sub clearScreen { # void ($class, $w, $h)
Subroutine clearScreen: called CC=2 SCAR=7.1
Pod documented
113 4 my ( $class, $w, $h ) = @_;
114 4 ▶ assert ( $class and !ref $class );
Condition33%1/3
$class && !ref($class)
!ll&&!rl&&r
004
MC/DC0%0/2
$class && !ref($class)
$class !ref($class)
Truth table33%1/3
A && not(B)
A= $classB= !ref($class)
ABresult
0X0
100
111
115 4 assert ( looks_like_number $w );
116 4 assert ( looks_like_number $h );
117 4 THardwareInfo->clearScreen( $w, $h );
118 4 return;
119 }
120
121 6 ▶sub getRows { # $rows ($class)
Subroutine getRows: called CC=2 SCAR=8.1
Pod documented
122 6 ▶ assert ( $_[0] and !ref $_[0] );
Condition33%1/3
$_[0] && !ref($_[0])
!ll&&!rl&&r
006
MC/DC0%0/2
$_[0] && !ref($_[0])
$_[0] !ref($_[0])
Truth table33%1/3
A && not(B)
A= $_[0]B= !ref($_[0])
ABresult
0X0
100
111
123 6 return THardwareInfo->getScreenRows();
124 }
125
126 6 ▶sub getCols { # $cols ($class)
Subroutine getCols: called CC=2 SCAR=8.1
Pod documented
127 6 ▶ assert ( $_[0] and !ref $_[0] );
Condition33%1/3
$_[0] && !ref($_[0])
!ll&&!rl&&r
006
MC/DC0%0/2
$_[0] && !ref($_[0])
$_[0] !ref($_[0])
Truth table33%1/3
A && not(B)
A= $_[0]B= !ref($_[0])
ABresult
0X0
100
111
128 6 return THardwareInfo->getScreenCols();
129 }
130
131 143 ▶sub getCrtMode { # void ($class)
Subroutine getCrtMode: called CC=2 SCAR=8.1
Pod documented
132 143 ▶ assert ( $_[0] and !ref $_[0] );
Condition33%1/3
$_[0] && !ref($_[0])
!ll&&!rl&&r
00143
MC/DC0%0/2
$_[0] && !ref($_[0])
$_[0] !ref($_[0])
Truth table33%1/3
A && not(B)
A= $_[0]B= !ref($_[0])
ABresult
0X0
100
111
133 143 return THardwareInfo->getScreenMode();
134 }
135
136 2 ▶sub setCrtMode { # void ($class, $mode)
Subroutine setCrtMode: called CC=2 SCAR=7.2
Pod documented
137 2 my ( $class, $mode ) = @_;
138 2 ▶ assert ( $class and !ref $class );
Condition33%1/3
$class && !ref($class)
!ll&&!rl&&r
002
MC/DC0%0/2
$class && !ref($class)
$class !ref($class)
Truth table33%1/3
A && not(B)
A= $classB= !ref($class)
ABresult
0X0
100
111
139 2 assert ( looks_like_number $mode );
140 2 THardwareInfo->setScreenMode( $mode );
141 2 return;
142 }
143
144 136 1
145
146 __END__
« lib/TUI/Outline/Outline.pm ↑ Summary lib/TUI/Validate/StringLookupValidator.pm »