2 repeat-acknowledge-engraver.cc -- implement Repeat_acknowledge_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "translator-group.hh"
12 #include "repeated-music.hh"
14 #include "translator.icc"
19 -- set and reset repeatCommands, so Unfolded_repeat_iterator knows
20 where to set variables.
22 -- collect information passed by Unfolded_repeat_iterator for
23 Bar_engraver: writes whichBar property. (TODO: check for
24 interactions with timing engraver.)
26 class Repeat_acknowledge_engraver : public Engraver
30 TRANSLATOR_DECLARATIONS (Repeat_acknowledge_engraver);
32 PRECOMPUTED_VIRTUAL void start_translation_timestep ();
33 PRECOMPUTED_VIRTUAL void process_music ();
34 virtual void initialize ();
38 Repeat_acknowledge_engraver::initialize ()
40 context ()->set_property ("repeatCommands", SCM_EOL);
43 Repeat_acknowledge_engraver::Repeat_acknowledge_engraver ()
48 Repeat_acknowledge_engraver::start_translation_timestep ()
50 Context *tr = context ()->where_defined (ly_symbol2scm ("repeatCommands"));
54 tr->set_property ("repeatCommands", SCM_EOL);
58 Repeat_acknowledge_engraver::process_music ()
61 At the start of a piece, we don't print any repeat bars.
63 if (!now_mom ().main_part_)
66 SCM cs = get_property ("repeatCommands");
71 bool volta_found = false;
72 while (scm_is_pair (cs))
74 SCM command = scm_car (cs);
75 if (command == ly_symbol2scm ("start-repeat"))
77 else if (command == ly_symbol2scm ("end-repeat"))
79 else if (scm_is_pair (command) && scm_car (command) == ly_symbol2scm ("volta"))
92 TODO: line breaks might be allowed if we set whichBar to "".
96 We only set the barline if we wouldn't overwrite a previously set
99 SCM wb = get_property ("whichBar");
100 SCM db = get_property ("defaultBarType");
101 if (!scm_is_string (wb) || ly_is_equal (db, wb))
103 if (s != "" || (volta_found && !scm_is_string (wb)))
105 context ()->set_property ("whichBar", scm_makfrom0str (s.to_str0 ()));
111 ADD_TRANSLATOR (Repeat_acknowledge_engraver,
112 /* descr */ "Acknowledge repeated music, and convert the contents of "
113 "repeatCommands ainto an appropriate setting for whichBar.",
117 /* reads */ "repeatCommands whichBar",