]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/lily.scm (get-output-module): New function.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 13 Mar 2004 21:24:15 +0000 (21:24 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sat, 13 Mar 2004 21:24:15 +0000 (21:24 +0000)
(output-alist): Remove ,ps-output-expression.

* scm/output-tex.scm (ps-output-expression): New function.

* scm/output-ps.scm (ps-output-expression): Remove.
(header, start-page): Output page metadata.

* lily/paper-outputter.cc (Paper_outputter)[PAGE_LAYOUT]:
initialise output_module_.  Do not write part of header.
(output_scheme)[PAGE_LAYOUT]: Output through output_module_.
(output_header): Output full header.

* scm/define-markup-commands.scm (bigger, smaller): Avoid crash.
FIXME.

ChangeLog
lily/include/paper-outputter.hh
lily/my-lily-lexer.cc
lily/paper-book.cc
lily/paper-outputter.cc
lily/parse-scm.cc
scm/define-markup-commands.scm
scm/lily.scm
scm/output-ps.scm
scm/output-tex.scm

index b2e0dc286f74ad0450d0572246cbebedb818bd86..9cbf4403f623ccd97160ae008ad5ba4093334c1a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2004-03-13  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * scm/lily.scm (get-output-module): New function.
+       (output-alist): Remove ,ps-output-expression.
+
+       * scm/output-tex.scm (ps-output-expression): New function.
+
+       * scm/output-ps.scm (ps-output-expression): Remove.
+       (header, start-page): Output page metadata.
+
+       * lily/paper-outputter.cc (Paper_outputter)[PAGE_LAYOUT]:
+       initialise output_module_.  Do not write part of header.
+       (output_scheme)[PAGE_LAYOUT]: Output through output_module_.
+       (output_header): Output full header.
+
+       * scm/define-markup-commands.scm (bigger, smaller): Avoid crash.
+       FIXME.
+
 2004-03-13  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
        * scm/new-font.scm: new file. Tree based font lookup.
index fc59ec65bc30d28654f022e05fd777c61564a0dc..4f2ea7b4cc0d8f4f517a07d3fc6e0abac701a2c4 100644 (file)
@@ -29,7 +29,8 @@ class Paper_outputter
   bool verbatim_scheme_b_;
 public:
 
-  SCM output_func_ ;
+  SCM output_func_;
+  SCM output_module_;
   Protected_scm file_;
   
   String basename_;
@@ -38,11 +39,11 @@ public:
   
   void dump_scheme (SCM);
 
-  void output_metadata (SCM, Paper_def*);
+  void output_metadata (Paper_def*, SCM);
   void output_music_output_def (Music_output_def* odef);
   void output_scheme (SCM scm);
   void output_expr (SCM expr, Offset o);
-  void output_header (Paper_def*);
+  void output_header (Paper_def*, SCM, int);
   void output_line (SCM, Offset*, bool);
 };
 
