index: release v1.18 with only altgr index linked
[sheet.git] / tools / mkxkeysymdef
1 #!/usr/bin/env perl
2 use 5.014;
3 use warnings;
4 use utf8;
5 use re '/mnsx';
6 use JSON;
7
8 our $VERSION = '1.01';
9
10 my (%keysym, %keyval);
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         my $cp = $+{unicode} // $keyval{ $+{value} } or next;
18         $keysym{ $+{name} } = chr hex $cp;
19         $keyval{ $+{value} } = $cp;
20 }
21
22 print JSON->new->ascii->canonical->indent->encode(\%keysym);
23
24 __END__
25
26 =head1 NAME
27
28 mkxkeysymdef - Map Xorg key symbol names to Unicode characters
29
30 =head1 SYNOPSIS
31
32     mkxkeysymdef /usr/incnlude/X11/keysymdef.h >keysymdef.json
33
34 =head1 AUTHOR
35
36 Mischa POSLAWSKY <perl@shiar.org>
37
38 =head1 LICENSE
39
40 Licensed under the GNU Affero General Public License version 3.
41