| 1 | package TUI::Gadgets::EventViewer; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: TEventViewer is a Terminal window for showing received TEvents. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | our $VERSION = '2.000002'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||
| 14 | TEventViewer | ||||||||||||||||||||||||||||||||||||||||||
| 15 | new_TEventViewer | ||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | require bytes; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use Encode qw( decode ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use Symbol (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use TUI::toolkit; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use TUI::toolkit::Types qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | :is | ||||||||||||||||||||||||||||||||||||||||||
| 25 | :types | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use TUI::Drivers::Const qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | kbCtrlShift | ||||||||||||||||||||||||||||||||||||||||||
| 30 | kbAltShift | ||||||||||||||||||||||||||||||||||||||||||
| 31 | :evXXXX | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | use TUI::Gadgets::Const qw( cmFndEventView ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | use TUI::Gadgets::PrintConstants qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | printKeyCode | ||||||||||||||||||||||||||||||||||||||||||
| 36 | printControlKeyState | ||||||||||||||||||||||||||||||||||||||||||
| 37 | printEventCode | ||||||||||||||||||||||||||||||||||||||||||
| 38 | printMouseButtonState | ||||||||||||||||||||||||||||||||||||||||||
| 39 | printMouseWheelState | ||||||||||||||||||||||||||||||||||||||||||
| 40 | printMouseEventFlags | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | ▶ | use TUI::TextView::Terminal; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | ▶ | use TUI::Views::Const qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | sbHandleKeyboard | ||||||||||||||||||||||||||||||||||||||||||
| 45 | sbVertical | ||||||||||||||||||||||||||||||||||||||||||
| 46 | wnNoNumber | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | ▶ | use TUI::Views::Window; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | ▶ | use constant _WIN32 => ($^O eq 'MSWin32') && !$ENV{WT_SESSION}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
Condition33%1/3
$^O eq 'MSWin32' && !$ENV{'WT_SESSION'}
MC/DC0%0/2
$^O eq 'MSWin32' && !$ENV{'WT_SESSION'}
$^O eq 'MSWin32'
!$ENV{'WT_SESSION'}
Truth table33%1/3
A && not(B)
A= $^O eq 'MSWin32'B= !$ENV{'WT_SESSION'}
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | sub TEventViewer() { __PACKAGE__ } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | sub name() { 'TEventViewer' } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub new_TEventViewer { __PACKAGE__->from(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_TEventViewer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | extends TWindow; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # private attributes | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | has stopped => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | has eventCount => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | has bufSize => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | has interior => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | has scrollBar => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | has out => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | my $titles = [ | |||||||||||||||||||||||||||||||||||||||||
| 67 | "Event Viewer", | ||||||||||||||||||||||||||||||||||||||||||
| 68 | "Event Viewer (Stopped)" | ||||||||||||||||||||||||||||||||||||||||||
| 69 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | # predeclare private methods | ||||||||||||||||||||||||||||||||||||||||||
| 72 | my ( | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 4 | $init, | |||||||||||||||||||||||||||||||||||||||||
| 74 | $printEvent, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub BUILDARGS { # \%args (%args) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 79 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | named => [ | ||||||||||||||||||||||||||||||||||||||||||
| 81 | bounds => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | bufSize => PositiveOrZeroInt, | ||||||||||||||||||||||||||||||||||||||||||
| 83 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 84 | caller_level => +1, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my ( $class, $args1 ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | local $Carp::CarpLevel = $Carp::CarpLevel + 1; | |||||||||||||||||||||||||||||||||||||||||
| 88 | my $args2 = $class->SUPER::BUILDARGS( | ||||||||||||||||||||||||||||||||||||||||||
| 89 | bounds => $args1->{bounds}, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | title => '', | |||||||||||||||||||||||||||||||||||||||||
| 91 | number => wnNoNumber, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return { %$args1, %$args2 }; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub BUILD { # void (\%args) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | assert ( is_HashRef $args ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->{eventMask} |= evBroadcast; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $self->$init( $args->{bufSize} ); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | $init = sub { # void ($bufSize) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my ( $self, $bufSize ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | assert ( is_PositiveOrZeroInt $bufSize ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $self->{stopped} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $self->{eventCount} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->{bufSize} = $bufSize; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $self->{title} = $titles->[ $self->{stopped} ? 1 : 0 ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $self->{scrollBar} = $self->standardScrollBar( sbVertical | sbHandleKeyboard ); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $ostream = Symbol::gensym; | |||||||||||||||||||||||||||||||||||||||||
| 117 | $self->{interior} = tie *$ostream, TTerminal, ( | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | bounds => do { local $_ = $self->getExtent(); $_->grow( -1, -1 ); $_ }, | |||||||||||||||||||||||||||||||||||||||||
| 119 | hScrollBar => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | vScrollBar => $self->{scrollBar}, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | bufSize => $self->{bufSize}, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $self->insert( $self->{interior} ); | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->{out} = $ostream; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | }; #/ sub $init | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub from { # $eventView ($bounds, aBufSize) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 130 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 131 | pos => [Object, PositiveOrZeroInt], | ||||||||||||||||||||||||||||||||||||||||||
| 132 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my ( $class, @args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return $class->new( bounds => $args[0], bufSize => $args[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub DEMOLISH { # void ($in_global_destruction) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DEMOLISH: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my ( $self, $in_global_destruction ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $self->{title} = undef; # So that TWindow doesn't delete it. | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub toggle { # void () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toggle: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 147 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | pos => [], | ||||||||||||||||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $self->{stopped} = !$self->{stopped}; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | $self->{title} = $titles->[ $self->{stopped} ? 1 : 0 ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $self->{frame}->drawView() if $self->{frame}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub print { # void ($event) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 159 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | pos => [Object], | ||||||||||||||||||||||||||||||||||||||||||
| 161 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my ( $self, $ev ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ( $ev->{what} != evNothing && !$self->{stopped} && $self->{out} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ev->{"what"} != 0 and not $self->{"stopped"} and $self->{"out"}
$ev->{"what"} != 0 and not $self->{"stopped"}
MC/DC0%0/3
$ev->{"what"} != 0 and not $self->{"stopped"} and $self->{"out"}
$ev->{"what"} != 0
not $self->{"stopped"}
$self->{"out"}
Truth table0%0/4
A and not(B) and C
A= $ev->{"what"} != 0B= not $self->{"stopped"}C= $self->{"out"}
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | local *OUT = $self->{out}; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->lock(); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | print OUT "Received event #", ++$self->{eventCount}, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->$printEvent( \*OUT, $ev ); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | tied(*OUT)->flush(); | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->unlock(); | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 172 | } #/ sub print | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub shutDown { # void () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutDown: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 176 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | pos => [], | ||||||||||||||||||||||||||||||||||||||||||
| 178 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->{out} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->{interior} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->{scrollBar} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->SUPER::shutDown(); | |||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub handleEvent { # void ($event) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handleEvent: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 189 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | pos => [Object], | ||||||||||||||||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my ( $self, $ev ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->SUPER::handleEvent( $ev ); | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( $ev->{what} == evBroadcast | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ev->{"what"} == 512 and $ev->{"message"}{"command"} == 114
MC/DC0%0/2
$ev->{"what"} == 512 and $ev->{"message"}{"command"} == 114
$ev->{"what"} == 512
$ev->{"message"}{"command"} == 114
Truth table0%0/3
A and B
A= $ev->{"what"} == 512B= $ev->{"message"}{"command"} == 114
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | && $ev->{message}{command} == cmFndEventView | ||||||||||||||||||||||||||||||||||||||||||
| 196 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $self->clearEvent( $ev ); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $printConstants = sub { # void ($value, $doPrint) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my ( $value, $doPrint ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | assert ( is_PositiveOrZeroInt $value ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | assert ( is_CodeRef $doPrint ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | printf "0x%04X", $value; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $buf = ''; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | open my $os, '>', \$buf; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $os->$doPrint( $value ); | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | close $os; | |||||||||||||||||||||||||||||||||||||||||
| 213 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ( !$@ && (split //, $buf)[0] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $@ and (split(//, $buf, 0))[0]
MC/DC0%0/2
not $@ and (split(//, $buf, 0))[0]
not $@
(split(//, $buf, 0))[0]
Truth table0%0/3
not(A) and B
A= not $@B= (split(//, $buf, 0))[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | print " (", $buf, ")"; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub _printEvent { goto &$printEvent } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_printEvent: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | $printEvent = sub { # void ($out, $ev) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my ( $self, $out, $ev ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | assert ( @_ == 3 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | assert ( ref $out ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | assert ( is_Object $ev ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $current = select $out; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | print "TEvent {\n", | |||||||||||||||||||||||||||||||||||||||||
| 230 | " .what = "; | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | &$printConstants( $ev->{what}, \&printEventCode ); | |||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | print ",\n"; | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if ( $ev->{what} & evMouse ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | print " .mouse = MouseEventType {\n", | ||||||||||||||||||||||||||||||||||||||||||
| 236 | " .where = TPoint {\n", | ||||||||||||||||||||||||||||||||||||||||||
| 237 | " .x = ", $ev->{mouse}{where}{x}, "\n", | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | " .y = ", $ev->{mouse}{where}{y}, "\n", | |||||||||||||||||||||||||||||||||||||||||
| 239 | " },\n", | ||||||||||||||||||||||||||||||||||||||||||
| 240 | " .eventFlags = "; | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | &$printConstants( $ev->{mouse}{eventFlags}, \&printMouseEventFlags ); | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | print ",\n", | |||||||||||||||||||||||||||||||||||||||||
| 243 | " .controlKeyState = "; | ||||||||||||||||||||||||||||||||||||||||||
| 244 | &$printConstants( $ev->{mouse}{controlKeyState}, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | \&printControlKeyState ); | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | print ",\n", | |||||||||||||||||||||||||||||||||||||||||
| 247 | " .buttons = "; | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | &$printConstants( $ev->{mouse}{buttons}, \&printMouseButtonState ); | |||||||||||||||||||||||||||||||||||||||||
| 249 | # TODO: TEvent->{mouse}{wheel} support | ||||||||||||||||||||||||||||||||||||||||||
| 250 | # print ",\n", | ||||||||||||||||||||||||||||||||||||||||||
| 251 | # " .wheel = "; | ||||||||||||||||||||||||||||||||||||||||||
| 252 | # &$printConstants( $ev->{mouse}{wheel}, \&printMouseWheelState ); | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | print "\n }\n"; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } #/ if ( $ev->{what} & evMouse) | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if ( $ev->{what} & evKeyboard ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $charCode = $ev->{keyDown}{charScan}{charCode}; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | print " .keyDown = KeyDownEvent {\n", | |||||||||||||||||||||||||||||||||||||||||
| 259 | " .keyCode = "; | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | &$printConstants( $ev->{keyDown}{keyCode}, \&printKeyCode ); | |||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | print ",\n", | |||||||||||||||||||||||||||||||||||||||||
| 262 | " .charScan = CharScanType {\n", | ||||||||||||||||||||||||||||||||||||||||||
| 263 | " .charCode = ", $charCode; | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | print " ('", chr $charCode, "')" if $charCode; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | print ",\n", | ||||||||||||||||||||||||||||||||||||||||||
| 266 | " .scanCode = ", $ev->{keyDown}{charScan}{scanCode}, | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | "\n", | |||||||||||||||||||||||||||||||||||||||||
| 268 | " },\n", | ||||||||||||||||||||||||||||||||||||||||||
| 269 | " .controlKeyState = "; | ||||||||||||||||||||||||||||||||||||||||||
| 270 | &$printConstants( $ev->{keyDown}{controlKeyState}, | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | \&printControlKeyState ); | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | print ",\n"; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | print " .text = {"; | |||||||||||||||||||||||||||||||||||||||||
| 274 | # NOTE: {charScan}{charCode} reflects the native character encoding | ||||||||||||||||||||||||||||||||||||||||||
| 275 | # used by the backend. For Win32 this is typically the legacy code page. | ||||||||||||||||||||||||||||||||||||||||||
| 276 | # The pseudo-fields 'text' and 'textLength' always show the UTF-8 byte | ||||||||||||||||||||||||||||||||||||||||||
| 277 | # sequence corresponding to the character. | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my @text = $charCode && !( $ev->{keyDown}{controlKeyState} & ( kbCtrlShift | kbAltShift ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$charCode and not $ev->{"keyDown"}{"controlKeyState"} & 12
MC/DC0%0/2
$charCode and not $ev->{"keyDown"}{"controlKeyState"} & 12
$charCode
not $ev->{"keyDown"}{"controlKeyState"} & 12
Truth table0%0/3
A and not(B)
A= $charCodeB= not $ev->{"keyDown"}{"controlKeyState"} & 12
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | ? unpack( 'C*', bytes::substr( decode( 'cp437' => chr $charCode ), 0 ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 280 | : (); | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $textLength = @text; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | print join(', ', map { sprintf "'\\x%02X'", $_ } @text ); | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | print "},\n", | |||||||||||||||||||||||||||||||||||||||||
| 284 | " .textLength = ", $textLength, "\n", | ||||||||||||||||||||||||||||||||||||||||||
| 285 | " }\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 286 | } #/ if ( $ev->{what} & evKeyboard) | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if ( $ev->{what} & evCommand ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | print " .message = MessageEvent {\n", | ||||||||||||||||||||||||||||||||||||||||||
| 290 | " .command = ", $ev->{message}{command}, ",\n", | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | " .infoPtr = ", $ev->{message}{infoPtr} // 'undef', "\n", | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ev->{"message"}{"infoPtr"} // "undef"
MC/DC0%0/1
$ev->{"message"}{"infoPtr"} // "undef"
$ev->{"message"}{"infoPtr"}
Truth table0%0/2
A
A= $ev->{"message"}{"infoPtr"}
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | " }\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | print( "}\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | select $current; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 4 | }; #/ sub $printEvent | |||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 4 | 1 | |||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | __END__ | ||||||||||||||||||||||||||||||||||||||||||