]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/paper-book.cc (split_string): new function
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 30 May 2004 09:31:40 +0000 (09:31 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 30 May 2004 09:31:40 +0000 (09:31 +0000)
(output): output multiple formats, i.e. --format=ps,tex

* scm/output-ps.scm (output-scopes): dump variables directly.
(define-fonts): rewrite for new interface

* ps/lilyponddefs.ps: remove lilypondpaper redefinitions.

* lily/paper-outputter.cc (Paper_outputter): take format argument.

* lily/main.cc (parse_argv): don't set extension for output.

* lily/clef-engraver.cc (create_clef): remove
Staff_symbol_referencer::set_position() call.

16 files changed:
ChangeLog
lily/clef-engraver.cc
lily/grob.cc
lily/include/grob.hh
lily/include/paper-outputter.hh
lily/main.cc
lily/my-lily-parser.cc
lily/paper-book.cc
lily/paper-column.cc
lily/paper-outputter.cc
lily/script-column.cc
lily/side-position-interface.cc
lily/spacing-spanner.cc
lily/staff-symbol-referencer.cc
ps/lilyponddefs.ps
scm/output-ps.scm

index 1955b018e2d58f682bd689062966fad7512c4784..abd9c68e7c362583ee9df9f802a007d0f48fb186 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2004-05-30  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * lily/paper-book.cc (split_string): new function
+       (output): output multiple formats, i.e. --format=ps,tex
+
+       * scm/output-ps.scm (output-scopes): dump variables directly.
+       (define-fonts): rewrite for new interface
+
+       * ps/lilyponddefs.ps: remove lilypondpaper redefinitions.
+
+       * lily/paper-outputter.cc (Paper_outputter): take format argument.
+
+       * lily/main.cc (parse_argv): don't set extension for output.
+
+       * lily/clef-engraver.cc (create_clef): remove
+       Staff_symbol_referencer::set_position() call. 
+       
 2004-05-29  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
        * lily/staff-symbol-engraver.cc (acknowledge_grob): remove item ->
index fb5daa0402ec9e2f9b212e3d11e23eaa71879909..c22408b300f96ebaf8fa1aa20f3dacf1eb9772b4 100644 (file)
@@ -93,7 +93,7 @@ Clef_engraver::create_clef ()
       SCM cpos = get_property ("clefPosition");
 
       if (ly_c_number_p (cpos))
-       Staff_symbol_referencer::set_position (clef_, ly_scm2int (cpos));
+       clef_->set_property ("staff-position", cpos);
 
       SCM oct =  get_property ("clefOctavation");
       if (ly_c_number_p (oct) && ly_scm2int (oct))
index 79152064b4ff53a62291085c041dcb4e8abb5840..477577066388d5d2059d8e62044fe4eebc6ac877 100644 (file)
@@ -138,9 +138,6 @@ Grob::Grob (Grob const&s)
 
 Grob::~Grob ()
 {
-  /*
-    do nothing scm-ish and no unprotecting here.
-   */
 }
 
 
@@ -164,13 +161,22 @@ Grob::get_paper ()  const
  return pscore_ ? pscore_->paper_ : 0;
 }
 
+
+/*
+  Recursively track all dependencies of this Grob.  The
+  status_ field is used as a mark-field.  It is marked with
+  BUSY during execution of this function, and marked with FINAL
+  when finished.
+
+  FUNCPTR is the function to call to update this element.
+*/
 void
 Grob::calculate_dependencies (int final, int busy, SCM funcname)
 {
   if (status_ >= final)
     return;
 
-  if (status_== busy)
+  if (status_ == busy)
     {
       programming_error ("Element is busy, come back later");
       return;
@@ -190,7 +196,7 @@ Grob::calculate_dependencies (int final, int busy, SCM funcname)
   if (ly_c_procedure_p (proc))
     scm_call_1 (proc, this->self_scm ());
  
-  status_= final;
+  status_ = final;
 }
 
 Stencil *
@@ -281,7 +287,6 @@ Grob::add_dependency (Grob*e)
     programming_error ("Null dependency added");
 }
 
