| 1 | package Game::Terminal::Kit::Screen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 14 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | has out => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | is => 'rw' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | has [qw/interactive colour depth columns rows mouse_reporting/] => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | is => 'rw' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | has [qw/ascii cursor_hidden/] => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 82 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 82 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 82 | ▶ | $self->out(\*STDOUT) unless $self->out; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 82 | ▶ | $self->interactive(-t $self->out ? 1 : 0) unless defined $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 82 | ▶ | $self->colour($self->interactive && !no_colour() ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$self->interactive and not no_colour()
MC/DC100%2/2
$self->interactive and not no_colour()
$self->interactive
not no_colour()
Truth table100%3/3
A and not(B)
A= $self->interactiveB= not no_colour()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | unless defined $self->colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 82 | ▶ | $self->depth(!$self->colour ? 0 : ($ENV{COLORTERM} // '') =~ m/truecolor|24bit/i ? 24 : 8) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%2/2
$ENV{"COLORTERM"} // ""
MC/DC100%1/1
$ENV{"COLORTERM"} // ""
$ENV{"COLORTERM"}
Truth table100%2/2
A
A= $ENV{"COLORTERM"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | unless defined $self->depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 82 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 6 | ▶ | sub no_colour { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
no_colour: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 6 | ▶ | return defined $ENV{NO_COLOR} && length $ENV{NO_COLOR} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $ENV{"NO_COLOR"} and length $ENV{"NO_COLOR"}
MC/DC100%2/2
defined $ENV{"NO_COLOR"} and length $ENV{"NO_COLOR"}
defined $ENV{"NO_COLOR"}
length $ENV{"NO_COLOR"}
Truth table100%3/3
A and B
A= defined $ENV{"NO_COLOR"}B= length $ENV{"NO_COLOR"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 162 | ▶ | sub _print { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_print: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 162 | my ($self, @text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 162 | my $out = $self->out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 162 | print {$out} @text; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 162 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | sub flush_on { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush_on: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | my $previous = select $self->out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | select $previous; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | ▶ | sub utf8 { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
utf8: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | ▶ | return $self if $self->ascii; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | my @layers = eval { PerlIO::get_layers($self->out) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | return $self if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | return $self if grep { m/\A(?:utf8|encoding)/ } @layers; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | binmode $self->out, ':encoding(UTF-8)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 9 | ▶ | sub say { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 9 | my ($self, @lines) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 9 | ▶ | @lines = ('') unless @lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 9 | ▶ | return $self->_print(map { (defined $_ ? $_ : '') . "\n" } @lines); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | my ($self, @text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | return $self->_print(@text); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | ▶ | sub draw { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
draw: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 5 | my ($self, @text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | my $text = join '', grep { defined } @text; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 5 | ▶ | return $self unless $self->interactive && length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->interactive and length $text
MC/DC100%2/2
$self->interactive and length $text
$self->interactive
length $text
Truth table100%3/3
A and B
A= $self->interactiveB= length $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | return $self->_print("\e[?2026h", $text, "\e[?2026l"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 5 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | my ($self, %option) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 5 | ▶ | return $self unless $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | ▶ | return $self->_print($option{scrollback} ? "\e[2J\e[3J\e[H" : "\e[2J\e[H"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 125 | ▶ | sub show { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 125 | my ($self, $lines) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 125 | ▶ | return $self->_print("\e[H", (map { "$_\e[K\n" } @{$lines}), "\e[J") | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | if $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 120 | return $self->_print(map { "$_\n" } @{$lines}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 6 | ▶ | sub rewind { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rewind: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | my ($self, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 6 | ▶ | return $self unless $self->interactive && $count && $count > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->interactive and $count and $count > 0
$self->interactive and $count
MC/DC100%3/3
$self->interactive and $count and $count > 0
$self->interactive
$count
$count > 0
Truth table100%4/4
A and B and C
A= $self->interactiveB= $countC= $count > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | return $self->_print("\e[${count}A\r"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | ▶ | sub at { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
at: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 3 | my ($self, $row, $column) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | ▶ | return $self unless $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | return $self->_print("\e[${row};${column}H"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | ▶ | sub paint { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paint: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 10 | my ($self, $text, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 10 | ▶ | return $text unless $self->colour && defined $code && length $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->colour and defined $code and length $code
$self->colour and defined $code
MC/DC100%3/3
$self->colour and defined $code and length $code
$self->colour
defined $code
length $code
Truth table100%4/4
A and B and C
A= $self->colourB= defined $codeC= length $code
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | return "\e[${code}m" . $text . "\e[0m"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 15 | ▶ | sub palette { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
palette: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 15 | my ($colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 15 | my @part = ($colour >> 16 & 255, $colour >> 8 & 255, $colour & 255); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 15 | ▶ | my @step = map { $_ < 48 ? 0 : $_ < 115 ? 1 : int(($_ - 35) / 40) } @part; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 15 | ▶ | my @cube = map { $_ ? 55 + 40 * $_ : 0 } @step; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 15 | my $mean = int(($part[0] + $part[1] + $part[2]) / 3); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 15 | ▶ | my $ramp = $mean < 8 ? 0 : $mean > 238 ? 23 : int(($mean - 8) / 10 + 0.5); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 15 | my $grey = 8 + 10 * $ramp; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 15 | my ($to_cube, $to_grey) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 15 | for my $index (0 .. 2) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 45 | $to_cube += ($part[$index] - $cube[$index]) ** 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 45 | $to_grey += ($part[$index] - $grey) ** 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 15 | ▶ | return 232 + $ramp if $to_grey < $to_cube; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 10 | return 16 + 36 * $step[0] + 6 * $step[1] + $step[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 11 | ▶ | sub _colour_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_colour_code: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 11 | my ($self, $lead, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 11 | ▶ | return '' unless defined $colour && $self->colour && $self->depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $colour and $self->colour and $self->depth
defined $colour and $self->colour
MC/DC100%3/3
defined $colour and $self->colour and $self->depth
defined $colour
$self->colour
$self->depth
Truth table100%4/4
A and B and C
A= defined $colourB= $self->colourC= $self->depth
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 5 | ▶ | return join ';', $lead, 2, $colour >> 16 & 255, $colour >> 8 & 255, $colour & 255 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | if $self->depth >= 24; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | return "$lead;5;" . palette($colour); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | ▶ | sub ink { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ink: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 7 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 7 | return $self->_colour_code(38, $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 4 | ▶ | sub ground { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ground: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 4 | return $self->_colour_code(48, $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 14 | ▶ | sub hide_cursor { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hide_cursor: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 14 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 14 | ▶ | return $self unless $self->interactive && !$self->cursor_hidden; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->interactive and not $self->cursor_hidden
MC/DC100%2/2
$self->interactive and not $self->cursor_hidden
$self->interactive
not $self->cursor_hidden
Truth table100%3/3
A and not(B)
A= $self->interactiveB= not $self->cursor_hidden
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 6 | $self->cursor_hidden(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 6 | return $self->_print("\e[?25l"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 11 | ▶ | sub show_cursor { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_cursor: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 11 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 11 | ▶ | return $self unless $self->cursor_hidden; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 6 | $self->cursor_hidden(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 6 | return $self->_print("\e[?25h"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | ▶ | sub mouse_on { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mouse_on: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 6 | my ($self, %option) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 6 | ▶ | my $motion = $option{motion} // 'drag'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$option{"motion"} // "drag"
MC/DC100%1/1
$option{"motion"} // "drag"
$option{"motion"}
Truth table100%2/2
A
A= $option{"motion"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 6 | ▶ | my $mode = { click => 1000, drag => 1002, all => 1003 }->{$motion} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | or die "mouse_on: motion is click, drag or all, not $motion\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | ▶ | return $self unless $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 4 | $self->mouse_off; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | $self->mouse_reporting($mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 4 | return $self->_print("\e[?${mode}h\e[?1006h"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 24 | ▶ | sub mouse_off { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mouse_off: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 24 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 24 | ▶ | my $mode = $self->mouse_reporting or return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | $self->mouse_reporting(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 4 | return $self->_print("\e[?1006l\e[?${mode}l"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 16 | ▶ | sub restore { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
restore: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 16 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 16 | $self->mouse_off; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 16 | ▶ | return $self unless $self->cursor_hidden; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 5 | $self->show_cursor; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 5 | ▶ | $self->_print("\e[0m") if $self->colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 18 | ▶ | sub measured { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
measured: called CC=11 SCAR=27.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 18 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 18 | ▶ | return ($self->columns, $self->rows || 0) if $self->columns; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->rows || 0
MC/DC100%1/1
$self->rows || 0
$self->rows
Truth table100%2/2
A
A= $self->rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if ($self->interactive && eval { require Term::ReadKey; 1 }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->interactive and eval {
do {
require Term::ReadKey;
1
}
}
MC/DC0%0/2
$self->interactive and eval {
do {
require Term::ReadKey;
1
}
}
$self->interactive
eval {
do {
require Term::ReadKey;
1
}
}
Truth table66%2/3
A and B
A= $self->interactiveB= eval {
do {
require Term::ReadKey;
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my ($columns, $rows) = eval { Term::ReadKey::GetTerminalSize($self->out) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | return ($columns, $rows || 0) if $columns; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$rows || 0
MC/DC0%0/1
$rows || 0
$rows
Truth table0%0/2
A
A= $rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | return ($ENV{COLUMNS} + 0, ($ENV{LINES} || 0) + 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 11 | ▶ | if defined $ENV{COLUMNS} && $ENV{COLUMNS} =~ m/^\d+$/ && $ENV{COLUMNS} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition87%7/8
defined $ENV{"COLUMNS"} and $ENV{"COLUMNS"} =~ /^\d+$/u and $ENV{"COLUMNS"} > 0
defined $ENV{"COLUMNS"} and $ENV{"COLUMNS"} =~ /^\d+$/u
$ENV{'LINES'} || 0
MC/DC66%2/3
defined $ENV{"COLUMNS"} and $ENV{"COLUMNS"} =~ /^\d+$/u and $ENV{"COLUMNS"} > 0
defined $ENV{"COLUMNS"}
$ENV{"COLUMNS"} =~ /^\d+$/u
$ENV{"COLUMNS"} > 0
MC/DC100%1/1
$ENV{'LINES'} || 0
$ENV{'LINES'}
Truth table75%3/4
A and B and C
A= defined $ENV{"COLUMNS"}B= $ENV{"COLUMNS"} =~ /^\d+$/uC= $ENV{"COLUMNS"} > 0
Truth table100%2/2
A
A= $ENV{'LINES'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 8 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 8 | ▶ | sub size { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 8 | my ($columns, $rows) = $self->measured; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 8 | ▶ | return ($columns || 80, $rows || 24); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$columns || 80
$rows || 24
MC/DC100%1/1
$columns || 80
$columns
MC/DC100%1/1
$rows || 24
$rows
Truth table100%2/2
A
A= $columns
Truth table100%2/2
A
A= $rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 7 | ▶ | sub too_small { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
too_small: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 7 | my ($self, $need_columns, $need_rows) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 7 | my ($columns, $rows) = $self->measured; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 7 | ▶ | return undef unless $columns; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 5 | my $narrow = $columns < $need_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 5 | ▶ | my $short = $need_rows && $rows && $rows < $need_rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$need_rows && $rows && $rows < $need_rows
$need_rows and $rows
MC/DC66%2/3
$need_rows && $rows && $rows < $need_rows
$need_rows
$rows
$rows < $need_rows
Truth table75%3/4
A and B && C
A= $need_rowsB= $rowsC= $rows < $need_rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 5 | ▶ | return undef unless $narrow || $short; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$narrow or $short
MC/DC100%2/2
$narrow or $short
$narrow
$short
Truth table100%3/3
A or B
A= $narrowB= $short
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | ▶ | return "This window is $columns columns by $rows lines and $need_columns by $need_rows are needed." | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$need_rows and $rows
MC/DC50%1/2
$need_rows and $rows
$need_rows
$rows
Truth table66%2/3
A and B
A= $need_rowsB= $rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | if $need_rows && $rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | return "This window is $columns columns wide and $need_columns are needed."; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||