]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/text-item.cc (text_to_molecule): new function
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 18 Nov 2002 00:09:28 +0000 (00:09 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 18 Nov 2002 00:09:28 +0000 (00:09 +0000)
* scm/new-markup.scm (lambda): new file

* lily/function-documentation.cc (ly_add_function_documentation):
add proc property as well

20 files changed:
lily/chord-name-engraver.cc
lily/clef-engraver.cc
lily/custos.cc
lily/dots.cc
lily/duration.cc
lily/font-interface.cc
lily/font-metric.cc
lily/function-documentation.cc
lily/include/font-interface.hh
lily/include/lily-guile.hh
lily/include/ly-smobs.icc
lily/include/my-lily-lexer.hh
lily/include/text-item.hh
lily/lexer.ll
lily/my-lily-lexer.cc
lily/parser.yy
lily/text-item.cc
ly/spanners-init.ly
scm/lily.scm
scm/new-markup.scm [new file with mode: 0644]

index 44e3fb84244ae39d7ca3c2ed8b22dd0855607ad4..2c6d0e4faaa8268775a8bfa3b731d9801d27a483 100644 (file)
@@ -107,8 +107,8 @@ Chord_name_engraver::stop_translation_timestep ()
 }
 
 ENTER_DESCRIPTION(Chord_name_engraver,
-/* descr */       "Catch note-events, Tonic_reqs, Inversion_reqs, Bass_req
-and generate the appropriate chordname.",
+/* descr */       "Catch note-events, Tonic_reqs, Inversion_reqs, Bass_req "
+"and generate the appropriate chordname.",
 /* creats*/       "ChordName",
 /* accepts */     "note-event busy-playing-event",
 /* acks  */      "",
index c2e671216b678de4b3104d5bc691457b5b5a629f..bcdd8f3e36ccbd9057050eca2756d0da181e0ccb 100644 (file)
 #include <ctype.h>
 
 #include "translator-group.hh"
-
 #include "bar-line.hh"
 #include "staff-symbol-referencer.hh"
-
 #include "engraver.hh"
 #include "direction.hh"
 #include "side-position-interface.hh"
 #include "item.hh"
 
-
 class Clef_engraver : public  Engraver
 {
 public:
@@ -82,7 +79,6 @@ Clef_engraver::acknowledge_grob (Grob_info info)
       if (Bar_line::has_interface (info.grob_)
          && gh_string_p (get_property ("clefGlyph")))
        create_clef ();
-
     } 
 }
 
index 3b6d91cc386b37c1205be7666fbe65793ed9b353..c14597e20ca2ff5c9020f8f663411cdf473517f0 100644 (file)
@@ -109,17 +109,5 @@ Custos::brew_molecule (SCM smob)
 }
 
 ADD_INTERFACE (Custos, "custos-interface",
-  "A custos is a staff context symbol that appears at the end of a
-  staff line with monophonic musical contents (i.e. with a single
-  voice).  It anticipates the pitch of the first note of the following
-  line and thus helps the player or singer to manage line breaks
-  during performance, thus enhancing readability of a score.
-
-  Custodes were frequently used in music notation until the 16th
-  century.  There were different appearences for different notation
-  styles.  Nowadays, they have survived only in special forms of
-  musical notation such as via the editio vaticana dating back to the
-  beginning of the 20th century.
-
-[TODO: add to glossary]",
+  "Engrave custodes",
   "style adjust-if-on-staffline neutral-direction neutral-position");
index 1af6f64c4e567af574eb726ef387d29ef55b5b2d..c048131e6a655304837d3c1b8a20417873a2bdd0 100644 (file)
@@ -76,9 +76,9 @@ Dots::brew_molecule (SCM d)
 
 
 ADD_INTERFACE (Dots, "dots-interface",
-  "The dots to go with a notehead/rest.  A separate interface, since they
-are a party in collision resolution.
-#'direction is the Direction to handle staff-line collisions in.",
+  "The dots to go with a notehead/rest.  A separate interface, since they "
+" are a party in collision resolution. "
+#'direction is the Direction to handle staff-line collisions in.",
   "direction dot-count");
 
 
