2 hyphen-engraver.cc -- implement Hyphen_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2005 Glen Prideaux <glenprideaux@iname.com>,
7 Han-Wen Nienhuys <hanwen@cs.uu.nl>,
8 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "engraver.hh"
16 class Hyphen_engraver : public Engraver
20 Spanner *finished_hyphen_;
22 TRANSLATOR_DECLARATIONS (Hyphen_engraver);
25 virtual void acknowledge_grob (Grob_info);
26 virtual void finalize ();
27 virtual bool try_music (Music *);
28 virtual void stop_translation_timestep ();
29 virtual void process_music ();
33 Hyphen_engraver::Hyphen_engraver ()
41 Hyphen_engraver::acknowledge_grob (Grob_info i)
43 Item *item = dynamic_cast<Item *> (i.grob ());
45 if (item && item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
48 hyphen_->set_bound (LEFT, item);
51 finished_hyphen_->set_bound (RIGHT, item);
56 Hyphen_engraver::try_music (Music *r)
66 completize_hyphen (Spanner *sp)
68 if (!sp->get_bound (RIGHT))
70 SCM heads = sp->get_property ("heads");
71 if (scm_is_pair (heads))
73 Item *it = dynamic_cast<Item *> (unsmob_grob (scm_car (heads)));
75 sp->set_bound (RIGHT, it);
81 Hyphen_engraver::finalize ()
85 completize_hyphen (hyphen_);
87 if (!hyphen_->get_bound (RIGHT))
89 hyphen_->warning (_ ("removing unterminated hyphen"));
98 completize_hyphen (finished_hyphen_);
100 if (!finished_hyphen_->get_bound (RIGHT))
102 finished_hyphen_->warning (_ ("unterminated hyphen; removing"));
103 finished_hyphen_->suicide ();
105 finished_hyphen_ = 0;
110 Hyphen_engraver::process_music ()
114 hyphen_ = make_spanner ("LyricHyphen", ev_->self_scm ());
119 Hyphen_engraver::stop_translation_timestep ()
121 if (finished_hyphen_ && finished_hyphen_->get_bound (RIGHT))
123 finished_hyphen_ = 0;
126 if (finished_hyphen_ && hyphen_)
128 programming_error ("hyphen not finished yet");
129 finished_hyphen_ = 0;
133 finished_hyphen_ = hyphen_;
139 ADD_TRANSLATOR (Hyphen_engraver,
140 /* descr */ "Create lyric hyphens",
141 /* creats*/ "LyricHyphen",
142 /* accepts */ "hyphen-event",
143 /* acks */ "lyric-syllable-interface",