vi: move legend data to translations include
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 18 Jun 2010 22:29:37 +0000 (22:29 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 29 Jun 2010 17:43:52 +0000 (19:43 +0200)
Move generic formatting to a reusable function.

Shiar_Sheet/Keyboard.pm
vi.eng.inc.pl
vi.plp

index 760733595c4d7cf2a0351613544d766e23d32b9b..7713009487f108a9732de3cc61c783b3cf85ce2f 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 no  warnings 'uninitialized';  # save some useless checks for more legible code
 use Carp;
 
 no  warnings 'uninitialized';  # save some useless checks for more legible code
 use Carp;
 
-our $VERSION = 'v2.00';
+our $VERSION = 'v2.01';
 
 my @casedesc = (undef, qw/shift ctrl meta/, 'shift meta');
 my @rowdesc = qw(numeric top home bottom);
 
 my @casedesc = (undef, qw/shift ctrl meta/, 'shift meta');
 my @rowdesc = qw(numeric top home bottom);
@@ -168,6 +168,17 @@ sub print_rows {
        } # row
 }
 
        } # row
 }
 
+sub print_legend {
+       my $self = shift;
+       my ($class, $flags) = @_;
+
+       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}->{$_} || ["($_)", '...'] }
+       ) for @$flags;
+       print "\t\t</dl>";
+}
+
 1;
 
 =head1 NAME
 1;
 
 =head1 NAME
index 9a4f6f132420ba2366227407a4485859f5d6cb70..7fb456bfcca459eb084d4d1440698ebb1b35ba5b 100644 (file)
@@ -459,4 +459,20 @@ mode => {
        'i^x' => "insert completion commands (i ctrl-x)",
 },
 
        'i^x' => "insert completion commands (i ctrl-x)",
 },
 
+flag => {
+       ci => ["info", "Info command: shows/does something without altering anything."],
+       pm => ["motion", "Moves the cursor, or defines the range for an operator (<:= $sign{motion} :>)."],
+       po => ["positioning", "Other movement (jumps, window (re)positioning)."],
+       co => ["command", "Direct action command."],
+       mi => ["ins mode", "Enters Insert or Replace mode."],
+       mo => ["mode", "Enters a different mode."],
+       mv => ["vis mode", "Enters Visual or Select mode."],
+       me => ["key cmd", "Additional key commands (click for overview)."],
+
+       arg => ["key$sign{arg}", "Commands with a dot need a char argument afterwards."],
+       motion => ["key$sign{motion}", "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."],
+},
+
 }
 }
diff --git a/vi.plp b/vi.plp
index f5820f12910c43c2c23548e98477a06bce49a521..ba92e1771207a69e000cd23cabde21d52e90a063 100644 (file)
--- a/vi.plp
+++ b/vi.plp
@@ -43,37 +43,15 @@ $keys->print_rows($get{rows});
 
 <div class="help">
        <div class="left">
 
 <div class="help">
        <div class="left">
-               <dl class="legend legend-types">
-               <dt class="ci">info
-                       <dd>Info command: shows/does something without altering anything.
-               <dt class="pm">motion
-                       <dd>Moves the cursor, or defines the range for an operator (<:= $sign{motion} :>).
-               <dt class="po">positioning
-                       <dd>Other movement (jumps, window (re)positioning).
-               <dt class="co">command
-                       <dd>Direct action command.
-               <dt class="mi">ins mode
-                       <dd>Enters Insert or Replace mode.
-               <dt class="mo">mode
-                       <dd>Enters a different mode.
-               <dt class="mv">vis mode
-                       <dd>Enters Visual or Select mode.
-               <dt class="me">key cmd
-                       <dd>Additional key commands (click for overview).
-               </dl>
+<:
+               $keys->print_legend('legend-types', [qw'ci pm po co mi mo mv me']);
+:>
        </div>
 
        <div class="right">
        </div>
 
        <div class="right">
-               <dl class="legend legend-options">
-               <dt>key<:= $sign{arg} :>
-                       <dd>Commands with a dot need a char argument afterwards.
-               <dt>key<:= $sign{motion} :>
-                       <dd>Requires a motion afterwards, operates between cursor and destination.
-               <dt class="ext vim6">vim
-                       <dd>Not in original Vi (assessment incomplete).
-               <dt class="ext new vim7">vim7
-                       <dd>New in vim version 7.x.
-               </dl>
+<:
+               $keys->print_legend('legend-options', [qw'arg motion', 'ext vim6', 'ext new vim7']);
+:>
 
                <ul class="legend legend-set">
                <li>keyboard <strong>map</strong> is
 
                <ul class="legend legend-set">
                <li>keyboard <strong>map</strong> is