Re: [frogs] LSR snippets for contributors and Frogs

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


Werner LEMBERG wrote:
> > [...] so just to make sure, you can confirm that what you get
> > differs from the output here?
> > 
> > http://lsr.dsi.unimi.it/LSR/Item?u=1&id=622
> 
> Yes.  What I get contains much more empty lines.

Werner,

I think I figured it out. I tweaked a bunch of newlines with
(format #f "~&"). This was very confusing if you can imagine.
Anyway, it's a tiny bit different from my original conception,
but I think it's better anyway. If you don't mind, please
compare your output with the example output I included at the
top of the attached file.

Hopefully it should look exactly the same.

Thanks.
- Mark


      
%%%% display-ancestry.ly -- Displaying grob ancestry.

\version "2.13.2"

%{
example console output:
...
Preprocessing graphical objects...

------------------------------------

NoteHead
X/Y: NoteColumn
     X: PaperColumn
        X/Y: System
     Y: VerticalAxisGroup
        X: NonMusicalPaperColumn
           X/Y: System
        Y: VerticalAlignment
           X: NonMusicalPaperColumn
              X/Y: System
           Y: System


------------------------------------

Arpeggio
X: PaperColumn
   X/Y: System
Y: Stem
   X/Y: NoteColumn
        X: PaperColumn
           X/Y: System
        Y: VerticalAxisGroup
           X: NonMusicalPaperColumn
              X/Y: System
           Y: VerticalAlignment
              X: NonMusicalPaperColumn
                 X/Y: System
              Y: System


------------------------------------

Accidental
X: AccidentalPlacement
   X: PaperColumn
      X/Y: System
   Y: VerticalAxisGroup
      X: NonMusicalPaperColumn
         X/Y: System
      Y: VerticalAlignment
         X: NonMusicalPaperColumn
            X/Y: System
         Y: System
Y: NoteHead
   X/Y: NoteColumn
        X: PaperColumn
           X/Y: System
        Y: VerticalAxisGroup
           X: NonMusicalPaperColumn
              X/Y: System
           Y: VerticalAlignment
              X: NonMusicalPaperColumn
                 X/Y: System
              Y: System

Solving 1 page-breaking chunks...[1: 1 pages]
%}

#(define (grob-name grob)
  (if (ly:grob? grob)
      (assoc-ref (ly:grob-property grob 'meta) 'name)
      #f))

#(define (get-ancestry grob)
    (if (not (null? (ly:grob-parent grob X)))
        (list (grob-name grob)
              (get-ancestry (ly:grob-parent grob X))
              (get-ancestry (ly:grob-parent grob Y)))
        (grob-name grob)))

#(define (format-ancestry lst padding)
  (string-append
    (symbol->string (car lst))
    "\n"
    (let ((X-ancestry
            (if (list? (cadr lst))
                (format-ancestry (cadr lst) (+ padding 3))
                (symbol->string (cadr lst))))
          (Y-ancestry
            (if (list? (caddr lst))
                (format-ancestry (caddr lst) (+ padding 3))
                (symbol->string (caddr lst)))))
       (if (equal? X-ancestry Y-ancestry)
           (string-append
             (format #f "~&")
             (make-string padding #\space)
             "X/Y: "
             (if (list? (cadr lst))
                 (format-ancestry (cadr lst) (+ padding 5))
                 (symbol->string (cadr lst))))
           (string-append
             (format #f "~&")
             (make-string padding #\space)
             "X: " X-ancestry
             "\n"
             (make-string padding #\space)
             "Y: " Y-ancestry
             (format #f "~&"))))
    (format #f "~&")))

#(define (display-ancestry grob)
  (display
    (string-append
      (format #f "~2&\n")
      (make-string 36 #\-)
      "\n\n"
      (format-ancestry (get-ancestry grob) 0)
      (format #f "~2&"))))

\relative {
  \once \override NoteHead #'before-line-breaking = #display-ancestry
  f
  \once \override Accidental #'before-line-breaking = #display-ancestry
  \once \override Arpeggio #'before-line-breaking = #display-ancestry
  <f as c>\arpeggio
}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/