Hi Harm,
So this seems to mean that right-broken.text should be changed by a
hook that determines if we are at a line break. I'llt try to see if I
can figure out how to do this.
It seems to suffice to copy right.text into right-broken.text only for
the last bit of a broken TextSpanner:
\override TextSpanner.after-line-breaking =
#(lambda (grob)
; Copies bound-details.right settings to bound-details.right-broken
; for the last part of a broken spanner.
; This is needed because, if to-barline = ##t and the last part ends
; at a line break, the values from right-broken are used.
(let*
((orig (ly:grob-original grob))
(siblings (if (ly:grob? orig)
(ly:spanner-broken-into orig)
'())))
(if (not (null? siblings))
(if (eq? grob (car (last-pair siblings)))
(ly:grob-set-nested-property!
grob
'(bound-details right-broken)
(ly:assoc-get 'right (ly:grob-property grob
'bound-details)))))))
Thanks for the hint, Harm!
Lukas
\version "2.22"
spanTest = {
\override TextSpanner.to-barline = ##t
\override TextSpanner.bound-details.right-broken.text = ##f
\override TextSpanner.after-line-breaking =
#(lambda (grob)
; Copies bound-details.right settings to bound-details.right-broken
; for the last part of a broken spanner.
; This is needed because, if to-barline = ##t and the last part ends
; at a line break, the values from right-broken are used.
(let*
((orig (ly:grob-original grob))
(siblings (if (ly:grob? orig)
(ly:spanner-broken-into orig)
'())))
(if (not (null? siblings))
(if (eq? grob (car (last-pair siblings)))
(ly:grob-set-nested-property!
grob
'(bound-details right-broken)
(ly:assoc-get 'right (ly:grob-property grob 'bound-details)))))))
\override TextSpanner.bound-details.right.text = "R"
\override TextSpanner.bound-details.left.text = "L"
\override TextSpanner.bound-details.left-broken.text = \markup\right-align "(L)"
<>\startTextSpan
s1
\break
<>\stopTextSpan
s1
<>\startTextSpan
s1 \break
s1 \break
s1
<>\stopTextSpan
<>\startTextSpan
s1 \break
s1 \break
s1 \break
<>\stopTextSpan
}
\new Staff {
\spanTest
s4 % makes last "right" appear (but extends piece)
}