lib/TUI/Gadgets/Table.pm

filter: Statementstmt 38.0% 38 / 100 Branchbran 0.0% 0 / 34 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 68.7% 11 / 16 Podpod 100% 5 / 5 totaltotal 34.8% 54 / 155 CC 21 SCAR 48.2
CC
21
Cov
28%
handleEvent
272.0
BUILD
12.0
draw
12.0
CRAP 123.6
« lib/TUI/ColorSel/ColorSelector.pm ↑ Summary lib/TUI/Views/Window.pm »
1 package TUI::Gadgets::Table;
2 # ABSTRACT: ASCII table view displaying the 256 characters of the code page
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 TTable
15 new_TTable
16 );
17
18 5 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use TUI::toolkit::Types qw( :Object );
Subroutine BEGIN: called CC=1 SCAR=0.0
20
21 5 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
22 :evXXXX
23 kbDown
24 kbEnd
25 kbHome
26 kbLeft
27 kbRight
28 kbUp
29 5 );
30 5 ▶use TUI::Drivers::Event;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 5 ▶use TUI::Gadgets::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
32 cmAsciiTableCmdBase
33 cmCharFocused
34 5 );
35 5 ▶use TUI::Views::DrawBuffer;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 5 ▶use TUI::Views::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
37
38 sub TTable() { __PACKAGE__ }
39 sub name() { 'TTable' }
40 0 ▶sub new_TTable { __PACKAGE__->from(@_) }
Subroutine new_TTable: not called CC=1 SCAR=6.9
Pod documented
41
42 5 extends TView;
43
44 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod documented
45 0 my ( $self, $args ) = @_;
46 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
47 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
48 0 $self->{eventMask} |= evKeyboard;
49 0 return;
50 }
51
52 0 ▶sub draw { # void ()
Subroutine draw: not called CC=3 SCAR=24.8
Pod documented
53 0 state $sig = signature(
54 method => Object,
55 pos => [],
56 );
57 0 my ( $self ) = $sig->( @_ );
58
59 0 my $color = $self->getColor( 6 );
60 0 for my $y ( 0 .. $self->{size}{y} - 1 ) {
61 0 my $buf = TDrawBuffer->new();
62 0 $buf->moveChar( 0, ' ', $color, $self->{size}{x} );
63 0 for my $x ( 0 .. $self->{size}{x} - 1 ) {
64 0 $buf->moveChar( $x, chr( ( 32 * $y + $x ) & 0xFF ), $color, 1 );
65 }
66 0 $self->writeLine( 0, $y, $self->{size}{x}, 1, $buf );
67 }
68 0 $self->showCursor();
69 0 return;
70 }
71
72 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=16 SCAR=56.1
Pod documented
73 0 state $sig = signature(
74 method => Object,
75 pos => [Object],
76 );
77 0 my ( $self, $event ) = $sig->( @_ );
78 0 $self->SUPER::handleEvent( $event );
79
80 0 ▶ if ( $event->{what} == evMouseDown ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($event->{'what'} == 1) { } 0 0 0
elsif ($event->{'what'} == 16) { } 0 0 0
81 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$self->mouseEvent($event, 4) and do { do { if ($self->mouseInView($event->{"mouse"}{"where"})) { my $spot = $self->makeLocal($event->{"mouse"}{"where"}); $self->setCursor($spot->{"x"}, $spot->{"y"}); $self->charFocused; } } } 0 0 0
82 0 ▶ if ( $self->mouseInView( $event->{mouse}{where} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mouseInView($event->{"mouse"}{"where"})) 0 0 0
83 0 my $spot = $self->makeLocal( $event->{mouse}{where} );
84 0 $self->setCursor( $spot->{x}, $spot->{y} );
85 0 $self->charFocused();
86 }
87 } while ( $self->mouseEvent( $event, evMouseMove ) );
88 0 $self->clearEvent( $event );
89 }
90 elsif ( $event->{what} == evKeyboard ) {
91 0 my $size = $self->{size};
92 0 my $cursor = $self->{cursor};
93 0 SWITCH: for ( $event->{keyDown}{keyCode} ) {
94 0 ▶ kbHome == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
18176 == $_ and do { $self->setCursor(0, 0); last } 0 0 0
95 0 $self->setCursor( 0, 0 );
96 0 last;
97 };
98 0 ▶ kbEnd == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
20224 == $_ and do { $self->setCursor($size->{"x"} - 1, $size->{"y"} - 1); last } 0 0 0
99 0 $self->setCursor( $size->{x} - 1, $size->{y} - 1 );
100 0 last;
101 };
102 0 ▶ kbUp == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
18432 == $_ and do { $self->setCursor($cursor->{"x"}, $cursor->{"y"} - 1) if $cursor->{"y"} > 0; last } 0 0 0
103 $self->setCursor( $cursor->{x}, $cursor->{y} - 1 )
104 0 ▶ if $cursor->{y} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $cursor->{"y"} > 0 0 0 0
105 0 last;
106 };
107 0 ▶ kbDown == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
20480 == $_ and do { $self->setCursor($cursor->{"x"}, $cursor->{"y"} + 1) if $cursor->{"y"} < $size->{"y"} - 1; last } 0 0 0
108 $self->setCursor( $cursor->{x}, $cursor->{y} + 1 )
109 0 ▶ if $cursor->{y} < $size->{y} - 1;
Branch: 1 branch
BranchTrueFalseTotal
if $cursor->{"y"} < $size->{"y"} - 1 0 0 0
110 0 last;
111 };
112 0 ▶ kbLeft == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
19200 == $_ and do { $self->setCursor($cursor->{"x"} - 1, $cursor->{"y"}) if $cursor->{"x"} > 0; last } 0 0 0
113 $self->setCursor( $cursor->{x} - 1, $cursor->{y} )
114 0 ▶ if $cursor->{x} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $cursor->{"x"} > 0 0 0 0
115 0 last;
116 };
117 0 ▶ kbRight == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
19712 == $_ and do { $self->setCursor($cursor->{"x"} + 1, $cursor->{"y"}) if $cursor->{"x"} < $size->{"x"} - 1; last } 0 0 0
118 $self->setCursor( $cursor->{x} + 1, $cursor->{y} )
119 0 ▶ if $cursor->{x} < $size->{x} - 1;
Branch: 1 branch
BranchTrueFalseTotal
if $cursor->{"x"} < $size->{"x"} - 1 0 0 0
120 0 last;
121 };
122 DEFAULT: {
123 0 my $code = $event->{keyDown}{charScan}{charCode};
124 0 $self->setCursor( $code % 32, int( $code / 32 ) );
125 }
126 } #/ SWITCH: for ( $event->{keyDown}...)
127 0 $self->charFocused();
128 0 $self->clearEvent( $event );
129 }
130 0 return;
131 }
132
133 0 ▶sub charFocused { # void ()
Subroutine charFocused: not called CC=2 SCAR=17.9
Pod documented
134 0 state $sig = signature(
135 method => Object,
136 pos => [],
137 );
138 0 my ( $self ) = $sig->( @_ );
139
140 my $owner = $self->{owner}
141 0 ▶ or return;
Branch: 1 branch
BranchTrueFalseTotal
my $owner = $self->{"owner"} or return 0 0 0
142 my $event = TEvent->new(
143 what => evBroadcast,
144 message => {
145 command => cmAsciiTableCmdBase + cmCharFocused,
146 infoLong => $self->{cursor}{x} + 32 * $self->{cursor}{y},
147 },
148 0 );
149 0 $owner->handleEvent( $event );
150 0 return;
151 }
152
153 5 1
154
155 __END__
« lib/TUI/ColorSel/ColorSelector.pm ↑ Summary lib/TUI/Views/Window.pm »