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