* lily/paper-book.cc: Fold hearders, score and texts into scores_.
* lily/parser.yy: Handle toplevel and book texts as score.
* scm/page-layout.scm (default-page-make-stencil):
Bugfix: (page-properties rename.
+2005-03-09 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * lily/book.cc:
+ * lily/paper-book.cc: Fold hearders, score and texts into scores_.
+
+ * lily/parser.yy: Handle toplevel and book texts as score.
+
+ * scm/page-layout.scm (default-page-make-stencil):
+ Bugfix: (page-properties rename.
+
+ * scm/backend-library.scm (ly:system): Typo.
+
2005-03-09 Han-Wen Nienhuys <hanwen@xs4all.nl>
* lily/font-select.cc (get_font_by_design_size): revert
\header {
- texidoc = "Markup texts are set beneath a score."
+ texidoc = "Markup texts are rendered above or below a score."
}
\paper {
linewidth = #110
}
+\markup {
+ \fill-line { "High up above" }
+}
<<
\relative {
\clef bass
if (ly_c_module_p (header))
book->header_ = header;
-
- for (SCM s = scores; scm_is_pair (s); s = scm_cdr (s))
- {
- Score *score = unsmob_score (scm_car (s));
- if (score)
- book->scores_.push (score);
- }
-
+
+ book->scores_ = scm_append (scm_list_2 (scores, book->scores_));
+
SCM x = book->self_scm ();
scm_gc_unprotect_object (x);
return x;
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include "book.hh"
#include <cstdio>
-#include "book.hh"
#include "lilypond-key.hh"
#include "global-context.hh"
#include "main.hh"
#include "paper-book.hh"
#include "score.hh"
#include "stencil.hh"
+#include "text-item.hh"
#include "warn.hh"
#include "ly-smobs.icc"
{
paper_ = 0;
header_ = SCM_EOL;
- assert (!scores_.size ());
+ scores_ = SCM_EOL;
smobify_self ();
}
Book::mark_smob (SCM s)
{
Book *book = (Book*) SCM_CELL_WORD_1 (s);
- int score_count = book->scores_.size ();
- for (int i = 0; i < score_count; i++)
- scm_gc_mark (book->scores_[i]->self_scm ());
#if 0
if (book->key_)
scm_gc_mark (book->key_->self_scm());
#endif
+
if (book->paper_)
scm_gc_mark (book->paper_->self_scm ());
+ scm_gc_mark (book->scores_);
+
return book->header_;
}
return 1;
}
+void
+Book::add_score (SCM s)
+{
+ scores_ = scm_cons (s, scores_);
+}
+
/* This function does not dump the output; outname is required eg. for
dumping header fields. */
Paper_book *
Book::process (String outname, Output_def *default_def)
{
- bool error = false;
- for (int i = 0; i < scores_.size(); i++)
- error = error || scores_[i]->error_found_;
-
- if (error)
- return 0;
+ for (SCM s = scores_; s != SCM_EOL; s = scm_cdr (s))
+ if (Score *score = unsmob_score (scm_car (s)))
+ if (score->error_found_)
+ return 0;
Paper_book *paper_book = new Paper_book ();
Real scale = scm_to_double (paper_->c_variable ("outputscale"));
Output_def * scaled_bookdef = scale_output_def (paper_, scale);
-
Object_key * key = new Lilypond_general_key (0, user_key_, 0);
SCM scm_key = key->self_scm();
scm_gc_unprotect_object (scm_key);
scm_gc_unprotect_object (scaled_bookdef->self_scm());
paper_book->header_ = header_;
- int score_count = scores_.size ();
- for (int i = 0; i < score_count; i++)
+
+ /* Render in order of parsing. */
+ for (SCM s = scm_reverse (scores_); s != SCM_EOL; s = scm_cdr (s))
{
- SCM systems = scores_[i]->book_rendering (outname,
- paper_book->paper_,
- default_def,
- key
- );
-
- /*
- If the score is empty, generate no output. Should we
- do titling?
- */
- if (SCM_NFALSEP(scm_vector_p (systems)))
+ if (Score *score = unsmob_score (scm_car (s)))
{
- Score_systems sc;
- sc.systems_ = systems;
- sc.header_ = scores_[i]->header_;
- sc.texts_ = scores_[i]->texts_;
- paper_book->score_systems_.push (sc);
+ SCM systems = score
+ ->book_rendering (outname, paper_book->paper_, default_def, key);
+
+ /* If the score is empty, generate no output. Should we do
+ titling? */
+ if (scm_is_vector (systems))
+ {
+ if (ly_c_module_p (header_))
+ paper_book->add_score (header_);
+ paper_book->add_score (systems);
+ }
}
+ else if (Text_interface::markup_p (scm_car (s)))
+ paper_book->add_score (scm_car (s));
+ else
+ assert (0);
}
-
scm_remember_upto_here_1 (scm_key);
return paper_book;
}
-
-
-
-
-void
-Book::add_score (Score *s)
-{
- scores_.push (s);
- scm_gc_unprotect_object (s->self_scm ());
-}
-/*
-accidental-interface.hh -- declare Accidental_interface
-
-source file of the GNU LilyPond music typesetter
-
-(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+/*
+ accidental-interface.hh -- declare Accidental_interface
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#ifndef ACCIDENTAL_INTERFACE_HH
#define ACCIDENTAL_INTERFACE_HH
class Book : public Input
{
DECLARE_SMOBS (Book, foo);
+
public:
String user_key_;
-
SCM header_;
Output_def *paper_;
+ SCM scores_;
- void add_score (Score*);
- Link_array<Score> scores_;
Book ();
- void set_keys ();
+ void add_score (SCM);
Paper_book* process (String, Output_def*);
+ void set_keys ();
};
+
DECLARE_UNSMOB (Book, book);
#endif /* BOOK_HH */
Music *make_music_by_name (SCM sym);
SCM ly_music_deep_copy (SCM);
-SCM ly_music_scorify (SCM, SCM, SCM);
#endif /* MUSIC_HH */
class Output_def;
class Stencil;
-struct Score_systems
-{
- SCM systems_;
- SCM header_;
- SCM texts_;
+/** Paper_book collects headers, systems (Paper_system) and texts, and
+ exports them to the output backend, either as systems or as
+ completely formatted pages. */
- Score_systems () ;
- void gc_mark ();
-};
-
-/*
-
-This class is rather empty. It collects systems (Paper_system), and
-exports them to the output backend, either as systems or as completely
-formatted pages.
-
-*/
class Paper_book
{
DECLARE_SMOBS (Paper_book, );
SCM systems_;
SCM pages_;
+
public:
SCM header_;
- Array<Score_systems> score_systems_;
+ SCM scores_;
Output_def *paper_;
Paper_book ();
+ void add_score (SCM);
SCM systems ();
SCM pages ();
Stencil book_title ();
- Stencil score_title (int);
+ Stencil score_title (SCM);
void classic_output (String);
void output (String);
void post_processing (SCM, SCM);
DECLARE_UNSMOB (Paper_book, paper_book)
#endif /* PAPER_BOOK_HH */
-
DECLARE_SMOBS (Score, foo);
SCM music_;
+
public:
String user_key_;
Link_array<Output_def> defs_;
SCM texts_;
bool error_found_;
- SCM get_music () const;
- void set_music (SCM music, SCM parser);
Score ();
Score (Score const&);
-
+
+ SCM get_music () const;
+ void set_music (SCM music, SCM parser);
SCM book_rendering (String, Output_def*, Output_def*, Object_key*);
};
DECLARE_UNSMOB (Score, score);
-SCM ly_run_translator (SCM, SCM, SCM);
+void default_rendering (SCM, SCM, SCM, SCM, SCM, SCM);
+SCM ly_music_scorify (SCM, SCM);
SCM ly_render_output (SCM, SCM);
-void default_rendering (SCM, SCM, SCM, SCM, SCM, SCM, SCM);
+SCM ly_run_translator (SCM, SCM, SCM);
#endif /* SCORE_HH */
1, 0, 0, (SCM what),
"Deprecated.")
{
+ (void) what;
warning ("ly:set-point-and-click called");
return SCM_UNSPECIFIED;
}
SCM paper = get_paper (parser)->self_scm ();
for (int i = 0; i < score->defs_.size (); i++)
default_rendering (score->get_music (), score->defs_[i]->self_scm (),
- paper, header, score->texts_,
- os, key->self_scm ());
+ paper, header, os, key->self_scm ());
if (score->defs_.is_empty ())
{
Output_def *layout = get_layout (parser);
default_rendering (score->get_music(), layout->self_scm (),
get_paper (parser)->self_scm (),
- header, score->texts_,
- os, key->self_scm ());
+ header, os, key->self_scm ());
scm_gc_unprotect_object (layout->self_scm ());
}
Paper_book::Paper_book ()
{
+ header_ = SCM_EOL;
pages_ = SCM_BOOL_F;
+ scores_ = SCM_EOL;
systems_ = SCM_BOOL_F;
- header_ = SCM_EOL;
paper_ = 0;
smobify_self ();
Paper_book::mark_smob (SCM smob)
{
Paper_book *b = (Paper_book*) SCM_CELL_WORD_1 (smob);
- for (int i = 0; i < b->score_systems_.size (); i++)
- b->score_systems_[i].gc_mark ();
-
if (b->paper_)
scm_gc_mark (b->paper_->self_scm ());
scm_gc_mark (b->header_);
scm_gc_mark (b->pages_);
+ scm_gc_mark (b->scores_);
return b->systems_;
}
return fields;
}
+void
+Paper_book::add_score (SCM s)
+{
+ scores_ = scm_cons (s, scores_);
+}
+
void
Paper_book::output (String outname)
{
- if (!score_systems_.size ())
+ if (scores_ == SCM_EOL)
return;
/* Generate all stencils to trigger font loads. */
if (ly_c_module_p (header_))
scopes = scm_cons (header_, scopes);
- if (ly_c_module_p (score_systems_[0].header_))
- scopes = scm_cons (score_systems_[0].header_, scopes);
+#if 0
+ if (ly_c_module_p (scores_[0].header_))
+ scopes = scm_cons (scores_[0].header_, scopes);
+#endif
//end ugh
String format = output_backend_global;
}
Stencil
-Paper_book::score_title (int i)
+Paper_book::score_title (SCM header)
{
SCM title_func = paper_->lookup_variable (ly_symbol2scm ("score-title"));
Stencil title;
- // ugh code dup
SCM scopes = SCM_EOL;
if (ly_c_module_p (header_))
scopes = scm_cons (header_, scopes);
- if (ly_c_module_p (score_systems_[i].header_))
- scopes = scm_cons (score_systems_[i].header_, scopes);
- //end ugh
+ if (ly_c_module_p (header))
+ scopes = scm_cons (header, scopes);
SCM tit = SCM_EOL;
if (ly_c_procedure_p (title_func))
= scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"),
paper_->self_scm ());
- int score_count = score_systems_.size ();
- for (int i = 0; i < score_count; i++)
+ SCM header = SCM_EOL;
+ for (SCM s = scm_reverse (scores_); s != SCM_EOL; s = scm_cdr (s))
{
- Stencil title = score_title (i);
- if (!title.is_empty ())
+ if (ly_c_module_p (scm_car (s)))
+ header = scm_car (s);
+ else if (scm_is_vector (scm_car (s)))
{
- Paper_system *ps = new Paper_system (title, true);
- systems_ = scm_cons (ps->self_scm (), systems_);
- scm_gc_unprotect_object (ps->self_scm ());
-
- set_system_penalty (ps, score_systems_[i].header_);
-
- }
+ Stencil title = score_title (header);
+ if (!title.is_empty ())
+ {
+ Paper_system *ps = new Paper_system (title, true);
+ systems_ = scm_cons (ps->self_scm (), systems_);
+ scm_gc_unprotect_object (ps->self_scm ());
+ set_system_penalty (ps, header);
+ }
+ header = SCM_EOL;
- if (scm_vector_p (score_systems_[i].systems_) == SCM_BOOL_T)
- {
- // guh.
- SCM system_list = scm_vector_to_list (score_systems_[i].systems_);
-
+ SCM system_list = scm_vector_to_list (scm_car (s));
system_list = scm_reverse (system_list);
systems_ = scm_append (scm_list_2 (system_list, systems_));
}
-
- for (SCM s = score_systems_[i].texts_; s != SCM_EOL; s = scm_cdr (s))
+ else if (Text_interface::markup_p (scm_car (s)))
{
SCM t = Text_interface::interpret_markup (paper_->self_scm (),
page_properties,
systems_ = scm_cons (ps->self_scm (), systems_);
scm_gc_unprotect_object (ps->self_scm ());
// FIXME: figure out penalty.
- //set_system_penalty (ps, score_systems_[i].header_);
+ //set_system_penalty (ps, scores_[i].header_);
}
+ else
+ assert (0);
}
systems_ = scm_reverse (systems_);
pages_ = scm_apply_0 (proc, scm_list_2 (systems (), self_scm ()));
return pages_;
}
-
-
-/****************************************************************/
-
-Score_systems::Score_systems ()
-{
- systems_ = SCM_EOL;
- header_ = SCM_EOL;
- texts_ = SCM_EOL;
-}
-
-void
-Score_systems::gc_mark ()
-{
- scm_gc_mark (systems_);
- scm_gc_mark (header_);
- scm_gc_mark (texts_);
-}
-
%type <scm> Alternative_music
%type <scm> full_markup lyric_markup
%type <scm> markup_list markup_composed_list markup_braced_list markup_braced_list_body
-%type <scm> optional_text
%type <scm> markup_head_1_item markup_head_1_list markup simple_markup markup_top
%type <scm> mode_changing_head
%type <scm> mode_changing_head_with_context
scm_call_2 (proc, THIS->self_scm (), score->self_scm ());
scm_gc_unprotect_object (score->self_scm ());
}
- | toplevel_music optional_text {
+ | toplevel_music {
Music *music = $1;
SCM proc = THIS->lexer_->lookup_identifier ("toplevel-music-handler");
- scm_call_3 (proc, THIS->self_scm (), music->self_scm (), $2);
+ scm_call_2 (proc, THIS->self_scm (), music->self_scm ());
scm_gc_unprotect_object (music->self_scm ());
}
+ | full_markup {
+ SCM proc = THIS->lexer_->lookup_identifier ("toplevel-text-handler");
+ scm_call_2 (proc, THIS->self_scm (), $1);
+ }
| output_def {
SCM id = SCM_EOL;
Output_def * od = $1;
}
;
-optional_text:
- /* empty */ {
- $$ = SCM_EOL
- }
- | optional_text full_markup {
- $$ = ly_snoc ($2, $1);
- }
- ;
-
/*
DECLARATIONS
*/
$$->paper_ = $2;
scm_gc_unprotect_object ($2->self_scm ());
}
- | book_body score_block optional_text {
- Score *score = $2;
- score->texts_ = $3;
- $$->add_score (score);
- }
- /* let's do optional
- | book_body full_markup {
- if (!$$->scores_.size ())
- THIS->parser_error (@2, _("\\markup cannot be used before \\score."));
- Score *score = $$->scores_.top ();
- score->texts_ = ly_snoc ($2, score->texts_);
+ | book_body score_block {
+ SCM s = $2->self_scm ();
+ $$->add_score (s);
+ scm_gc_unprotect_object (s);
}
- */
| book_body lilypond_header {
$$->header_ = $2;
}
| book_body error {
$$->paper_ = 0;
- $$->scores_.clear();
+ $$->scores_ = SCM_EOL;
}
| book_body object_id_setting {
$$->user_key_ = ly_scm2string ($2);
#include "global-context.hh"
LY_DEFINE (ly_music_scorify, "ly:music-scorify",
- 3, 0, 0,
- (SCM music, SCM texts, SCM parser),
+ 2, 0, 0,
+ (SCM music, SCM parser),
"Return MUSIC with TEXTS encapsulated in SCORE.")
{
#if 0
SCM_ASSERT_TYPE (ly_c_music_p (music), music, SCM_ARG1, __FUNCTION__, "music");
#endif
Score *score = new Score;
-
score->set_music (music, parser);
- score->texts_ = texts;
-
scm_gc_unprotect_object (score->self_scm ());
return score->self_scm ();
}
Output_def *od = unsmob_output_def (layout);
if (sc->error_found_)
- {
- return SCM_EOL;
- }
+ return SCM_EOL;
SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def");
void
default_rendering (SCM music, SCM outdef,
SCM book_outputdef,
- SCM header, SCM texts,
+ SCM header,
SCM outname,
SCM key)
{
Paper_book *paper_book = new Paper_book ();
paper_book->header_ = header;
paper_book->paper_ = unsmob_output_def (scaled_bookdef);
-
- Score_systems sc;
- sc.systems_ = systems;
- sc.header_ = header;
- sc.texts_ = texts;
-
- paper_book->score_systems_.push (sc);
-
+
+ if (ly_c_module_p (header))
+ paper_book->add_score (header);
+ paper_book->add_score (systems);
+
paper_book->classic_output (ly_scm2string (outname));
scm_gc_unprotect_object (paper_book->self_scm ());
}
#(define toplevel-book-handler ly:parser-print-book)
#(define toplevel-music-handler collect-music-for-book)
#(define toplevel-score-handler collect-scores-for-book)
+#(define toplevel-text-handler collect-scores-for-book)
#(if (pair? toplevel-scores)
(ly:parser-print-book parser
- (apply ly:make-book $defaultpaper $globalheader (reverse toplevel-scores))))
+ (apply ly:make-book $defaultpaper $globalheader toplevel-scores)))
parser 'toplevel-scores
(cons score (ly:parser-lookup parser 'toplevel-scores))))
-(define-public (collect-music-for-book parser music texts)
- (collect-scores-for-book parser (ly:music-scorify music texts parser)))
-
+(define-public (collect-music-for-book parser music)
+ (collect-scores-for-book parser (ly:music-scorify music parser)))
;;;;;;;;;;;;;;;;
(system-separator-markup (ly:output-def-lookup layout 'systemSeparatorMarkup))
(system-separator-stencil (if (markup? system-separator-markup)
(interpret-markup layout
- (page-properties layout)
+ (layout-extract-page-properties layout)
system-separator-markup)
#f))
(lmargin (ly:output-def-lookup layout 'leftmargin))
%%%% Options: [%(option_string)s]
#(set! toplevel-score-handler ly:parser-print-score)
-#(set! toplevel-music-handler (lambda (p m t)
+#(set! toplevel-music-handler (lambda (p m)
(ly:parser-print-score
- p (ly:music-scorify m t p))))
+ p (ly:music-scorify m p))))
#(define version-seen? #t)
%(preamble_string)s