index bfee07eba4ca3580da758c52f089dc7613dec826..c8e604052782251c81ef34541a9717ea3f968fd0 100644 (file)
@@ -137,19 +137,19 @@ Duration::less_p (SCM p1, SCM p2)
 LY_DEFINE(make_duration,
          "ly:make-duration", 2, 2, 0, (SCM length, SCM dotcount,
                                     SCM num, SCM den),
-         "
-@var{length} is the negative logarithm (base 2) of the duration:
-1 is a half note, 2 is a quarter note, 3 is an eighth
-note, etc.  The number of dots after the note is given by
-@var{dotcount}.
-
-The duration factor is optionally given by @var{num} and @var{den}.
-
-A duration is a musical duration, i.e. a length of time described by a
-power of two (whole, half, quarter, etc.) and a number of augmentation
-dots. 
-
-")
+"        \n"
+"@var{length} is the negative logarithm (base 2) of the duration:\n"
+"1 is a half note, 2 is a quarter note, 3 is an eighth\n"
+"note, etc.  The number of dots after the note is given by\n"
+"@var{dotcount}.\n"
+"\n"
+"The duration factor is optionally given by @var{num} and @var{den}.\n"
+"\n"
+"A duration is a musical duration, i.e. a length of time described by a\n"
+"power of two (whole, half, quarter, etc.) and a number of augmentation\n"
+"dots. \n"
+"\n"
+"")
 {
   SCM_ASSERT_TYPE(gh_number_p (length), length, SCM_ARG1, __FUNCTION__, "integer");
   SCM_ASSERT_TYPE(gh_number_p (dotcount), dotcount, SCM_ARG2, __FUNCTION__, "integer");
index eb1c518a4a66a78244efdf7c7d0d7a717671b884..f8fbf0dfaf6ca81dcf0a000c0397ee8ff4d2c12c 100644 (file)
@@ -44,6 +44,21 @@ Font_interface::font_alist_chain (Grob *me)
   return ch;
 }
 
+
+MAKE_SCHEME_CALLBACK(Font_interface, get_property_alist_chain, 1);
+SCM
+Font_interface::get_property_alist_chain (SCM grob)
+{
+
+  Grob * g = unsmob_grob (grob);
+  SCM_ASSERT_TYPE(g, grob, SCM_ARG1, __FUNCTION__, "grob");
+  return  font_alist_chain (g);
+  
+}
+  
+  
+
+
 /*
   todo: split up this func, reuse in text_item? 
  */
