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({
57 'l5' => "matching RFC-1345",
58 'l4' => "matching proposal",
59 'l3' => "unique to Xorg",
61 'l0 ex' => "duplicate",
69 mkdigraphs-xorg - Output Xorg compose sequences
74 mkdigraphs-xorg /usr/share/X11/locale/en_US.UTF-8/Compose |
75 jq -r '.key."AT"[0]' | perl -nE 'say chr' # @
79 Extracts Multi_key definitions from X11/Xorg Compose.pre include file.
80 If successful, a JSON object is output containing a digraphs list in C<key>
81 with Unicode code points keyed by mnemonics.
82 Any errors and warnings are given at STDERR.
86 Mischa POSLAWSKY <perl@shiar.org>
90 Licensed under the GNU Affero General Public License version 3.