digraphs: expand intro, with links to (and from) screen and emacs
[sheet.git] / digraphs.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'digraph cheat sheet',
5         version => 'v1.0',
6         description => [
7                 "Complete table of digraph characters from RFC-1345.",
8         ],
9         keywords => [qw'
10                 digraph mnemonic compose composition pair
11                 character char glyph table unicode vim
12         '],
13         stylesheet => [qw'light'],
14         data => [qw( digraphs.inc.pl )],
15 });
16
17 :>
18 <h1>RFC-1345 Digraphs</h1>
19
20 <p>Character mnemonics
21 following composition key ⎄:
22 i^k in <a href="/vi">Vim</a>,
23 ^u^\ in <a href="/readline">Emacs</a>,
24 ^a^v in <a href="/screen">Screen</a>.
25 Also see <a href="/unicode">common Unicode</a>.</p>
26
27 <p class="aside">Unofficial <span class="u-prop ex">proposals</span>
28 are available as <a href="/digraphs.vim">ex commands</a>.</p>
29
30 <:
31 my $di = do 'digraphs.inc.pl'
32         or die "Error loading digraphs data: ", $@ // $!;
33
34 my @chars = (
35         [qw{! " % ' ( ) * + , - . /}],
36         ['0'..'9'], [qw{: ; < = > ?}],
37         ['A'..'M'], ['N'..'Z'],
38         ['a'..'m'], ['n'..'z'],
39 );
40 my @chars2 = (['_'], @chars);  # trailing character (extended set)
41 my @columns = !exists $get{split} ? \@chars2 :
42         ([@chars2[0, 1, 3, 4, 6]], [@chars2[2, 5, 7]]);
43
44 if (exists $get{xorg}) {
45         my $xorg = do 'data/digraphs-xorg.inc.pl'
46                 or die "Error loading Xorg data: ", $@ // $!;
47         $_ = [ord $_] for values %{$xorg};
48         $xorg->{$_}->[2] =  # class = same as rfc | any other spec | xorg only
49                 $di->{$_} ? $di->{$_}->[2] =~ /\bu-di\b/ ? 'l5' : 'l3' : 'l1'
50                 for keys %{$xorg};
51         $chars2[0] = [qw( # ^ _ ` ~ )];
52         @chars = @chars2;
53         $di = $xorg;
54 }
55
56 for my $colchars (@columns) {
57 print '<table class="glyphs dimap"><col>';
58 print qq'<colgroup span="$_">' for map {scalar @$_} @{$colchars};
59 print "</colgroup><col>\n";
60 for my $section (qw{thead tfoot}) {
61         print "<$section><tr><th>↳";
62         print '<th>', EscapeHTML($_) for map {@$_} @{$colchars};
63         print "<th>&nbsp;\n";
64 }
65 for my $c1group (@chars) {
66         print '<tbody>';
67         for my $c1 (@$c1group) {
68                 print '<tr><th>', EscapeHTML($c1);
69                 for my $c2 (map {@$_} @$colchars) {
70                         my $mnem = $c1 . $c2;
71                         if (not defined $di->{$mnem}) {
72                                 print '<td>';
73                                 next;
74                         }
75                         if (ref $di->{$mnem} ne 'ARRAY') {
76                                 printf '<td class="X Xr" title="%s">', EscapeHTML($mnem);
77                                 next;
78                         }
79                         my ($codepoint, $name, $prop, $script, $string) = @{ $di->{$mnem} };
80
81                         my $glyph = $string || chr $codepoint;
82                         utf8::upgrade($glyph);  # prevent latin1 output
83                         my $desc = $mnem . ($name && " ($name)");
84                         my @class = ('X', grep {$_} $prop, $script);
85
86                         $glyph = EscapeHTML($glyph);
87                         $glyph = "<span>$glyph</span>" if $script =~ /\bZs\b/;
88
89                         printf "\n".'<td class="%s" title="%s">%s',
90                                 join(' ', @class), EscapeHTML($desc), $glyph;
91                 }
92                 print "\n<th>", EscapeHTML($c1), "\n";
93         }
94 }
95 print "</table>\n";
96 print '<hr>' if exists $get{split};
97 }
98 :>
99 <div class="legend">
100         <table class="glyphs"><tr>
101         <td class="X Cc">control
102         <td class="X Zs"><span>space</span>
103         <td class="X Mn">combining
104         <td class="X Sk">spacing&nbsp;modifier
105         <td class="X Pf">quote
106         <td class="X Po">punctuation
107         <td class="X So">symbol
108         <td class="X Sm">math
109         <td class="X Sc">currency
110         <td class="X No">numeric
111         <td class="X Greek">greek
112         <td class="X Cyrillic">cyrillic
113         <td class="X Latin">latin
114         <td class="X Hebrew">hebrew
115         <td class="X Arabic">arabic
116         <td class="X Hangul">korean
117         <td class="X Hiragana">japanese
118         <td class="X Bopomofo">chinese
119         </table>
120
121         <table class="glyphs"><tr>
122         <td class="X">unicode
123         <td class="X Xl">latin1
124         <td class="X Xa">ascii
125         <td class="X u-prop">vim extension
126         <td class="X u-prop ex">proposal
127         <td class="X ex">not in vim
128         </table>
129 </div>
130