unicode: avoid undetected use of lexical_topic
[sheet.git] / keyboard.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'keyboard cheat sheet',
5         version => '1.0',
6         stylesheet => [qw( light dark circus mono red )],
7         keys => 1,
8 });
9
10 :>
11 <h1>keyboard cheat sheet</h1>
12
13 <h2>normal mode (default)</h2>
14
15 <:
16 use Shiar_Sheet::Keyboard 2.07;
17 use Unicode::Normalize qw( NFKD );
18
19 my $usint = [
20         [  'a' ..                                            'z'],
21         [qw(Á B ¢ Ð É F G H Í J Œ Ø µ Ñ Ó Ö Ä ® § Þ Ú V Å X Ü Æ)],
22         [qw(á b © ð é f g h í j œ ø µ ñ ó ö ä ® ß þ ú v å x ü æ)],
23         [qw(Å ı Ç ð ´ ̉ ˝ ̣ ˆ ½  Þ ¾ ˜ Ø ∏ Œ ‰ / ˇ ¨ ◊ „ ˛ ¼ ¸)],
24         [qw(å ∫ ç ∂ ́ ƒ © ˙ ̂ ∆ ° ¬ µ ̃ ø π œ ® ß † ̈ √ ∑ ≈ ¥ Ω)],
25 ];
26
27 my $keys = Shiar_Sheet::Keyboard->new({
28         def => {
29                 '' => {
30                         map {
31                                 my $c = $_;
32                                 my @row = map { $usint->[$_]->[$c] } 0 .. 2;
33                                 my $class = (
34                                           !defined $row[2] || $row[0] eq $row[2] ? 1 # identical
35                                         : NFKD($row[2]) =~ $row[0] ? 2 # decomposed equivalent
36                                         : $row[2] =~ /^\p{Latin}/ ? 3 # latin script
37                                         : $row[2] =~ /^\p{Mn}/ ? 5 # combining accent
38                                         : 4
39                                 );
40                                 $row[0] => "g$class"
41                         } 0 .. $#{ $usint->[0] }
42                 },
43         },
44         key => {
45                 map {
46                         $usint->[0]->[$_] => "$usint->[1]->[$_]<br>$usint->[2]->[$_]"
47                 } 0 .. $#{ $usint->[0] }
48         },
49         flag => {
50                 g1 => ['unaltered'],
51                 g2 => ['accented'],
52                 g3 => ['latin'],
53                 g4 => ['other'],
54                 g5 => ['combining'],
55         },
56 });
57 $keys->map($get{map}) or undef $get{map};
58 $keys->print_rows($get{rows}, [0]);
59 $keys->print_legends(\%get);
60