]> git.donarmstrong.com Git - lilypond.git/commitdiff
* python/lilylib.py (make_ps_images): bugfixes; GS can produce
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 27 Apr 2005 13:00:50 +0000 (13:00 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 27 Apr 2005 13:00:50 +0000 (13:00 +0000)
empty 2nd page for mono page.

* scm/lily.scm: remove p&c definitions.

ChangeLog
lily/main.cc
lily/scm-option.cc
python/lilylib.py
scm/framework-ps.scm
scm/framework-tex.scm
scm/lily.scm
scm/output-tex.scm

index e5207869011fc807f56e3079dda80b2b3e7b2541..8ab5324b203785ab9f1ec554c6df2dd46afcb26a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-04-27  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * python/lilylib.py (make_ps_images): bugfixes; GS can produce
+       empty 2nd page for mono page.
+
+       * scm/lily.scm: remove p&c definitions.
+
        * po/zh_TW.po (Module): new translation.
 
        * lily/lily-guile.cc (ly_chain_assoc): remove.
index dfc986ceb444d80362198ea4065322872405828e..690f1d70f2562e70d61a7e8676542b9d6744c10c 100644 (file)
@@ -70,7 +70,8 @@ bool be_verbose_global = false;
 
 /* Scheme code to execute before parsing, after .scm init.
    This is where -e arguments are appended to.  */
-String init_scheme_code_string = "(begin #t ";
+String init_scheme_code_string;
+String init_scheme_variables;
 
 /* Generate preview of first system.  */
 bool make_preview = false;
@@ -393,9 +394,29 @@ main_with_guile (void *, int, char **)
 
   all_fonts_global = new All_font_metrics (global_path.to_string ());
 
-  init_scheme_code_string += ")";
-  scm_c_eval_string ((char *) init_scheme_code_string.to_str0 ());
+  
+  if (!init_scheme_variables.is_empty ()
+      || !init_scheme_code_string.is_empty ())
+    {
+      init_scheme_variables = "(ly:set-option 'command-line-settings (list "
+       + init_scheme_variables + "))";
+      
+      init_scheme_code_string
+       += "(begin #t "
+       + init_scheme_variables
+       + init_scheme_code_string
+       + ")";
+
+      char const *str0 = init_scheme_code_string.to_str0 ();
+      
+      if (be_verbose_global)
+       {
+         progress_indication (_f("Evaluating %s", str0));
+       }
+      scm_c_eval_string ((char *) str0);
+    }
 
+  
   /* We accept multiple independent music files on the command line to
      reduce compile time when processing lots of small files.
      Starting the GUILE engine is very time consuming.  */
@@ -478,7 +499,22 @@ parse_argv (int argc, char **argv)
          break;
 
        case 'd':
-         
+         {
+           String arg (option_parser->optional_argument_str0_);
+           int eq = arg.index ('=');
+
+           String key = arg;
+           String val = "#t";
+           
+           if (eq >= 0)
+             {
+               key = arg.left_string (eq);
+               val = arg.right_string (arg.length () - eq - 1);
+             }
+
+           init_scheme_variables
+             += "(cons \'" + key  + "  " + val + ")\n";
+         }
          break;
          
        case 'v':
index e7042cc44ddcdb9f579be21003e32a7f04375f9b..7e007cadb94c1e545c65aeaf905487beef332636 100644 (file)
@@ -6,10 +6,10 @@
   (c) 2001--2005  Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "scm-option.hh"
-
 #include <cstdio>
 
+#include "scm-option.hh"
+#include "protected-scm.hh"
 #include "parse-scm.hh"
 #include "warn.hh"
 #include "main.hh"
@@ -29,8 +29,6 @@
 /* Write midi as formatted ascii stream? */
 bool midi_debug_global_b;
 
-int preview_resolution_global = 90;
-
 /* General purpose testing flag */
 int testing_level_global;
 
@@ -45,6 +43,8 @@ bool lily_1_8_compatibility_used = false;
 */
 bool do_internal_type_checking_global;
 
+Protected_scm command_line_settings = SCM_EOL;
+
 /*
   What is this function for ?
 */
@@ -96,6 +96,8 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
           "Relative for simultaneous music functions similar to chord syntax\n"
           "@item new-relative\n"
           "Relative for simultaneous music functions similar to sequential music\n"
+          "@item command-line-settings\n"
+          "An alist of generic key/value pairs\n"
           "@end table\n"
           "\n"
           "This function is useful to call from the command line: @code{lilypond -e\n"
@@ -123,10 +125,14 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
       /*  Needs to be reset for each file that uses this option.  */
       lily_1_8_compatibility_used = false;
     }