-
 void
 Grob::handle_broken_dependencies ()
 {
@@ -592,7 +597,7 @@ Grob::has_offset_callback (SCM cb, Axis a)const
 void
 Grob::set_extent (SCM dc, Axis a)
 {
-  dim_cache_[a].dimension_ =dc;
+  dim_cache_[a].dimension_ = dc;
 }
 
 void
index 2be13c6c24ae4b443b2450a6708a7cd9f65f84f5..ad0ae53136c12d50f6f40e0ecc18d8a3d9978884 100644 (file)
@@ -40,17 +40,13 @@ protected:
   friend class Spanner;
   
   void substitute_mutable_properties(SCM,SCM);
-
+  char status_;
 public:
   Grob *original_;
 
-  /**
-    Administration: Where are we?. This is mainly used by Super_element and
-    Grob::calcalute_dependencies ()
-
-    0 means ORPHAN,
+  /*
+    TODO: junk this member.
    */
-  char status_;
   Paper_score *pscore_;
   Dimension_cache dim_cache_[NO_AXES];
 
@@ -69,25 +65,10 @@ public:
   void warning (String)const;
   void programming_error (String)const;
   
-  /*
-    related classes.
-   */
   Output_def *get_paper () const;
-
-  /**
-    add a dependency. It may be the 0 pointer, in which case, it is ignored.
-    */
   void add_dependency (Grob*);    
-  virtual System * get_system () const;
+  virtual System *get_system () const;
 
-  /**
-     Recursively track all dependencies of this Grob.  The
-     status_ field is used as a mark-field.  It is marked with
-     #busy# during execution of this function, and marked with #final#
-     when finished.
-
-     #funcptr# is the function to call to update this element.
-   */
   void calculate_dependencies (int final, int busy, SCM funcname);
 
 
index dca083ffa86932396c3345629732c27196289888..cffab8cfb8686931bfe2918a5fea91a45202e905 100644 (file)
@@ -36,7 +36,7 @@ class Paper_outputter
   void output_music_output_def (Output_def* odef);
 
 public:
-  Paper_outputter (String nm);
+  Paper_outputter (String nm, String format);
   ~Paper_outputter ();
 
   void dump_scheme (SCM);
@@ -47,6 +47,6 @@ public:
   void output_page (Page*, bool);
 };
 
-Paper_outputter* get_paper_outputter (String);
+Paper_outputter* get_paper_outputter (String,String);
 
 #endif /* PAPER_OUTPUTTER_HH */
index c8811fdc04350d43a017dcf0ab192074855d30ce..4fc6dfb1f1300e583cb9dacd0d35db59e6eb6919 100644 (file)
@@ -329,8 +329,6 @@ parse_argv (int argc, char **argv)
          {
            String s = option_parser->optional_argument_str0_;
            File_name file_name (s);
-           if (s != "-" && file_name.ext_.is_empty ())
-             file_name.ext_ = output_format_global;
            output_name_global = file_name.to_string ();
          }
          break;
index 365e64694cb406d16e62f9dbee895b265acd0a76..f5a54cc8853ca72426183ad6f97a0e0b4b50a027 100644 (file)
@@ -239,8 +239,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
      write output to cwd; do not use root and directory parts of input
      file name.  */
   File_name out_file_name (file_name);
-  if (file_name != "-")
-    out_file_name.ext_ = output_format_global;
+  out_file_name.ext_ = "";
   out_file_name.root_ = "";
   out_file_name.dir_ = "";
 
index 04759a3b1c3c8ae9ddd7666a4d5f4ddf80e63fd4..c379fb090c6024165bb29ba106972750a8e037a0 100644 (file)
@@ -82,6 +82,31 @@ Paper_book::print_smob (SCM smob, SCM port, scm_print_state*)
   return 1;
 }
 
