]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 1334: A \score-lines markup list command for multi-lines embedded scores
authorDavid Kastrup <dak@gnu.org>
Sun, 3 Mar 2013 11:24:32 +0000 (12:24 +0100)
committerDavid Kastrup <dak@gnu.org>
Fri, 8 Mar 2013 17:28:38 +0000 (18:28 +0100)
Like the \score markup, this is not usually called by users directly
as it would require something awkward along the lines of

\score-lines ##{ \score { ... } #}

to get this through.  Instead, using \score in contexts where only
markup lists are allowed will pass the action to the \score-lines
markup list command.

Note that there are as of yet no user-level commands spacing a markup
list in a way similar to the spacing inside of a \score markup.

lily/parser.yy
scm/define-markup-commands.scm

index 3f4faf5d7c06ceadc599fade3b9a08355ed3ee16..478d05377540e10033d55fb569792645d35e3612 100644 (file)
@@ -3236,7 +3236,7 @@ full_markup:
        ;
 
 markup_top:
-       markup_list {
+       simple_markup_list {
                $$ = scm_list_2 (ly_lily_module_constant ("line-markup"),  $1);
        }
        | markup_head_1_list simple_markup      {
@@ -3262,7 +3262,7 @@ markup_scm:
        ;
                        
 
-markup_list:
+simple_markup_list:
        markup_composed_list {
                $$ = $1;
        }
@@ -3278,6 +3278,24 @@ markup_list:
        }
        ;
 
+markup_list:
+       simple_markup_list
+       | markup_score
+       {
+               $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $1));
+       }
+       ;
+
+markup_score:
+       SCORE {
+               SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
+               parser->lexer_->push_note_state (nn);
+       } '{' score_body '}' {
+               $$ = $4;
+               parser->lexer_->pop_state ();
+       }
+       ;
+
 markup_composed_list:
        markup_head_1_list markup_braced_list {
                $$ = scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, $2);
@@ -3296,7 +3314,7 @@ markup_braced_list_body:
        | markup_braced_list_body markup {
                $$ = scm_cons ($2, $1);
        }
-       | markup_braced_list_body markup_list {
+       | markup_braced_list_body simple_markup_list {
                $$ = scm_reverse_x ($2, $1);
        }
        ;
@@ -3345,13 +3363,6 @@ simple_markup:
        STRING {
                $$ = make_simple_markup ($1);
        }
-       | SCORE {
-               SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
-               parser->lexer_->push_note_state (nn);
-       } '{' score_body '}' {
-               $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $4);
-               parser->lexer_->pop_state ();
-       }
        | MARKUP_FUNCTION markup_command_basic_arguments {
                $$ = scm_cons ($1, scm_reverse_x ($2, SCM_EOL));
        }
@@ -3359,6 +3370,10 @@ simple_markup:
        {
                $$ = $2;
        }
+       | markup_score
+       {
+               $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $1);
+       }
        ;
 
 markup:
index d3ad150ff64a1e645bf20c52abd376f04bb3976a..251415d85b522a9cdaa7d78647be249c7290ebc4 100755 (executable)
@@ -961,6 +961,31 @@ samplePath =
       X-extent
       Y-extent)))
 
+(define-markup-list-command (score-lines layout props score)
+  (ly:score?)
+  "
+This is the same as the @code{\\score} markup but delivers its
+systems as a list of lines.  This is not usually called directly by
+the user.  Instead, it is called when the parser encounters
+@code{\\score} in a context where only markup lists are allowed.  When
+used as the argument of a toplevel @code{\\markuplist}, the result can
+be split across pages."
+  (let ((output (ly:score-embedded-format score layout)))
+
+    (if (ly:music-output? output)
+        (map
+         (lambda (paper-system)
+           ;; shift such that the refpoint of the bottom staff of
+           ;; the first system is the baseline of the score
+           (ly:stencil-translate-axis
+            (paper-system-stencil paper-system)
+            (- (car (paper-system-staff-extents paper-system)))
+            Y))
+         (vector->list (ly:paper-score-paper-systems output)))
+       (begin
+         (ly:warning (_"no systems found in \\score markup, does it have a \\layout block?"))
+          '()))))
+
 (define-markup-command (score layout props score)
   (ly:score?)
   #:category music
@@ -1013,24 +1038,8 @@ baseline.
   }
 }
 @end lilypond"
-  (let ((output (ly:score-embedded-format score layout)))
-
-    (if (ly:music-output? output)
-        (let ((paper-systems
-               (vector->list
-                (ly:paper-score-paper-systems output))))
-          (if (pair? paper-systems)
-              ;; shift such that the refpoint of the bottom staff of
-              ;; the first system is the baseline of the score
-              (ly:stencil-translate-axis
-               (stack-stencils Y DOWN baseline-skip
-                               (map paper-system-stencil paper-systems))
-               (- (car (paper-system-staff-extents (car paper-systems))))
-               Y)
-              empty-stencil))
-       (begin
-         (ly:warning (_"no systems found in \\score markup, does it have a \\layout block?"))
-         empty-stencil))))
+  (stack-stencils Y DOWN baseline-skip
+                  (score-lines-markup-list layout props score)))
 
 (define-markup-command (null layout props)
   ()