Hi Harm, On Wed, Mar 3, 2021 at 6:56 AM Thomas Morley <thomasmorle...@gmail.com> wrote: > > Hi, > > please have a look at the following minimal, producing three staves, > the middle one with consecutive TextSpanners: > > mus = { bes \startTextSpan b\stopTextSpan \startTextSpan bis\stopTextSpan } > << { a4 a a } \mus { c' c' c' } >> > > Now I want to know the starting and ending NoteColumns of the _first_ > TextSpanner. > Though, the first TextSpanner is left-bounded by NoteColumn and > right-bounded by PaperColumn. > > How to get the NoteColumn at first TextSpanner's end? > > Below some test-code. > Obviously I can filter PaperColumn's elements for NoteColumns, but > PaperColumn is a Score-grob, thus I get all three. > How to select? > (I may not know the position of the Staff with the TextSpanners) > > #(define tst > (lambda (grob) > (let* ((left-bound (ly:spanner-bound grob LEFT)) > (right-bound (ly:spanner-bound grob RIGHT)) > (ncs-from-grob > (ly:grob-array->list (ly:grob-object grob 'note-columns))) > (right-bound-elts > (ly:grob-array->list > (ly:grob-object right-bound 'elements))) > (ncs-from-right-bound > (filter > (lambda (elt) (grob::has-interface elt 'note-column-interface)) > right-bound-elts)) > ) > (pretty-print > (list > left-bound > right-bound > ncs-from-grob > (equal? left-bound (car ncs-from-grob)) > ncs-from-right-bound > ))))) > > mus = { > bes4-\tweak #'after-line-breaking #tst > \startTextSpan > b\stopTextSpan > \startTextSpan > bis\stopTextSpan > } > > << > { a4 a a } > \mus > { c' c' c' } > >> > > Thanks, > Harm >
The only thing I can think of at the moment is to compare the StaffSymbol of the left bound with that of each of the NoteColumns on the right. Of course, I realize right away that that will break down if the spanner crosses a line break. (Use an override of 'before-line-breaking?) Here's the code I hacked up. I'll keep thinking about this. Best, David %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #(define tst (lambda (grob) (let* ((left-bound (ly:spanner-bound grob LEFT)) (right-bound (ly:spanner-bound grob RIGHT)) (ncs-from-grob (ly:grob-array->list (ly:grob-object grob 'note-columns))) (right-bound-elts (ly:grob-array->list (ly:grob-object right-bound 'elements))) (ncs-from-right-bound (filter (lambda (elt) (grob::has-interface elt 'note-column-interface)) right-bound-elts)) (left-bound-staff-symbol (ly:grob-object left-bound 'staff-symbol)) (same-staff-right-bound-nc (filter (lambda (nc) (eq? (ly:grob-object nc 'staff-symbol) left-bound-staff-symbol)) ncs-from-right-bound)) ) (ly:grob-set-property! (ly:grob-array-ref (ly:grob-object (car same-staff-right-bound-nc) 'note-heads) 0) 'color red) (pretty-print (list left-bound right-bound ncs-from-grob (equal? left-bound (car ncs-from-grob)) ncs-from-right-bound same-staff-right-bound-nc ))))) mus = { bes4-\tweak #'after-line-breaking #tst \startTextSpan b\stopTextSpan \startTextSpan bis\stopTextSpan } << { a4 a a } \mus { c' c' c' } >>