keyboard/altgr/index: metadata and inventory counts in include
[sheet.git] / keyboard / altgr / index.inc.pl
1 use strict;
2 use warnings;
3
4 my %cat = (
5         default => [qw( euro latin science graph )],
6         euro => [qw( windows ukext macos macos-abc weur eurkey msx )],
7         latin => [qw( ipa olpc boyeg drix )],
8         science => [qw( symbolics apl spacecadet )],
9         graph => [qw( unigraph emojiworks )],
10         extra => [qw( msx-graph p8scii zoo )],
11 );
12
13 for my $name (map {@{$_}} values %cat) {
14         my $keys = do "keyboard/altgr/$name.eng.inc.pl" or next;
15         my %row = %{$keys}{qw( title category flag mode image imagealt )};
16         $cat{$name} = \%row;
17
18         $keys->{mode} //= {'' => undef};
19         for my $mode (keys %{ $keys->{mode} }) {
20                 $row{key}{$_} = $keys->{key}{$_} for $mode || ();
21                 $row{inventory}{$mode}{$_}++ for grep { /^g[2-9]/ } map { s/ (?!ext).*//r }
22                         values %{ $keys->{def}{$mode} };
23         }
24 }
25
26 \%cat