From 5c847268af443432989030e9573a7e4bcf7ceb30 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 26 Dec 2012 16:44:09 +0000 Subject: colin's wall clock patch update, modified to update every second, not every millisecond git-svn-id: svn://localhost/ardour2/branches/3.0@13732 d708f5d6-7413-0410-9779-e7cbd77b26cf --- tools/fmt-bindings | 201 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 170 insertions(+), 31 deletions(-) (limited to 'tools/fmt-bindings') diff --git a/tools/fmt-bindings b/tools/fmt-bindings index 15d24a3853..cd69e04a59 100755 --- a/tools/fmt-bindings +++ b/tools/fmt-bindings @@ -22,12 +22,14 @@ $winkey = 'Mod4\>\ \$platform, "winkey=s" => \$winkey, "cheatsheet" => \$make_cheatsheet, "accelmap" => \$make_accelmap, - "merge=s" => \$merge_from); + "merge=s" => \$merge_from, + "html" => \$html); if ($platform eq "darwin") { @@ -73,37 +75,78 @@ if ($platform eq "darwin") { $mouse_modifier_map{$winkey} => 'Win'; } -%keycodes = ( - 'asciicircum' => '\\verb=^=', - 'apostrophe' => '\'', - 'bracketleft' => '[', - 'bracketright' => ']', - 'braceleft' => '\\{', - 'braceright' => '\\}', - 'backslash' => '$\\backslash$', - 'slash' => '/', - 'rightanglebracket' => '>', - 'leftanglebracket' => '<', - 'ampersand' => '\\&', - 'comma' => ',', - 'period' => '.', - 'semicolon' => ';', - 'colon' => ':', - 'equal' => '=', - 'minus' => '-', - 'plus' => '+', - 'grave' => '`', - 'rightarrow' => '$\rightarrow$', - 'leftarrow' => '$\\leftarrow$', - 'uparrow' => '$\\uparrow$', - 'downarrow' => '$\\downarrow$', - 'Page_Down' => 'Page Down', - 'Page_Up' => 'Page Up', - 'space' => 'space', - 'KP_' => 'KP$\_$', - 'greater' => '>', - 'less' => '<', +%keycodes = (); + +if ($html) { + %keycodes = ( + 'asciicircum' => '^', + 'apostrophe' => '\'', + 'bracketleft' => '[', + 'bracketright' => ']', + 'braceleft' => '{', + 'braceright' => '}', + 'backslash' => '\\', + 'slash' => '/', + 'rightanglebracket' => '>', + 'leftanglebracket' => '<', + 'ampersand' => '&', + 'comma' => ',', + 'period' => '.', + 'semicolon' => ';', + 'colon' => ':', + 'equal' => '=', + 'minus' => '-', + 'plus' => '+', + 'grave' => '`', + 'rightarrow' => '→', + 'leftarrow' => '←', + 'uparrow' => '↑', + 'downarrow' => '↓', + 'Page_Down' => 'PageDown', + 'Page_Up' => 'PageUp', + 'space' => 'space', + 'KP_Right' => 'KP-→', + 'KP_Left' => 'KP-←', + 'KP_Up' => 'KP-↑', + 'KP_Down' => 'KP-↓', + 'KP_0' => 'KP-0;', + 'greater' => '>', + 'less' => '<', + ); +} else { + + %keycodes = ( + 'asciicircum' => '\\verb=^=', + 'apostrophe' => '\'', + 'bracketleft' => '[', + 'bracketright' => ']', + 'braceleft' => '\\{', + 'braceright' => '\\}', + 'backslash' => '$\\backslash$', + 'slash' => '/', + 'rightanglebracket' => '>', + 'leftanglebracket' => '<', + 'ampersand' => '\\&', + 'comma' => ',', + 'period' => '.', + 'semicolon' => ';', + 'colon' => ':', + 'equal' => '=', + 'minus' => '-', + 'plus' => '+', + 'grave' => '`', + 'rightarrow' => '$\rightarrow$', + 'leftarrow' => '$\\leftarrow$', + 'uparrow' => '$\\uparrow$', + 'downarrow' => '$\\downarrow$', + 'Page_Down' => 'Page Down', + 'Page_Up' => 'Page Up', + 'space' => 'space', + 'KP_' => 'KP$\_$', + 'greater' => '>', + 'less' => '<', ); +} if ($merge_from) { open (BINDINGS, $merge_from) || die ("merge from bindings: file not readable"); @@ -226,6 +269,102 @@ if ($make_accelmap || !$make_cheatsheet) { exit 0; } +if ($html) { + + @groups_sorted_by_number = sort { $group_numbering{$a} <=> $group_numbering{$b} } keys %group_numbering; + + foreach $gk (@groups_sorted_by_number) { + + if ($gk =~ /^m/) { + # mouse stuff - ignore + next; + } + + # $bref is a reference to the array of arrays for this group + $bref = $group_bindings{$gk}; + + if (scalar @$bref > 1) { + + $name = $group_names{$gk}; + $name =~ s/\\linebreak.*//; + $name =~ s/\\&/&/; + $name =~ s/\$\\_\$/-/g; + $name =~ s/\\[a-z]+ //g; + $name =~ s/[{}]//g; + $name =~ s/\\par//g; + + print "

$name

\n"; + + $gtext = $group_text{$gk}; + $gtext =~ s/\\linebreak.*//; + $gtext =~ s/\\&/&/; + $gtext =~ s/\$\\_\$/-/g; + $gtext =~ s/\\[a-z]+ //g; + $gtext =~ s/[{}]//g; + $gtext =~ s/\\par//g; + + if (!($gtext eq "")) { + print "$gtext\n\n"; + } + + # ignore the first entry, which was empty + + shift (@$bref); + + # set up the list + + print "
\n"; + + # sort the array of arrays by the descriptive text for nicer appearance, + # and print them + + for $bbref (sort { @$a[1] cmp @$b[1] } @$bref) { + # $bbref is a reference to an array + + $binding = @$bbref[0]; + $text = @$bbref[1]; + + if ($binding =~ /:/) { # mouse binding with "where" clause + ($binding,$where) = split (/:/, $binding, 2); + } + + foreach $k (keys %cs_modifier_map) { + $binding =~ s/\@$k\@/$cs_modifier_map{$k}/; + } + + # remove braces for HTML + + $binding =~ s/>/\+/; + + # substitute keycode names for something printable + + $re = qr/${ \(join'|', map quotemeta, keys %keycodes)}/; + $binding =~ s/($re)/$keycodes{$1}/g; + + # tidy up description + + $descr = @$bbref[1]; + $descr =~ s/\\linebreak.*//; + $descr =~ s/\\&/&/; + $descr =~ s/\$\\_\$/-/g; + $descr =~ s/\\[a-z]+ //g; + $descr =~ s/[{}]//g; + $descr =~ s/\\par//g; + + print "
$descr
$binding
\n"; + } + + print "
\n"; + + } + } + print "  \n"; + exit 0; +} + + # Now print the cheatsheet $boilerplate_header = <