index 20776e444a6e97c8fc980ca4e9c070b903f518ab..c3374a4b026b95ad5e86dad31117f724c44c5c68 100644 (file)
@@ -146,8 +146,8 @@ Font_metric::find_by_name (String) const
 
 LY_DEFINE(ly_find_glyph_by_name, "ly:find-glyph-by-name", 2 , 0, 0,
          (SCM font, SCM name),
-         "This function retrieves a Molecule for the glyph named @var{name} in
-@var{font}.  The font must be available as an AFM file.")
+         "This function retrieves a Molecule for the glyph named @var{name} in "
+"@var{font}.  The font must be available as an AFM file.")
 {
   Font_metric *fm = unsmob_metrics (font);
   SCM_ASSERT_TYPE(fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
@@ -159,9 +159,9 @@ LY_DEFINE(ly_find_glyph_by_name, "ly:find-glyph-by-name", 2 , 0, 0,
 
 LY_DEFINE(ly_text_dimension,"ly:text-dimension", 2 , 0, 0,
          (SCM font, SCM text),
-         "Given the font metric in @var{font} and the string @var{text}, compute
-the extents of that text in that font. The return value is a pair of
-number-pairs.")
+         "Given the font metric in @var{font} and the string @var{text}, compute "
+"the extents of that text in that font. The return value is a pair of "
+"number-pairs.")
 {
   Box b;
   Font_metric *fm = unsmob_metrics (font);
@@ -180,7 +180,6 @@ number-pairs.")
 Molecule
 Font_metric::get_char_molecule (int code)  const
 {
-  Molecule  m ;
   SCM at = scm_list_n (ly_symbol2scm ("char"), gh_int2scm (code),
                       SCM_UNDEFINED);
   at = fontify_atom (this, at);
index 73cba4aac227aa37b76641c0fb8e557347bf0f04..46dbbfe5720df38e3da4dc805feb8f4a057bbb2b 100644 (file)
@@ -1,16 +1,22 @@
 #include "lily-guile.hh"
 #include "protected-scm.hh"
+#include "string.hh"
 
 static Protected_scm doc_hash_table ;
 
-void ly_add_function_documentation (char const * fname,
+void ly_add_function_documentation (SCM func,
+                                   char const * fname,
                                    char const * varlist,
                                    char const * doc)
 {
   if (!gh_vector_p (doc_hash_table ))
     doc_hash_table = scm_make_vector (gh_int2scm (59), SCM_EOL);
 
+  String s = String (" - ") + "LilyPond procedure: " + fname + " " + varlist
+    + "\n" + doc ;
 
+  scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"),
+                               scm_makfrom0str (s.to_str0 ()));
   SCM entry = gh_cons (scm_makfrom0str (varlist), scm_makfrom0str (doc));
   scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname), entry);
 }
index 176e4c32104b1a571de4fd5cc49ef665745987b9..ada4660ce9dd2602aecd6e2da05c401db105b652 100644 (file)
@@ -21,6 +21,7 @@ struct Font_interface
   static SCM add_style (Grob*, SCM style, SCM alist_chain);
   static bool wild_compare (SCM field_val, SCM val);
   DECLARE_SCHEME_CALLBACK (properties_to_font_name, (SCM,SCM));
+  DECLARE_SCHEME_CALLBACK (get_property_alist_chain, (SCM));
   static bool has_interface (Grob*);
 };
 
index c0aed3729c52edea1efbd2925f655b7c02eb1e77..cf1fe9dfed6b477dbbc0e342a20806d2a21bea87 100644 (file)
@@ -265,7 +265,7 @@ TYPE ## _ ## FUNC ## _init_functions ()                                     \
 ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, TYPE ## _ ## FUNC ## _init_functions);      \
 
 
-void ly_add_function_documentation (char const * fname,
+void ly_add_function_documentation (SCM proc, char const * fname,
                                    char const * varlist,
                                    char const * doc);
 
@@ -286,7 +286,7 @@ INITPREFIX ## init ()\
 {\
  FNAME ## _proc \
     = scm_c_define_gsubr (PRIMNAME,REQ, OPT, VAR, (Scheme_function_unknown) FNAME);\
-  ly_add_function_documentation (PRIMNAME, #ARGLIST,  DOCSTRING);\
+  ly_add_function_documentation ( FNAME ## _proc ,PRIMNAME, #ARGLIST,  DOCSTRING);\
   scm_c_export (PRIMNAME,NULL);\
 }\
 ADD_SCM_INIT_FUNC (INITPREFIX ## init_unique_prefix, INITPREFIX ## init);\
index 7140218fef7908e4d8342554d5c0bee55cd7e5cd..24c746b6ae516902848c8855ebaac237776f2ac7 100644 (file)
@@ -15,8 +15,8 @@
 #define IMPLEMENT_TYPE_P(CL, FUNCNAME)\
 void init_type_ ## CL ()\
 {\
-  scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\
-  ly_add_function_documentation (FUNCNAME, "(SCM x)", "Check if @var{x} is a " #CL " object");\
+  SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\
+  ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", "Check if @var{x} is a " #CL " object");\
   scm_c_export (FUNCNAME, NULL);\
 }\
 ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL)
index 3cc210b9589a902615971ab847c39643ecc8e2ad..e52d22573beff6f2cc67a55d32b4a47ad01e2170 100644 (file)
@@ -72,6 +72,7 @@ public:
 private:
   int lookup_keyword (String);
   int scan_bare_word (String);
+  SCM scan_markup_word (String);
   int scan_escaped_word (String);
   int identifier_type (SCM);
   char escaped_char (char) const;
index e8479e9d748003c28d779a7825891275d8333add..70a7609d21144fb1fb94e1f1ae17101c2cbae084 100644 (file)
@@ -19,13 +19,12 @@ class Text_item
 {
 public:
   DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM));
+  DECLARE_SCHEME_CALLBACK (text_to_molecule, (SCM,SCM, SCM));
   static Molecule text2molecule (Grob *me, SCM text, SCM properties);
   static Molecule string2molecule (Grob *me, SCM text, SCM properties);
   static Molecule markup_text2molecule (Grob *me, SCM markup_text, SCM properties);
-
   static bool has_interface (Grob*);
-
-
+  
 private:
   static Molecule lookup_character (Grob *me, Font_metric*, SCM char_name);
   static Molecule lookup_text (Grob *me, Font_metric*, SCM text);
index c6e6b7a920f9b103d23aa0828fe8c87c1f016945..de7da4965861615dcf4eb7e7e8dc7dad0f0ed1d9 100644 (file)
@@ -296,6 +296,7 @@ HYPHEN              --
                return FIGURE_OPEN;
        }
 }
+
 <notes,figures>{
        {ALPHAWORD}     {
                return scan_bare_word (YYText ());
@@ -427,6 +428,9 @@ HYPHEN              --
        }
 }
 
+
+
+
 <<EOF>> {
 
 
index cc3e5df35148a2396d6a60f3b28208c06be9497d..55519c2176168a259c5309df2d758688143d6f5f 100644 (file)
@@ -224,3 +224,21 @@ My_lily_lexer::prepare_for_next_token ()
 {
   last_input_ = here_input();
 }
+
+#if 0
+SCM
+My_lily_lexer::scan_markup_word (String s)
+{
+  /*
+    TODO: better implementation:
+
+    - make a table of markup functions, for quicker lookup
+
+    - error handling.
+    
+   */
+  SCM s = scm_c_eval_str ((s + "-markup").to_str0());
+  yylval.scm = s;
+  return MARKUP_HEAD;
+}
+#endif
index bb919029b69a775cfa09fd981f6cb162627bcb91..204426ae8a441a6307bf2b71b2b313087e0e7e33 100644 (file)
@@ -2215,3 +2215,33 @@ My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
        }
        return -1;      
 }
+#if 0
+
+markup:
+       STRING {
+               $$ = scm_list_n (scm_c_eval_string ("simple-markup"), $1, SCM_UNDEFINED);
+       }
+       | MARKUP_HEAD0 markup
+       | MARKUP_HEAD1 SCM_T markup
+       | MARKUP_HEAD2 markup
+       | MARKUP_LIST_HEAD 
+       | MARKUP_LIST_HEAD 
+       | markup_list {
+               $$ = $1 
+       ;
+
+markup_list:
+       '<' markup_list_body '>' { $$ = scm_reverse_x ($1, SCM_EOL); }
+       ;
+
+markup_line:
+       '{' markup_list_body '}' { $$ = .. scm_reverse_x ($1, SCM_EOL); }
+       
+       ;
+markup_list_body:
+       /**/ {  $$ = SCM_EOL; }
+       markup_list_body markup {
+               $$ = gh_cons ($2, $1) ;
+       }
+       ;
+#endif
index c84ee7e7f0509dcf10cf5831eb4eafdde28fefa9..47a7426c27cb0e07755fa8122c1f8e3fbaee71fb 100644 (file)
@@ -59,7 +59,18 @@ Text_item::text2molecule (Grob *me, SCM text, SCM alist_chain)
     }
   return Molecule ();
 }
-            
+
+
+MAKE_SCHEME_CALLBACK(Text_item,text_to_molecule,3);
+SCM
+Text_item::text_to_molecule (SCM grob, SCM props, SCM markup)
+{
+  Grob *me = unsmob_grob (grob);
+  
+  return Text_item::text2molecule (me, markup, props).smobbed_copy();
+}
+
+
 Molecule
 Text_item::string2molecule (Grob *me, SCM text, SCM alist_chain)
 {
index 78d81ad99965a99c722b1debe8914739dcebfcb7..60ad14adeece100e2576ed57649df2dce36e4883 100644 (file)
@@ -3,6 +3,7 @@
 startCluster = #(make-span-event 'ClusterEvent START)
 stopCluster = #(make-span-event 'ClusterEvent STOP)
 
+
 groupOpen = #(make-span-event 'NoteGroupingEvent START)
 groupClose = #(make-span-event 'NoteGroupingEvent STOP)
 
index 9980da2c38293af40a25e5e9f9cafc36a6452649..51a2dd819b9a5a9cae7ac6b79c7779e20862edc1 100644 (file)
@@ -238,5 +238,6 @@ is the  first to satisfy CRIT
        "script.scm"
        "drums.scm"
        "midi.scm"
+       "new-markup.scm"
        ))
 
diff --git a/scm/new-markup.scm b/scm/new-markup.scm
new file mode 100644 (file)
index 0000000..78cbb77
--- /dev/null
@@ -0,0 +1,65 @@
+
+
+
+(define-public (simple-markup grob props . rest)
+  (Text_item::text_to_molecule grob props (car rest))
+  )
+
+(define-public (line-markup grob props . rest)
+  (stack-molecules
+   X 1 1.0 
+   (map (lambda (x) (interpret_markup grob props x)) (car rest)))
+  )
+
+(define (combine-molecule-list lst)
+  (if (null? (cdr lst)) (car lst)
+      (ly:add-molecule (car lst) (combine-molecule-list (cdr lst)))
+      ))
+
+(define-public (combine-markup grob props . rest)
+   (combine-molecule-list (map (lambda (x) (interpret_markup grob props x)) (car rest))))
+
+(define-public (bold-markup grob props . rest)
+   (interpret_markup grob (cons '((font-series .  bold)) props) (car rest))
+  )
+
+(define-public (column-markup grob props . rest)
+  (stack-molecules
+   Y -1 0.0 
+   (map (lambda (x) (interpret_markup grob props x)) (car rest)))
+  )
+
+;; todo. Use macro?  
+(map
+ (lambda (x)
+
+   (set-object-property!
+    (eval (string->symbol (string-append (symbol->string x) "-markup")) (current-module))
+    'markup-function? #t))
+
+ '(simple column bold combine line )
+ )
+
+(define-public (brew-new-markup-molecule grob)
+  (interpret_markup grob
+                   (Font_interface::get_property_alist_chain grob)
+                   (ly:get-grob-property grob 'text)
+                   )
+  )
+
+(define (interpret_markup  grob props markup)
+  (let*
+      (
+       (func (car markup))
+       (args (cdr markup))
+       )
+    
+    (apply func (cons grob (cons props args)) )
+    ))
+
+(define (new-markup? x)
+       (markup-function? (car x))
+)
+
+(define (markup-function? x)
+       (object-property 'markup-function? x))