]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/ly2dvi.py
release: 1.3.147
[lilypond.git] / scripts / ly2dvi.py
index cc2be23f75aa73fd610acab7b365642cbac4bb4e..4a67ce26e6aa132637ed234604cef61376a676be 100644 (file)
@@ -82,6 +82,7 @@ extra_init = {
        'language' : [],
        'latexheaders' : [],
        'latexpackages' :  ['geometry'],
+       'latexoptions' : [],
        'papersize' : [],
        'pagenumber' : [1],
        'textheight' : [], 
@@ -329,10 +330,16 @@ def run_lilypond (files, outbase, dep_prefix):
        if track_dependencies_p:
                opts = opts + " --dependencies"
                if dep_prefix:
-                       opts = ' --dep_prefix=%s' % dep_prefix
+                       opts = opts + ' --dep-prefix=%s' % dep_prefix
 
        fs = string.join (files)
 
+       if not verbose_p:
+               progress ( _("Running %s...") % 'LilyPond')
+               # cmd = cmd + ' 1> /dev/null 2> /dev/null'
+       else:
+               opts = opts + ' --verbose'
+       
        system ('lilypond %s %s ' % (opts, fs))
 
 def analyse_lilypond_output (filename, extra):
@@ -422,16 +429,19 @@ def global_latex_definition (tfiles, extra):
        s = ""
        s = s + '% generation tag\n'
 
-       paper = ''
+       options = ''
 
        if extra['papersize']:
                try:
-                       paper = '[%s]' % ly_paper_to_latexpaper[extra['papersize'][0]]
+                       options = '%s' % ly_paper_to_latexpaper[extra['papersize'][0]]
                except:
                        warning (_ ("invalid value: %s") % `extra['papersize'][0]`)
                        pass
+
+       if extra['latexoptions']:
+               options = options + ',' + extra['latexoptions'][-1]
        
-       s = s + '\\documentclass%s{article}\n' % paper
+       s = s + '\\documentclass[%s]{article}\n' % options
 
        if extra['language']:
                s = s + r'\usepackage[%s]{babel}\n' % extra['language'][-1]
@@ -457,17 +467,23 @@ def global_latex_definition (tfiles, extra):
                linewidth = 597
        else:
                linewidth = extra['linewidth'][0]
-       s = s + '\geometry{width=%spt%s,headheight=2mm,headsep=0pt,footskip=2mm,%s}\n' % (linewidth, textheight, orientation)
+       s = s + '\geometry{width=%spt%s,headheight=2mm,headsep=12pt,footskip=2mm,%s}\n' % (linewidth, textheight, orientation)
 
+       if extra['latexoptions']:
+               s = s + '\geometry{twosideshift=4mm}\n'
+               
        s = s + r'''
 \usepackage[latin1]{inputenc}
 \input{titledefs}
 \makeatletter
 \renewcommand{\@oddfoot}{\parbox{\textwidth}{\mbox{}\thefooter}}%
+\renewcommand{\@evenfoot}{\parbox{\textwidth}{\mbox{}\thefooter}}%
 '''
        
        if extra['pagenumber'] and extra['pagenumber'][-1] and extra['pagenumber'][-1] != 'no':
                s = s + r'''
+\renewcommand{\@evenhead}{\parbox{\textwidth}%
+    {\mbox{}\textbf{\thepage}\hfill\small\theheader}}
 \renewcommand{\@oddhead}{\parbox{\textwidth}%
     {\mbox{}\small\theheader\hfill\textbf{\thepage}}}
 '''
@@ -484,9 +500,11 @@ def global_latex_definition (tfiles, extra):
                first = 0
 
        s = s + r'''
-\makeatletter
-\renewcommand{\@oddfoot}{\parbox{\textwidth}{\mbox{}\makelilypondtagline}}%
-\makeatother
+% I don't see why we want to clobber the footer here
+\vfill\hfill\parbox{\textwidth}{\mbox{}\makelilypondtagline}
+%\makeatletter
+%\renewcommand{\@oddfoot}{\parbox{\textwidth}{\mbox{}\makelilypondtagline}}%
+%\makeatother
 '''
        s = s + '\\end{document}'
 
@@ -604,6 +622,9 @@ if files and files[0] != '-':
        if not output:
                output = os.path.basename (files[0])
 
+       for i in ('.dvi', '.latex', '.ly', '.ps', '.tex'):
+               output = strip_extension (output, i)
+
        files = map (compat_abspath, files) 
 
        if os.path.dirname (output) != '.':
@@ -658,7 +679,7 @@ if files and files[0] != '-':
        # add DEP to targets?
        if track_dependencies_p:
                depfile = os.path.join (outdir, outbase + '.dep')
-               generate_dependency_file (depfile, dest)
+               generate_dependency_file (depfile, depfile)
                if os.path.isfile (depfile):
                        progress (_ ("dependencies output to %s...") % depfile)