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