keyboard: distinct altgr subpage for macos
[sheet.git] / keyboard.eng.inc.pl
1 use Unicode::Normalize qw( NFKD );
2 use Text::Unidecode qw( unidecode );
3
4 {
5         rows => [0, 1],
6         def => {
7                 '' => {
8                         map {
9                                 my $v = $rows{$_};
10                                 my $class = (
11                                           !defined $v || $_ eq $v ? 1 # identical
12                                         : $v =~ /\A\p{Mn}+\z/ ? 8 # combining accent
13                                         : NFKD($v) =~ $_ ? 2 # decomposed equivalent
14                                         : $v =~ /^\p{Latin}/ ? 4 # latin script
15                                         : unidecode($v) =~ /^\W*\Q$_/ ? 5 # transliterated
16                                         : 7
17                                 );
18                                 $_ => "g$class"
19                         } keys %rows
20                 },
21         },
22         key => \%rows,
23         flag => {
24                 g1 => ['unaltered', "same results as without modifier"],
25                 g2 => ['accented', "decomposes to the original letter with a combining accent"],
26                 g4 => ['latin', "a different (accented) latin letter"],
27                 g5 => ['similar', "transliterates (mostly) into the unmodified letter"],
28                 g7 => ['other', "symbol not directly deducible from key"],
29                 g8 => ['combining', "diacritical mark to be combined with a following character"],
30         },
31 }