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 $title =~ s/(.)(.+)/\U$1\E$2/;
61 <sect2 id="${map}-map">
62 <title>$maptitle Menu</title>
65 <table id="tab-${map}-bindings">
66 <title>Default $title Menu Bindings</title>
69 <row><entry>Function</entry><entry>Default key</entry><entry>Description</entry></row>
87 warn "unprinted maps: ". join(" ", keys %MAP) if %MAP;