[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Defining a function that passes contents between braces to a markup
From: |
Mojca Miklavec |
Subject: |
Re: Defining a function that passes contents between braces to a markup |
Date: |
Tue, 19 Jul 2016 13:03:13 +0200 |
Dear David,
On 16 July 2016 at 09:31, David Kastrup wrote:
> Mojca Miklavec writes:
>>
>> I've learnt some basics of scheme and managed to write some simple
>> functions, but I'm unable to figure out how to write a function that
>> would take all the contents between braces as an argument and return a
>> markup.
>>
>> I would be grateful even if I get just the simplified version working, so
>> that
>>
>> \A {<foo>}
>>
>> would be translated into
>>
>> \markup { \small \override #'(direction . 1) { \dir-column { <foo> } } }
>
> Well, first thing to note is that scheme/music functions do not switch
> modes for their arguments. So you either need to write something like
>
> \A \markup <foo>
>
> here to get something in markup mode, or be in lyrics mode (which
> interprets <foo> as lyrics), \A should be a markup command and are
> already in markup mode, like \markup \A <foo> .
>
>> I would use this markup as part of the lyrics as in
>>
>> \lyricsto "melody" {
>> \A {foo bar}
>> \A {three short lines}
>> \A {one}
>> }
>
> Ah, we are in lyrics mode already. That simplifies things. Your
> arguments will then be of type ly:music? and you'll pick off the
> respective markup from the 'text field of the lyrics.
I'm no more confused than I was before :(
How could I simplify the input in attachment?
>> In a slightly more advanced version it would be nice to be able to type
>>
>> \lyricsto "melody" {
>> % \command { array of values }
>> % each entry can have an optional "-<number>"
>> \A {A1-1}
>> \A {A1-1 C2-2}
>> \A {A1-1 C2-2 E2-3}
>> \A {C2 E2-3}
>> \A {E2}
>> }
>
> Lyrics mode does not really take text scripts I think. All of A1-1 will
> likely end up one lyrics syllable.
>
>> So far I came up with a function definition
>>
>> M = #(define-scheme-function (parser location aFinger aButton) (markup?
>> markup?)
>> #{ \markup{ \small \bold \with-color #(rgb-color 0.5 0 0) #aFinger
>> \small \with-color #(rgb-color 0 0 0.5) #aButton } #}
>> )
>> that can handle input like
>> \M "1" "A1"
>> and then I would enter multiple lines of lyrics, but this is tedious
>> to write, even more so when the number of lines varies from one pitch
>> to the other.
>
> Strings are the most simple form of markup, but I guess that pretty much
> everything else needs to be explicitly preceded by \markup. You could
> work here with an optional finger argument as a number:
>
> M =
> #(define-scheme-function (parser location aFinger aButton) ((number?) markup?)
> (if afinger
> #{ \markup{ \small \bold \with-color #(rgb-color 0.5 0 0) #aFinger
> \small \with-color #(rgb-color 0 0 0.5) #aButton } #}
> ;; #{ \markup whatever you want here when no finger is given #}
> ))
>
> which can handle then both
> \M 1 "A1"
> as well as
> \M "A1"
This doesn't seem to work properly. The number is always treated as
the second argument (markup). See the attachment.
Thank you,
Mojca
function-to-type-multiline-markup-above-scores.ly
Description: Binary data