blib/lib/App/Asciio/Actions.pm

filter: Statementstmt 7.3% 5 / 68 Branchbran 0.0% 0 / 50 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 20.0% 1 / 5 Podpod 0.0% 0 / 4 totaltotal 3.7% 6 / 159 CC 35 SCAR 63.0
CC
35
Cov
4%
run_actions
756.0
run_actions_by_name
90.0
use_action_group
2.0
CRAP 544.3
« blib/lib/App/Asciio/Text/Asciio.pm ↑ Summary blib/lib/App/Asciio/setup/hooks/canonize_connections.pl »
1  
2 package App::Asciio ;
3 4 ▶use Encode ;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 #------------------------------------------------------------------------------------------------------
6  
7 4 $|++ ;
8  
9 #------------------------------------------------------------------------------------------------------
10  
11 sub use_action_group
12 0 ▶{
Subroutine use_action_group: not called CC=1 SCAR=6.9
Pod undocumented
13 0 my ($self, $action) = @_ ; ;
14  
15 0 $self->{CURRENT_ACTIONS} = $self->{ACTIONS} ;
16 0 $self->run_actions($action) ;
17 0 $self->{CROSS_ACTION_GROUP}++ ;
18 }
19  
20 #------------------------------------------------------------------------------------------------------
21  
22 sub run_actions
23 0 ▶{
Subroutine run_actions: not called CC=27 SCAR=66.3
Pod undocumented
24 0 my ($self, @actions) = @_ ;
25  
26 0 my @results ;
27  
28 0 for my $action (@actions)
29 {
30 0 my @arguments ;
31
32 0 ▶ if('ARRAY' eq ref $action)
Branch: 1 branch
BranchTrueFalseTotal
if ("ARRAY" eq ref $action) 0 0 0
33 {
34 0 ($action, @arguments) = @{ $action } ;
35 }
36
37 0 my ($modifiers, $action_key) = $action =~ /(...-)?(.*)/ ;
38
39 0 ▶ next if $action_key eq 'Shift_R' || $action_key eq 'Shift_L' || $action_key eq 'Alt_R' || $action_key eq 'Alt_L' ;
Branch: 1 branch
BranchTrueFalseTotal
if $action_key eq "Shift_R" or $action_key eq "Shift_L" or $action_key eq "Alt_R" or $action_key eq "Alt_L" 0 0 0
Condition0%0/9
$action_key eq "Shift_R" or $action_key eq "Shift_L" or $action_key eq "Alt_R" or $action_key eq "Alt_L"
l!l&&r!l&&!r
000
$action_key eq "Shift_R" or $action_key eq "Shift_L" or $action_key eq "Alt_R"
l!l&&r!l&&!r
000
$action_key eq "Shift_R" or $action_key eq "Shift_L"
l!l&&r!l&&!r
000
MC/DC0%0/4
$action_key eq "Shift_R" or $action_key eq "Shift_L" or $action_key eq "Alt_R" or $action_key eq "Alt_L"
$action_key eq "Shift_R" $action_key eq "Shift_L" $action_key eq "Alt_R" $action_key eq "Alt_L"
Truth table0%0/5
A or B or C or D
A= $action_key eq "Shift_R"B= $action_key eq "Shift_L"C= $action_key eq "Alt_R"D= $action_key eq "Alt_L"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
40 # C00-Shift_R
41 # C00-Shift_L
42 # C00-Alt_L
43 # C00-Alt_L
44 # CA0-Shift_R
45 # C00-Shift_L
46 # C0S-Shift_R
47 # 0A0-Shift_R
48 # 0A0-Shift_L
49
50 0 my $action = encode('utf8', $action) ;
51
52 0 ▶ if(exists $self->{CURRENT_ACTIONS}{$action})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'CURRENT_ACTIONS'}{$action}) { } 0 0 0
53 {
54 0 my $is_group = $self->{CURRENT_ACTIONS}{$action}{IS_GROUP} ;
55 0 my $in_capture = defined $self->{CURRENT_ACTIONS}{ESCAPE_KEY} ;
56
57 my $group_tag = $is_group ? defined $self->{CURRENT_ACTIONS}{$action}{ESCAPE_KEY}
58 0 ▶ ? "[c] "
Branch: 2 branches
BranchTrueFalseTotal
$is_group ? : 0 0 0
defined $self->{'CURRENT_ACTIONS'}{$action}{'ESCAPE_KEY'} ? : 0 0 0
59 : "[g] "
60 : '' ;
61
62 0 ▶ my $capture_tag = $in_capture ? "[$self->{CURRENT_ACTIONS}{NAME}] " : '' ;
Branch: 1 branch
BranchTrueFalseTotal
$in_capture ? : 0 0 0
63
64 $self->{ACTION_VERBOSE}->
65 (
66 sprintf
67 (
68 "%-30s %-30s [%s]",
69 "${modifiers}$action_key $group_tag$capture_tag",
70 $self->{CURRENT_ACTIONS}{$action}{NAME},
71 $self->{CURRENT_ACTIONS}{$action}{ORIGIN}
72 )
73 0 ▶ ) if $self->{ACTION_VERBOSE} && $self->{CURRENT_ACTIONS}{$action}{NAME} ne 'Mouse motion' ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ACTION_VERBOSE"} and $self->{"CURRENT_ACTIONS"}{$action}{"NAME"} ne "Mouse motion" 0 0 0
Condition0%0/3
$self->{"ACTION_VERBOSE"} and $self->{"CURRENT_ACTIONS"}{$action}{"NAME"} ne "Mouse motion"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"ACTION_VERBOSE"} and $self->{"CURRENT_ACTIONS"}{$action}{"NAME"} ne "Mouse motion"
$self->{"ACTION_VERBOSE"} $self->{"CURRENT_ACTIONS"}{$action}{"NAME"} ne "Mouse motion"
Truth table0%0/3
A and B
A= $self->{"ACTION_VERBOSE"}B= $self->{"CURRENT_ACTIONS"}{$action}{"NAME"} ne "Mouse motion"
ABresult
0X0
100
111
74
75 0 ▶ if(defined $self->{CURRENT_ACTIONS}{$action}{ARGUMENTS})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'CURRENT_ACTIONS'}{$action}{'ARGUMENTS'}) { } 0 0 0
76 {
77 push @results,
78 [
79 $self->{CURRENT_ACTIONS}{$action}{CODE}->
80 (
81 $self,
82 $self->{CURRENT_ACTIONS}{$action}{ARGUMENTS},
83 0 @arguments,
84 )
85 ] ;
86 }
87 else
88 {
89 push @results,
90 [
91 0 $self->{CURRENT_ACTIONS}{$action}{CODE}->($self, @arguments)
92 ] ;
93 }
94
95 0 ▶ $self->{CURRENT_ACTIONS} = $self->{ACTIONS} unless $is_group || $in_capture || $self->{CROSS_ACTION_GROUP} ;
Branch: 1 branch
BranchTrueFalseTotal
unless $is_group or $in_capture or $self->{"CROSS_ACTION_GROUP"} 0 0 0
Condition0%0/6
$is_group or $in_capture or $self->{"CROSS_ACTION_GROUP"}
l!l&&r!l&&!r
000
$is_group or $in_capture
l!l&&r!l&&!r
000
MC/DC0%0/3
$is_group or $in_capture or $self->{"CROSS_ACTION_GROUP"}
$is_group $in_capture $self->{"CROSS_ACTION_GROUP"}
Truth table0%0/4
A or B or C
A= $is_groupB= $in_captureC= $self->{"CROSS_ACTION_GROUP"}
ABCresult
1XX1
01X1
0011
0000
96 0 delete $self->{CROSS_ACTION_GROUP} ;
97
98 0 ▶ if($is_group && defined $self->{CURRENT_ACTIONS}{ENTER_GROUP})
Branch: 1 branch
BranchTrueFalseTotal
if ($is_group and defined $self->{"CURRENT_ACTIONS"}{"ENTER_GROUP"}) 0 0 0
Condition0%0/3
$is_group and defined $self->{"CURRENT_ACTIONS"}{"ENTER_GROUP"}
!ll&&!rl&&r
000
MC/DC0%0/2
$is_group and defined $self->{"CURRENT_ACTIONS"}{"ENTER_GROUP"}
$is_group defined $self->{"CURRENT_ACTIONS"}{"ENTER_GROUP"}
Truth table0%0/3
A and B
A= $is_groupB= defined $self->{"CURRENT_ACTIONS"}{"ENTER_GROUP"}
ABresult
0X0
100
111
99 {
100 0 $self->{CURRENT_ACTIONS}{ENTER_GROUP}->($self) ;
101 }
102
103 0 ▶ if(defined $self->{CURRENT_ACTIONS}{ESCAPE_KEY})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"CURRENT_ACTIONS"}{"ESCAPE_KEY"}) 0 0 0
104 {
105 0 my $escape_key = "escape key: $self->{CURRENT_ACTIONS}{ESCAPE_KEY}" ;
106
107 0 ▶ if($action eq $self->{CURRENT_ACTIONS}{ESCAPE_KEY})
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq $self->{"CURRENT_ACTIONS"}{"ESCAPE_KEY"}) 0 0 0
108 {
109 0 ▶ $self->{ACTION_VERBOSE}->("\e[33m[$self->{CURRENT_ACTIONS}{NAME}] leaving\e[m") if $self->{ACTION_VERBOSE} ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ACTION_VERBOSE"} 0 0 0
110 0 $self->{CURRENT_ACTIONS} = $self->{ACTIONS} ;
111 }
112 }
113 }
114 else
115 {
116 0 ▶ if(defined $self->{CURRENT_ACTIONS}{ESCAPE_KEY})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'CURRENT_ACTIONS'}{'ESCAPE_KEY'}) { } 0 0 0
117 {
118 0 my $escape_key = "escape key: $self->{CURRENT_ACTIONS}{ESCAPE_KEY}" ;
119
120 0 ▶ if($action eq $self->{CURRENT_ACTIONS}{ESCAPE_KEY})
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq $self->{'CURRENT_ACTIONS'}{'ESCAPE_KEY'}) { } 0 0 0
121 {
122 0 ▶ $self->{ACTION_VERBOSE}->("\e[33m[$self->{CURRENT_ACTIONS}{NAME}] leaving\e[m") if $self->{ACTION_VERBOSE} ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ACTION_VERBOSE"} 0 0 0
123 0 $self->{CURRENT_ACTIONS} = $self->{ACTIONS} ;
124 }
125 else
126 {
127 0 ▶ $self->{ACTION_VERBOSE}->("\e[31m$action, [$self->{CURRENT_ACTIONS}{NAME}], $escape_key\e[m") if $self->{ACTION_VERBOSE} ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ACTION_VERBOSE"} 0 0 0
128 }
129 }
130 else
131 {
132 0 ▶ $self->{ACTION_VERBOSE}->(sprintf "\e[31m%-30s\e[m", "$action") if $self->{ACTION_VERBOSE} ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ACTION_VERBOSE"} 0 0 0
133 0 $self->{CURRENT_ACTIONS} = $self->{ACTIONS} ;
134 }
135
136 0 $self->update_display() ;
137 }
138 }
139
140 0 return @results ;
141 }
142  
143 #------------------------------------------------------------------------------------------------------
144  
145 sub run_actions_by_name
146 0 ▶{
Subroutine run_actions_by_name: not called CC=9 SCAR=45.0
Pod undocumented
147 0 my ($self, @actions) = @_ ;
148 0 my @results ;
149  
150 0 my $current_actions_by_name = $self->{ACTIONS_BY_NAME} ;
151  
152 0 for my $action (@actions)
153 {
154 0 my @arguments ;
155
156 0 ▶ if('ARRAY' eq ref $action)
Branch: 1 branch
BranchTrueFalseTotal
if ("ARRAY" eq ref $action) 0 0 0
157 {
158 0 ($action, @arguments) = @{ $action } ;
159 }
160
161 0 ▶ if(exists $current_actions_by_name->{$action})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $current_actions_by_name->{$action}) { } 0 0 0
162 {
163 0 ▶ if('HASH' eq ref $self->{CURRENT_ACTIONS}{$action})
Branch: 1 branch
BranchTrueFalseTotal
if ('HASH' eq ref $self->{'CURRENT_ACTIONS'}{$action}) { } 0 0 0
164 {
165 0 ▶ $self->{ACTION_VERBOSE}->(sprintf '%30s %s', '', "\e[32m$action [group]\e[0m") if $self->{ACTION_VERBOSE} ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ACTION_VERBOSE"} 0 0 0
166 0 $current_actions_by_name = $self->{CURRENT_ACTIONS}{$action} ;
167 }
168 else
169 {
170 0 ▶ $self->{ACTION_VERBOSE}->(sprintf '%30s %s', '', "\e[32m$action\e[0m") if $self->{ACTION_VERBOSE} ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ACTION_VERBOSE"} 0 0 0
171
172 0 ▶ if(defined $current_actions_by_name->{$action}{ARGUMENTS})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $current_actions_by_name->{$action}{'ARGUMENTS'}) { } 0 0 0
173 {
174 push @results,
175 [
176 $current_actions_by_name->{$action}{CODE}->
177 (
178 $self,
179 $self->{CURRENT_ACTIONS}{$action}{ARGUMENTS},
180 @arguments
181 0 )
182 ] ;
183 }
184 else
185 {
186 push @results,
187 [
188 0 $current_actions_by_name->{$action}{CODE}->($self, @arguments)
189 ] ;
190 }
191 }
192 }
193 else
194 {
195 0 ▶ $self->{ACTION_VERBOSE}->(sprintf '%30s %s', '', "\e[31m$action\e[0m") if $self->{ACTION_VERBOSE} ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ACTION_VERBOSE"} 0 0 0
196 0 last ;
197 }
198 }
199  
200 0 return @results ;
201 }
202  
203 #------------------------------------------------------------------------------------------------------
204  
205 sub exists_action
206 0 ▶{
Subroutine exists_action: not called CC=1 SCAR=6.9
Pod undocumented
207 0 my ($self, $action) = @_ ;
208  
209 0 return exists $self->{CURRENT_ACTIONS}{$action} ;
210 }
211  
212 #------------------------------------------------------------------------------------------------------
213  
214 4 1 ;
« blib/lib/App/Asciio/Text/Asciio.pm ↑ Summary blib/lib/App/Asciio/setup/hooks/canonize_connections.pl »