+Array<String>
+split_string (String s, char c)
+{
+  Array<String> rv; 
+  while (s.length ())
+    {
+      int i = s.index (c);
+      
+      if (i == 0)
+       {
+         s = s.nomid_string (0, 1);
+         continue;
+       }
+      
+      if (i < 0)
+       i = s.length () ;
+
+      rv.push (s.cut_string (0, i));
+      s = s.nomid_string (0, i);
+    }
+
+  return rv;
+}
+  
+
 
 /*
   TODO: there is too much code dup, and the interface is not
@@ -97,28 +122,33 @@ Paper_book::output (String outname)
   /* Generate all stencils to trigger font loads.  */
   SCM pages = this->pages ();
 
-  Paper_outputter *out = get_paper_outputter (outname);
-  int page_count = scm_ilength (pages);
+  Array<String> output_formats = split_string (output_format_global, ',');
 
-  SCM scopes = SCM_EOL;
-  if (ly_c_module_p (header_))
-    scopes = scm_cons (header_, scopes);
+  for (int i = 0; i < output_formats.size (); i++)
+    {
+      String format = output_formats[i];
+      Paper_outputter *out = get_paper_outputter (outname + "." + output_formats[i], format);
+      int page_count = scm_ilength (pages);
+
+      SCM scopes = SCM_EOL;
+      if (ly_c_module_p (header_))
+       scopes = scm_cons (header_, scopes);
   
-  out->output_header (bookpaper_, scopes, page_count, false);
+      out->output_header (bookpaper_, scopes, page_count, false);
 
-  for (SCM s = pages; s != SCM_EOL; s = ly_cdr (s))
-    {
-      Page *p = unsmob_page (ly_car (s));
-      progress_indication ("[" + to_string (p->number_));
-      out->output_page (p, ly_cdr (s) == SCM_EOL);
-      progress_indication ("]");
-    }
+      for (SCM s = pages; s != SCM_EOL; s = ly_cdr (s))
+       {
+         Page *p = unsmob_page (ly_car (s));
+         progress_indication ("[" + to_string (p->number_));
+         out->output_page (p, ly_cdr (s) == SCM_EOL);
+         progress_indication ("]");
+       }
 
-  out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
-  progress_indication ("\n");
+      out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
+      progress_indication ("\n");
+    }
 }
 
