X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/79f8945f7b66f8cf1ba1f1b84567665a051a76ff..2a3184b0ed95d89b689961a394e3d1035494ee45:/Shiar_Sheet/Keyboard.pm?ds=inline
diff --git a/Shiar_Sheet/Keyboard.pm b/Shiar_Sheet/Keyboard.pm
index 6ba2a4a..4bc142c 100644
--- a/Shiar_Sheet/Keyboard.pm
+++ b/Shiar_Sheet/Keyboard.pm
@@ -5,7 +5,7 @@ use warnings;
no warnings 'uninitialized'; # save some useless checks for more legible code
use Carp;
-our $VERSION = '1.02';
+our $VERSION = 'v1.04';
my @casedesc = (undef, qw/shift ctrl meta/, 'shift meta');
my @rowdesc = qw(numeric top home bottom);
@@ -90,6 +90,7 @@ sub print_key {
$keytxt .= $self->{sign}->{$1} while $flags =~ s/(?:^| )(arg[a-ln-z]?)\b//; # arguments
$keytxt .= "$self->{sign}->{motion}" if $flags =~ s/ ?\bargm\b//; # motion argument
$keytxt =~ s{\^(?=.)}{^}; # element around ctrl-identifier
+ $keytxt =~ s{\+(?=.)}{+}; # meta
my $onclick = $flags =~ s/ ?\bmode(\S*)// && defined $self->{keys}{$1} && sprintf(
' onclick="setmode(%s)"',
$1 eq '' ? '' : sprintf(q{'mode%s'}, escapeclass($1))
@@ -97,6 +98,7 @@ sub print_key {
$onclick .= sprintf(q{ onclick="document.location='%s'"}, $1)
if $flags =~ s/ ?\blink(\S*)//;
my $keyhint = defined($mnem) && qq{ title="$mnem"};
+ $flags .= ' chr'.ord(substr $key, -1) if $key ne '^0';
print qq{\t\t
$keytxt};
print ' ', $desc if defined $desc;
@@ -105,29 +107,37 @@ sub print_key {
sub print_rows {
my $self = shift;
- my $static = shift;
- my @moderows = $static ? split(/\s+/, $static) : sort keys %{ $self->{keys} };
+ my %moderows = (
+ -DEFAULT => !@_ ? '' : split(/(?:\s*([^=\s]*)=\s*)/, shift),
+ # plus specific mode overrides prefixed by '='
+ );
+ my $defrows = shift || [2, 1, 0];
+ my @modes = sort keys %{ $self->{keys} };
for (my $row = 0; $row <= $#{ $keyrows{$self->{map}} }; $row++) {
my $keyrow = $keyrows{$self->{map}}->[$row];
- my @caserows = 0 .. $#$keyrow;
print qq{\n};
- for my $modefull (@moderows) {
- my $mode = $modefull;
- my @showcase = $mode =~ s/(\d+)(?:-(\d+))?$//
- ? (map {3 - $_} split //, $row == 0 && $2 || $1) : @caserows;
+ for my $basemode (@modes) {
+ my @moderows = split /\s+/,
+ defined $moderows{$basemode} ? $moderows{$basemode} : $moderows{-DEFAULT};
+
+ for my $submode (@moderows ? @moderows : '') {
+ my $mode = $basemode . $submode;
+ my @caserows = $mode =~ s/(\d+)(?:-(\d+))?$//
+ ? (map {$_ - 1} split //, $row == 0 && $2 || $1) # user override
+ : @$defrows; # default
my $modekeys = $self->{keys}{$mode};
- for my $case (@showcase) {
+ for my $case (@caserows) {
my $keycase = $keyrow->[$case] or next;
@$keycase or next;
- printf "\t- ", $mode ne '' && sprintf(
- ' class="%s"', ($static ? '' : 'mode ') . 'mode' . escapeclass($mode)
+ printf "\t
- ", $basemode ne '' && sprintf(
+ ' class="%s"', 'mode mode' . escapeclass($basemode)
);
printf("
%s: %s
\n", # XXX insert here to fix msie<=6
- $modekeys->{desc} || "mode $mode",
+ $modekeys->{desc} || "mode $basemode",
"$rowdesc[$row] row $casedesc[$case]"
);
my $caseclass = 'keys';
@@ -138,7 +148,9 @@ sub print_rows {
print qq{\t\t
\n};
} # case
- } # mode
+ } # submode
+
+ } # basemode
print qq{\t\n};
} # row
}