2 repeat-acknowledge-engraver.cc -- implement Repeat_acknowledge_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2007 Han-Wen Nienhuys <hanwen@xs4all.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 void start_translation_timestep ();
33 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 ()
51 Context
*tr
= context ()->where_defined (ly_symbol2scm ("repeatCommands"), &rc
);
55 tr
->set_property ("repeatCommands", SCM_EOL
);
59 Repeat_acknowledge_engraver::process_music ()
62 At the start of a piece, we don't print any repeat bars.
64 if (!now_mom ().main_part_
)
67 SCM cs
= get_property ("repeatCommands");
72 bool volta_found
= false;
73 while (scm_is_pair (cs
))
75 SCM command
= scm_car (cs
);
76 if (command
== ly_symbol2scm ("start-repeat"))
78 else if (command
== ly_symbol2scm ("end-repeat"))
80 else if (scm_is_pair (command
) && scm_car (command
) == ly_symbol2scm ("volta"))
93 TODO: line breaks might be allowed if we set whichBar to "".
97 We only set the barline if we wouldn't overwrite a previously set
100 SCM wb
= get_property ("whichBar");
101 SCM db
= get_property ("defaultBarType");
102 if (!scm_is_string (wb
) || ly_is_equal (db
, wb
))
104 if (s
!= "" || (volta_found
&& !scm_is_string (wb
)))
105 context ()->set_property ("whichBar", ly_string2scm (s
));
109 ADD_TRANSLATOR (Repeat_acknowledge_engraver
,
110 /* doc */ "Acknowledge repeated music, and convert the contents of "
111 "repeatCommands ainto an appropriate setting for whichBar.",
113 /* read */ "repeatCommands whichBar",