package Shiar_Sheet::Keyboard;
+use 5.010;
use strict;
use warnings;
no warnings 'uninitialized'; # save some useless checks for more legible code
use Carp;
-our $VERSION = 'v2.03';
+our $VERSION = 'v2.04';
my @casedesc = (undef, qw/shift ctrl meta/, 'shift meta');
my @rowdesc = qw(numeric top home bottom);
croak 'No key definitions specified' unless ref $self->{def} eq 'HASH';
$self->{map} ||= 'qwerty';
- my $parent = (caller)[0]; # calling module
- my $sign = do {
- no strict 'refs'; # temporarily allow variable references
- \%{ $parent.'::sign' }; # return %sign from parent
+ $self->{sign} ||= do {
+ require Shiar_Sheet::KeySigns;
+ Shiar_Sheet::KeySigns->VERSION(1.04);
+ \%Shiar_Sheet::KeySigns::sign;
};
- croak "%${parent}::sign not found" unless %$sign;
- $self->{sign} = $sign;
bless $self, $class;
}
return $_;
}
+sub escapedesc {
+ my $self = shift;
+ local $_ = shift;
+ s{ (< ([^>]*) >) }{ $self->{sign}->{$2} // $1 }xeg;
+ return $_;
+}
+
sub keyunalias {
my $self = shift;
my ($key, $ancestry) = @_;
}
my ($flags, $desc, $mnem) = @{$flags};
if (my $txt = $self->{key}->{$mode.$key}) {
- ($desc, $mnem) = split /\n/, $txt;
+ ($desc, $mnem) = split /\n/, $self->escapedesc($txt);
}
# $key = $keytrans{$key} if defined $keytrans{$key};
' class="%s"', join ' ', @caseclass
);
printf('<th>%s<small>: %s</small></th>', # XXX insert here to fix msie<=6
- $self->{mode}->{$mode} || "mode $basemode",
+ $self->escapedesc($self->{mode}->{$mode} || "mode $basemode"),
"$rowdesc[$row] row $casedesc[$case]"
) unless $row < 0;
print "\n";
print qq{\t\t<dl class="legend $class">\n};
printf("\t\t".'<dt class="%s">%s'."\n\t\t\t".'<dd>%s'."\n",
- $_, @{ $self->{flag}->{$_} || ["($_)", '...'] }
+ $_, map { $self->escapedesc($_) } @{ $self->{flag}->{$_} || ["($_)", '...'] }
) for @$flags;
print "\t\t</dl>";
}