lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Get input location within a stencil override function


From: Urs Liska
Subject: Get input location within a stencil override function
Date: Wed, 1 Feb 2017 11:26:09 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0

I'm writing a custom stencil and want to issue a warning under certain circumstances.

The warning should point to the input location whose grob caused that circumstance. But I don't "find" the proper location within the stencil function.

\version "2.19.54" testLocation = #(define-scheme-function (grob)(ly:grob?)    (ly:input-message (*location*) "Where is the origin?")    (ly:message "Location???: ~a" (ly:grob-property grob 'cause))    (ly:make-stencil       `(path 1 `(moveto 0 0 lineto 1 1)))) {   c'   \override NoteHead.stencil = #testLocation   c' }

FIrst I try (*location*), which points to somewhere in LilyPond itself:

/home/uliska/lilypond/usr/share/lilypond/current/ly/init.ly:56:2: Where is the origin?

#

(let ((book-handler (if (defined? 'default-toplevel-book-handler)


The next (and last) thing I came up with is retrieving the 'cause of the grob:

Location???: #<Prob: Stream_event C++: Stream_event((music-cause . #<Prob: Music C++: Music((length . #<Mom 1/4>) (pitch . #<Pitch c' >) (duration . #<Duration 4 >) (origin . #<location /tmp/frescobaldi-v2tso25z/tmp_qbil8qe/document.ly:14:3>))((display-methods #<procedure #f (note)>) (name . NoteEvent) (iterator-ctor . #<primitive-procedure ly:rhythmic-music-iterator::constructor>) (types event note-event rhythmic-event melodic-event)) >

) (length . #<Mom 1/4>))((class note-event melodic-event rhythmic-event music-event StreamEvent) (length . #<Mom 1/4>) (pitch . #<Pitch c' >) (duration . #<Duration 4 >) (origin . #<location /tmp/frescobaldi-v2tso25z/tmp_qbil8qe/document.ly:14:3>)) >


This is better because obviously it contains the correct location. (14:3 of the input file).
However, I don't know how to get "inside" that <Prob: or if there's another, more straightforward way to get to the location of the grob.

Any suggestions?
TIA
Urs

-- 
address@hidden
https://openlilylib.org
http://lilypondblog.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]