2 repeat-acknowledge-engraver.cc -- implement Repeat_acknowledge_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
11 #include "translator-group.hh"
13 #include "repeated-music.hh"
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.)
27 class Repeat_acknowledge_engraver : public Engraver
31 TRANSLATOR_DECLARATIONS (Repeat_acknowledge_engraver);
33 virtual void start_translation_timestep ();
34 virtual void process_music ();
35 virtual void initialize ();
40 Repeat_acknowledge_engraver::initialize ()
42 context ()->set_property ("repeatCommands", SCM_EOL);
46 Repeat_acknowledge_engraver::Repeat_acknowledge_engraver ()
51 Repeat_acknowledge_engraver::start_translation_timestep ()
53 Context * tr = context ()->where_defined (ly_symbol2scm ("repeatCommands"));
57 tr->set_property ("repeatCommands", SCM_EOL);
61 Repeat_acknowledge_engraver::process_music ()
64 At the start of a piece, we don't print any repeat bars.
66 if (!now_mom ().main_part_)
69 SCM cs = get_property ("repeatCommands");
74 bool volta_found = false;
75 while (scm_is_pair (cs))
77 SCM command = scm_car (cs);
78 if (command == ly_symbol2scm ("start-repeat"))
80 else if (command == ly_symbol2scm ("end-repeat"))
82 else if (scm_is_pair (command) && scm_car (command) == ly_symbol2scm ("volta"))
95 TODO: line breaks might be allowed if we set whichBar to "".
99 We only set the barline if we wouldn't overwrite a previously set
102 SCM wb = get_property ("whichBar");
103 SCM db = get_property ("defaultBarType");
104 if (!scm_is_string (wb) || ly_c_equal_p (db, wb))
106 if (s != "" || (volta_found && !scm_is_string (wb)))
108 context ()->set_property ("whichBar", scm_makfrom0str (s.to_str0 ()));
113 ENTER_DESCRIPTION (Repeat_acknowledge_engraver,
114 /* descr */ "Acknowledge repeated music, and convert the contents of "
115 "repeatCommands ainto an appropriate setting for whichBar.",
119 /* reads */ "repeatCommands whichBar",