X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/e5ad6046eceee35635afa188230707a5ae14caa9..3bb0146072f0a611c18b31dca137cd135e2cc0ff:/tools/mkdigraphs-xorg diff --git a/tools/mkdigraphs-xorg b/tools/mkdigraphs-xorg index 32a5044..aeed5fe 100755 --- a/tools/mkdigraphs-xorg +++ b/tools/mkdigraphs-xorg @@ -3,11 +3,14 @@ use 5.014; use warnings; use utf8; use open IO => ':utf8', ':std'; +use re '/msx'; use Data::Dump 'pp'; -our $VERSION = '1.00'; +our $VERSION = '1.01'; -open my $keysymh, '<', '/usr/include/X11/keysymdef.h' +my $keysymh; +open $keysymh, '<', 'data/keysymdef.h' + or open $keysymh, '<', '/usr/include/X11/keysymdef.h' or die "Could not find keysym definitions: $!\n"; my %keysym; @@ -16,7 +19,7 @@ while (readline $keysymh) { \A [#]define[ ]XK_ (?[a-zA-Z_0-9]+) \h+ 0x(?[0-9a-f]+) \h* [/][*] [\h(] U[+] (?[0-9A-F]{4,6}) - }msx or next; + } or next; $keysym{ $+{name} } = chr hex $+{unicode}; } @@ -24,12 +27,12 @@ say "# automatically generated by $0"; say '+{'; while ($_ = readline) { - my ($mnem, $chr, $trail) = /^\h(.*?)\h+:\h"([^"]+)"\h*(.*)/ + my ($mnem, $chr, $trail) = m/\A \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 + $mnem !~ m/]+)> \h?}{$keysym{$1} // die "reference to unknown keysym $1\n"}eg; + $mnem !~ m/[^\x20-\x7F]/ or next; # skip unicode # (state $seen = {})->{$chr}++ and next; printf "%s => %s,\n", pp($mnem), pp($chr); }