| 1 | package Game::Terminal::Kit::Keys; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 12 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 12 | my %SEQUENCE = ( | |||||||||||||||||||||||||||||||
| 12 | 'A' => 'up', | ||||||||||||||||||||||||||||||||
| 13 | 'B' => 'down', | ||||||||||||||||||||||||||||||||
| 14 | 'C' => 'right', | ||||||||||||||||||||||||||||||||
| 15 | 'D' => 'left', | ||||||||||||||||||||||||||||||||
| 16 | 'H' => 'home', | ||||||||||||||||||||||||||||||||
| 17 | 'F' => 'end', | ||||||||||||||||||||||||||||||||
| 18 | 'Z' => 'back_tab', | ||||||||||||||||||||||||||||||||
| 19 | '1~' => 'home', | ||||||||||||||||||||||||||||||||
| 20 | '2~' => 'insert', | ||||||||||||||||||||||||||||||||
| 21 | '3~' => 'delete', | ||||||||||||||||||||||||||||||||
| 22 | '4~' => 'end', | ||||||||||||||||||||||||||||||||
| 23 | '5~' => 'page_up', | ||||||||||||||||||||||||||||||||
| 24 | '6~' => 'page_down', | ||||||||||||||||||||||||||||||||
| 25 | '7~' => 'home', | ||||||||||||||||||||||||||||||||
| 26 | '8~' => 'end', | ||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 12 | my %CONTROL = ( | |||||||||||||||||||||||||||||||
| 30 | "\r" => 'enter', | ||||||||||||||||||||||||||||||||
| 31 | "\n" => 'enter', | ||||||||||||||||||||||||||||||||
| 32 | "\t" => 'tab', | ||||||||||||||||||||||||||||||||
| 33 | "\x7f" => 'backspace', | ||||||||||||||||||||||||||||||||
| 34 | "\x08" => 'backspace', | ||||||||||||||||||||||||||||||||
| 35 | "\x03" => 'interrupt', | ||||||||||||||||||||||||||||||||
| 36 | "\x04" => 'eof', | ||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | has in => ( | ||||||||||||||||||||||||||||||||
| 40 | is => 'rw' | ||||||||||||||||||||||||||||||||
| 41 | 12 | ); | |||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | has raw => ( | ||||||||||||||||||||||||||||||||
| 44 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 45 | isa => Bool, | ||||||||||||||||||||||||||||||||
| 46 | default => 0 | ||||||||||||||||||||||||||||||||
| 47 | 12 | ); | |||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | has [qw/keysource sleeper/] => ( | ||||||||||||||||||||||||||||||||
| 50 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 51 | isa => CodeRef | ||||||||||||||||||||||||||||||||
| 52 | 12 | ); | |||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | has pending => ( | ||||||||||||||||||||||||||||||||
| 55 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 56 | isa => ArrayRef, | ||||||||||||||||||||||||||||||||
| 57 | default => [] | ||||||||||||||||||||||||||||||||
| 58 | 12 | ); | |||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | has sequence_wait => ( | ||||||||||||||||||||||||||||||||
| 61 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 62 | isa => Num | ||||||||||||||||||||||||||||||||
| 63 | 12 | ); | |||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | has [qw/mouse held/] => ( | ||||||||||||||||||||||||||||||||
| 66 | is => 'rw' | ||||||||||||||||||||||||||||||||
| 67 | 12 | ); | |||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 110 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=4 SCAR=14.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 70 | 110 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 71 | 110 | ▶ | $self->in(\*STDIN) unless $self->in; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 72 | 110 | ▶ | $self->sequence_wait(0.05) unless defined $self->sequence_wait; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $self->sleeper(sub { select undef, undef, undef, $_[0]; return }) | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 74 | 110 | ▶ | unless $self->sleeper; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 75 | 110 | return $self; | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | sub names { | ||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 79 | 1 | my %seen; | |||||||||||||||||||||||||||||||
| 80 | 1 | return sort grep { !$seen{$_}++ } | |||||||||||||||||||||||||||||||
| 81 | values %SEQUENCE, values %CONTROL, 'escape', 'mouse', 'unknown'; | ||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | 5 | ▶ | sub _on_a_terminal { | ||||||||||||||||||||||||||||||
|
Subroutine
_on_a_terminal: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||
| 85 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | return defined $self->in && -t $self->in ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->in and -t $self->in
MC/DC0%0/2
defined $self->in and -t $self->in
defined $self->in
-t $self->in
Truth table33%1/3
A and B
A= defined $self->inB= -t $self->in
| |||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 9 | ▶ | sub keys_available { | ||||||||||||||||||||||||||||||
|
Subroutine
keys_available: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 90 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 91 | 9 | ▶ | return 1 if $self->keysource; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 92 | 7 | ▶ | return 0 unless $self->_on_a_terminal; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | return eval { require Term::ReadKey; 1 } ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | 17 | ▶ | sub enter_raw { | ||||||||||||||||||||||||||||||
|
Subroutine
enter_raw: called CC=5 SCAR=19.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 97 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 98 | 17 | ▶ | return $self if $self->raw; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 99 | 16 | ▶ | if ($self->keysource) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 100 | 13 | $self->raw(1); | |||||||||||||||||||||||||||||||
| 101 | 13 | return $self; | |||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | 3 | ▶ | return undef unless $self->keys_available; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | return undef unless eval { Term::ReadKey::ReadMode(3, $self->in); 1 }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 105 | 0 | $self->raw(1); | |||||||||||||||||||||||||||||||
| 106 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 18 | ▶ | sub leave_raw { | ||||||||||||||||||||||||||||||
|
Subroutine
leave_raw: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 110 | 18 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 111 | 18 | ▶ | return $self unless $self->raw; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | eval { Term::ReadKey::ReadMode(0, $self->in) } unless $self->keysource; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 113 | 9 | $self->raw(0); | |||||||||||||||||||||||||||||||
| 114 | 9 | return $self; | |||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | 5 | ▶ | sub unread { | ||||||||||||||||||||||||||||||
|
Subroutine
unread: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 118 | 5 | my ($self, @chars) = @_; | |||||||||||||||||||||||||||||||
| 119 | 5 | unshift @{$self->pending}, @chars; | |||||||||||||||||||||||||||||||
| 120 | 5 | return $self; | |||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 679 | ▶ | sub read_char { | ||||||||||||||||||||||||||||||
|
Subroutine
read_char: called CC=7 SCAR=21.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 124 | 679 | my ($self, $wait) = @_; | |||||||||||||||||||||||||||||||
| 125 | 679 | my $pending = $self->pending; | |||||||||||||||||||||||||||||||
| 126 | 679 | ▶ | return shift @{$pending} if @{$pending}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 127 | 672 | ▶ | return $self->keysource->($wait) if $self->keysource; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 128 | 2 | ▶ | unless ($self->raw) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 129 | 2 | ▶ | $self->sleeper->($wait) if $wait; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 130 | 2 | return undef; | |||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my $mode = !defined $wait ? 0 : $wait > 0 ? $wait : -1; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 133 | 0 | return Term::ReadKey::ReadKey($mode, $self->in); | |||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | 271 | ▶ | sub read_key { | ||||||||||||||||||||||||||||||
|
Subroutine
read_key: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 137 | 271 | my ($self, $wait) = @_; | |||||||||||||||||||||||||||||||
| 138 | 271 | my $char = $self->read_char($wait); | |||||||||||||||||||||||||||||||
| 139 | 271 | ▶ | return undef unless defined $char; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 140 | 220 | ▶ | return $CONTROL{$char} if $CONTROL{$char}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 141 | 167 | ▶ | return $self->read_sequence if $char eq "\e"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 142 | 70 | return $char; | |||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 97 | ▶ | sub read_sequence { | ||||||||||||||||||||||||||||||
|
Subroutine
read_sequence: called CC=13 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 146 | 97 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 147 | 97 | my $opener = $self->read_char($self->sequence_wait); | |||||||||||||||||||||||||||||||
| 148 | 97 | ▶ | return 'escape' unless defined $opener; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 149 | 92 | ▶ | unless ($opener eq '[' || $opener eq 'O') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opener eq "[" or $opener eq "O"
MC/DC100%2/2
$opener eq "[" or $opener eq "O"
$opener eq "["
$opener eq "O"
Truth table100%3/3
A or B
A= $opener eq "["B= $opener eq "O"
| |||||||||||||||||||||||||||||||||
| 150 | 2 | $self->unread($opener); | |||||||||||||||||||||||||||||||
| 151 | 2 | return 'escape'; | |||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||
| 153 | 90 | my $tail = ''; | |||||||||||||||||||||||||||||||
| 154 | 90 | my $limit = 8; | |||||||||||||||||||||||||||||||
| 155 | 90 | ▶ | while (length $tail < $limit) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 156 | 293 | my $char = $self->read_char($self->sequence_wait); | |||||||||||||||||||||||||||||||
| 157 | 293 | ▶ | last unless defined $char; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 158 | 291 | $tail .= $char; | |||||||||||||||||||||||||||||||
| 159 | 291 | ▶ | $limit = 32 if $opener eq '[' && $tail eq '<'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opener eq "[" and $tail eq "<"
MC/DC100%2/2
$opener eq "[" and $tail eq "<"
$opener eq "["
$tail eq "<"
Truth table100%3/3
A and B
A= $opener eq "["B= $tail eq "<"
| |||||||||||||||||||||||||||||||||
| 160 | 291 | ▶ | last if $char =~ m/[A-Za-z~]/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||
| 162 | 90 | ▶ | if ($opener eq '[') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 84 | ▶ | return $self->_sgr_mouse($tail) if $tail =~ m/\A</; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 164 | 58 | ▶ | return $self->_legacy_mouse if $tail eq 'M'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | 58 | ▶ | return $SEQUENCE{$tail} || 'unknown'; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$SEQUENCE{$tail} || 'unknown'
MC/DC100%1/1
$SEQUENCE{$tail} || 'unknown'
$SEQUENCE{$tail}
Truth table100%2/2
A
A= $SEQUENCE{$tail}
| |||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | 26 | ▶ | sub _sgr_mouse { | ||||||||||||||||||||||||||||||
|
Subroutine
_sgr_mouse: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 170 | 26 | my ($self, $tail) = @_; | |||||||||||||||||||||||||||||||
| 171 | 26 | ▶ | return 'unknown' unless $tail =~ m/\A<(\d+);(\d+);(\d+)([Mm])\z/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 172 | 21 | return $self->_mouse_event($1, $2, $3, $4 eq 'm'); | |||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 6 | ▶ | sub _legacy_mouse { | ||||||||||||||||||||||||||||||
|
Subroutine
_legacy_mouse: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 176 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 177 | 6 | my @chars; | |||||||||||||||||||||||||||||||
| 178 | 6 | for (1 .. 3) { | |||||||||||||||||||||||||||||||
| 179 | 18 | my $char = $self->read_char($self->sequence_wait); | |||||||||||||||||||||||||||||||
| 180 | 18 | ▶ | last unless defined $char; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 181 | 17 | push @chars, $char; | |||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||
| 183 | 6 | ▶ | if (@chars < 3 || grep { ord $_ < 32 } @chars) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@chars < 3 or grep {ord $_ < 32;} @chars
MC/DC50%1/2
@chars < 3 or grep {ord $_ < 32;} @chars
@chars < 3
grep {ord $_ < 32;} @chars
Truth table66%2/3
A or B
A= @chars < 3B= grep {ord $_ < 32;} @chars
| |||||||||||||||||||||||||||||||||
| 184 | 1 | $self->unread(@chars); | |||||||||||||||||||||||||||||||
| 185 | 1 | return 'unknown'; | |||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||
| 187 | 5 | my ($code, $column, $row) = map { ord($_) - 32 } @chars; | |||||||||||||||||||||||||||||||
| 188 | 5 | return $self->_mouse_event($code, $column, $row, ($code & 99) == 3); | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||
| 191 | 26 | ▶ | sub _mouse_event { | ||||||||||||||||||||||||||||||
|
Subroutine
_mouse_event: called CC=12 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 192 | 26 | my ($self, $code, $column, $row, $released) = @_; | |||||||||||||||||||||||||||||||
| 193 | 26 | ▶ | return 'unknown' if $code & 128; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 194 | 25 | my $button = $code & 3; | |||||||||||||||||||||||||||||||
| 195 | 25 | my ($type, $name); | |||||||||||||||||||||||||||||||
| 196 | 25 | ▶ | if ($code & 64) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 197 | 6 | ($type, $name) = ('scroll', (qw/up down left right/)[$button]); | |||||||||||||||||||||||||||||||
| 198 | } elsif ($code & 32) { | ||||||||||||||||||||||||||||||||
| 199 | 7 | ▶ | ($type, $name) = $button == 3 ? ('move', undef) : ('drag', (qw/left middle right/)[$button]); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 200 | } else { | ||||||||||||||||||||||||||||||||
| 201 | 12 | ▶ | ($type, $name) = ($released ? 'release' : 'press', (qw/left middle right/)[$button]); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||
| 203 | 25 | ▶ | $self->mouse({ | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 204 | type => $type, | ||||||||||||||||||||||||||||||||
| 205 | button => $name, | ||||||||||||||||||||||||||||||||
| 206 | column => $column + 0, | ||||||||||||||||||||||||||||||||
| 207 | row => $row + 0, | ||||||||||||||||||||||||||||||||
| 208 | shift => $code & 4 ? 1 : 0, | ||||||||||||||||||||||||||||||||
| 209 | alt => $code & 8 ? 1 : 0, | ||||||||||||||||||||||||||||||||
| 210 | control => $code & 16 ? 1 : 0, | ||||||||||||||||||||||||||||||||
| 211 | }); | ||||||||||||||||||||||||||||||||
| 212 | 25 | ▶ | if ($type eq 'press' || $type eq 'drag') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$type eq "press" or $type eq "drag"
MC/DC100%2/2
$type eq "press" or $type eq "drag"
$type eq "press"
$type eq "drag"
Truth table100%3/3
A or B
A= $type eq "press"B= $type eq "drag"
| |||||||||||||||||||||||||||||||||
| 213 | 12 | $self->held({ button => $name, column => $column + 0, row => $row + 0 }); | |||||||||||||||||||||||||||||||
| 214 | } elsif ($type eq 'release') { | ||||||||||||||||||||||||||||||||
| 215 | 4 | $self->held(undef); | |||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | 25 | return 'mouse'; | |||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||
| 220 | 8 | ▶ | sub read_line { | ||||||||||||||||||||||||||||||
|
Subroutine
read_line: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 221 | 8 | my ($self, $prompt, $out) = @_; | |||||||||||||||||||||||||||||||
| 222 | 8 | my $was_raw = $self->raw; | |||||||||||||||||||||||||||||||
| 223 | 8 | $self->leave_raw; | |||||||||||||||||||||||||||||||
| 224 | 8 | ▶ | if (defined $prompt && $out) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $prompt and $out
MC/DC100%2/2
defined $prompt and $out
defined $prompt
$out
Truth table100%3/3
A and B
A= defined $promptB= $out
| |||||||||||||||||||||||||||||||||
| 225 | 4 | my $previous = select $out; | |||||||||||||||||||||||||||||||
| 226 | 4 | my $buffered = $|; | |||||||||||||||||||||||||||||||
| 227 | 4 | print {$out} $prompt; | |||||||||||||||||||||||||||||||
| 228 | 4 | $| = 1; | |||||||||||||||||||||||||||||||
| 229 | 4 | $| = $buffered; | |||||||||||||||||||||||||||||||
| 230 | 4 | select $previous; | |||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||
| 232 | 8 | my $line = readline $self->in; | |||||||||||||||||||||||||||||||
| 233 | 8 | ▶ | $self->enter_raw if $was_raw; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 234 | 8 | ▶ | return undef unless defined $line; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 235 | 6 | $line =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||
| 236 | 6 | return $line; | |||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||
| 239 | 12 | 1; | |||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||
| 241 | __END__ | ||||||||||||||||||||||||||||||||