CVSROOT:        /cvsroot/lilypond
Module name:    lilypond
Branch:         
Changes by:     Han-Wen Nienhuys <[EMAIL PROTECTED]>    05/04/27 13:00:50

Modified files:
        .              : ChangeLog 
        lily           : main.cc scm-option.cc 
        python         : lilylib.py 
        scm            : framework-ps.scm framework-tex.scm lily.scm 
                         output-tex.scm 

Log message:
        * python/lilylib.py (make_ps_images): bugfixes; GS can produce
        empty 2nd page for mono page.
        
        * scm/lily.scm: remove p&c definitions.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3510&tr2=1.3511&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/main.cc.diff?tr1=1.242&tr2=1.243&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/scm-option.cc.diff?tr1=1.53&tr2=1.54&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/python/lilylib.py.diff?tr1=1.63&tr2=1.64&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/framework-ps.scm.diff?tr1=1.91&tr2=1.92&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/framework-tex.scm.diff?tr1=1.79&tr2=1.80&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/lily.scm.diff?tr1=1.328&tr2=1.329&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/output-tex.scm.diff?tr1=1.89&tr2=1.90&r1=text&r2=text

Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3510 lilypond/ChangeLog:1.3511
--- lilypond/ChangeLog:1.3510   Wed Apr 27 09:51:23 2005
+++ lilypond/ChangeLog  Wed Apr 27 13:00:49 2005
@@ -1,5 +1,10 @@
 2005-04-27  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
+       * 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: lilypond/lily/main.cc
diff -u lilypond/lily/main.cc:1.242 lilypond/lily/main.cc:1.243
--- lilypond/lily/main.cc:1.242 Wed Apr 27 09:12:33 2005
+++ lilypond/lily/main.cc       Wed Apr 27 13:00:50 2005
@@ -70,7 +70,8 @@
 
 /* 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 @@
 
   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 @@
          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: lilypond/lily/scm-option.cc
diff -u lilypond/lily/scm-option.cc:1.53 lilypond/lily/scm-option.cc:1.54
--- lilypond/lily/scm-option.cc:1.53    Wed Apr 13 13:18:09 2005
+++ lilypond/lily/scm-option.cc Wed Apr 27 13:00:50 2005
@@ -6,10 +6,10 @@
   (c) 2001--2005  Han-Wen Nienhuys <[EMAIL PROTECTED]>
 */
 
-#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 do_internal_type_checking_global;
 
+Protected_scm command_line_settings = SCM_EOL;
+
 /*
   What is this function for ?
 */
@@ -96,6 +96,8 @@
           "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 @@
       /*  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 @@
           "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 @@
     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: lilypond/python/lilylib.py
diff -u lilypond/python/lilylib.py:1.63 lilypond/python/lilylib.py:1.64
--- lilypond/python/lilylib.py:1.63     Tue Apr 19 22:19:36 2005
+++ lilypond/python/lilylib.py  Wed Apr 27 13:00:50 2005
@@ -474,6 +474,9 @@
 
        # 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 @@
                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: lilypond/scm/framework-ps.scm
diff -u lilypond/scm/framework-ps.scm:1.91 lilypond/scm/framework-ps.scm:1.92
--- lilypond/scm/framework-ps.scm:1.91  Wed Apr 13 13:18:09 2005
+++ lilypond/scm/framework-ps.scm       Wed Apr 27 13:00:50 2005
@@ -342,22 +342,74 @@
     (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)
@@ -371,12 +423,17 @@
 
 (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: lilypond/scm/framework-tex.scm
diff -u lilypond/scm/framework-tex.scm:1.79 lilypond/scm/framework-tex.scm:1.80
--- lilypond/scm/framework-tex.scm:1.79 Tue Apr 12 22:49:25 2005
+++ lilypond/scm/framework-tex.scm      Wed Apr 27 13:00:50 2005
@@ -298,8 +298,16 @@
         (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: lilypond/scm/lily.scm
diff -u lilypond/scm/lily.scm:1.328 lilypond/scm/lily.scm:1.329
--- lilypond/scm/lily.scm:1.328 Mon Apr 25 16:47:47 2005
+++ lilypond/scm/lily.scm       Wed Apr 27 13:00:50 2005
@@ -36,16 +36,13 @@
       (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: lilypond/scm/output-tex.scm
diff -u lilypond/scm/output-tex.scm:1.89 lilypond/scm/output-tex.scm:1.90
--- lilypond/scm/output-tex.scm:1.89    Tue Apr 12 22:49:25 2005
+++ lilypond/scm/output-tex.scm Wed Apr 27 13:00:50 2005
@@ -192,7 +192,21 @@
 ;; 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)
@@ -202,6 +216,6 @@
        (if (pair? location)
             ;;; \\string ? 
            (string-append "\\special{src:"
-                          (apply point-and-click location) "}")
+                          (line-column-location location) "}")
            ""))
       ""))


_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

Reply via email to