-
 Stencil
 Paper_book::title (int i)
 {
@@ -157,7 +187,8 @@ Paper_book::title (int i)
 void
 Paper_book::classic_output (String outname)
 {
-  Paper_outputter *out = get_paper_outputter (outname);
+  String format = "tex";
+  Paper_outputter *out = get_paper_outputter (outname + "." + format, format);
 
   Output_def * p = bookpaper_;
   while (p && p->parent_)
@@ -187,7 +218,7 @@ Paper_book::classic_output (String outname)
 
         FIXME: vague... why is TeX is different from other ouput
                backends, why not fix the TeX backend? -- jcn */
-      if (output_format_global == "tex")
+      if (format == "tex")
        o = Offset (0, 0);
 
       out->output_line (scm_vector_ref (top_lines, scm_int2num (i)),
@@ -296,6 +327,7 @@ Paper_book::pages ()
   SCM pages = SCM_EOL;
   int page_count = SCM_VECTOR_LENGTH ((SCM) breaks);
   int line = 1;
+
   for (int i = 0; i < page_count; i++)
     {
       if (i)
index 5e5bc659a5722b82bd7707204cd2405112a9aedc..9eb5f1c3dd120e541b42a9e1787af2243a54c915 100644 (file)
@@ -67,7 +67,7 @@ Paper_column::get_column () const
 Paper_column::Paper_column (SCM l)
   : Item (l)           // guh.?
 {
-  system_=0;
+  system_ = 0;
   rank_ = -1;
 }
 
index ec1f3f9f8dad42435b79e005531240fcb9807c8f..f091341def67d8a10cee49ad252d4b08ec6296a6 100644 (file)
 // JUNKME
 extern SCM stencil2line (Stencil* stil, bool is_title = false);
 
-Paper_outputter::Paper_outputter (String filename)
+Paper_outputter::Paper_outputter (String filename, String format)
 {
   filename_ = filename;
   file_ = scm_open_file (scm_makfrom0str (filename.to_str0 ()),
                         scm_makfrom0str ("w"));
 
-  String module_name = "scm output-" + output_format_global;
+  String module_name = "scm output-" + format;
   output_module_ = scm_c_resolve_module (module_name.to_str0 ());
 }
 
@@ -168,10 +168,10 @@ Paper_outputter::output_stencil (Stencil stil)
 }
 
 Paper_outputter*
-get_paper_outputter (String outname) 
+get_paper_outputter (String outname, String f
 {
   progress_indication (_f ("paper output to `%s'...",
                           outname == "-" ? String ("<stdout>") : outname));
-  return new Paper_outputter (outname);
+  return new Paper_outputter (outname, f);
 
 }
index 52e5adcd0dbdbbe07f76b647a369c82987aad796..b7a70bd4627daac4d24b18791042525774bd37b1 100644 (file)
@@ -48,6 +48,9 @@ Script_column::before_line_breaking (SCM smob)
     {
       Grob *sc = unsmob_grob (ly_car (s));
 
+      /*
+       Don't want to consider scripts horizontally next to notes.
+       */
       if (!sc->has_offset_callback (Side_position_interface::aligned_side_proc,
                                    X_AXIS))
        staff_sided.push (sc);
index 556381419accbfa8ef51fbc7d60c5b970a12106a..896bbb2b3326dae03c30bf754e6c89a5e9abbf55 100644 (file)
@@ -255,14 +255,11 @@ Side_position_interface::get_axis (Grob*me)
   if (me->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS)
       || me->has_offset_callback (Side_position_interface::aligned_side_proc , X_AXIS))
     return X_AXIS;
-
   
   return Y_AXIS;
 }
 
 
-
-
 ADD_INTERFACE (Side_position_interface,"side-position-interface",
               "Position a victim object (this one) next to other objects (the "
               "support).   The property @code{direction} signifies where to put the  "
index bdb3212023149bddb52cc8f7fe67df44eaba2c4c..fdc5bacad4a0c78c87c63f6b75f6d370c8a5f7b6 100644 (file)
@@ -368,6 +368,9 @@ Spacing_spanner::set_springs (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
 
+  /*
+    can't use get_system() ? --hwn.
+   */
   Link_array<Grob> all (me->pscore_->system_->columns ());
 
   set_explicit_neighbor_columns (all);
index 160576caae4364f5cde613242a8355e70183ef9c..4ef9fbe9be622197a5e14afb50b04788d8543193 100644 (file)
@@ -120,7 +120,7 @@ Staff_symbol_referencer::callback (SCM element_smob, SCM)
 
 /*  This sets the position relative to the center of the staff symbol.
 
-The function is hairy, because it can be callled in two situations:
+The function is hairy, because it can be called in two situations:
 
 1. There is no staff yet; we must set staff-position
 
@@ -142,9 +142,7 @@ Staff_symbol_referencer::set_position (Grob *me, Real p)
   else
     me->set_property ("staff-position", scm_make_real (p));
 
-  if (!me->has_offset_callback (Staff_symbol_referencer::callback_proc,
-                               Y_AXIS))
-    me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS);
+  me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS);
 }
 
 /* Half of the height, in staff space, i.e. 2.0 for a normal staff. */
index b4116e2b21276363c483052fb4b85d47852856f0..60252c745c11abb21b714fc8d7b558b9e1f2e5cb 100644 (file)
@@ -9,18 +9,9 @@
 % To let gs load fonts from builddir, do:
 % export GS_LIB=$(pwd)/mf/out:/usr/share/texmf/fonts/type1/bluesky/cm
 
-/staff-line-thickness lilypondpaperlinethickness def
-/staff-height lilypondpaperstaffheight def
-/line-width lilypondpaperlinewidth def
-
-/lily-output-units 2.83464  def  %% milimeter
-% /lily-output-units 0.996264  def  %% true points.
-
-/output-scale lilypondpaperoutputscale lily-output-units mul def
 
 /set-ps-scale-to-lily-scale { output-scale output-scale scale } bind def
 
-/paper-size { lilypondpaperpapersize } bind def
 
 /init-paper {
        gsave
index 537b5f03308ad35b8de7ce024db7e51a75531fd3..e9ad248e45e174d0ef8fbb86e81304ba22432ff3 100644 (file)
      "m" (string-encode-integer (inexact->exact (round (* 1000 magnify))))
      (if (not coding-command) "" (string-append "e" coding-command)))))
 
-(define (define-fonts paper font-list)
-  
+(define (define-fonts bookpaper)
+
+  (define font-list (ly:bookpaper-fonts bookpaper))
   (define (define-font command fontname scaling)
     (string-append
      "/" command " { /" fontname " findfont "
      (else (string-append basename ".pfa"))
      ))
 
-  (define (font-load-command paper font)
+  (define (font-load-command font)
     (let* ((specced-font-name (ly:font-name font))
           (fontname (if specced-font-name
                         specced-font-name
           (plain (font-command font #f))
           (designsize (ly:font-design-size font))
           (magnification (* (ly:font-magnification font)))
-          (ops (ly:output-def-lookup paper 'outputscale))
+          (ops (ly:output-def-lookup bookpaper 'outputscale))
           (scaling (* ops magnification designsize)))
 
       (string-append
     (string-append
      (apply string-append (map font-load-encoding encodings))
      (apply string-append
-           (map (lambda (x) (font-load-command paper x)) font-list)))))
+           (map (lambda (x) (font-load-command x)) font-list)))))
 
 (define (define-origin file line col) "")
 
    ;; FIXME: duplicated in every backend
    (ps-string-def
     "lilypond" 'tagline
-    (string-append "Engraved by LilyPond (version " (lilypond-version) ")"))))
+    (string-append "Engraved by LilyPond (version " (lilypond-version) ")"))
+   ))
 
 (define (header-end)
-  (string-append
-   (ly:gulp-file "lilyponddefs.ps")
-   (ly:gulp-file "music-drawing-routines.ps")))
+  "")
 
 ;; WTF is this in every backend?
 (define (horizontal-line x1 x2 th)
   (let ((prefix "lilypond"))
 
     ;; FIXME: duplicates output-paper's scope-entry->string, mostly
-    (define (scope-entry->string key var)
-      (if (variable-bound? var)
-         (let ((val (variable-ref var)))
-           (if (and (memq key fields) (string? val))
-               (header-to-file basename key val))
-           (cond
-            ((string? val) (ps-string-def prefix key val))
-            ((number? val) (ps-number-def prefix key val))
-            (else "")))
-         ""))
-    
-    (define (output-scope scope)
-      (apply string-append (module-map scope-entry->string scope)))
+    (define (value->string  val)
+      (cond
+       ((string? val) (string-append "(" val ")"))
+       ((symbol? val) (symbol->string val))
+       ((number? val) (number->string val))
+       (else "")))
+      
+    (define (output-entry ps-key ly-key)
+      (string-append
+       "/" ps-key " " (value->string (ly:output-def-lookup paper ly-key)) " def \n"))
 
-    (string-append (apply string-append (map output-scope scopes)))))
+    
+    (string-append
+     "/lily-output-units 2.83464  def  %% milimeter \n"
+     "% /lily-output-units 0.996264  def  %% true points.\n"
+     (output-entry "staff-line-thickness" 'linethickness)
+     (output-entry "line-width" 'linewidth)
+     (output-entry "paper-size" 'papersize)
+     (output-entry "staff-height" 'staffheight)        ;junkme.
+     "/output-scale "
+     (number->string (ly:output-def-lookup paper 'outputscale))
+     " lily-output-units mul def \n"
+     
+     (ly:gulp-file "music-drawing-routines.ps")
+     (ly:gulp-file "lilyponddefs.ps")
+
+    )))
+  
 
 (define (placebox x y s) 
   (string-append