2004-04-27 Jan Nieuwenhuizen <janneke@gnu.org>
+ * lily/paper-book.cc (pages): Change signature. Update callers.
+
+ * lily/include/page.hh:
+ * lily/page.cc: New file.
+
+ * lily/paper-line.cc (to_stencil): New method.
+
* lily/paper-outputter.cc (output_stencil): New method.
+ * lily/paper-outputter.cc (output_line): Use them.
+
+ * lily/warn.cc: Remove.
+
* lily/my-lily-parser.cc (distill_inname): Remove.
* flower/include/file-name.hh:
- * flower/file-name.cc: New file. Change users.
+ * flower/file-name.cc: New file. Update users.
* flower/file-path.cc [CYGWIN]: Junk testing code. Remove Path.
(find): New method of same name.
+ * lily/my-lily-parser.cc (ly:parse-file): Use it.
+
* lily/scm-option.cc (ly:set-option, ly:get-option): Bugfix:
constant error message.
#include <typeinfo>
-#define classname(class_ptr) demangle_classname (typeid (* (class_ptr)))
+#define classname(class_ptr) demangle_classname (typeid (*(class_ptr)))
const char *
demangle_classname (std::type_info const &);
(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef WARN_HH
#define WARN_HH
#include "string.hh"
-void programming_error (String s);
-void warning (String message_string);
void error (String message_string);
+void message (String s);
void non_fatal_error (String);
-#endif // WARN_HH
+void programming_error (String s);
+void warning (String message_string);
+
+#define progress_indication message
+
+#endif /* WARN_HH */
#include "warn.hh"
-
void
message (String s)
{
/*
- balloon.cc -- implement Balloon objects
- */
+ balloon.cc -- implement Balloon
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#include "text-item.hh"
#include "grob.hh"
#include "paper-def.hh"
#include "misc.hh"
-struct Balloon_interface
+class Balloon_interface
{
-
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
static bool has_interface (Grob*);
SCM
Balloon_interface::print (SCM smob)
{
- Grob *me= unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
SCM cb = me->get_property ("balloon-original-callback");
- SCM scm_mol = SCM_EOL;
+ SCM stil = SCM_EOL;
if (ly_c_procedure_p (cb))
- {
- scm_mol = scm_call_1 (cb, smob);
- }
+ stil = scm_call_1 (cb, smob);
- if (!unsmob_stencil (scm_mol))
- return scm_mol;
+ if (!unsmob_stencil (stil))
+ return stil;
SCM scm_off = me->get_property ("balloon-text-offset");
if (!is_number_pair (scm_off))
- return scm_mol;
+ return stil;
Offset off = ly_scm2offset (scm_off);
- Stencil * m = unsmob_stencil (scm_mol);
- Box orig_extent = m->extent_box ();
+ Stencil *s = unsmob_stencil (stil);
+ Box orig_extent = s->extent_box ();
Box box_extent = orig_extent;
- Real w = robust_scm2double (me->get_property ("balloon-padding"), .1);
+ Real w = robust_scm2double (me->get_property ("balloon-padding"), .1);
box_extent.widen (w, w);
-
-
+
+ // FIXME
Stencil fr = Lookup::frame (box_extent, 0.1, 0.05);
+ fr.add_stencil (*s);
- fr.add_stencil (*m);
-
-
-
SCM bt = me->get_property ("balloon-text");
SCM chain = Font_interface::text_font_alist_chain (me);
chain = scm_cons (me->get_property ("balloon-text-props"), chain);
+ SCM text = Text_item::interpret_markup (me->get_paper ()->self_scm (),
+ chain, bt);
- SCM text = Text_item::interpret_markup (me->get_paper ()->self_scm (), chain, bt);
-
-
- Stencil *text_mol = unsmob_stencil (text);
-
+ Stencil *text_stil = unsmob_stencil (text);
+
Offset z1;
-
for (int i = X_AXIS; i < NO_AXES; i++)
{
- Axis a ((Axis)i);
+ Axis a ((Axis)i);
z1[a] = box_extent [a].linear_combination (sign (off[a]));
- text_mol->align_to (a, -sign (off[a]));
+ text_stil->align_to (a, -sign (off[a]));
}
Offset z2 = z1 + off;
-
+
fr.add_stencil (Line_interface::line (me, z1, z2));
- text_mol->translate (z2);
- fr.add_stencil (*text_mol);
-
+ text_stil->translate (z2);
+ fr.add_stencil (*text_stil);
+
fr = Stencil (orig_extent, fr.get_expr ());
return fr.smobbed_copy ();
}
extern String init_name_global;
-/* FIXME: in warn.cc */
-void progress_indication (String);
-
/* options */
extern Array<String> dump_header_fieldnames_global;
extern bool no_paper_global_b;
--- /dev/null
+/*
+ page.hh -- declare Page
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+#ifndef PAGE_HH
+#define PAGE_HH
+
+#include "lily-proto.hh"
+#include "smobs.hh"
+
+/* WIP -- moving toward flexible stencil based output. */
+class Page
+{
+ DECLARE_SMOBS (Page, );
+
+public:
+ static int page_count_;
+ Paper_def *paper_;
+ int number_;
+ int line_count_;
+ SCM lines_;
+ SCM header_;
+ SCM footer_;
+ SCM copyright_;
+ SCM tagline_;
+
+ /* actual height filled with text. */
+ Real height_;
+
+ // HMMM all this size stuff to paper/paper-outputter?
+ Real hsize_;
+ Real vsize_;
+ Real left_margin_;
+ Real top_margin_;
+ Real bottom_margin_;
+ Real foot_sep_;
+ Real head_sep_;
+ Real text_width_;
+
+ /* available area for text. */
+ Real text_height ();
+
+ Page (Paper_def*, int);
+ void output (Paper_outputter*, bool);
+};
+
+DECLARE_UNSMOB (Page, page);
+
+#endif /* PAGE_HH */
class Paper_book
{
- DECLARE_SMOBS (Paper_book, )
+ DECLARE_SMOBS (Paper_book, );
-public:
- Array<SCM> headers_;
- Array<SCM> global_headers_;
- Link_array<Paper_def> papers_;
- Array<SCM> scores_;
Real height_;
SCM copyright_;
SCM tagline_;
+public:
+ Array<SCM> scores_;
+ Array<SCM> headers_;
+ Array<SCM> global_headers_;
+ Link_array<Paper_def> papers_;
+
Paper_book ();
- void init ();
- Link_array<Page> *pages ();
+
SCM lines ();
+ SCM pages ();
SCM scopes (int);
- Stencil* title (int);
- void output (String);
+ Stencil *title (int);
void classic_output (String);
+ void init ();
+ void output (String);
};
DECLARE_UNSMOB (Paper_book, paper_book)
int penalty_;
public:
+ int number_;
+
Paper_line (Offset, SCM, int penalty = 0, bool = false);
- int number_;
Offset dim () const;
+ SCM to_stencil () const;
SCM stencils () const;
bool is_title () const;
int penalty () const;
char const *extensions[] = {"ly", "", 0};
String file_name = global_path.find (file, extensions);
- /* By default, use base name of input file for output file name */
+ /* By default, use base name of input file for output file name,
+ 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;
-
- /* By default, write output to cwd; do not copy directory part
- of input file name */
out_file_name.root_ = "";
out_file_name.dir_ = "";
-
+
if (!output_name_global.is_empty ())
out_file_name = File_name (output_name_global);
init = init_name_global;
else
init = "init.ly";
-
+
String out_file = out_file_name.to_string ();
if (init.length () && global_path.find (init).is_empty ())
{
warning (_f ("can't find init file: `%s'", init));
- warning (_f ("(search path: `%s')", global_path.to_string ().to_str0 ()));
+ warning (_f ("(search path: `%s')",
+ global_path.to_string ().to_str0 ()));
exit (2);
}
--- /dev/null
+/*
+ page.cc -- implement Page
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "ly-module.hh"
+#include "page.hh"
+#include "paper-def.hh"
+#include "paper-outputter.hh"
+#include "paper-line.hh"
+#include "stencil.hh"
+#include "warn.hh"
+
+// JUNKME
+SCM
+stencil2line (Stencil* stil, bool is_title = false)
+{
+ static SCM z;
+ if (!z)
+ z = scm_permanent_object (ly_offset2scm (Offset (0, 0)));
+ Offset dim = Offset (stil->extent (X_AXIS).length (),
+ stil->extent (Y_AXIS).length ());
+ Paper_line *pl = new Paper_line (dim, scm_cons (stil->smobbed_copy (),
+ SCM_EOL),
+ -10001 * is_title, is_title);
+
+ return scm_gc_unprotect_object (pl->self_scm ());
+}
+
+static Real const MIN_COVERAGE = 0.66;
+
+int Page::page_count_ = 0;
+
+Page::Page (Paper_def *paper, int number)
+{
+ paper_ = paper;
+ number_ = number;
+
+ copyright_ = SCM_EOL;
+ footer_ = SCM_EOL;
+ header_ = SCM_EOL;
+ lines_ = SCM_EOL;
+ tagline_ = SCM_EOL;
+
+ height_ = 0;
+ line_count_ = 0;
+
+ page_count_++;
+
+ hsize_ = paper->get_dimension (ly_symbol2scm ("hsize"));
+ vsize_ = paper->get_dimension (ly_symbol2scm ("vsize"));
+ top_margin_ = paper->get_dimension (ly_symbol2scm ("top-margin"));
+ bottom_margin_ = paper->get_dimension (ly_symbol2scm ("bottom-margin"));
+ head_sep_ = paper->get_dimension (ly_symbol2scm ("head-sep"));
+ foot_sep_ = paper->get_dimension (ly_symbol2scm ("foot-sep"));
+ text_width_ = paper->get_dimension (ly_symbol2scm ("linewidth"));
+ left_margin_ = (hsize_ - text_width_) / 2;
+
+ SCM make_header = ly_scheme_function ("make-header");
+ SCM make_footer = ly_scheme_function ("make-footer");
+
+ header_ = scm_call_2 (make_header, paper_->self_scm (),
+ scm_int2num (number_));
+ if (unsmob_stencil (header_))
+ unsmob_stencil (header_)->align_to (Y_AXIS, UP);
+
+ footer_ = scm_call_2 (make_footer, paper_->self_scm (),
+ scm_int2num (number_));
+ if (unsmob_stencil (footer_))
+ unsmob_stencil (footer_)->align_to (Y_AXIS, UP);
+
+ smobify_self ();
+}
+
+Page::~Page ()
+{
+}
+
+#include "ly-smobs.icc"
+
+IMPLEMENT_DEFAULT_EQUAL_P (Page)
+IMPLEMENT_SMOBS (Page)
+IMPLEMENT_TYPE_P (Page, "ly:page?")
+
+SCM
+Page::mark_smob (SCM smob)
+{
+ Page *p = (Page*) SCM_CELL_WORD_1 (smob);
+ scm_gc_mark (p->lines_);
+ scm_gc_mark (p->header_);
+ scm_gc_mark (p->footer_);
+ scm_gc_mark (p->copyright_);
+ scm_gc_mark (p->tagline_);
+ return p->lines_;
+}
+
+int
+Page::print_smob (SCM smob, SCM port, scm_print_state*)
+{
+ Page *p = (Page*) ly_cdr (smob);
+
+ scm_puts ("#<", port);
+ scm_puts (classname (p), port);
+ scm_puts (to_string (p->number_).to_str0 (), port);
+ scm_puts (" ", port);
+ scm_puts (">", port);
+ return 1;
+}
+
+void
+Page::output (Paper_outputter *out, bool is_last)
+{
+ progress_indication ("[" + to_string (number_));
+ out->output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
+ Offset o (left_margin_, top_margin_);
+ Real vfill = line_count_ > 1 ? (text_height () - height_) / (line_count_ - 1)
+ : 0;
+
+ Real coverage = height_ / text_height ();
+ if (coverage < MIN_COVERAGE)
+ /* Do not space out a badly filled page. This is too simplistic
+ (ie broken), because this should not vary too much between
+ (subsequent?) pages in a book. */
+ vfill = 0;
+
+ if (unsmob_stencil (header_))
+ {
+ out->output_line (stencil2line (unsmob_stencil (header_)), &o, false);
+ o[Y_AXIS] += head_sep_;
+ }
+ for (SCM s = lines_; s != SCM_EOL; s = ly_cdr (s))
+ {
+ SCM line = ly_car (s);
+ out->output_line (line, &o,
+ is_last && ly_cdr (s) != SCM_EOL && !unsmob_stencil (copyright_)
+ && !unsmob_stencil (tagline_) && !unsmob_stencil (footer_));
+
+ /* Do not put vfill between title and its music, */
+ if (scm_pair_p (ly_cdr (s))
+ && (!unsmob_paper_line (line)->is_title () || vfill < 0))
+ o[Y_AXIS] += vfill;
+ /* rather put extra just before the title. */
+ if (ly_cdr (s) != SCM_EOL
+ && (unsmob_paper_line (ly_cadr (s))->is_title () && vfill > 0))
+ o[Y_AXIS] += vfill;
+ }
+
+ o[Y_AXIS] = vsize_ - bottom_margin_;
+ if (unsmob_stencil (copyright_))
+ o[Y_AXIS] -= unsmob_stencil (copyright_)->extent (Y_AXIS).length ();
+ if (unsmob_stencil (tagline_))
+ o[Y_AXIS] -= unsmob_stencil (tagline_)->extent (Y_AXIS).length ();
+ if (unsmob_stencil (footer_))
+ o[Y_AXIS] -= unsmob_stencil (footer_)->extent (Y_AXIS).length ();
+
+ if (unsmob_stencil (copyright_))
+ out->output_line (stencil2line (unsmob_stencil (copyright_)), &o,
+ is_last && !unsmob_stencil (tagline_) && !unsmob_stencil (footer_));
+ if (unsmob_stencil (tagline_))
+ out->output_line (stencil2line (unsmob_stencil (tagline_)), &o,
+ is_last && !unsmob_stencil (footer_));
+ if (unsmob_stencil (footer_))
+ out->output_line (stencil2line (unsmob_stencil (footer_)), &o, is_last);
+ out->output_scheme (scm_list_2 (ly_symbol2scm ("stop-page"),
+ ly_bool2scm (is_last && !unsmob_stencil (footer_))));
+ progress_indication ("]");
+}
+
+Real
+Page::text_height ()
+{
+ Real h = vsize_ - top_margin_ - bottom_margin_;
+ if (unsmob_stencil (header_))
+ h -= unsmob_stencil (header_)->extent (Y_AXIS).length () + head_sep_;
+ if (unsmob_stencil (copyright_) || unsmob_stencil (tagline_) || unsmob_stencil (footer_))
+ h -= foot_sep_;
+ if (unsmob_stencil (copyright_))
+ h -= unsmob_stencil (copyright_)->extent (Y_AXIS).length ();
+ if (unsmob_stencil (tagline_))
+ h -= unsmob_stencil (tagline_)->extent (Y_AXIS).length ();
+ if (unsmob_stencil (footer_))
+ h -= unsmob_stencil (footer_)->extent (Y_AXIS).length ();
+ return h;
+}
(c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-#include <stdio.h>
-#include <math.h>
-
#include "ly-module.hh"
#include "main.hh"
+#include "page.hh"
#include "paper-book.hh"
#include "paper-def.hh"
#include "paper-outputter.hh"
#include "paper-line.hh"
#include "paper-score.hh"
#include "stencil.hh"
+#include "warn.hh"
-static Real const MIN_COVERAGE = 0.66;
-
-static SCM
-stencil2line (Stencil* stil, bool is_title = false)
-{
- static SCM z;
- if (!z)
- z = scm_permanent_object (ly_offset2scm (Offset (0, 0)));
- Offset dim = Offset (stil->extent (X_AXIS).length (),
- stil->extent (Y_AXIS).length ());
- Paper_line *pl = new Paper_line (dim, scm_cons (stil->smobbed_copy (),
- SCM_EOL),
- -10001 * is_title, is_title);
-
- return scm_gc_unprotect_object (pl->self_scm ());
-}
-
-/* Simplistic page interface */
-class Page
-{
-public:
- Paper_def *paper_;
- static int page_count_;
- int number_;
- int line_count_;
-
- Protected_scm lines_;
- Protected_scm header_;
- Protected_scm footer_;
- Protected_scm copyright_;
- Protected_scm tagline_;
-
- Stencil *get_header () { return unsmob_stencil (header_); }
- Stencil *get_copyright () { return unsmob_stencil (copyright_); }
- Stencil *get_tagline () { return unsmob_stencil (tagline_); }
- Stencil *get_footer () { return unsmob_stencil (footer_); }
-
- /* actual height filled with text. */
- Real height_;
-
- // HMMM all this size stuff to paper/paper-outputter?
- Real hsize_;
- Real vsize_;
- Real left_margin_;
- Real top_margin_;
- Real bottom_margin_;
- Real foot_sep_;
- Real head_sep_;
- Real text_width_;
-
- /* available area for text. */
- Real text_height ();
-
- Page (Paper_def*, int);
- void output (Paper_outputter*, bool);
-};
-
-int Page::page_count_ = 0;
-
-Page::Page (Paper_def *paper, int number)
-{
- paper_ = paper;
- number_ = number;
- page_count_++;
-
- height_ = 0;
- lines_ = SCM_EOL;
- line_count_ = 0;
-
- hsize_ = paper->get_dimension (ly_symbol2scm ("hsize"));
- vsize_ = paper->get_dimension (ly_symbol2scm ("vsize"));
- top_margin_ = paper->get_dimension (ly_symbol2scm ("top-margin"));
- bottom_margin_ = paper->get_dimension (ly_symbol2scm ("bottom-margin"));
- head_sep_ = paper->get_dimension (ly_symbol2scm ("head-sep"));
- foot_sep_ = paper->get_dimension (ly_symbol2scm ("foot-sep"));
- text_width_ = paper->get_dimension (ly_symbol2scm ("linewidth"));
- left_margin_ = (hsize_ - text_width_) / 2;
-
- copyright_ = SCM_EOL;
- tagline_ = SCM_EOL;
-
- SCM make_header = ly_scheme_function ("make-header");
- SCM make_footer = ly_scheme_function ("make-footer");
-
- header_ = scm_call_2 (make_header, paper_->self_scm (),
- scm_int2num (number_));
- if (get_header ())
- get_header ()->align_to (Y_AXIS, UP);
-
- footer_ = scm_call_2 (make_footer, paper_->self_scm (),
- scm_int2num (number_));
- if (get_footer ())
- get_footer ()->align_to (Y_AXIS, UP);
-}
-
-void
-Page::output (Paper_outputter *out, bool is_last)
-{
- progress_indication ("[" + to_string (number_));
- out->output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
- Offset o (left_margin_, top_margin_);
- Real vfill = line_count_ > 1 ? (text_height () - height_) / (line_count_ - 1)
- : 0;
-
- Real coverage = height_ / text_height ();
- if (coverage < MIN_COVERAGE)
- /* Do not space out a badly filled page. This is too simplistic
- (ie broken), because this should not vary too much between
- (subsequent?) pages in a book. */
- vfill = 0;
-
- if (get_header ())
- {
- out->output_line (stencil2line (get_header ()), &o, false);
- o[Y_AXIS] += head_sep_;
- }
- for (SCM s = lines_; s != SCM_EOL; s = ly_cdr (s))
- {
- SCM line = ly_car (s);
- out->output_line (line, &o,
- is_last && ly_cdr (s) != SCM_EOL && !get_copyright ()
- && !get_tagline () && !get_footer ());
-
- /* Do not put vfill between title and its music, */
- if (scm_pair_p (ly_cdr (s))
- && (!unsmob_paper_line (line)->is_title () || vfill < 0))
- o[Y_AXIS] += vfill;
- /* rather put extra just before the title. */
- if (ly_cdr (s) != SCM_EOL
- && (unsmob_paper_line (ly_cadr (s))->is_title () && vfill > 0))
- o[Y_AXIS] += vfill;
- }
-
- o[Y_AXIS] = vsize_ - bottom_margin_;
- if (get_copyright ())
- o[Y_AXIS] -= get_copyright ()->extent (Y_AXIS).length ();
- if (get_tagline ())
- o[Y_AXIS] -= get_tagline ()->extent (Y_AXIS).length ();
- if (get_footer ())
- o[Y_AXIS] -= get_footer ()->extent (Y_AXIS).length ();
-
- if (get_copyright ())
- out->output_line (stencil2line (get_copyright ()), &o,
- is_last && !get_tagline () && !get_footer ());
- if (get_tagline ())
- out->output_line (stencil2line (get_tagline ()), &o,
- is_last && !get_footer ());
- if (get_footer ())
- out->output_line (stencil2line (get_footer ()), &o, is_last);
- out->output_scheme (scm_list_2 (ly_symbol2scm ("stop-page"),
- ly_bool2scm (is_last && !get_footer ())));
- progress_indication ("]");
-}
-
-Real
-Page::text_height ()
-{
- Real h = vsize_ - top_margin_ - bottom_margin_;
- if (get_header ())
- h -= get_header ()->extent (Y_AXIS).length () + head_sep_;
- if (get_copyright () || get_tagline () || get_footer ())
- h -= foot_sep_;
- if (get_copyright ())
- h -= get_copyright ()->extent (Y_AXIS).length ();
- if (get_tagline ())
- h -= get_tagline ()->extent (Y_AXIS).length ();
- if (get_footer ())
- h -= get_footer ()->extent (Y_AXIS).length ();
- return h;
-}
-
-/****************************************************************/
+// JUNKME.
+extern SCM stencil2line (Stencil* stil, bool is_title = false);
Paper_book::Paper_book ()
{
SCM
Paper_book::mark_smob (SCM smob)
{
- Paper_book *pb = (Paper_book*) SCM_CELL_WORD_1 (smob);
- for (int i = 0; i < pb->headers_.size (); i++)
- scm_gc_mark (pb->headers_[i]);
- for (int i = 0; i < pb->global_headers_.size (); i++)
- scm_gc_mark (pb->global_headers_[i]);
- for (int i = 0; i < pb->papers_.size (); i++)
- scm_gc_mark (pb->papers_[i]->self_scm ());
- for (int i = 0; i < pb->scores_.size (); i++)
- scm_gc_mark (pb->scores_[i]);
-
- scm_gc_mark (pb->copyright_);
+ Paper_book *b = (Paper_book*) SCM_CELL_WORD_1 (smob);
+ for (int i = 0; i < b->headers_.size (); i++)
+ scm_gc_mark (b->headers_[i]);
+ for (int i = 0; i < b->global_headers_.size (); i++)
+ scm_gc_mark (b->global_headers_[i]);
+ for (int i = 0; i < b->papers_.size (); i++)
+ scm_gc_mark (b->papers_[i]->self_scm ());
+ for (int i = 0; i < b->scores_.size (); i++)
+ scm_gc_mark (b->scores_[i]);
+
+ scm_gc_mark (b->copyright_);
- return pb->tagline_;
+ return b->tagline_;
}
int
return;
/* Generate all stencils to trigger font loads. */
- Link_array<Page> *pages = this->pages ();
+ SCM pages = this->pages ();
Paper_def *paper = papers_[0];
Paper_outputter *out = paper->get_paper_outputter (outname);
- out->output_header (paper, scopes (0), pages->size (), false);
+ int page_count = scm_ilength (pages);
+ out->output_header (paper, scopes (0), page_count, false);
- int page_count = pages->size ();
- for (int i = 0; i < page_count; i++)
- (*pages)[i]->output (out, i + 1 == page_count);
+ for (SCM s = pages; ly_c_pair_p (s); s = ly_cdr (s))
+ unsmob_page (ly_car (s))->output (out, ly_c_pair_p (ly_cdr (s)));
out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
- /* Ugh. */
- for (int i = pages->size (); i--;)
- delete pages->elem (i);
- delete pages;
-
progress_indication ("\n");
}
int line_count = SCM_VECTOR_LENGTH ((SCM) scores_.top ());
for (int i = 0; i < line_count; i++)
{
- /*
- In classic compatibility TeX tracks how large things are, and
- advances the Y pos for us. If we advance it too, we get too
- much space.
- */
+ /* In classic compatibility TeX tracks how large things are, and
+ advances the Y pos for us. If we advance it too, we get too
+ much space.
+
+ FIXME: vague... why is TeX is different from other ouput
+ backends, why not fix the TeX backend? -- jcn */
if (output_format_global == "tex")
- o = Offset (0,0);
+ o = Offset (0, 0);
-
- out->output_line (scm_vector_ref ((SCM) scores_.top (),
- scm_int2num (i)),
- &o, i == line_count - 1);
+ out->output_line (scm_vector_ref ((SCM) scores_.top (), scm_int2num (i)),
+ &o, i == line_count - 1);
}
out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
progress_indication ("\n");
}
-
/* calculate book height, #lines, stencils. */
void
Paper_book::init ()
return lines;
}
-Link_array<Page>*
+SCM
Paper_book::pages ()
{
init ();
if (unsmob_stencil (copyright_))
page->copyright_ = copyright_;
- Link_array<Page> *pages = new Link_array<Page>;
+ SCM pages = SCM_EOL;
int page_count = SCM_VECTOR_LENGTH ((SCM) breaks);
int line = 1;
for (int i = 0; i < page_count; i++)
all = ly_cdr (all);
line++;
}
- pages->push (page);
+ pages = scm_cons (page->self_scm (), pages);
}
/* Tagline on last page. */
if (unsmob_stencil (tagline_))
page->tagline_ = tagline_;
- return pages;
+ return scm_reverse (pages);
}
static SCM
*/
#include "paper-line.hh"
-#include "ly-smobs.icc"
-#include "string.hh" // to_string
+#include "stencil.hh"
+#include "string.hh"
+#include "virtual-methods.hh"
#define TITLE_PENALTY -1
{
}
+#include "ly-smobs.icc"
IMPLEMENT_SMOBS (Paper_line);
IMPLEMENT_TYPE_P (Paper_line, "ly:paper-line?");
IMPLEMENT_DEFAULT_EQUAL_P (Paper_line);
SCM
-Paper_line::mark_smob (SCM s)
+Paper_line::mark_smob (SCM smob)
{
- Paper_line *line = (Paper_line*) ly_cdr (s);
+ Paper_line *line = (Paper_line*) ly_cdr (smob);
return line->stencils_;
}
int
-Paper_line::print_smob (SCM s, SCM port, scm_print_state*)
+Paper_line::print_smob (SCM smob, SCM port, scm_print_state*)
{
- scm_puts ("#<Paper_line ", port);
- Paper_line *line = (Paper_line*) ly_cdr (s);
- scm_puts (to_string (line->number_).to_str0 (), port);
- if (line->is_title ())
+ Paper_line *p = (Paper_line*) ly_cdr (smob);
+ scm_puts ("#<", port);
+ scm_puts (classname (p), port);
+ scm_puts (to_string (p->number_).to_str0 (), port);
+ if (p->is_title ())
scm_puts (" t", port);
scm_puts (" >", port);
return 1;
return stencils_;
}
+SCM
+Paper_line::to_stencil () const
+{
+ Stencil stencil = Stencil ();
+ for (SCM s = stencils_; ly_c_pair_p (s); s = ly_cdr (s))
+ stencil.add_stencil (*unsmob_stencil (ly_car (s)));
+ return stencil.smobbed_copy ();
+}
+
LY_DEFINE (ly_paper_line_height, "ly:paper-line-height",
1, 0, 0, (SCM line),
"Return the height of @var{line}.")
void
Paper_outputter::output_line (SCM line, Offset *origin, bool is_last)
{
- Paper_line *pl = unsmob_paper_line (line);
- Offset dim = pl->dim ();
+ Paper_line *p = unsmob_paper_line (line);
+ Offset dim = p->dim ();
if (dim[Y_AXIS] > 50 CM)
{
programming_error ("Improbable system height.");
ly_quote_scm (ly_offset2scm (*origin)),
ly_quote_scm (ly_offset2scm (dim))));
- for (SCM s = pl->stencils (); ly_c_pair_p (s); s = ly_cdr (s))
+#if 0 /* FIXME: how stupid is this wrt memory management? */
+ for (SCM s = p->stencils (); ly_c_pair_p (s); s = ly_cdr (s))
output_expr (unsmob_stencil (ly_car (s))->get_expr (), Offset (0, 0));
+#else
+ output_stencil (unsmob_stencil (p->to_stencil ()));
+#endif
output_scheme (scm_list_2 (ly_symbol2scm ("stop-system"),
ly_bool2scm (is_last)));
-
- (*origin)[Y_AXIS] += dim[Y_AXIS];
}
void
#include "ly-smobs.icc"
+Stencil::Stencil ()
+{
+ expr_ = SCM_EOL;
+ set_empty (true);
+}
-Offset
-Stencil::origin () const
+Stencil::Stencil (Box b, SCM func)
{
- return origin_;
+ expr_ = func;
+ dim_ = b;
}
-Interval
-Stencil::extent (Axis a) const
+int
+Stencil::print_smob (SCM, SCM port, scm_print_state *)
{
- return dim_[a];
+ scm_puts ("#<Stencil ", port);
+ scm_puts (" >", port);
+ return 1;
}
-Stencil::Stencil (Box b, SCM func)
+SCM
+Stencil::mark_smob (SCM smob)
{
- expr_ = func;
- dim_ = b;
+ Stencil *s = (Stencil*) ly_cdr (smob);
+ return s->expr_;
}
-Stencil::Stencil ()
+IMPLEMENT_SIMPLE_SMOBS (Stencil);
+IMPLEMENT_TYPE_P (Stencil, "ly:stencil?");
+IMPLEMENT_DEFAULT_EQUAL_P (Stencil);
+
+Interval
+Stencil::extent (Axis a) const
{
- expr_ = SCM_EOL;
- set_empty (true);
+ return dim_[a];
+}
+
+Offset
+Stencil::origin () const
+{
+ return origin_;
}
void
void
Stencil::add_stencil (Stencil const &s)
{
- expr_ = scm_list_n (ly_symbol2scm ("combine-stencil"),
- s.expr_, expr_, SCM_UNDEFINED);
+ expr_ = scm_list_3 (ly_symbol2scm ("combine-stencil"), s.expr_, expr_);
dim_.unite (s.dim_);
}
translate_axis (-i.linear_combination (x), a);
}
-/*
- TODO: unintuitive naming, you would expect *this to be moved. Kept
- API for compat with add_at_edge ().
-*/
+/* FIXME: unintuitive naming, you would expect *this to be moved.
+ Kept (keeping?) API for compat with add_at_edge (). */
Stencil
Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s, Real padding,
Real minimum) const
Real his_extent;
if (i.is_empty ())
{
- programming_error ("Stencil::move_to_edge: adding empty stencil.");
+ programming_error ("Stencil::moved_to_edge: adding empty stencil.");
his_extent = 0.0;
}
else
Stencil::add_at_edge (Axis a, Direction d, Stencil const &s, Real padding,
Real minimum)
{
- add_stencil (moved_to_edge (a,d,s,padding, minimum));
+ add_stencil (moved_to_edge (a, d, s, padding, minimum));
}
/* Hmm... maybe this is not such a good idea ; stuff can be empty,
{
return dim_;
}
-
-int
-Stencil::print_smob (SCM , SCM port, scm_print_state *)
-{
- scm_puts ("#<Stencil ", port);
- scm_puts (" >", port);
- return 1;
-}
-
-SCM
-Stencil::mark_smob (SCM s)
-{
- Stencil *r = (Stencil *) ly_cdr (s);
- return r->expr_;
-}
-
-IMPLEMENT_SIMPLE_SMOBS (Stencil);
-IMPLEMENT_TYPE_P (Stencil, "ly:stencil?");
-IMPLEMENT_DEFAULT_EQUAL_P (Stencil);