5 my (%OPS, %MAP, %DOC, $map);
9 open F, "cat @ARGV |" or die "OPS*: $!";
11 /(\w+) "(.+)"/ or die "$.: parse error";
17 if (/^struct binding_t Op.*{ \/\* map: (.*) \*\//) {
21 if ($map and /^\s*\*\*\s*(.*)/) {
24 if ($map and /{\s*"(.+)"\s*,\s*(\w+)\s*,\s*(?:"([^"]+)"|(\w+))\s*}/) {
25 my ($function, $op, $binding) = ($1, $2, $3 || $4);
26 $binding =~ s/&/&/;
27 # for <key>, try CamelCasing into <Key>
28 $binding =~ s/<(.)(.+)>/<\U$1\E$2>/;
29 $binding =~ s/</</;
30 $binding =~ s/>/>/;
31 $binding =~ s/ /<Space>/;
32 $binding =~ s/^\\033/Esc /;
33 $binding =~ s/^\\010/<Backspace>/;
34 $binding =~ s/^\\(0\d+)$/'^'.chr(64+oct($1))/e;
35 $binding =~ s/^\\(0\d+)(.)/'^'.chr(64+oct($1)) ." $2"/e;
36 $binding =~ s/\\t/<Tab>/;
37 $binding =~ s/M_ENTER_S/<Return>/;
39 die "unknown key $binding" if $binding =~ /\\[^\\]|<|>/;
40 die "unknown OP $op" unless $OPS{$op};
41 $MAP{$map} .= "<row><entry><literal><$function></literal></entry><entry>$binding</entry><entry>$OPS{$op}</entry></row>\n";
48 open XML, $xml or die "$xml: $!";
50 if (/__print_map\((.*)\)/) {
53 $maptitle =~ s/^(.)/\U$1\E/;
55 warn "map $map undefined";
59 <sect2 id="${map}-map">
60 <title>$maptitle Menu</title>
63 <table id="${map}-table">
64 <title>Default $map Function Bindings</title>
67 <row><entry>Function</entry><entry>Default key</entry><entry>Description</entry></row>
85 warn "unprinted maps: ". join(" ", keys %MAP) if %MAP;