keyboard: prepare mode inventory per key
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 21 Feb 2018 08:58:10 +0000 (09:58 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 5 Mar 2018 22:51:17 +0000 (23:51 +0100)
Code cleanup; identical results.

keyboard.plp

index cd75090..1ad9324 100644 (file)
@@ -16,20 +16,25 @@ Html({
 use Shiar_Sheet::Keyboard 2.07;
 use Unicode::Normalize qw( NFKD );
 
-my $usint = [
+my @usintrows = (
        [  'a' ..                                            'z'],
        [qw(Á B ¢ Ð É F G H Í J Œ Ø µ Ñ Ó Ö Ä ® § Þ Ú V Å X Ü Æ)],
        [qw(á b © ð é f g h í j œ ø µ ñ ó ö ä ® ß þ ú v å x ü æ)],
        [qw(Å ı Ç ð ´ ̉ ˝ ̣ ˆ ½  Þ ¾ ˜ Ø ∏ Œ ‰ / ˇ ¨ ◊ „ ˛ ¼ ¸)],
        [qw(å ∫ ç ∂ ́ ƒ © ˙ ̂ ∆ ° ¬ µ ̃ ø π œ ® ß † ̈ √ ∑ ≈ ¥ Ω)],
-];
+);
+my @usint = (
+       map {
+               my $c = $_;
+               [ map { $usintrows[$_]->[$c] } 0 .. 2 ]
+       } 0 .. $#{ $usintrows[0] }
+);
 
 my $keys = Shiar_Sheet::Keyboard->new({
        def => {
                '' => {
                        map {
-                               my $c = $_;
-                               my @row = map { $usint->[$_]->[$c] } 0 .. 2;
+                               my @row = @{$_};
                                my $class = (
                                          !defined $row[2] || $row[0] eq $row[2] ? 1 # identical
                                        : NFKD($row[2]) =~ $row[0] ? 2 # decomposed equivalent
@@ -38,13 +43,13 @@ my $keys = Shiar_Sheet::Keyboard->new({
                                        : 4
                                );
                                $row[0] => "g$class"
-                       } 0 .. $#{ $usint->[0] }
+                       } @usint
                },
        },
        key => {
                map {
-                       $usint->[0]->[$_] => "$usint->[1]->[$_]<br>$usint->[2]->[$_]"
-               } 0 .. $#{ $usint->[0] }
+                       $_->[0] => "$_->[1]<br>$_->[2]"
+               } @usint
        },
        flag => {
                g1 => ['unaltered'],