X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/ec70841119a49ebeed4e14ce682f29d15e1ed27d..388747c44481439d1fa4614a804cbaa75441db35:/Shiar_Sheet/Keyboard.pm diff --git a/Shiar_Sheet/Keyboard.pm b/Shiar_Sheet/Keyboard.pm index 2b3cc86..44ecc4d 100644 --- a/Shiar_Sheet/Keyboard.pm +++ b/Shiar_Sheet/Keyboard.pm @@ -6,7 +6,7 @@ use warnings; no warnings 'uninitialized'; # save some useless checks for more legible code use Carp; -our $VERSION = 'v2.05'; +our $VERSION = '2.07'; my @casedesc = (undef, qw/shift ctrl meta/, 'shift meta'); my @rowdesc = qw(numeric top home bottom); @@ -36,6 +36,9 @@ sub new { \%Shiar_Sheet::KeySigns::sign; }; + $self->{showkeys} = $PLP::Script::showkeys; + $self->{style } = $PLP::Script::style; + bless $self, $class; } @@ -125,11 +128,13 @@ sub print_key { sub print_rows { my $self = shift; + my ($rowsspec, $defrows) = @_; + $defrows ||= [2, 1, 0]; my %moderows = ( - -DEFAULT => !!@_ && $_[0] ne '' && split(/(?:\s*([^=\s]*)=\s*)/, shift), + -DEFAULT => defined $rowsspec && $rowsspec ne '' && + split(/\s* ([^=\s]*) = \s*/x, $rowsspec), # plus specific mode overrides prefixed by '=' ); - my $defrows = shift || [2, 1, 0]; my @modes = sort keys %{ $self->{def} }; print ''."\n\n"; @@ -140,8 +145,8 @@ sub print_rows { printf qq{\n}, $row+1; for my $basemode (@modes) { my @moderows = split /\s+/, - $row < 0 ? "0" : - defined $moderows{$basemode} ? $moderows{$basemode} : $moderows{-DEFAULT}; + $row < 0 ? '1' : # top row (esc key) always unshifted + $moderows{$basemode} // $moderows{-DEFAULT}; for my $submode (@moderows ? @moderows : '') { my $mode = $basemode . $submode; @@ -183,11 +188,43 @@ sub print_legend { my $self = shift; my ($class, $flags) = @_; - print qq{\t\t
\n}; + say qq{\t\t
}; printf("\t\t".'
%s'."\n\t\t\t".'
%s'."\n", $_, map { $self->escapedesc($_) } @{ $self->{flag}->{$_} || ["($_)", '...'] } ) for @$flags; - print "\t\t
"; + say "\t\t
"; +} + +sub print_legends { + my $self = shift; + my ($input) = @_; + + say "
\n"; + say '
'; + + say "\t", '
'; + my @groups = sort grep {/^g\d/} keys %{ $self->{flag} }; + $self->print_legend('legend-types', \@groups); + say "\t
\n"; + + say "\t", '
'; + my @attr = sort grep {!/^g\d/} keys %{ $self->{flag} }; + $self->print_legend('legend-options', \@attr); + say ''; + + say "\t\t", '"; + say "\t
\n"; + say "
\n"; } 1;