-  else if (var == ly_symbol2scm ("resolution"))
-    preview_resolution_global = robust_scm2int (val, 90);
   else if (var == ly_symbol2scm ("new-relative"))
     lily_1_8_relative = false;
+  else if (var == ly_symbol2scm ("command-line-settings"))
+    {
+      SCM_ASSERT_TYPE(scm_list_p (val) == SCM_BOOL_T,
+                     val, SCM_ARG2, __FUNCTION__, "alist");
+      command_line_settings = scm_append (scm_list_2 (val, command_line_settings));
+    }
   else
     {
       if (scm_is_symbol (var))
@@ -148,8 +154,8 @@ LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
           "Report whether old-relative compatibility mode is used\n"
           "@item verbose\n"
           "Report whether we are running in verbose mode\n"
-          "@item resolution\n"
-          "Resolution for the PNG output."
+          "@item command-line-settings\n"
+          
           "@end table\n"
           "\n")
 {
@@ -163,8 +169,10 @@ LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
     o = ly_bool2scm (lily_1_8_relative);
   else if (var == ly_symbol2scm ("verbose"))
     o = ly_bool2scm (be_verbose_global);
-  else if (var == ly_symbol2scm ("resolution"))
-    o = scm_from_int (preview_resolution_global);
+  else if (var == ly_symbol2scm ("command-line-settings"))
+    {
+      o = command_line_settings;
+    }
   else
     {
       if (scm_is_symbol (var))
index 2c5cc1620999b7b0e1b5aa14b297b9e9bc164537..a9d6ebacde1395bf55c4ac49a2c530d98edf90c4 100644 (file)
@@ -474,6 +474,9 @@ def make_ps_images (ps_name, resolution = 90, papersize = "a4",
 
        # png16m is because Lily produces color nowadays.
        if not multi_page:
+
+               # GS can produce empty 2nd page if pngn is used.
+               output_file = png1
                cmd = r'''gs\
                -dEPSCrop\
                -dGraphicsAlphaBits=4\
@@ -514,7 +517,7 @@ def make_ps_images (ps_name, resolution = 90, papersize = "a4",
                error (_ ("%s exited with status: %d") % ('GS', status))
                exit (1)
 
-       if rename_page1_p or not multi_page:
+       if rename_page1_p and multi_page:
                os.rename (pngn % 1, png1)
-       files = glob.glob (png1) + glob.glob (re.sub ('%d', '*', output_file))
+       files = glob.glob (png1) + glob.glob (re.sub ('%d', '*', pngn))
        return files
index 6275b12ec6abf6830c905920d5ebd49c14813d75..0e2bdf78dec4024d2b70ffc7cdc67db6632357ec 100644 (file)
     (display "} stop-system\n%%Trailer\n%%EOF\n" port)
     (ly:outputter-close outputter)))
 
+
 (define-public (output-preview-framework basename book scopes fields)
+  
   (let* ((paper (ly:paper-book-paper book))
         (systems (ly:paper-book-systems book))
         (scale (ly:output-def-lookup paper 'outputscale))
-        (titles (take-while ly:paper-system-title? systems))
-        (non-title (find (lambda (x)
-                           (not (ly:paper-system-title? x))) systems))
-        (dump-me
-         (stack-stencils Y DOWN 0.0
-                         (map ly:paper-system-stencil
-                              (append titles (list non-title))))))
-    (output-scopes scopes fields basename)
-    (dump-stencil-as-EPS paper dump-me
-                        (format "~a.preview" basename)
-                        #t)))
+        (to-dump-systems '())
+        )
+
+    
+    ;; skip booktitles.
+    (if (and
+        (not
+         (cdr (assoc
+              'preview-include-book-title
+              (ly:get-option 'command-line-settings)
+              )))
+        (< 1 (length systems))
+        (ly:paper-system-title? (list-ref systems 0))
+        (ly:paper-system-title? (list-ref systems 1)))
+       (set! systems (cdr systems)))
 
+    
+    (for-each
+     (lambda (sys)
+       (if (or
+           (ly:paper-system-title? sys)
+           (and (pair? to-dump-systems)
+                (ly:paper-system-title? (car to-dump-systems))))
+          (set! to-dump-systems (cons sys to-dump-systems))))
+     systems)
+
+    (dump-stencil-as-EPS
+     paper
+     (stack-stencils Y DOWN 0.0
+                    (map ly:paper-system-stencil (reverse to-dump-systems)))
+     (format "~a.preview" basename)
+     #t)
+
+    (postprocess-output book framework-ps-module
+                       (format "~a.preview.eps" basename)
+                       (completize-formats (cons "png" (ly:output-formats))))
+    
+    ))
+(if #f
+    (define-public (output-preview-framework basename book scopes fields)
+      
+      (let* ((paper (ly:paper-book-paper book))
+            (systems (ly:paper-book-systems book))
+            (scale (ly:output-def-lookup paper 'outputscale))
+            (titles (take-while ly:paper-system-title? systems))
+            (non-title (find (lambda (x)
+                               (not (ly:paper-system-title? x))) systems))
+            (dump-me
+             (stack-stencils Y DOWN 0.0
+                             (map ly:paper-system-stencil
+                                  (append titles (list non-title))))))
+       (output-scopes scopes fields basename)
+       (dump-stencil-as-EPS paper dump-me
+                            (format "~a.preview" basename)
+                            #t)
+
+       (postprocess-output book framework-ps-module
+                           (format "~a.preview.eps" basename)
+                           (completize-formats (ly:output-formats)))
+       
+       ))
+    )
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define-public (convert-to-pdf book name)
 
 (define-public (convert-to-png book name)
   (let* ((defs (ly:paper-book-paper book))
-        (resolution (ly:output-def-lookup defs 'pngresolution))
+        (defs-resolution (ly:output-def-lookup defs 'pngresolution))
+        (resolution (if (number? defs-resolution)
+                        defs-resolution
+                        (cdr (assoc 'resolution
+                               (ly:get-option 'command-line-settings)))))
         (papersizename (ly:output-def-lookup defs 'papersizename)))
 
-    (postscript->png (if (number? resolution) resolution
-                        (ly:get-option 'resolution))
-                    (if (string? papersizename) papersizename "a4")
+    (postscript->png resolution
+                    (if (string? papersizename)
+                        papersizename "a4")
+                    
                     name)))
 
 (define-public (convert-to-dvi book name)
index d71a26246bbd3e4b73700c1437763f70f9a43723..561c5c5e7c7f00fd2df76656c7ef08f08cd74cc2 100644 (file)
         (resolution (ly:output-def-lookup defs 'pngresolution))
         (papersizename (ly:output-def-lookup defs 'papersizename)))
     (postscript->png
-     (if (number? resolution) resolution (ly:get-option 'resolution))
-     (if (string? papersizename) papersizename "a4")
+     (if (number? resolution)
+        resolution
+        (assoc
+         'resolution
+         (ly:get-option 'command-line-settings)))
+
+     (if (string? papersizename)
+        papersizename
+        "a4")
+     
      (string-append (basename name ".tex") ".ps"))))
 
 (define-public (convert-to-ps book name)
index 3d912310ff1d31622f6ab9f850454030181bd139..02a6671ac97272231cb5315cfd6c59b8754c53e9 100644 (file)
       (debug-enable 'backtrace)
       (read-enable 'positions)))
 
-(define-public (line-column-location file line col)
-  "Print an input location, including column number ."
-  (string-append (number->string line) ":"
-                (number->string col) " " file))
 
-(define-public (line-location  file line col)
-  "Print an input location, without column number ."
-  (string-append (number->string line) " " file))
 
-(define-public point-and-click #f)
+;; initialize defaults. 
+(ly:set-option 'command-line-settings
+              '((resolution . 90)
+                (preview-include-book-title . #t)
+                ))
 
 (define-public tex-backend?
   (member (ly:output-backend) '("texstr" "tex")))
index 6537a688e43fda373dc331be1c01709876cc4a47..960d62d439220f0b1f192489c28657529a7158bf 100644 (file)
 ;; no-origin not yet supported by Xdvi
 (define (no-origin) "")
 
+
+
+
+(define-public (line-location  file line col)
+  "Print an input location, without column number ."
+  (string-append (number->string line) " " file))
+
+(define-public point-and-click #f)
+
 (define (grob-cause offset grob)
+  (define (line-column-location file line col)
+    "Print an input location, including column number ."
+    (string-append (number->string line) ":"
+                  (number->string col) " " file))
+
   (if (procedure? point-and-click)
       (let* ((cause (ly:grob-property grob 'cause))
             (music-origin (if (ly:music? cause)
        (if (pair? location)
             ;;; \\string ? 
            (string-append "\\special{src:"
-                          (apply point-and-click location) "}")
+                          (line-column-location location) "}")
            ""))
       ""))