From: Mischa POSLAWSKY Date: Sun, 18 Jun 2017 11:59:27 +0000 (+0200) Subject: vi: generic function to print entire help legends X-Git-Tag: v1.11~29 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/8bf4b29ac2bea396e7aafe10713ec3b148a153a8 vi: generic function to print entire help legends Replace setup of help container consisting of left type legend (ordered .g*) and right options legend (other flags and provided user options) as it is identical on all other keyboard pages. --- diff --git a/Shiar_Sheet/Keyboard.pm b/Shiar_Sheet/Keyboard.pm index c5fdb09..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.06'; +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; } @@ -185,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\t
  • keyboard map is ", + ($input->{map} ? 'set to ' : ''), "$self->{map}"; + say "\t\t
  • keys are ", + "", ($self->{showkeys} ? 'always shown' : 'hidden if unassigned'), "", + (!defined $self->{showkeys} && ' by default'); + say "\t\t
  • default style is ", + (defined $input->{style} && 'set to '), "$self->{style}"; + + say "\t\t
"; + say "\t
\n"; + say "
\n"; } 1; diff --git a/vi.eng.inc.pl b/vi.eng.inc.pl index 77c6acc..823bbfe 100644 --- a/vi.eng.inc.pl +++ b/vi.eng.inc.pl @@ -472,8 +472,8 @@ flag => { arg => ["key", "Commands with a dot need a char argument afterwards."], motion => ["key", "Requires a motion afterwards, operates between cursor and destination."], - 'ext vim6' => ["vim", "Not in original Vi (assessment incomplete)."], - 'ext new vim7' => ["vim7", "New in vim version 7.x."], + 'vim6 ext' => ["vim", "Not in original Vi (assessment incomplete)."], + 'vim7 ext new' => ["vim7", "New in vim version 7.x."], }, def => { diff --git a/vi.plp b/vi.plp index 203fdc8..9a11580 100644 --- a/vi.plp +++ b/vi.plp @@ -20,36 +20,10 @@ Html({

normal mode (default)

<: -use Shiar_Sheet::Keyboard 2; +use Shiar_Sheet::Keyboard 2.07; my $info = do 'vi.eng.inc.pl' or die $@; my $keys = Shiar_Sheet::Keyboard->new($info); $keys->map($get{map}) or undef $get{map}; $keys->print_rows($get{rows}); -:> - -
- -
-
-<: - $keys->print_legend('legend-types', ['g1' .. 'g4', 'g6' .. 'g9']); -:> -
- -
-<: - $keys->print_legend('legend-options', [qw'arg motion', 'ext vim6', 'ext new vim7']); -:> - -
    -
  • keyboard map is - <:= $get{map} ? 'set to ' : '' :><:= $keys->{map} :> -
  • keys are - <:= $showkeys ? 'always shown' : 'hidden if unassigned' :><:= - !defined $showkeys && ' by default' :> -
  • default style is - <:= defined $get{style} && 'set to ' :><:= $style :> -
-
-
+$keys->print_legends(\%get);