index a0a276ccf7ff33d8fcad1a42a0b153c1f59dcf00..5653b3b989fb1194a046d4eaf44bd1b05bff6e80 100644 (file)
@@ -165,6 +165,7 @@ void
 My_lily_lexer::start_main_input ()
 {  
   new_input (main_input_name_, &global_input_file->sources_);
+  /* Do not allow \include in --safe-mode */
   allow_includes_b_ = allow_includes_b_ && ! safe_global_b;
 
   scm_module_define (gh_car (scopes_),
index b89d0a86b6b06a2c3fc7b0ad31630256e0498786..31f939c5573de5be0c76c654f06ad2a9a7244927 100644 (file)
@@ -217,8 +217,7 @@ Paper_book::output (String outname)
 
   Paper_def *paper = papers_[0];
   Paper_outputter *out = paper->get_paper_outputter (outname);
-  out->output_metadata (get_scopes (0), paper);
-  out->output_header (paper);
+  out->output_header (paper, get_scopes (0), pages->size ());
 
   int page_count = pages->size ();
   for (int i = 0; i < page_count; i++)
@@ -437,11 +436,9 @@ Paper_book::fill_pages (Page *page, int page_count, Real fudge)
 void
 Paper_book::classic_output (String outname)
 {
-  Paper_outputter *out = papers_.top ()->get_paper_outputter (outname);
   int count = scores_.size ();
-  
-  out->output_metadata (get_scopes (count - 1), papers_.top ());
-  out->output_header (papers_.top ());
+  Paper_outputter *out = papers_.top ()->get_paper_outputter (outname);
+  out->output_header (papers_.top (), get_scopes (count - 1), 0);
 
   int line_count = SCM_VECTOR_LENGTH ((SCM) scores_.top ());
   for (int i = 0; i < line_count; i++)
index 4797a837ec0e18150151828e6840d85f9206ea8a..0e9d30eb913afe9f9d70e8d366c115fe345726da 100644 (file)
@@ -36,23 +36,31 @@ Paper_outputter::Paper_outputter (String name)
   file_ = scm_open_file (scm_makfrom0str (name.to_str0 ()),
                         scm_makfrom0str ("w"));
 
-  static SCM find_dumper;
-  if (!find_dumper)
-    find_dumper = scm_c_eval_string ("find-dumper");
-
-  output_func_
-    = scm_call_1 (find_dumper,
-                 scm_makfrom0str (output_format_global.to_str0 ()));
-
-  String creator = gnu_lilypond_version_string ();
-  creator += " (http://lilypond.org)";
-  time_t t (time (0));
-  String time_stamp = ctime (&t);
-  time_stamp = time_stamp.left_string (time_stamp.length () - 1)
-    + " " + *tzname;
-  output_scheme (scm_list_3 (ly_symbol2scm ("header"),
-                            scm_makfrom0str (creator.to_str0 ()),
-                            scm_makfrom0str (time_stamp.to_str0 ())));
+  if (output_format_global == PAGE_LAYOUT)
+    {
+      output_func_ = SCM_UNDEFINED;
+      output_module_
+       = scm_call_1 (scm_primitive_eval (ly_symbol2scm ("get-output-module")),
+                     scm_makfrom0str (output_format_global.to_str0 ()));
+      if (safe_global_b)
+       {
+         SCM safe_module = scm_primitive_eval (ly_symbol2scm ("safe-module"));
+         SCM m = scm_set_current_module (safe_module);
+         scm_c_use_module (("output-" + output_format_global).to_str0 ());
+         output_module_ = scm_set_current_module (m);
+       }
+    }
+  else
+    {
+      static SCM find_dumper;
+      if (!find_dumper)
+       find_dumper = scm_c_eval_string ("find-dumper");
+      
+      output_func_
+       = scm_call_1 (find_dumper,
+                     scm_makfrom0str (output_format_global.to_str0 ()));
+      output_module_ = SCM_UNDEFINED;
+    }
 }
 
 Paper_outputter::~Paper_outputter ()
@@ -64,11 +72,14 @@ Paper_outputter::~Paper_outputter ()
 void
 Paper_outputter::output_scheme (SCM scm)
 {
-  gh_call2 (output_func_, scm, file_);
+  if (output_format_global == PAGE_LAYOUT)
+    scm_display (scm_eval (scm, output_module_), file_);
+  else
+    gh_call2 (output_func_, scm, file_);
 }
 
 void
-Paper_outputter::output_metadata (SCM scopes, Paper_def *paper)
+Paper_outputter::output_metadata (Paper_def *paper, SCM scopes)
 {
   SCM fields = SCM_EOL;
   for (int i = dump_header_fieldnames_global.size (); i--; )
@@ -86,9 +97,22 @@ Paper_outputter::output_metadata (SCM scopes, Paper_def *paper)
 }
 
 void
-Paper_outputter::output_header (Paper_def *paper)
+Paper_outputter::output_header (Paper_def *paper, SCM scopes, int page_count)
 {
+  String creator = gnu_lilypond_version_string ();
+  creator += " (http://lilypond.org)";
+  time_t t (time (0));
+  String time_stamp = ctime (&t);
+  time_stamp = time_stamp.left_string (time_stamp.length () - 1)
+    + " " + *tzname;
+  output_scheme (scm_list_4 (ly_symbol2scm ("header"),
+                            scm_makfrom0str (creator.to_str0 ()),
+                            scm_makfrom0str (time_stamp.to_str0 ()),
+                            scm_int2num (page_count)));
+
+  output_metadata (paper, scopes);
   output_music_output_def (paper);
+
   output_scheme (scm_list_1 (ly_symbol2scm ("header-end")));
   output_scheme (scm_list_2 (ly_symbol2scm ("define-fonts"),
                             ly_quote_scm (paper->font_descriptions ())));
index e95eb644f7c84d5bf02ecfcb40c4523bd31e22c4..a5de3e9866121d64c23051fb1a227679382c1b45 100644 (file)
@@ -5,14 +5,10 @@
 #include "string.hh"
 #include "source-file.hh"
 
-/*
-  Pass string to scm parser, evaluate one expression.
-  Return result value and #chars read.
-
-  Thanks to Gary Houston <ghouston@freewire.co.uk>
-
-  Need guile-1.3.4 (>1.3 anyway) for ftell on str ports -- jcn
-*/
+/* Pass string to scm parser, evaluate one expression.
+   Return result value and #chars read.
+   
+   Thanks to Gary Houston <ghouston@freewire.co.uk>  */
 SCM
 internal_ly_parse_scm (Parse_start * ps, bool safe)
 {
@@ -35,8 +31,6 @@ internal_ly_parse_scm (Parse_start * ps, bool safe)
          static SCM safe_module;
          if (!safe_module)
            safe_module = scm_primitive_eval (ly_symbol2scm ("safe-module"));
-
-         
          answer = scm_eval (form, safe_module);
        }
       else
index 6d765b7182e83c7057a9fedda35dd4717dddcb4c..6332287c412a676f2c4a71bfdcac26550a10a707 100644 (file)
@@ -518,14 +518,18 @@ any sort of property supported by @internalsref{font-interface} and
 (def-markup-command (smaller paper props arg) (markup?)
   "Decrease the font size relative to current setting"
   (let* ((fs (chain-assoc-get 'font-size props 0))
-         (entry (cons 'font-size (- fs 1))))
+        ;; FIXME: crasher fix
+         ;; (entry (cons 'font-size (- fs 1))))
+         (entry (cons 'font-size (if (number? fs) (- fs 1) 0))))
     (interpret-markup paper (cons (list entry) props) arg)))
 
 
 (def-markup-command (bigger paper props arg) (markup?)
   "Increase the font size relative to current setting"
   (let* ((fs (chain-assoc-get 'font-size props 0))
-         (entry (cons 'font-size (+ fs 1))))
+        ;; FIXME: crasher fix
+         ;; (entry (cons 'font-size (+ fs 1))))
+         (entry (cons 'font-size (if (number? fs) (+ fs 1) 0))))
     (interpret-markup paper (cons (list entry) props) arg)))
 
 (def-markup-command larger (markup?)
index 60fbcf744b99162abdce409879e6a871b8b53512..9329701c04280c9d2f0d2a60dbf9b9199e0a623f 100644 (file)
@@ -371,7 +371,6 @@ L1 is copied, L2 not.
 (define output-alist
   `(
     ("tex" . ("TeX output. The default output form." ,tex-output-expression))
-    ("ps" . ("Direct postscript. Requires setting GS_LIB and GS_FONTPATH" ,ps-output-expression))
     ("scm" . ("Scheme dump: debug scheme stencil expressions" ,write))
     ("sketch" . ("Bare bones Sketch output." ,sketch-output-expression))
     ("sodipodi" . ("Bare bones Sodipodi output." ,sodipodi-output-expression))
@@ -386,13 +385,16 @@ L1 is copied, L2 not.
      output-alist)
    ))
 
-(define-public (find-dumper format )
-  (let* ((d (assoc format output-alist)))
-    
+(define-public (find-dumper format)
+  (let ((d (assoc format output-alist)))
     (if (pair? d)
        (caddr d)
        (scm-error "Could not find dumper for format ~s" format))))
 
+(define-public (get-output-module output-format)
+  (resolve-module `(scm ,(string->symbol
+                         (string-append "output-" output-format)))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; other files.
 
index 3bb2094353c97ae1eef932fe04770504cd1d833a..36d9dffbcde6f1247302642919ca62d0fedfec90 100644 (file)
@@ -16,6 +16,8 @@
 ;;;;   * text setting, kerning.
 ;;;;   * document output-interface
 
+;;(if (not safe-mode?)
+;;    (debug-enable 'backtrace))
 (debug-enable 'backtrace)
 
 (define-module (scm output-ps))
  (srfi srfi-13)
  (lily))
 
-
-
-
-;;; Lily output interface, PostScript implementation --- cleanup and docme
+(define (expression->string expr)
+  (eval expr this-module))
 
 ;;; Output interface entry
-(define-public (ps-output-expression expr port)
+(define (output-expression expr port)
   (display (expression->string expr) port))
 
+
 ;;; Global vars
 ;; alist containing fontname -> fontcommand assoc (both strings)
+(define page-count 0)
+(define page-number 0)
 (define font-name-alist '())
 
 ;; /lilypondpaperoutputscale 1.75729901757299 def
 (define (tex-font? fontname)
   (equal? (substring fontname 0 2) "cm"))
 
+
+;;;
+;;; Lily output interface, PostScript implementation --- cleanup and docme
+;;;
+
 ;;; Output-interface functions
 (define (beam width slope thick blot)
   (string-append
 (define (end-output)
   "\nend-lilypond-output\n")
 
-(define (expression->string expr)
-  (eval expr this-module))
-
 (define (ez-ball ch letter-col ball-col)
   (string-append
    " (" ch ") "
   
   (string-append (select-font name-mag-pair) exp))
 
-(define (header creator time-stamp)
+(define (header creator time-stamp page-count-)
+  (set! page-count page-count-)
+  (set! page-number 0)
   (string-append
    "%!PS-Adobe-3.0\n"
    "%%Creator: " creator " " time-stamp "\n"
+   "%%Pages: " (number->string page-count) "\n"
+   "%%PageOrder: Ascend\n"
    ;;(string-append "GNU LilyPond (" (lilypond-version) "), ")
    ;;     (strftime "%c" (localtime (current-time))))
    ;; FIXME: duplicated in every backend
     " draw_zigzag_line "))
 
 (define (start-page)
-  "\nstart-page\n")
+  (set! page-number (+ page-number 1))
+  (string-append
+   "%%Page: " (number->string page-number) " " (number->string page-count) "\n"
+  "start-page\n"))
 
 (define (stop-page last?)
   (if last?
index 52c86ed58a37b6e4be43bb4c4000836a60b5e17e..f86cc536997c76802b980b07ec0580c1c96d11e5 100644 (file)
 
 (define this-module (current-module))
 
+;; dumper-compatibility
+
+(define (ps-output-expression expr port)
+  (let ((output-ps (resolve-module '(scm output-ps))))
+    (display (eval expr output-ps) port)))
+
 ;;; Output interface entry
 (define-public (tex-output-expression expr port)
   (display (eval expr this-module) port ))
 
 (define (end-output) 
   (begin
-                                       ; uncomment for some stats about lily memory      
-                                       ;               (display (gc-stats))
+    ;; uncomment for some stats about lily memory        
+    ;; (display (gc-stats))
     (string-append
      "\\lilypondend\n"
-                                       ; Put GC stats here.
-                  )))
+     ;; Put GC stats here.
+     )))
 
 (define (experimental-on)
   "")
    "\\lilypondspecial\n"
    "\\lilypondpostscript\n"))
 
-(define (header creator time-stamp
+(define (header creator time-stamp page-count)
   (string-append
    "% Generated by " creator "\n"
    "% at " time-stamp "\n"