lib/TUI/Drivers/Display.pm

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