2009-07-30 10:07:49 -04:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2009-07-30 20:34:36 -04:00
|
|
|
# import module
|
|
|
|
use Getopt::Long;
|
|
|
|
|
|
|
|
$semicolon = ";"; # help out stupid emacs
|
2009-07-31 16:26:15 -04:00
|
|
|
$title = "Ardour Shortcuts";
|
2009-07-30 10:07:49 -04:00
|
|
|
$in_group_def = 0;
|
|
|
|
$group_name;
|
|
|
|
$group_text;
|
|
|
|
$group_key;
|
2009-07-30 20:34:36 -04:00
|
|
|
$group_number = 0;
|
2009-07-30 10:07:49 -04:00
|
|
|
%group_names;
|
|
|
|
%group_text;
|
2009-07-30 20:34:36 -04:00
|
|
|
%group_bindings;
|
|
|
|
%modifier_map;
|
|
|
|
%group_numbering;
|
2009-07-31 16:26:15 -04:00
|
|
|
%merge_bindings;
|
2009-07-30 20:34:36 -04:00
|
|
|
|
|
|
|
$platform = linux;
|
2009-07-31 16:26:15 -04:00
|
|
|
$winkey = 'Mod4><Super';
|
|
|
|
$make_cheatsheet = 1;
|
|
|
|
$make_accelmap = 0;
|
|
|
|
$merge_from = "";
|
2009-07-30 20:34:36 -04:00
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
GetOptions ("platform=s" => \$platform,
|
|
|
|
"winkey=s" => \$winkey,
|
|
|
|
"cheatsheet" => \$make_cheatsheet,
|
|
|
|
"accelmap" => \$make_accelmap,
|
|
|
|
"merge=s" => \$merge_from);
|
2009-07-30 20:34:36 -04:00
|
|
|
|
|
|
|
if ($platform eq "osx") {
|
2009-07-31 16:26:15 -04:00
|
|
|
|
2009-07-30 20:34:36 -04:00
|
|
|
$gtk_modifier_map{'PRIMARY'} = 'meta';
|
|
|
|
$gtk_modifier_map{'SECONDARY'} = 'Mod1';
|
|
|
|
$gtk_modifier_map{'TERTIARY'} = 'Shift';
|
|
|
|
$gtk_modifier_map{'LEVEL4'} = 'Control';
|
|
|
|
$gtk_modifier_map{'WINDOW'} = 'Mod1';
|
|
|
|
|
|
|
|
$cs_modifier_map{'PRIMARY'} = 'Command';
|
2009-07-31 16:26:15 -04:00
|
|
|
$cs_modifier_map{'SECONDARY'} = 'Opt';
|
2009-07-30 20:34:36 -04:00
|
|
|
$cs_modifier_map{'TERTIARY'} = 'Shift';
|
|
|
|
$cs_modifier_map{'LEVEL4'} = 'Control';
|
2009-07-31 16:26:15 -04:00
|
|
|
$cs_modifier_map{'WINDOW'} = 'Opt';
|
|
|
|
|
|
|
|
$mouse_modifier_map{'PRIMARY'} = 'Cmd';
|
|
|
|
$mouse_modifier_map{'SECONDARY'} = 'Opt';
|
|
|
|
$mouse_modifier_map{'TERTIARY'} = 'Shift';
|
|
|
|
$mouse_modifier_map{'LEVEL4'} = 'Control';
|
|
|
|
$mouse_modifier_map{'WINDOW'} = 'Opt';
|
2009-07-30 20:34:36 -04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$gtk_modifier_map{'PRIMARY'} = 'Control';
|
|
|
|
$gtk_modifier_map{'SECONDARY'} = 'Alt';
|
|
|
|
$gtk_modifier_map{'TERTIARY'} = 'Shift';
|
2009-07-31 16:26:15 -04:00
|
|
|
$gtk_modifier_map{'LEVEL4'} = $winkey;
|
2009-07-30 20:34:36 -04:00
|
|
|
$gtk_modifier_map{'WINDOW'} = 'Alt';
|
2009-07-31 16:26:15 -04:00
|
|
|
$gtk_modifier_map{$winkey} => 'Win';
|
2009-07-30 20:34:36 -04:00
|
|
|
|
|
|
|
$cs_modifier_map{'PRIMARY'} = 'Control';
|
|
|
|
$cs_modifier_map{'SECONDARY'} = 'Alt';
|
|
|
|
$cs_modifier_map{'TERTIARY'} = 'Shift';
|
|
|
|
$cs_modifier_map{'LEVEL4'} = 'Win';
|
|
|
|
$cs_modifier_map{'WINDOW'} = 'Alt';
|
2009-07-31 16:26:15 -04:00
|
|
|
$cs_modifier_map{$winkey} => 'Win';
|
|
|
|
|
|
|
|
$mouse_modifier_map{'PRIMARY'} = 'Ctl';
|
|
|
|
$mouse_modifier_map{'SECONDARY'} = 'Alt';
|
|
|
|
$mouse_modifier_map{'TERTIARY'} = 'Shift';
|
|
|
|
$mouse_modifier_map{'LEVEL4'} = 'Win';
|
|
|
|
$mouse_modifier_map{'WINDOW'} = 'Alt';
|
|
|
|
$mouse_modifier_map{$winkey} => 'Win';
|
2009-07-30 20:34:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
%keycodes = (
|
|
|
|
'asciicircum' => '\\verb=^=',
|
|
|
|
'apostrophe' => '\'',
|
|
|
|
'bracketleft' => '[',
|
|
|
|
'bracketright' => ']',
|
|
|
|
'braceleft' => '\\{',
|
|
|
|
'braceright' => '\\}',
|
|
|
|
'backslash' => '$\\backslash$',
|
2009-07-31 16:26:15 -04:00
|
|
|
'slash' => '/',
|
2009-07-30 20:34:36 -04:00
|
|
|
'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',
|
2009-07-31 16:26:15 -04:00
|
|
|
'KP_' => 'KP$\_$',
|
2009-07-30 20:34:36 -04:00
|
|
|
);
|
2009-07-30 10:07:49 -04:00
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
if ($merge_from) {
|
|
|
|
open (BINDINGS, $merge_from) || die ("merge from bindings: file not readable");
|
|
|
|
while (<BINDINGS>) {
|
|
|
|
next if (/^$semicolon/);
|
|
|
|
if (/^\(gtk_accel/) {
|
|
|
|
chop; # newline
|
|
|
|
chop; # closing parenthesis
|
|
|
|
s/"//g;
|
|
|
|
($junk, $action, $binding) = split;
|
|
|
|
$merge_bindings{$action} = $binding;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close (BINDINGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($make_accelmap && !$merge_from) {
|
|
|
|
print ";; this accelmap was produced by tools/fmt-bindings\n";
|
|
|
|
}
|
|
|
|
|
2009-07-30 10:07:49 -04:00
|
|
|
while (<>) {
|
2009-07-30 20:34:36 -04:00
|
|
|
next if /^$semicolon/;
|
2009-07-30 10:07:49 -04:00
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
if (/^\$/) {
|
|
|
|
s/^\$//;
|
|
|
|
$title = $_;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2009-07-30 10:07:49 -04:00
|
|
|
if (/^%/) {
|
2009-07-30 20:34:36 -04:00
|
|
|
|
2009-07-30 10:07:49 -04:00
|
|
|
if ($in_group_def) {
|
|
|
|
chop $group_text;
|
|
|
|
$group_names{$group_key} = $group_name;
|
|
|
|
$group_text{$group_key} = $group_text;
|
2009-07-30 20:34:36 -04:00
|
|
|
$group_numbering{$group_key} = $group_number;
|
|
|
|
# each binding entry is 2 element array. bindings
|
|
|
|
# are all collected into a container array. create
|
|
|
|
# the first dummy entry so that perl knows what we
|
|
|
|
# are doing.
|
|
|
|
$group_bindings{$group_key} = [ [] ];
|
2009-07-30 10:07:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
s/^%//;
|
|
|
|
chop;
|
|
|
|
($group_key,$group_name) = split (/\s+/, $_, 2);
|
2009-07-30 20:34:36 -04:00
|
|
|
$group_number++;
|
2009-07-30 10:07:49 -04:00
|
|
|
$group_text = "";
|
|
|
|
$in_group_def = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($in_group_def) {
|
2009-07-30 20:34:36 -04:00
|
|
|
if (/^@/) {
|
|
|
|
chop $group_text;
|
|
|
|
$group_names{$group_key} = $group_name;
|
|
|
|
$group_text{$group_key} = $group_text;
|
|
|
|
$in_group_def = 0;
|
|
|
|
} else {
|
|
|
|
next if (/^[ \t]+$/);
|
|
|
|
$group_text .= $_;
|
|
|
|
$group_text;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (/^@/) {
|
|
|
|
s/^@//;
|
|
|
|
chop;
|
|
|
|
($key,$action,$binding,$text) = split (/\|/, $_, 4);
|
|
|
|
|
|
|
|
# substitute bindings
|
|
|
|
|
|
|
|
$gtk_binding = $binding;
|
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
if ($merge_from) {
|
|
|
|
$lookup = "<Actions>/" . $action;
|
|
|
|
if ($merge_bindings{$lookup}) {
|
|
|
|
$binding = $merge_bindings{$lookup};
|
|
|
|
} else {
|
2009-07-31 16:33:58 -04:00
|
|
|
if ($key =~ /^\+/) {
|
|
|
|
# forced inclusion of bindings from template
|
|
|
|
} else {
|
|
|
|
# this action is not defined in the merge from set, so forget it
|
|
|
|
next;
|
|
|
|
}
|
2009-07-31 16:26:15 -04:00
|
|
|
}
|
|
|
|
}
|
2009-07-30 20:34:36 -04:00
|
|
|
|
|
|
|
# print the accelmap output
|
|
|
|
|
|
|
|
if ($key =~ /^\+/) {
|
|
|
|
# remove + and don't print it in the accelmap
|
|
|
|
$key =~ s/^\+//;
|
|
|
|
} else {
|
|
|
|
# include this in the accelmap
|
2009-07-31 16:26:15 -04:00
|
|
|
if (!$merge_from && $make_accelmap) {
|
|
|
|
foreach $k (keys %gtk_modifier_map) {
|
|
|
|
$gtk_binding =~ s/\@$k\@/$gtk_modifier_map{$k}/;
|
|
|
|
}
|
|
|
|
print "(gtk_accel_map \"<Actions>/$action\" \"$gtk_binding\")\n";
|
|
|
|
}
|
2009-07-30 20:34:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($key =~ /^-/) {
|
|
|
|
# do not include this binding in the cheat sheet
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
$bref = $group_bindings{$key};
|
|
|
|
push (@$bref, [$binding, $text]);
|
|
|
|
|
2009-07-30 10:07:49 -04:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
if ($make_accelmap || !$make_cheatsheet) {
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
2009-07-30 20:34:36 -04:00
|
|
|
# Now print the cheatsheet
|
|
|
|
|
|
|
|
$boilerplate_header = <<END_HEADER;
|
|
|
|
\\documentclass[10pt,landscape]{article}
|
|
|
|
\\usepackage{multicol}
|
|
|
|
\\usepackage{calc}
|
|
|
|
\\usepackage{ifthen}
|
|
|
|
\\usepackage{palatino}
|
2009-07-31 16:26:15 -04:00
|
|
|
\\usepackage{geometry}
|
2009-07-30 20:34:36 -04:00
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
\\setlength{\\parskip}{0pt}
|
|
|
|
\\setlength{\\parsep}{0pt}
|
|
|
|
\\setlength{\\headsep}{0pt}
|
|
|
|
\\setlength{\\topskip}{0pt}
|
|
|
|
\\setlength{\\topmargin}{0pt}
|
|
|
|
\\setlength{\\topsep}{0pt}
|
|
|
|
\\setlength{\\partopsep}{0pt}
|
2009-07-30 20:34:36 -04:00
|
|
|
|
|
|
|
% This sets page margins to .5 inch if using letter paper, and to 1cm
|
|
|
|
% if using A4 paper. (This probably isnott strictly necessary.)
|
|
|
|
% If using another size paper, use default 1cm margins.
|
|
|
|
\\ifthenelse{\\lengthtest { \\paperwidth = 11in}}
|
2009-07-31 16:26:15 -04:00
|
|
|
{ \\geometry{top=.5in,left=1in,right=0in,bottom=.5in} }
|
2009-07-30 20:34:36 -04:00
|
|
|
{\\ifthenelse{ \\lengthtest{ \\paperwidth = 297mm}}
|
|
|
|
{\\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
|
|
|
{\\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
|
|
|
}
|
|
|
|
|
|
|
|
% Turn off header and footer
|
|
|
|
\\pagestyle{empty}
|
|
|
|
|
|
|
|
% Redefine section commands to use less space
|
|
|
|
\\makeatletter
|
|
|
|
\\renewcommand{\\section}{\\\@startsection{section}{1}{0mm}%
|
|
|
|
{-1ex plus -.5ex minus -.2ex}%
|
2009-07-31 16:26:15 -04:00
|
|
|
{0.5ex plus .2ex}%
|
2009-07-30 20:34:36 -04:00
|
|
|
{\\normalfont\\large\\bfseries}}
|
|
|
|
\\renewcommand{\\subsection}{\\\@startsection{subsection}{2}{0mm}%
|
|
|
|
{-1explus -.5ex minus -.2ex}%
|
|
|
|
{0.5ex plus .2ex}%
|
|
|
|
{\\normalfont\\normalsize\\bfseries}}
|
|
|
|
\\renewcommand{\\subsubsection}{\\\@startsection{subsubsection}{3}{0mm}%
|
|
|
|
{-1ex plus -.5ex minus -.2ex}%
|
|
|
|
{1ex plus .2ex}%
|
|
|
|
{\\normalfont\\small\\bfseries}}
|
|
|
|
\\makeatother
|
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
% Do not print section numbers% Do not print section numbers
|
2009-07-30 20:34:36 -04:00
|
|
|
\\setcounter{secnumdepth}{0}
|
|
|
|
|
|
|
|
\\setlength{\\parindent}{0pt}
|
|
|
|
\\setlength{\\parskip}{0pt plus 0.5ex}
|
|
|
|
|
|
|
|
%-------------------------------------------
|
|
|
|
|
|
|
|
\\begin{document}
|
|
|
|
\\newlength{\\MyLen}
|
|
|
|
\\raggedright
|
|
|
|
\\footnotesize
|
|
|
|
\\begin{multicols}{3}
|
|
|
|
END_HEADER
|
|
|
|
|
|
|
|
$boilerplate_footer = <<END_FOOTER;
|
2009-07-31 16:26:15 -04:00
|
|
|
\\rule{0.3\\linewidth}{0.25pt}
|
|
|
|
\\scriptsize
|
|
|
|
|
|
|
|
Copyright \\copyright\\ 2009 ardour.org
|
|
|
|
|
|
|
|
% Should change this to be date of file, not current date.
|
|
|
|
%\\verb!$Revision: 1.13 $, $Date: 2008/05/29 06:11:56 $.!
|
|
|
|
|
|
|
|
http://ardour.org/manual
|
|
|
|
|
2009-07-30 20:34:36 -04:00
|
|
|
\\end{multicols}
|
|
|
|
\\end{document}
|
|
|
|
END_FOOTER
|
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
if ($make_cheatsheet) {
|
|
|
|
print $boilerplate_header;
|
|
|
|
print "\\begin{center}\\Large\\bf $title \\end{center}\n";
|
|
|
|
}
|
2009-07-30 20:34:36 -04:00
|
|
|
|
|
|
|
@groups_sorted_by_number = sort { $group_numbering{$a} <=> $group_numbering{$b} } keys %group_numbering;
|
|
|
|
|
|
|
|
foreach $gk (@groups_sorted_by_number) {
|
|
|
|
# $bref is a reference to the array of arrays for this group
|
|
|
|
$bref = $group_bindings{$gk};
|
|
|
|
|
|
|
|
if (scalar @$bref > 1) {
|
2009-07-31 16:26:15 -04:00
|
|
|
print "\\section{$group_names{$gk}}\n";
|
2009-07-30 20:34:36 -04:00
|
|
|
|
|
|
|
if (!($group_text{$gk} eq "")) {
|
|
|
|
print "$group_text{$gk}\n\\par\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# ignore the first entry, which was empty
|
|
|
|
|
|
|
|
shift (@$bref);
|
|
|
|
|
|
|
|
# find the longest descriptive text (this is not 100% accuracy due to typography)
|
|
|
|
|
|
|
|
$maxtextlen = 0;
|
|
|
|
$maxtext = "";
|
|
|
|
|
|
|
|
for $bbref (@$bref) {
|
|
|
|
# $bbref is a reference to an array
|
|
|
|
$text = @$bbref[1];
|
2009-07-31 16:26:15 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# if there is a linebreak, just use everything up the linebreak
|
|
|
|
# to determine the width
|
|
|
|
#
|
|
|
|
|
2009-07-30 20:34:36 -04:00
|
|
|
if ($text =~ /\\linebreak/) {
|
|
|
|
$matchtext = s/\\linebreak.*//;
|
|
|
|
} else {
|
|
|
|
$matchtext = $text;
|
|
|
|
}
|
|
|
|
if (length ($matchtext) > $maxtextlen) {
|
|
|
|
$maxtextlen = length ($matchtext);
|
|
|
|
$maxtext = $matchtext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
if ($gk =~ /^m/) {
|
|
|
|
# mouse mode: don't extend max text at all - space it tight
|
|
|
|
$maxtext .= ".";
|
|
|
|
} else {
|
|
|
|
$maxtext .= "....";
|
|
|
|
}
|
2009-07-30 20:34:36 -04:00
|
|
|
|
|
|
|
# set up the table
|
|
|
|
|
|
|
|
print "\\settowidth{\\MyLen}{\\texttt{$maxtext}}\n";
|
|
|
|
print "\\begin{tabular}{\@{}p{\\the\\MyLen}%
|
|
|
|
\@{}p{\\linewidth-\\the\\MyLen}%
|
|
|
|
\@{}}\n";
|
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
# sort the array of arrays by the descriptive text for nicer appearance,
|
|
|
|
# and print them
|
2009-07-30 20:34:36 -04:00
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
for $bbref (sort { @$a[1] cmp @$b[1] } @$bref) {
|
2009-07-30 20:34:36 -04:00
|
|
|
# $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);
|
|
|
|
}
|
|
|
|
|
2009-07-31 16:26:15 -04:00
|
|
|
if ($gk =~ /^m/) {
|
|
|
|
# mouse mode - use shorter abbrevs
|
|
|
|
foreach $k (keys %mouse_modifier_map) {
|
|
|
|
$binding =~ s/\@$k\@/$mouse_modifier_map{$k}/;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach $k (keys %cs_modifier_map) {
|
|
|
|
$binding =~ s/\@$k\@/$cs_modifier_map{$k}/;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-30 20:34:36 -04:00
|
|
|
$binding =~ s/></\+/g;
|
|
|
|
$binding =~ s/^<//;
|
|
|
|
$binding =~ s/>/\+/;
|
|
|
|
|
|
|
|
# substitute keycode names for something printable
|
|
|
|
|
|
|
|
$re = qr/${ \(join'|', map quotemeta, keys %keycodes)}/;
|
|
|
|
$binding =~ s/($re)/$keycodes{$1}/g;
|
|
|
|
|
|
|
|
# split up mouse bindings to "click" and "where" parts
|
|
|
|
|
|
|
|
if ($gk eq "mobject") {
|
|
|
|
print "{\\tt @$bbref[1] } & {\\tt $binding} {\\it $where}\\\\\n";
|
|
|
|
} else {
|
|
|
|
print "{\\tt @$bbref[1] } & {\\tt $binding} \\\\\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\\end{tabular}\n";
|
|
|
|
|
|
|
|
}
|
2009-07-30 10:07:49 -04:00
|
|
|
}
|
|
|
|
|
2009-07-30 20:34:36 -04:00
|
|
|
print $boilerplate_footer;
|
|
|
|
|
2009-07-30 10:07:49 -04:00
|
|
|
exit 0;
|