keyboard/altgr/index: metadata and inventory counts in include
[sheet.git] / keyboard / altgr / index.inc.pl
index 47a0b7a88add1be44f09e8328b11cc1630cf4891..a9030e0e321e2648ee3b4c0160b48e78bde4c239 100644 (file)
@@ -1,9 +1,26 @@
 use strict;
-+{
+use warnings;
+
+my %cat = (
        default => [qw( euro latin science graph )],
        euro => [qw( windows ukext macos macos-abc weur eurkey msx )],
        latin => [qw( ipa olpc boyeg drix )],
        science => [qw( symbolics apl spacecadet )],
        graph => [qw( unigraph emojiworks )],
        extra => [qw( msx-graph p8scii zoo )],
+);
+
+for my $name (map {@{$_}} values %cat) {
+       my $keys = do "keyboard/altgr/$name.eng.inc.pl" or next;
+       my %row = %{$keys}{qw( title category flag mode image imagealt )};
+       $cat{$name} = \%row;
+
+       $keys->{mode} //= {'' => undef};
+       for my $mode (keys %{ $keys->{mode} }) {
+               $row{key}{$_} = $keys->{key}{$_} for $mode || ();
+               $row{inventory}{$mode}{$_}++ for grep { /^g[2-9]/ } map { s/ (?!ext).*//r }
+                       values %{ $keys->{def}{$mode} };
+       }
 }
+
+\%cat