keyboard: report code errors in altgr includes
[sheet.git] / keyboard.eng.inc.pl
1 use strict;
2 use warnings;
3 use Unicode::Normalize qw( NFKD );
4 use Text::Unidecode qw( unidecode );
5
6 our %rows;
7 my %g; # present group classes
8 {
9         rows => [0, 1],
10         def => {
11                 '' => {
12                         map {
13                                 my $v = $rows{$_};
14                                 my $class = (
15                                           !defined $v || $_ eq $v ? 1 # identical
16                                         : $v =~ /\A\p{Mn}+\z/ ? 9 # combining accent
17                                         : $v =~ /\A[\p{Sk}\p{Lm}]+\z/ ? 8 # modifier symbol
18                                         : $v =~ /\A[\pM\pP]+\z/ ? 7 # mark
19                                         : NFKD($v) =~ /\Q$_/ ? 2 # decomposed equivalent
20                                         : unidecode($v) =~ /\Q$_\E+/i ? 4 # transliterated
21                                         : $v =~ /^\p{Latin}/ ? 5 # latin script
22                                         : 6
23                                 );
24                                 $g{$class} = 1;
25                                 $_ => "g$class"
26                         } keys %rows
27                 },
28         },
29         key => \%rows,
30         flag => {
31                 g1 => ['unaltered', "same results as without modifier"],
32                 g2 => ['accented', "decomposes to the original letter with a combining accent"],
33                 g4 => ['similar', "transliterates (mostly) into the unmodified letter"],
34                 g5 => ['latin', "a different (accented) latin letter"],
35                 g6 => ['symbol', "other character not directly deducible from key"],
36                 g7 => ['punctuation', "(punctuation) mark"],
37                         !$g{9} ? () : (
38                 g8 => ['mark', "modifier letter or mark (spacing diacritic)"],
39                 g9 => ['combining', "diacritical mark to be combined with a following character"],
40                         ),
41         },
42 }