]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3293: Add point-and-click to SVG output
authorDavid Kastrup <dak@gnu.org>
Fri, 26 Apr 2013 12:20:28 +0000 (14:20 +0200)
committerDavid Kastrup <dak@gnu.org>
Sun, 11 Aug 2013 08:23:13 +0000 (10:23 +0200)
scm/output-svg.scm

index 8e2c532a3b1a67f303a044f25820a83af4e0fe13..1df5a53d703bec054ba29eb566de86ab4c6b2511 100644 (file)
   (if (not (ly:get-option 'svg-woff)) embedded-glyph-string woff-glyph-string))
 
 (define (grob-cause offset grob)
-  "")
+  (and (ly:get-option 'point-and-click)
+       (let* ((cause (ly:grob-property grob 'cause))
+              (music-origin (if (ly:stream-event? cause)
+                                (ly:event-property cause 'origin)))
+              (point-and-click (ly:get-option 'point-and-click)))
+         (and (ly:input-location? music-origin)
+              (cond ((boolean? point-and-click) point-and-click)
+                    ((symbol? point-and-click)
+                     (ly:in-event-class? cause point-and-click))
+                    (else (any (lambda (t)
+                                 (ly:in-event-class? cause t))
+                               point-and-click)))
+              (let* ((location (ly:input-file-line-char-column music-origin))
+                     (raw-file (car location))
+                     (file (if (is-absolute? raw-file)
+                               raw-file
+                               (string-append (ly-getcwd) "/" raw-file))))
+                
+                (ly:format "<a style=\"color:inherit;\" xlink:href=\"textedit://~a:~a:~a:~a\">\n"
+                           ;; Backslashes are not valid
+                           ;; file URI path separators.
+                           (ly:string-percent-encode
+                            (ly:string-substitute "\\" "/" file))
+                           
+                           (cadr location)
+                           (caddr location)
+                           (1+ (cadddr location))))))))
 
 (define (named-glyph font name)
   (fontify font name))
 
-(define (no-origin)
-  "")
+(define (no-origin) "</a>\n")
 
 (define* (path thick commands #:optional (cap 'round) (join 'round) (fill? #f))
   (define (convert-path-exps exps)