keyboard/altgr/index: move ctrl rows to distinct inventory mode
[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         ipa     => [qw( ipa-ucl xipa )],
8         latin   => [qw( ipa-ucl olpc boyeg drix )],
9         science => [qw( symbolics apl spacecadet )],
10         graph => [qw( unigraph emojiworks )],
11         extra => [qw( msx-graph c64 atari p8scii zoo )],
12 );
13
14 for my $name (map {@{$_}} values %cat) {
15         my $keys = do "keyboard/altgr/$name.eng.inc.pl" or next;
16         my %row = %{$keys}{qw( title category flag mode image imagealt )};
17         $cat{$name} = \%row;
18
19         $row{mode} //= {'' => undef};
20
21         if (($keys->{moderows} // '') =~ /^\d* [3-9] \d{2,}/x) {
22                 # move root ^ctrl or +meta keys to distinct mode
23                 $row{mode}{"\e"} = '+';
24                 /^[+^]./ and $keys->{def}{"\e"}{$_} = delete $keys->{def}{''}{$_}
25                         for keys %{ $keys->{def}{''} };
26         }
27
28         for my $mode (keys %{ $row{mode} }) {
29                 $row{inventory}{$mode}{$_}++
30                         for grep { /^g[2-9]/ } map { s/ (?!ext).*//r } map {$_->[0]}
31                         values %{ $keys->{def}{$mode} };
32         }
33 }
34
35 \%cat