[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Let's make TextSpanners easier to use!
From: |
Neil Puttock |
Subject: |
Re: Let's make TextSpanners easier to use! |
Date: |
Wed, 29 Oct 2008 20:29:02 +0000 |
2008/10/29 Valentin Villenave <address@hidden>:
> OK, here is a function that works much better.
>
> It works very much like Graham's recent "extra" dynamics: you can
> either have a predefined TextSpanner, either define your spanners
> on-the-fly through a music-function (but in this case you have to
> enter it *before* the starting note).
> %%%%%%%%%%%%%
> #(define (make-text-span txt)
> "Make a TextSpanner that begins with the given STR."
> (let* ((m (make-music 'TextSpanEvent
> 'span-direction -1))
> (details (cdr (assoc 'bound-details
> (cdr (assoc 'TextSpanner
> all-grob-descriptions)))))
> (left-details (cdr (assoc 'left
> details))))
> (ly:music-set-property! m 'tweaks
> (acons 'bound-details
> (acons 'left
> (acons 'text txt
> left-details)
> details)
> (ly:music-property m 'tweaks)))
> m))
Looks good. :)
As a minor refinement, you could use assoc-get instead of assoc.
> textSpan=
> #(define-music-function (location parser txt) (string?)
> (make-text-span txt))
Hmm, this isn't as elegant as make-text-span itself; you can't use markup.
It's a bit academic now, but concerning your problem with passing the
text variable in the original example, you need to use a backquote for
the bound-details, together with a comma before txt; this ensures that
the value of txt is substituted in the list, rather than returning the
symbol.
(acons 'bound-details `((left . ((text . ,txt))))
You can see the same syntax in define-grobs.scm for grob callbacks.
Regards,
Neil