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