lib/TUI/Drivers/Event.pm

filter: Statementstmt 81.3% 358 / 440 Branchbran 66.3% 61 / 92 Conditioncond 42.3% 22 / 52 MC/DCmcdc 15.1% 5 / 33 Subroutinesub 85.8% 109 / 127 Podpod 43.7% 7 / 16 totaltotal 73.9% 562 / 760 CC 67 SCAR 14.8
CC
67
Cov
76%
clone
30.0
assign
20.0
getKeyEvent
13.9
CRAP 4.4
« lib/TUI/Gadgets/HeapView.pm ↑ Summary lib/TUI/ColorSel/ColorGroup.pm »
1 package TUI::Drivers::Event;
2 # ABSTRACT: Unified event structure for input handling
3
4 139 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 139 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 139 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 139 our $VERSION = '2.000003';
9 139 $VERSION =~ tr/_//d;
10 139 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 139 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 139 our @EXPORT = qw(
14 TEvent
15 new_TEvent
16 );
17
18 139 ▶use PerlX::Assert::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 139 ▶use Hash::Util qw( lock_hash );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 139 ▶use Scalar::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 blessed
22 looks_like_number
23 139 );
24 139 ▶use Tie::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
25
26 139 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 :evXXXX
28 kbAltShift
29 kbAltSpace
30 kbDel
31 kbCtrlShift
32 kbCtrlDel
33 kbShift
34 kbShiftDel
35 kbIns
36 kbCtrlIns
37 kbShiftIns
38 139 );
39 139 ▶use TUI::Drivers::HardwareInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
40
41 # The following code section represents the 'MouseEventType' structure used for
42 # the 'THWMouse' and 'TEvent' class.
43 139 package MouseEventType {
44 139 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 139 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
46
47 139 ▶ use Devel::StrictMode;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 139 ▶ use PerlX::Assert::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 139 ▶ use if STRICT => 'Hash::Util';
Subroutine BEGIN: called CC=1 SCAR=0.0
50 139 ▶ use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
51 139 ▶ use TUI::Objects::Point;
Subroutine BEGIN: called CC=1 SCAR=0.0
52
53 139 ▶ our %HAS; BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
54 %HAS = (
55 176 ▶ eventFlags => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
56 176 ▶ controlKeyState => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
57 176 ▶ buttons => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
58 176 ▶ where => sub { TPoint->new() },
Subroutine __ANON__: called CC=1 SCAR=0.0
59 139 );
60 }
61
62 181 ▶ sub new { # $obj (%args)
Subroutine new: called CC=8 SCAR=21.1
Pod undocumented
63 139 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
64 181 my ( $class, %args ) = @_;
65 181 ▶ assert ( $class and !ref $class );
Condition33%1/3
$class && !ref($class)
!ll&&!rl&&r
00181
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
66 my $self = {
67 eventFlags => 0+ $args{eventFlags} || $HAS{eventFlags}->(),
68 controlKeyState => 0+ $args{controlKeyState} || $HAS{controlKeyState}->(),
69 181 ▶ buttons => 0+ $args{buttons} || $HAS{buttons}->(),
Condition66%6/9
0 + $args{'eventFlags'} || $MouseEventType::HAS{'eventFlags'}->()
l!l&&r!l&&!r
50176
0 + $args{'controlKeyState'} || $MouseEventType::HAS{'controlKeyState'}->()
l!l&&r!l&&!r
50176
0 + $args{'buttons'} || $MouseEventType::HAS{'buttons'}->()
l!l&&r!l&&!r
50176
MC/DC50%1/2
0 + $args{'eventFlags'} || $MouseEventType::HAS{'eventFlags'}->()
0 + $args{'eventFlags'} $MouseEventType::HAS{'eventFlags'}->()
MC/DC50%1/2
0 + $args{'controlKeyState'} || $MouseEventType::HAS{'controlKeyState'}->()
0 + $args{'controlKeyState'} $MouseEventType::HAS{'controlKeyState'}->()
MC/DC50%1/2
0 + $args{'buttons'} || $MouseEventType::HAS{'buttons'}->()
0 + $args{'buttons'} $MouseEventType::HAS{'buttons'}->()
Truth table66%2/3
A || B
A= 0 + $args{'eventFlags'}B= $MouseEventType::HAS{'eventFlags'}->()
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= 0 + $args{'controlKeyState'}B= $MouseEventType::HAS{'controlKeyState'}->()
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= 0 + $args{'buttons'}B= $MouseEventType::HAS{'buttons'}->()
ABresult
1X1
011
000
70 };
71 181 my $type = ref $args{where};
72 181 ▶ if ( $type eq 'HASH' || $type eq TPoint ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'HASH' or $type eq 'TUI::Objects::Point') { } 3 178 181
elsif ($type eq 'ARRAY') { } 2 176 178
Condition100%3/3
$type eq "HASH" or $type eq "TUI::Objects::Point"
l!l&&r!l&&!r
21178
MC/DC100%2/2
$type eq "HASH" or $type eq "TUI::Objects::Point"
$type eq "HASH" $type eq "TUI::Objects::Point"
Truth table100%3/3
A or B
A= $type eq "HASH"B= $type eq "TUI::Objects::Point"
ABresult
1X1
011
000
73 $self->{where} = TPoint->new(
74 x => 0+ $args{where}{x},
75 y => 0+ $args{where}{y},
76 3 );
77 }
78 elsif ( $type eq 'ARRAY' ) {
79 $self->{where} = TPoint->new(
80 x => 0+ $args{where}->[0],
81 2 y => 0+ $args{where}->[1],
82 );
83 }
84 else {
85 176 $self->{where} = $HAS{where}->();
86 }
87 181 bless $self, $class;
88 181 Hash::Util::lock_keys( %$self ) if STRICT;
89 181 return $self;
90 } #/ sub MouseEventType::new
91
92 10 ▶ sub clone { # $obj ()
Subroutine clone: called CC=2 SCAR=7.0
Pod undocumented
93 10 my ( $self ) = @_;
94 10 assert ( @_ == 1 );
95 10 assert ( blessed $self );
96 10 ▶ my $class = ref $self || return;
Condition50%1/2
ref $self || (return)
l!l
100
MC/DC0%0/1
ref $self || (return)
ref $self
Truth table50%1/2
A
A= ref $self
Aresult
11
00
97 10 my $clone = bless { %$self }, $class;
98 10 Hash::Util::lock_keys( %$clone ) if STRICT;
99 10 $clone->{where} = $self->{where}->clone();
100 10 return $clone;
101 }
102
103 139 $INC{"MouseEventType.pm"} = 1;
104 }
105
106 # The following code section represents the 'CharScanType' structure used for
107 # the 'KeyDownEvent' class.
108 139 package CharScanType {
109 139 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
110 139 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
111
112 139 ▶ use PerlX::Assert::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
113 139 ▶ use Hash::Util qw( lock_hash );
Subroutine BEGIN: called CC=1 SCAR=0.0
114 139 ▶ use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
115 139 ▶ use Tie::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
116
117 our %HAS = (
118 11 ▶ scanCode => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
119 139 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
120 11 my ( $this, $code ) = @_;
121 11 ▶ $$this = ($$this & 0xff) + (0+$code << 8) if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 5 6 11
122 11 $$this >> 8;
123 },
124 9 ▶ charCode => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
125 139 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
126 9 my ( $this, $code ) = @_;
127 9 ▶ $$this = ($$this & ~0xff) + (0+$code & 0xff) if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 4 5 9
128 9 $$this & 0xff;
129 },
130 139 );
131 139 lock_hash( %HAS );
132
133 139 ▶ use parent 'Tie::Hash';
Subroutine BEGIN: called CC=1 SCAR=0.0
134
135 10 ▶ sub new { # $obj (%args)
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
136 10 my ( $class, %args ) = @_;
137 10 ▶ assert ( $class and !ref $class );
Condition33%1/3
$class && !ref($class)
!ll&&!rl&&r
0010
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
138 10 my $self = bless {}, $class;
139 10 tie %$self, $class;
140 6 map { $self->{$_} = $args{$_} }
141 10 grep { exists $args{$_} }
142 keys %HAS;
143 10 return $self;
144 }
145
146 0 ▶ sub clone { # $obj ()
Subroutine clone: not called CC=2 SCAR=17.9
Pod undocumented
147 0 my ( $self ) = @_;
148 0 assert ( @_ == 1 );
149 0 assert ( blessed $self );
150 0 ▶ my $class = ref $self || return;
Condition0%0/2
ref $self || (return)
l!l
00
MC/DC0%0/1
ref $self || (return)
ref $self
Truth table0%0/2
A
A= ref $self
Aresult
11
00
151 0 my $clone = bless {}, $class;
152 0 tie %$clone, $class;
153 0 map { $clone->{$_} = $self->{$_} } keys %HAS;
154 0 return $clone;
155 }
156
157 10 ▶ sub TIEHASH { bless \( my $data ), $_[0] }
Subroutine TIEHASH: called CC=1 SCAR=0.0
158 10 ▶ sub STORE { $HAS{ $_[1] }->( $_[0], $_[2] ) }
Subroutine STORE: called CC=1 SCAR=0.0
159 11 ▶ sub FETCH { $HAS{ $_[1] }->( $_[0] ) }
Subroutine FETCH: called CC=1 SCAR=0.0
160 3 ▶ sub FIRSTKEY { my $a = scalar keys %HAS; each %HAS }
Subroutine FIRSTKEY: called CC=1 SCAR=0.0
161 6 ▶ sub NEXTKEY { each %HAS }
Subroutine NEXTKEY: called CC=1 SCAR=0.0
162 7 ▶ sub EXISTS { exists $HAS{ $_[1] } }
Subroutine EXISTS: called CC=1 SCAR=0.0
163 1 ▶ sub DELETE { delete $HAS{ $_[1] } } # raise an exception
Subroutine DELETE: called CC=1 SCAR=0.0
164 1 ▶ sub CLEAR { %HAS = () } # raise an exception
Subroutine CLEAR: called CC=1 SCAR=0.0
165 1 ▶ sub SCALAR { scalar keys %HAS } # return number of elements (> 5.24)
Subroutine SCALAR: called CC=1 SCAR=0.0
166
167 139 $INC{"CharScanType.pm"} = 1;
168 }
169
170 # The following code section represents the 'KeyDownEvent' structure used for
171 # the 'TEvent' class.
172 139 package KeyDownEvent {
173 139 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
174 139 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
175
176 139 ▶ use PerlX::Assert::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
177 139 ▶ use Hash::Util qw( lock_hash );
Subroutine BEGIN: called CC=1 SCAR=0.0
178 139 ▶ use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
179 139 ▶ use Tie::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
180
181 our %HAS = (
182 19 ▶ keyCode => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
183 139 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
184 19 my ( $this, $code ) = @_;
185 19 my $obj = tied %{ $this->[0] };
186 19 ▶ $$obj = 0+$code if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 8 11 19
187 19 $$obj;
188 },
189 6 ▶ charScan => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
190 6 my ( $this, $obj ) = @_;
191 6 ▶ $this->[0] = $obj if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 1 5 6
192 6 $this->[0];
193 },
194 16 ▶ controlKeyState => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
195 139 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
196 16 my ( $this, $state ) = @_;
197 16 ▶ $this->[1] = 0+$state if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 7 9 16
198 16 $this->[1];
199 },
200 139 );
201 139 lock_hash( %HAS );
202
203 139 ▶ use parent 'Tie::Hash';
Subroutine BEGIN: called CC=1 SCAR=0.0
204
205 4 ▶ sub new { # $obj (%args)
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
206 4 my ( $class, %args ) = @_;
207 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
208 4 my $self = bless {}, $class;
209 4 tie %$self, $class;
210 6 map { $self->{$_} = $args{$_} }
211 4 grep { exists $args{$_} }
212 keys %HAS;
213 4 return $self;
214 }
215
216 0 ▶ sub clone { # $obj ()
Subroutine clone: not called CC=2 SCAR=17.9
Pod undocumented
217 0 my ( $self ) = @_;
218 0 assert ( @_ == 1 );
219 0 assert ( blessed $self );
220 0 ▶ my $class = ref $self || return;
Condition0%0/2
ref $self || (return)
l!l
00
MC/DC0%0/1
ref $self || (return)
ref $self
Truth table0%0/2
A
A= ref $self
Aresult
11
00
221 0 my $clone = bless {}, $class;
222 0 tie %$clone, $class;
223 0 $clone->{keyCode} = $self->{keyCode};
224 0 $clone->{controlKeyState} = $self->{controlKeyState};
225 0 return $clone;
226 }
227
228 4 ▶ sub TIEHASH { bless [ CharScanType->new(), 0 ], $_[0] }
Subroutine TIEHASH: called CC=1 SCAR=0.0
229 16 ▶ sub STORE { $HAS{ $_[1] }->( $_[0], $_[2] ) }
Subroutine STORE: called CC=1 SCAR=0.0
230 25 ▶ sub FETCH { $HAS{ $_[1] }->( $_[0] ) }
Subroutine FETCH: called CC=1 SCAR=0.0
231 3 ▶ sub FIRSTKEY { my $a = scalar keys %HAS; each %HAS }
Subroutine FIRSTKEY: called CC=1 SCAR=0.0
232 9 ▶ sub NEXTKEY { each %HAS }
Subroutine NEXTKEY: called CC=1 SCAR=0.0
233 6 ▶ sub EXISTS { exists $HAS{ $_[1] } }
Subroutine EXISTS: called CC=1 SCAR=0.0
234 0 ▶ sub DELETE { delete $HAS{ $_[1] } } # raise an exception
Subroutine DELETE: not called CC=1 SCAR=6.9
235 1 ▶ sub CLEAR { %HAS = () } # raise an exception
Subroutine CLEAR: called CC=1 SCAR=0.0
236 0 ▶ sub SCALAR { scalar keys %HAS } # return number of elements (> 5.24)
Subroutine SCALAR: not called CC=1 SCAR=6.9
237
238 139 $INC{"KeyDownEvent.pm"} = 1;
239 }
240
241 # The following code section represents the 'MessageEvent' structure used for
242 # the 'TEvent' class.
243 139 package MessageEvent {
244 139 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
245 139 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
246
247 139 ▶ use PerlX::Assert::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
248 139 ▶ use Hash::Util qw( lock_hash );
Subroutine BEGIN: called CC=1 SCAR=0.0
249 139 ▶ use Hash::Util::FieldHash qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
250 id
251 id_2obj
252 register
253 139 );
254 139 ▶ use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
255 139 ▶ use Tie::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
256
257 our %HAS = (
258 8 ▶ command => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
259 139 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
260 8 my ( $this, $cmd ) = @_;
261 8 ▶ $this->[0] = 0+$cmd if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 4 4 8
262 8 $this->[0];
263 },
264 9 ▶ infoPtr => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
265 9 my ( $this, $info ) = @_;
266 9 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 4 5 9
267 4 $this->[1] = id $info;
268 4 ▶ register $info if ref $info;
Branch: 1 branch
BranchTrueFalseTotal
if ref $info 2 2 4
269 }
270 9 ▶ $this->[1] ? id_2obj $this->[1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$this->[1] ? : 9 0 9
271 },
272 8 ▶ infoLong => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
273 139 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
274 8 my ( $this, $info ) = @_;
275 8 ▶ $this->[1] = 0+$info & 0xffff_ffff if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 4 4 8
276 8 0+$this->[1] & 0xffff_ffff;
277 },
278 7 ▶ infoWord => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
279 139 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
280 7 my ( $this, $info ) = @_;
281 7 ▶ $this->[1] = 0+$info & 0xffff if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 3 4 7
282 7 0+$this->[1] & 0xffff;
283 },
284 9 ▶ infoInt => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
285 139 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
286 9 my ( $this, $info ) = @_;
287 9 ▶ $this->[1] = 0+$info if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 1 8 9
288 9 0+$this->[1];
289 },
290 6 ▶ infoByte => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
291 139 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
292 6 my ( $this, $info ) = @_;
293 6 ▶ $this->[1] = 0+$info & 0xff if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 2 4 6
294 6 0+$this->[1] & 0xff;
295 },
296 6 ▶ infoChar => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
297 139 ▶ no warnings qw( uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
298 6 my ( $this, $info ) = @_;
299 6 ▶ $this->[1] = ord $_[1] if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 2 4 6
300 6 chr( 0+$this->[1] );
301 },
302 139 );
303 139 lock_hash( %HAS );
304
305 139 ▶ use parent 'Tie::Hash';
Subroutine BEGIN: called CC=1 SCAR=0.0
306
307 8 ▶ sub new { # $obj (%args)
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
308 8 my ( $class, %args ) = @_;
309 8 ▶ assert ( $class and !ref $class );
Condition33%1/3
$class && !ref($class)
!ll&&!rl&&r
008
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
310 8 my $self = bless {}, $class;
311 8 tie %$self, $class;
312 11 map { $self->{$_} = $args{$_} }
313 8 grep { exists $args{$_} }
314 keys %HAS;
315 8 return $self;
316 } #/ sub new
317
318 0 ▶ sub clone { # $obj ()
Subroutine clone: not called CC=2 SCAR=17.9
Pod undocumented
319 0 my ( $self ) = @_;
320 0 assert ( @_ == 1 );
321 0 assert ( blessed $self );
322 0 ▶ my $class = ref $self || return;
Condition0%0/2
ref $self || (return)
l!l
00
MC/DC0%0/1
ref $self || (return)
ref $self
Truth table0%0/2
A
A= ref $self
Aresult
11
00
323 0 my $clone = bless {}, $class;
324 0 tie %$clone, $class;
325 0 $clone->{command} = $self->{command};
326 0 $clone->{infoInt} = $self->{infoInt};
327 0 return $clone;
328 }
329
330 8 ▶ sub TIEHASH { bless [ 0, 0 ], $_[0] }
Subroutine TIEHASH: called CC=1 SCAR=0.0
331 20 ▶ sub STORE { $HAS{ $_[1] }->( $_[0], $_[2] ) }
Subroutine STORE: called CC=1 SCAR=0.0
332 33 ▶ sub FETCH { $HAS{ $_[1] }->( $_[0] ) }
Subroutine FETCH: called CC=1 SCAR=0.0
333 3 ▶ sub FIRSTKEY { my $a = scalar keys %HAS; each %HAS }
Subroutine FIRSTKEY: called CC=1 SCAR=0.0
334 21 ▶ sub NEXTKEY { each %HAS }
Subroutine NEXTKEY: called CC=1 SCAR=0.0
335 14 ▶ sub EXISTS { exists $HAS{ $_[1] } }
Subroutine EXISTS: called CC=1 SCAR=0.0
336 1 ▶ sub DELETE { delete $HAS{ $_[1] } } # raise an exception
Subroutine DELETE: called CC=1 SCAR=0.0
337 1 ▶ sub CLEAR { %HAS = () } # raise an exception
Subroutine CLEAR: called CC=1 SCAR=0.0
338 0 ▶ sub SCALAR { scalar keys %HAS } # return number of elements (> 5.24)
Subroutine SCALAR: not called CC=1 SCAR=6.9
339
340 139 $INC{"MessageEvent.pm"} = 1;
341 }
342
343 sub TEvent() { __PACKAGE__ }
344 0 ▶sub new_TEvent { __PACKAGE__->from(@_) }
Subroutine new_TEvent: not called CC=1 SCAR=6.9
Pod documented
345
346 our %HAS = (
347 26 ▶ what => sub {
Subroutine __ANON__: called CC=8 SCAR=23.2
348 26 my ( $this, $what ) = @_;
349 26 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 14 12 26
350 14 assert ( looks_like_number $what );
351 139 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
352 14 $what += evNothing;
353 14 my $type = ref $this->[1];
354 14 ▶ if ( ( $what & evMouse ) && $type !~ /mouse/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($what & 15 and not $type =~ /mouse/iu) { } 0 14 14
elsif ($what & 16 and not $type =~ /keyDown/iu) { } 0 14 14
elsif ($what & 65280 and not $type =~ /message/iu) { } 0 14 14
Condition66%2/3
$what & 15 and not $type =~ /mouse/iu
!ll&&!rl&&r
1040
MC/DC0%0/2
$what & 15 and not $type =~ /mouse/iu
$what & 15 not $type =~ /mouse/iu
Truth table66%2/3
A and not(B)
A= $what & 15B= not $type =~ /mouse/iu
ABresult
0X0
100
111
355 0 @$this = ( $what, MouseEventType->new() );
356 }
357 ▶ elsif ( ( $what & evKeyboard ) && $type !~ /keyDown/i ) {
Condition66%2/3
$what & 16 and not $type =~ /keyDown/iu
!ll&&!rl&&r
1130
MC/DC0%0/2
$what & 16 and not $type =~ /keyDown/iu
$what & 16 not $type =~ /keyDown/iu
Truth table66%2/3
A and not(B)
A= $what & 16B= not $type =~ /keyDown/iu
ABresult
0X0
100
111
358 0 @$this = ( $what, KeyDownEvent->new() );
359 }
360 ▶ elsif ( ( $what & evMessage ) && $type !~ /message/i ) {
Condition33%1/3
$what & 65280 and not $type =~ /message/iu
!ll&&!rl&&r
1400
MC/DC0%0/2
$what & 65280 and not $type =~ /message/iu
$what & 65280 not $type =~ /message/iu
Truth table33%1/3
A and not(B)
A= $what & 65280B= not $type =~ /message/iu
ABresult
0X0
100
111
361 0 @$this = ( $what, MessageEvent->new() );
362 }
363 else {
364 14 $this->[0] = $what;
365 }
366 }
367 26 $this->[0];
368 },
369 35 ▶ mouse => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
370 35 my ( $this, $mouse ) = @_;
371 35 ▶ $this->[1] = $mouse if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 5 30 35
372 35 my $type = ref $this->[1];
373 35 ▶ $type =~ /mouse/i ? $this->[1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /mouse/iu ? : 35 0 35
374 },
375 21 ▶ keyDown => sub {
Subroutine __ANON__: called CC=3 SCAR=11.4
376 21 my ( $this, $keyDown ) = @_;
377 21 ▶ $this->[1] = $keyDown if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 21 21
378 21 my $type = ref $this->[1];
379 21 ▶ $type =~ /keyDown/i ? $this->[1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /keyDown/iu ? : 21 0 21
380 },
381 1 ▶ message => sub {
Subroutine __ANON__: called CC=3 SCAR=11.4
382 1 my ( $this, $message ) = @_;
383 1 ▶ $this->[1] = $message if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 1 1
384 1 my $type = ref $this->[1];
385 1 ▶ $type =~ /message/i ? $this->[1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /message/iu ? : 1 0 1
386 },
387 139 );
388 139 lock_hash( %HAS );
389
390 139 ▶use parent 'Tie::Hash';
Subroutine BEGIN: called CC=1 SCAR=0.0
391
392 66 ▶sub new { # $obj (%args)
Subroutine new: called CC=6 SCAR=18.0
Pod documented
393 139 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
394 66 my ( $class, %args ) = @_;
395 66 ▶ assert ( $class and !ref $class );
Condition33%1/3
$class && !ref($class)
!ll&&!rl&&r
0066
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
396 66 my $self = bless {}, $class;
397 66 tie %$self, $class;
398 66 my $this = tied %$self;
399 66 ▶ assert ( !exists $args{what} or looks_like_number $args{what} );
Condition66%2/3
!exists $args{'what'} || &looks_like_number($args{'what'})
l!l&&r!l&&!r
6240
MC/DC0%0/2
!exists $args{'what'} || &looks_like_number($args{'what'})
!exists $args{'what'} &looks_like_number($args{'what'})
Truth table66%2/3
not(A) || B
A= !exists $args{'what'}B= &looks_like_number($args{'what'})
ABresult
1X1
011
000
400 66 ▶ if ( $args{what} & evMouse ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($args{'what'} & 15) { } 1 65 66
elsif ($args{'what'} & 16) { } 2 63 65
elsif ($args{'what'} & 65280) { } 1 62 63
401 $this->[0] = $args{what},
402 $this->[1] = MouseEventType->new(
403 4 map { $_ => $args{mouse}{$_} }
404 1 grep { exists $args{mouse}{$_} }
405 qw( where eventFlags controlKeyState buttons )
406 );
407 }
408 elsif ( $args{what} & evKeyboard ) {
409 $this->[0] = $args{what},
410 $this->[1] = KeyDownEvent->new(
411 2 map { $_ => $args{keyDown}{$_} }
412 2 grep { exists $args{keyDown}{$_} }
413 qw( keyCode charScan controlKeyState )
414 );
415 }
416 elsif ( $args{what} & evMessage ) {
417 $this->[0] = $args{what},
418 $this->[1] = MessageEvent->new(
419 2 map { $_ => $args{message}{$_} }
420 1 grep { exists $args{message}{$_} }
421 qw( command infoPtr infoLong infoWord infoInt infoByte infoChar )
422 );
423 }
424 66 return $self;
425 } #/ sub new
426
427 0 ▶sub from { # $obj ()
Subroutine from: not called CC=2 SCAR=17.9
Pod undocumented
428 0 my $class = shift;
429 0 ▶ assert ( $class and !ref $class );
Condition0%0/3
$class && !ref($class)
!ll&&!rl&&r
000
MC/DC0%0/2
$class && !ref($class)
$class !ref($class)
Truth table0%0/3
A && not(B)
A= $classB= !ref($class)
ABresult
0X0
100
111
430 0 assert ( @_ == 0 );
431 0 return $class->new();
432 }
433
434 0 ▶sub dump { # $str (|$maxDepth)
Subroutine dump: not called CC=2 SCAR=13.7
Pod documented
435 0 my ( $self ) = @_;
436 0 assert ( @_ == 1 );
437 0 assert ( blessed $self );
438 139 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
439 0 require Data::Dumper;
440 0 local $Data::Dumper::Sortkeys = 1;
441 0 ▶ local $Data::Dumper::Maxdepth = @_ ? shift : 3;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
442 0 my $str = Data::Dumper::Dumper $self;
443 0 $str =~ s/(^|\s)\$VAR\d+\b/$1'$self'/g;
444 0 return $str;
445 }
446
447 0 ▶sub assign { # $self ($event)
Subroutine assign: not called CC=4 SCAR=30.0
Pod documented
448 0 my ( $self, $event ) = @_;
449 0 assert ( @_ == 2 );
450 0 assert ( blessed $self );
451 0 assert ( blessed $event );
452 0 $self->{what} = $event->{what};
453 0 ▶ if ( $event->{mouse} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($event->{'mouse'}) { } 0 0 0
elsif ($event->{'keyDown'}) { } 0 0 0
elsif ($event->{'message'}) { } 0 0 0
454 0 $self->{mouse} = $event->{mouse}->clone();
455 }
456 elsif ( $event->{keyDown} ) {
457 0 $self->{keyDown} = $event->{keyDown}->clone();
458 }
459 elsif ( $event->{message} ) {
460 0 $self->{message} = $event->{message}->clone();
461 }
462 0 return $self;
463 }
464
465 0 ▶sub clone { # $obj ()
Subroutine clone: not called CC=5 SCAR=34.0
Pod documented
466 0 my ( $self ) = @_;
467 0 assert ( @_ == 1 );
468 0 assert ( blessed $self );
469 0 ▶ my $class = ref $self || return;
Condition0%0/2
ref $self || (return)
l!l
00
MC/DC0%0/1
ref $self || (return)
ref $self
Truth table0%0/2
A
A= ref $self
Aresult
11
00
470 0 my $clone = bless {}, $class;
471 0 tie %$clone, $class;
472 0 $clone->{what} = $self->{what};
473 0 ▶ if ( $self->{mouse} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'mouse'}) { } 0 0 0
elsif ($self->{'keyDown'}) { } 0 0 0
elsif ($self->{'message'}) { } 0 0 0
474 0 $clone->{mouse} = $self->{mouse}->clone();
475 }
476 elsif ( $self->{keyDown} ) {
477 0 $clone->{keyDown} = $self->{keyDown}->clone();
478 }
479 elsif ( $self->{message} ) {
480 0 $clone->{message} = $self->{message}->clone();
481 }
482 0 return $clone;
483 }
484
485 66 ▶sub TIEHASH { bless [ evNothing, undef ], $_[0] }
Subroutine TIEHASH: called CC=1 SCAR=0.0
486 19 ▶sub STORE { $HAS{ $_[1] }->( $_[0], $_[2] ) }
Subroutine STORE: called CC=1 SCAR=0.0
487 64 ▶sub FETCH { $HAS{ $_[1] }->( $_[0] ) }
Subroutine FETCH: called CC=1 SCAR=0.0
488 0 ▶sub FIRSTKEY { my $a = scalar keys %HAS; each %HAS }
Subroutine FIRSTKEY: not called CC=1 SCAR=6.9
489 0 ▶sub NEXTKEY { each %HAS }
Subroutine NEXTKEY: not called CC=1 SCAR=6.9
490 0 ▶sub EXISTS { exists $HAS{ $_[1] } }
Subroutine EXISTS: not called CC=1 SCAR=6.9
491 0 ▶sub DELETE { delete $HAS{ $_[1] } } # raise an exception
Subroutine DELETE: not called CC=1 SCAR=6.9
492 0 ▶sub CLEAR { %HAS = () } # raise an exception
Subroutine CLEAR: not called CC=1 SCAR=6.9
493 0 ▶sub SCALAR { scalar keys %HAS } # return number of elements (> 5.24)
Subroutine SCALAR: not called CC=1 SCAR=6.9
494
495 0 ▶sub getMouseEvent { # void ($self)
Subroutine getMouseEvent: not called CC=1 SCAR=6.9
Pod documented
496 0 assert ( blessed $_[0] );
497 0 require TUI::Drivers::EventQueue;
498 0 TUI::Drivers::EventQueue->getMouseEvent( $_[0] );
499 0 return;
500 }
501
502 4 ▶sub getKeyEvent { # void ($self)
Subroutine getKeyEvent: called CC=12 SCAR=26.4
Pod documented
503 4 my ( $self ) = @_;
504 4 assert ( @_ == 1 );
505 4 assert ( blessed $self );
506 4 ▶ if ( THardwareInfo->getKeyEvent( $self ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&THardwareInfo()->getKeyEvent($self)) { } 3 1 4
507
508 3 ▶ return if $self->{what} != evKeyboard;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"what"} != 16 0 3 3
509
510 # Need to handle special case of Alt-Space, Ctrl-Ins, Shift-Ins,
511 # Ctrl-Del, Shift-Del
512
513 3 SWITCH: for ( $self->{keyDown}{keyCode} ) {
514 3 ▶ $_ == ord(' ') and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 32 and do { if ($self->{"keyDown"}{"controlKeyState"} & 8) { $self->{"keyDown"}{"keyCode"} = 512; } ; last } 1 2 3
515 1 ▶ if ( $self->{keyDown}{controlKeyState} & kbAltShift ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"keyDown"}{"controlKeyState"} & 8) 1 0 1
516 1 $self->{keyDown}{keyCode} = kbAltSpace;
517 }
518 1 last;
519 };
520 2 ▶ $_ == kbDel and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 21248 and do { if ($self->{"keyDown"}{"controlKeyState"} & 4) { $self->{"keyDown"}{"keyCode"} = 1536; } elsif ($self->{"keyDown"}{"controlKeyState"} & 3) { $self->{"keyDown"}{"keyCode"} = 1792; } ; last } 1 1 2
521 1 ▶ if ( $self->{keyDown}{controlKeyState} & kbCtrlShift ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'keyDown'}{'controlKeyState'} & 4) { } 1 0 1
elsif ($self->{'keyDown'}{'controlKeyState'} & 3) { } 0 0 0
522 1 $self->{keyDown}{keyCode} = kbCtrlDel;
523 }
524 elsif ( $self->{keyDown}{controlKeyState} & kbShift ) {
525 0 $self->{keyDown}{keyCode} = kbShiftDel;
526 }
527 1 last;
528 };
529 1 ▶ $_ == kbIns and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ == 20992 and do { if ($self->{"keyDown"}{"controlKeyState"} & 4) { $self->{"keyDown"}{"keyCode"} = 1024; } elsif ($self->{"keyDown"}{"controlKeyState"} & 3) { $self->{"keyDown"}{"keyCode"} = 1280; } ; last } 1 0 1
530 1 ▶ if ( $self->{keyDown}{controlKeyState} & kbCtrlShift ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'keyDown'}{'controlKeyState'} & 4) { } 0 1 1
elsif ($self->{'keyDown'}{'controlKeyState'} & 3) { } 1 0 1
531 0 $self->{keyDown}{keyCode} = kbCtrlIns;
532 }
533 elsif ( $self->{keyDown}{controlKeyState} & kbShift ) {
534 1 $self->{keyDown}{keyCode} = kbShiftIns;
535 }
536 1 last;
537 };
538 } #/ SWITCH: for ( $self->{keyDown}{...})
539 } #/ if ( THardwareInfo->getKeyEvent...)
540 else {
541 1 $self->{what} = evNothing;
542 }
543 4 return;
544 } #/ sub getKeyEvent
545
546 139 1
547
548 __END__
« lib/TUI/Gadgets/HeapView.pm ↑ Summary lib/TUI/ColorSel/ColorGroup.pm »