digits: split up table method to display rows
[sheet.git] / unicode.plp
1 <(common.inc.plp)><:
2
3 Html({
4         title => 'unicode glyph cheat sheet',
5         version => '1.1',
6         description => [
7                 "Common Unicode characters with digraph or code point, layed out for quick location.",
8                 "Includes general symbols, arrows, drawing characters, and IPA letters.",
9         ],
10         keywords => [qw'
11                 unicode glyph char character reference common ipa symbol sign mark table digraph
12         '],
13         stylesheet => [qw'light dark mono circus red'],
14         data => [qw'unicode-table.inc.pl unicode-char.inc.pl'],
15 });
16
17 :>
18 <h1>Common Unicode</h1>
19
20 <p>
21 Glyphs are followed by
22 <a href="/digraphs">digraph</a> or <a href="/charset">code point</a>,
23 i^k or i^vu respectively in <a href="/vi">Vim</a>.
24 </p>
25
26 <div class="diinfo">
27
28 <:
29 use Shiar_Sheet::FormatChar;
30 my $glyphs = Shiar_Sheet::FormatChar->new;
31
32 if (exists $get{di}) {
33         $glyphs->{anno} = [ (!defined $get{di} || $get{di}) && 'di', 'hex' ];
34 }
35 if (exists $get{q}) {
36         $glyphs->{anno} = [];
37 }
38 if (exists $get{html}) {
39         $glyphs->{anno} = ['html', 'xml'];
40         $glyphs->{style} = 'html';
41 }
42
43 our $verbose = exists $get{v};
44
45 my @config = qw(
46         Popular
47                 punctuation/quoting
48                         common=-5?common
49                 symbols/binary?symbols/binary=-5
50                 latin/sample=-1
51                         ?sample=2-
52                         ?uncommon
53                 punctuation/version
54                 punctuation/marks
55                         spacing
56         Symbols
57                 symbols/currency
58                         cards=-3?cards
59                         ?chess
60                         harvey
61                         signs1
62                         communic=0?communic
63                         trinity=0?trinity
64                         signs2
65         Signs
66                         solar
67                         zodiac=0-1=3?zodiac
68         Key_commands
69                 keys/spacing
70                         editing
71                         modifier
72                         control
73                         command
74                         android=0
75                         ps
76                         ?player
77         Mathematics
78                 math/size
79                         equal
80                         set
81                         logic
82         Arrows
83                 arrows/single
84                         double
85                         white
86                         black
87                         block
88                         blacktri
89                         whitetri
90                         ?-large
91                         ?-heavy
92         Line_drawing
93                 lines/double
94                         doubleh
95                         doublev
96                         single
97                         heavy
98                         heavyh
99                         heavyv
100                         straight
101                         curved
102                         diagonal
103         Blocks
104                 block/square
105                         shades
106                         fill4
107                         fill4i
108                         fill8
109         IPA
110                 ipa/cons
111                         consco
112                         vowels
113         ?Japanese
114                 ?japanese/hira
115                         ?hiraderiv
116                         ?kata
117                         ?kataderiv
118 );
119
120 splice @config, 4, 2, qw(
121                 latin/vowels=-5?latin/vowels
122                          westeuro
123                         ?easteuro
124 ) if exists $get{html};
125
126 $_ and m{/*+(.+)} and @config = split /[ ]/, $1 for $Request, $get{q};
127
128 my $tables = do 'unicode-table.inc.pl' or die $@ || $!;
129
130 $glyphs->print(map {
131         my $_ = /(.*)\?(.*)/ ? ($verbose ? $2 : $1) : $_;
132         if (!$_) {
133                 ();
134         }
135         elsif (/[A-Z]/) {
136                 tr/_/ /;
137                 $_;
138         }
139         else {
140                 state $group;
141                 $group = $1 if s{^([^/]+)/}{};
142                 my @select = s/=(.*)// ? split(/=/, $1) : ();
143                 my $table = $tables->{$group}->{$_}
144                         or die "Unknown table specified: $group/$_";
145
146                 if (@select) {
147                         my $rowlen;
148                         for ($rowlen = 1; $rowlen++; $rowlen <= $#$table) {
149                                 last if $table->[$rowlen] =~ /\./;
150                         }
151                         my @cells = map {
152                                 my $end = (s/-(.+)?// ? ($1 // @$table / $rowlen - 1) : $_) + 1;
153                                 $_ * $rowlen .. $end * $rowlen - 1;
154                         } @select;
155                         $table = [ @$table[@cells] ];
156                 }
157                 $table;
158         }
159 } @config);
160
161 :></div>
162
163 <div class="legend">
164         <table class="glyphs"><tr>
165         <td class="X l5">ascii
166         <td class="X l4"><:= $glyphs->{style} eq 'di' ? 'digraph' : 'latin1' :>
167         <td class="X l3"><:= $glyphs->{style} eq 'di' ? 'proposed' : 'HTML4' :>
168         <td class="X l2">unicode ≤6.0
169         <td class="X l1">other unicode
170         <td class="X ex">discouraged
171         </table>
172 </div>
173
174 <script type="text/javascript" src="/clipboard.js"></script>
175