]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/hyphen-engraver.cc
lilypond-manuals.css: edit color scheme and some spacing
[lilypond.git] / lily / hyphen-engraver.cc
index 24b8665e80d111ffd9d401af5e474d083ddfceef..20d2a7c9380d3d4cd13fbb8cbae1d2a9f98ab916 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1999--2010 Glen Prideaux <glenprideaux@iname.com>,
+  Copyright (C) 1999--2015 Glen Prideaux <glenprideaux@iname.com>,
   Han-Wen Nienhuys <hanwen@xs4all.nl>,
   Jan Nieuwenhuizen <janneke@gnu.org>
 
@@ -36,15 +36,14 @@ class Hyphen_engraver : public Engraver
 
   Spanner *hyphen_;
   Spanner *finished_hyphen_;
-  bool current_lyric_is_skip_;
 
 public:
   TRANSLATOR_DECLARATIONS (Hyphen_engraver);
 
 protected:
 
-  DECLARE_ACKNOWLEDGER (lyric_syllable);
-  DECLARE_TRANSLATOR_LISTENER (hyphen);
+  void acknowledge_lyric_syllable (Grob_info);
+  void listen_hyphen (Stream_event *);
 
   virtual void finalize ();
 
@@ -52,9 +51,9 @@ protected:
   void process_music ();
 };
 
-Hyphen_engraver::Hyphen_engraver ()
+Hyphen_engraver::Hyphen_engraver (Context *c)
+  : Engraver (c)
 {
-  current_lyric_is_skip_ = false;
   hyphen_ = 0;
   finished_hyphen_ = 0;
   finished_ev_ = 0;
@@ -65,20 +64,17 @@ void
 Hyphen_engraver::acknowledge_lyric_syllable (Grob_info i)
 {
   Item *item = i.item ();
-  SCM text = item->get_property ("text");
-  current_lyric_is_skip_ = ly_is_equal (text, scm_from_locale_string (" "));
-  
-  if (!hyphen_ && !current_lyric_is_skip_)
+
+  if (!hyphen_)
     hyphen_ = make_spanner ("LyricSpace", item->self_scm ());
 
   if (hyphen_)
     hyphen_->set_bound (LEFT, item);
-      
-  if (finished_hyphen_ && !current_lyric_is_skip_)
+
+  if (finished_hyphen_)
     finished_hyphen_->set_bound (RIGHT, item);
 }
 
-IMPLEMENT_TRANSLATOR_LISTENER (Hyphen_engraver, hyphen);
 void
 Hyphen_engraver::listen_hyphen (Stream_event *ev)
 {
@@ -92,7 +88,7 @@ completize_hyphen (Spanner *sp)
     {
       extract_item_set (sp, "heads", heads);
       if (heads.size ())
-       sp->set_bound (RIGHT, heads.back ());
+        sp->set_bound (RIGHT, heads.back ());
     }
 }
 
@@ -104,10 +100,10 @@ Hyphen_engraver::finalize ()
       completize_hyphen (hyphen_);
 
       if (!hyphen_->get_bound (RIGHT))
-       {
-         hyphen_->warning (_ ("removing unterminated hyphen"));
-         hyphen_->suicide ();
-       }
+        {
+          hyphen_->warning (_ ("removing unterminated hyphen"));
+          hyphen_->suicide ();
+        }
 
       hyphen_ = 0;
     }
@@ -117,11 +113,11 @@ Hyphen_engraver::finalize ()
       completize_hyphen (finished_hyphen_);
 
       if (!finished_hyphen_->get_bound (RIGHT))
-       {
-         if (finished_ev_)
-           finished_hyphen_->warning (_ ("unterminated hyphen; removing"));
-         finished_hyphen_->suicide ();
-       }
+        {
+          if (finished_ev_)
+            finished_hyphen_->warning (_ ("unterminated hyphen; removing"));
+          finished_hyphen_->suicide ();
+        }
       finished_hyphen_ = 0;
     }
 }
@@ -141,8 +137,8 @@ Hyphen_engraver::stop_translation_timestep ()
       finished_hyphen_ = 0;
       finished_ev_ = 0;
     }
-  
-  if (finished_hyphen_ && hyphen_ && !current_lyric_is_skip_)
+
+  if (finished_hyphen_ && hyphen_)
     {
       programming_error ("hyphen not finished yet");
       finished_hyphen_ = 0;
@@ -154,24 +150,30 @@ Hyphen_engraver::stop_translation_timestep ()
       finished_hyphen_ = hyphen_;
       finished_ev_ = ev_;
     }
-  
+
   hyphen_ = 0;
   ev_ = 0;
 }
 
-ADD_ACKNOWLEDGER (Hyphen_engraver, lyric_syllable);
+
+void
+Hyphen_engraver::boot ()
+{
+  ADD_LISTENER (Hyphen_engraver, hyphen);
+  ADD_ACKNOWLEDGER (Hyphen_engraver, lyric_syllable);
+}
 
 ADD_TRANSLATOR (Hyphen_engraver,
-               /* doc */
-               "Create lyric hyphens and distance constraints between words.",
+                /* doc */
+                "Create lyric hyphens and distance constraints between words.",
 
-               /* create */
-               "LyricHyphen "
-               "LyricSpace ",
+                /* create */
+                "LyricHyphen "
+                "LyricSpace ",
 
-               /* read */
-               "",
+                /* read */
+                "",
 
-               /* write */
-               ""
-               );
+                /* write */
+                ""
+               );