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
30 TRANSLATOR_DECLARATIONS (Repeat_acknowledge_engraver);
32 virtual void start_translation_timestep ();
33 virtual void process_music ();
34 virtual void initialize ();
39 Repeat_acknowledge_engraver::initialize ()
41 get_parent_context ()->set_property ("repeatCommands", SCM_EOL);
45 Repeat_acknowledge_engraver::Repeat_acknowledge_engraver ()
50 Repeat_acknowledge_engraver::start_translation_timestep ()
52 Context * tr = get_parent_context ()->where_defined (ly_symbol2scm ("repeatCommands"));
54 tr = get_parent_context ();
56 tr->set_property ("repeatCommands", SCM_EOL);
60 Repeat_acknowledge_engraver::process_music ()
63 At the start of a piece, we don't print any repeat bars.
65 if (now_mom () == Moment (0))
68 SCM cs = get_property ("repeatCommands");
73 bool volta_found = false;
74 while (ly_c_pair_p (cs))
76 SCM command = ly_car (cs);
77 if (command == ly_symbol2scm ("start-repeat"))
79 else if (command == ly_symbol2scm ("end-repeat"))
81 else if (ly_c_pair_p (command) && ly_car (command) == ly_symbol2scm ("volta"))
94 TODO: line breaks might be allowed if we set whichBar to "".
98 We only set the barline if we wouldn't overwrite a previously set
101 SCM wb = get_property ("whichBar");
102 SCM db = get_property ("defaultBarType");
103 if (!ly_c_string_p (wb) || ly_c_equal_p (db, wb))
105 if (s != "" || (volta_found && !ly_c_string_p (wb)))
107 get_parent_context ()->set_property ("whichBar", scm_makfrom0str (s.to_str0 ()));
112 ENTER_DESCRIPTION (Repeat_acknowledge_engraver,
113 /* descr */ "Acknowledge repeated music, and convert the contents of "
114 "repeatCommands ainto an appropriate setting for whichBar.",
118 /* reads */ "repeatCommands whichBar",