digraphs/xorg: intermediate map of keysymdef.h names
[sheet.git] / tools / mkxkeysymdef
1 #!/usr/bin/env perl
2 use 5.014;
3 use warnings;
4 use utf8;
5 use re '/msx';
6 use JSON;
7
8 our $VERSION = '1.00';
9
10 my %keysym;
11 while (readline) {
12         m{
13                 \A  [#]define[ ]XK_ (?<name>[a-zA-Z_0-9]+)
14                 \h+ 0x(?<value>[0-9a-fA-F]+)
15                 \h* [/][*] [\h(] U[+] (?<unicode>[0-9A-F]{4,6})
16         } or next;
17         $keysym{ $+{name} } = chr hex $+{unicode};
18 }
19
20 print JSON->new->ascii->canonical->indent->encode(\%keysym);
21
22 __END__
23
24 =head1 NAME
25
26 mkxkeysymdef - Map Xorg key symbol names to Unicode characters
27
28 =head1 SYNOPSIS
29
30     mkxkeysymdef /usr/incnlude/X11/keysymdef.h >keysymdef.json
31
32 =head1 AUTHOR
33
34 Mischa POSLAWSKY <perl@shiar.org>
35
36 =head1 LICENSE
37
38 Licensed under the GNU Affero General Public License version 3.
39