5 use open IO => ':encoding(utf-8)', ':std';
7 use JSON 'decode_json';
9 use Shiar_Sheet::FormatChar;
11 our $VERSION = '1.01';
14 open my $keysymh, '<', 'data/keysymdef.json' or die $!;
16 return decode_json(readline $keysymh);
17 } or die "Could not read keysym definitions: $@\n";
20 open my $jsfh, '<', 'data/digraphs.json' or die $!;
22 return JSON->new->decode(readline $jsfh);
23 } or warn "Could not read comparison digraphs: $@\n";
26 while ($_ = readline) {
27 my ($mnem, $chr, $trail) = m/\A <Multi_key> \h (.*?) \h+ : \h "([^"]+)" \h* (.*)/
30 $mnem !~ m/<dead | <KP_ | <U[0-9A-Fa-f]{4}/ or next; # skip non-standard keys
32 $mnem =~ s{<([^>]+)> \h?}{$symname->{$1} // die "reference to unknown keysym $1\n"}eg;
35 $mnem =~ m/\A [\x20-\x7F]{2} \z/ or next; # only interested in two ascii
36 my $alias = (state $seen = {})->{$chr}++; # assume first is preferred
38 my $uninfo = Shiar_Sheet::FormatChar->glyph_info($cp);
40 !$vidi->{key}->{$mnem} ? 'l3' : # free
41 $vidi->{key}->{$mnem}->[0] != $cp ? 'l1' : # conflict
42 $vidi->{key}->{$mnem}->[2] eq 'l4' ? 'l5' : # rfc
47 $uninfo->[1] // '', # name
49 $alias ? 'l0 ex' : $uninfo->[0] // '', # class
50 $uninfo->[4] // (), # string
54 print JSON->new->canonical->indent->encode({
58 'Character mnemonics following compose key ⎄:',
59 'in the X Window System (Shift+AltGr by default).',
60 'Differences from <a href="/digraphs">RFC-1345</a> are indicated.',
61 'Also see <a href="/unicode">common Unicode</a>.',
63 keywords => [qw( xorg x11 x )],
65 'l5' => "matching RFC-1345",
66 'l4' => "matching proposal",
67 'l3' => "unique to Xorg",
69 'l0 ex' => "duplicate",
77 mkdigraphs-xorg - Output Xorg compose sequences
82 mkdigraphs-xorg /usr/share/X11/locale/en_US.UTF-8/Compose |
83 jq -r '.key."AT"[0]' | perl -nE 'say chr' # @
87 Extracts Multi_key definitions from X11/Xorg Compose.pre include file.
88 If successful, a JSON object is output containing a digraphs list in C<key>
89 with Unicode code points keyed by mnemonics.
90 Any errors and warnings are given at STDERR.
94 Mischa POSLAWSKY <perl@shiar.org>
98 Licensed under the GNU Affero General Public License version 3.