/usr/share/perl5/App/Asciio/Actions.pm is in asciio 1.02.71-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | package App::Asciio ;
$|++ ;
use strict;
use warnings;
#------------------------------------------------------------------------------------------------------
sub get_key_modifiers
{
my ($event) = @_ ;
my $key_modifiers = $event->state() ;
my $modifiers = $key_modifiers =~ /control-mask/ ? 'C' :0 ;
$modifiers .= $key_modifiers =~ /mod1-mask/ ? 'A' :0 ;
$modifiers .= $key_modifiers =~ /shift-mask/ ? 'S' :0 ;
return($modifiers) ;
}
#------------------------------------------------------------------------------------------------------
my Readonly $SHORTCUTS = 0 ;
my Readonly $CODE = 1 ;
my Readonly $ARGUMENTS = 2 ;
my Readonly $CONTEXT_MENUE_SUB = 3 ;
my Readonly $CONTEXT_MENUE_ARGUMENTS = 4 ;
my Readonly $NAME= 5 ;
my Readonly $ORIGIN= 6 ;
sub run_actions
{
my ($self, @actions) = @_ ;
my @results ;
for my $action (@actions)
{
my @arguments ;
if('ARRAY' eq ref $action)
{
($action, @arguments) = @{ $action } ;
}
my ($modifiers, $action_key) = $action =~ /(...)-(.*)/ ;
if(exists $self->{CURRENT_ACTIONS}{$action})
{
if('HASH' eq ref $self->{CURRENT_ACTIONS}{$action})
{
my $action_group_name =
$self->{CURRENT_ACTIONS}{$action}{GROUP_NAME} || 'unnamed action group' ;
print "using action handlers group '$action_group_name'"
. "[$self->{CURRENT_ACTIONS}{$action}{ORIGIN}].\n" ;
$self->{CURRENT_ACTIONS} = $self->{CURRENT_ACTIONS}{$action} ;
}
else
{
print "Handling input '$modifiers + $action_key' with action '$self->{CURRENT_ACTIONS}{$action}[$NAME]'"
. "[$self->{CURRENT_ACTIONS}{$action}[$ORIGIN]].\n" ;
if(defined $self->{CURRENT_ACTIONS}{$action}[$ARGUMENTS])
{
push @results,
[
$self->{CURRENT_ACTIONS}{$action}[$CODE]->
(
$self,
$self->{CURRENT_ACTIONS}{$action}[$ARGUMENTS],
@arguments
)
] ;
}
else
{
push @results,
[
$self->{CURRENT_ACTIONS}{$action}[$CODE]->($self, @arguments)
] ;
}
}
}
else
{
print "no handler for input '$modifiers + $action_key'.\n" ;
$self->{CURRENT_ACTIONS} = $self->{ACTIONS} ;
}
}
return @results ;
}
#------------------------------------------------------------------------------------------------------
sub run_actions_by_name
{
my ($self, @actions) = @_ ;
my @results ;
my $current_actions_by_name = $self->{ACTIONS_BY_NAME} ;
for my $action (@actions)
{
my @arguments ;
if('ARRAY' eq ref $action)
{
($action, @arguments) = @{ $action } ;
}
if(exists $current_actions_by_name->{$action})
{
if('HASH' eq ref $self->{CURRENT_ACTIONS}{$action})
{
print "using action handlers group '$action'\n" ;
$current_actions_by_name = $self->{CURRENT_ACTIONS}{$action} ;
}
else
{
print "running action '$action'.\n" ;
if(defined $current_actions_by_name->{$action}[$ARGUMENTS])
{
push @results,
[
$current_actions_by_name->{$action}[$CODE]->
(
$self,
$self->{CURRENT_ACTIONS}{$action}[$ARGUMENTS],
@arguments
)
] ;
}
else
{
push @results,
[
$current_actions_by_name->{$action}[$CODE]->($self, @arguments)
] ;
}
}
}
else
{
print "no handler for '$action'.\n" ;
last ;
}
}
return @results ;
}
#------------------------------------------------------------------------------------------------------
sub exists_action
{
my ($self, $action) = @_ ;
return exists $self->{CURRENT_ACTIONS}{$action} ;
}
#------------------------------------------------------------------------------------------------------
1 ;
|