1 <: # included from keyboard.plp
5 my @incs = glob 'keyboard/altgr/*.eng.inc.pl';
8 title => "altgr keyboard cheat sheets",
11 "Overview of alternate keyboard modes,",
12 "offering extended Unicode characters if a modifier key",
13 "(such as AltGr or option) is pressed.",
16 sheet cheat reference overview keyboard altgr option
18 image => 'data/keyboard/thumb/ibm-m.jpg',
19 stylesheet => [qw( light dark circus mono red )],
20 data => ['keyboard/altgr/index.inc.plp', @incs],
24 display: inline-table; /* centered */
27 border-collapse: separate;
29 border-spacing: .4vw; /* inline td margin equivalent */
35 display: table-row-group;
42 position: static; /* under sticky thead */
56 /* subsequent graphs */
60 display: inline-block;
69 border: 1px solid #000;
70 border-right-width: 0;
73 .graph > :last-of-type {
74 border-right-width: 1px;
77 border-left: 0; /* assume following unext */
83 vertical-align: middle;
90 <h1>Extended keyboards</h1>
92 <p>Overview of available key layouts with AltGr or similar modifier keys.</p>
95 my @sample = split /(?<!\+)/, $get{sample} // 'asSci1!+1';
96 require Shiar_Sheet::Keyboard;
97 use List::Util qw( uniq max );
99 printf '<section class="%s">', @sample ? 'section' : 'gallery';
101 print '<table class="big keys cmp">';
102 print '<thead><tr><th>';
103 print "<th>$_" for @sample;
106 my %idx = map {s/\Q.inc.pl\E$//; ($_ => eval{ Data($_) })} @incs;
107 my $most = max(map { scalar keys %{$_->{def}{''}} } values %idx);
109 $idx{$a}{category} cmp $idx{$b}{category} || $a cmp $b
111 print @sample ? '<tr><th>' : '<figure>';
112 printf '<a href="/%s">', $inc =~ s/\.eng$//r;
113 my $table = $idx{$inc};
114 my $title = $table && $table->{title} || $inc;
117 if ($table and my $img = $table->{image}) {
118 EscapeHTML $name = $table->{imagealt} // $img =~ m{.*/([^/.]*)};
119 print qq{<img src="/$img" alt="$name" />};
121 printf '<figcaption>%s</figcaption>', $title;
126 print '</a>', "\n\t";
127 my $keys = Shiar_Sheet::Keyboard->new($table);
128 for my $mode ($keys->{mode} ? sort keys %{ $keys->{mode} } : '') {
130 $inventory{ s/ (?!ext).*//r }++ for values %{ $keys->{def}{$mode} };
131 print '<span class=graph>';
132 print "<label>$_</label>" for $keys->{key}{$mode} =~ s/\s.*//r || ();
133 for my $g (sort keys %inventory) {
134 printf '<span class="%s" style="width:%.0f%%" title="%3$d %4$s"> %s</span>',
135 $g, $_/$most*100, $_,
137 $keys->{flag}{$_}[0] || 'extra' # legend label of each class
138 } reverse split / /, $g)
143 $keys->print_key('', $_, $keys->{def}{''}{$_} // 'ni') for @sample;
147 print '</table>' if @sample;