#!/usr/bin/env perl use 5.014; use warnings; use utf8; use open IO => ':utf8', ':std'; use Data::Dump 'pp'; our $VERSION = '1.00'; open my $keysymh, '<', '/usr/include/X11/keysymdef.h' or die "Could not find keysym definitions: $!\n"; my %keysym; while (readline $keysymh) { m{ \A [#]define[ ]XK_ (?[a-zA-Z_0-9]+) \h+ 0x(?[0-9a-f]+) \h* [/][*] [\h(] U[+] (?[0-9A-F]{4,6}) }msx or next; $keysym{ $+{name} } = chr hex $+{unicode}; } say "# automatically generated by $0"; say '+{'; while ($_ = readline) { my ($mnem, $chr, $trail) = /^\h(.*?)\h+:\h"([^"]+)"\h*(.*)/ or next; $chr =~ s/\\(.)/$1/g; $mnem !~ /]+)> ?}{$keysym{$1} // die "reference to unknown keysym $1\n"}eg; $mnem !~ /[^ -\x7F]/ or next; # skip unicode # (state $seen = {})->{$chr}++ and next; printf "%s => %s,\n", pp($mnem), pp($chr); } say '}'; __END__ =head1 NAME mkdigraphs-xorg - Output Xorg compose sequences =head1 SYNOPSIS mkdigraphs-xorg /usr/share/X11/locale/en_US.UTF-8/Compose >digraphs-xorg.inc.pl perl -e'$di = do "digraphs-xorg.inc.pl"; print chr $di->{AT}' =head1 DESCRIPTION Extracts Multi_key definitions from X11/Xorg Compose.pre include file. If successful, Perl code is output resulting in a hash with Unicode code points keyed by mnemonics. Any errors and warnings are given at STDERR. =head1 AUTHOR Mischa POSLAWSKY =head1 LICENSE Licensed under the GNU Affero General Public License version 3.