]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3644: A \score-lines markup list command for multi-lines embedded scores
authorDavid Kastrup <dak@gnu.org>
Sun, 3 Nov 2013 07:54:21 +0000 (08:54 +0100)
committerDavid Kastrup <dak@gnu.org>
Wed, 13 Nov 2013 10:53:40 +0000 (11:53 +0100)
Originally requested as issue 1334.

Like the \score markup, \score-lines is not called through the normal
markup list command mechanisms as it would require something awkward
along the lines of

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

to get this through.  Instead, a reserved word \score-lines in the
parser will manually call the command with an embedded score, leading
to just

\score-lines { ... }

This is somewhat clumsy in several ways: it requires an additional
reserved identifier (no other reserved identifier contains a dash),
and it means that a score may occur in a file without an explicit
enclosing \score command.

Nevertheless, the previous semantics implemented as issue 1334 were
not tenable: particularly after issue 3270 had been passed, it was
close to impossible for the average user to come up with a way of
getting an actual markup list from a score.

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.

input/regression/score-lines.ly [new file with mode: 0644]
lily/lexer.ll
lily/parser.yy
scm/define-markup-commands.scm

diff --git a/input/regression/score-lines.ly b/input/regression/score-lines.ly
new file mode 100644 (file)
index 0000000..edb300f
--- /dev/null
@@ -0,0 +1,40 @@
+\version "2.19.0"
+
+\header {
+  texidoc = "The @code{\\score-lines} markup returns individual score
+lines as stencils rather than a single stencil.  Calling a function 
+like @code{\\rotate} on @code{\\score-lines} rotates the lines
+individually, as contrasted with rotating an entire @code{\\score}
+markup."
+}
+
+\markup \fill-line {
+  \null
+  \column \rotate #-15 {
+    \score-lines
+    {
+      \new Staff \with { instrumentName = \markup \typewriter
+                        "\\score-lines" }
+      \repeat unfold 16 c'4
+      \layout {
+       short-indent = 0
+       indent = 0
+       line-width = 4\cm
+      }
+    }
+  }
+  \column \rotate #-15 {
+    \score
+    {
+      \new Staff \with { instrumentName = \markup \typewriter
+                        "\\score" }
+      \repeat unfold 16 c'4
+      \layout {
+       short-indent = 0
+       indent = 0
+       line-width = 4\cm
+      }
+    }
+  }
+  \null
+}
index 285de24267d372d2ca7498a9c5bcf96f0006d003..68000182bd1bfe8071b88cc47d05fae93f7c7009 100644 (file)
@@ -673,6 +673,10 @@ BOM_UTF8   \357\273\277
                 yylval = SCM_UNSPECIFIED;
                return SCORE;
        }
+       \\score-lines {
+               yylval = SCM_UNSPECIFIED;
+               return SCORELINES;
+       }
        \\\"    {
                start_command_quote ();
        }
index ab09f537b2a8693f413c4121d9dcb82e13916d12..b3c3fe9145ec469b254445b660597bf43956fd94 100644 (file)
@@ -269,6 +269,7 @@ int yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser);
 %token REST "\\rest"
 %token REVERT "\\revert"
 %token SCORE "\\score"
+%token SCORELINES "\\score-lines"
 %token SEQUENTIAL "\\sequential"
 %token SET "\\set"
 %token SIMULTANEOUS "\\simultaneous"
@@ -3355,7 +3356,7 @@ full_markup:
        ;
 
 markup_top:
-       simple_markup_list {
+       markup_list {
                $$ = scm_list_2 (ly_lily_module_constant ("line-markup"),  $1);
        }
        | markup_head_1_list simple_markup
@@ -3383,7 +3384,7 @@ markup_scm:
        ;
                        
 
-simple_markup_list:
+markup_list:
        markup_composed_list {
                $$ = $1;
        }
@@ -3401,22 +3402,11 @@ markup_uncomposed_list:
        {
                $$ = $2;
        }
-       ;
-
-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 {
+       | SCORELINES {
                SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
                parser->lexer_->push_note_state (nn);
        } '{' score_body '}' {
-               $$ = $4;
+               $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $4));
                parser->lexer_->pop_state ();
        }
        ;
@@ -3439,7 +3429,7 @@ markup_braced_list_body:
        | markup_braced_list_body markup {
                $$ = scm_cons ($2, $1);
        }
-       | markup_braced_list_body simple_markup_list {
+       | markup_braced_list_body markup_list {
                $$ = scm_reverse_x ($2, $1);
        }
        ;
@@ -3488,6 +3478,13 @@ 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));
        }
@@ -3495,10 +3492,6 @@ simple_markup:
        {
                $$ = $2;
        }
-       | markup_score
-       {
-               $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $1);
-       }
        ;
 
 markup:
index 9e5528f5bb2a7eafa0d7eb1d6de990463245f650..ee2671a963f13ca7ea8c8c428ed5fde192324d37 100644 (file)
@@ -1014,13 +1014,9 @@ samplePath =
 
 (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."
+  "This is the same as the @code{\\score} markup but delivers its
+systems as a list of lines.  Its @var{score} argument is entered in
+braces like it would be for @code{\\score}."
   (let ((output (ly:score-embedded-format score layout)))
 
     (if (ly:music-output? output)