X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fdisplay-lily.scm;h=e85159059df198020dba621b003d713de156040f;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=e20053128c4004e09b280fb8f7065fffb31ccbb6;hpb=75eebcb49e52d296b1da3e1074e0825d2c780db4;p=lilypond.git diff --git a/scm/display-lily.scm b/scm/display-lily.scm index e20053128c..e85159059d 100644 --- a/scm/display-lily.scm +++ b/scm/display-lily.scm @@ -2,7 +2,7 @@ ;;; ;;; ;;; -;;; (c) 2005--2006 Nicolas Sceaux +;;; (c) 2005--2008 Nicolas Sceaux ;;; ;;; - This file defines the procedures used to define display methods for each @@ -11,9 +11,10 @@ ;;; Display methods are stored in the `display-methods' property of each music ;;; type. ;;; -;;; - `display-lily-music' can be called to display a music expression using -;;; LilyPond notation. `music->lily-string' return a string describing a music -;;; expression using LilyPond notation. +;;; - `music->lily-string' return a string describing a music expression using +;;; LilyPond notation. The special variables *indent*, *previous-duration*, +;;; and *force-duration* influence the indentation level and the display of +;;; music durations. ;;; ;;; - `with-music-match' can be used to destructure a music expression, extracting ;;; some interesting music properties. @@ -42,7 +43,7 @@ `display-methods' property of the music type entry found in the `music-name-to-property-table' hash table. Print methods previously defined for that music type are lost. -Syntax: (define-display-method MusicType (expression) +Syntax: (define-display-method MusicType (expression parser) ...body...))" `(let ((type-props (hashq-ref music-name-to-property-table ',music-type '())) @@ -76,11 +77,11 @@ display method will be called." (define* (tag->lily-string expr #:optional (post-event? #f)) (format #f "~{~a ~}" - (map (lambda (tag) - (format #f "~a\\tag #'~a" (if post-event? "-" "") tag)) - (ly:music-property expr 'tags)))) + (map (lambda (tag) + (format #f "~a\\tag #'~a" (if post-event? "-" "") tag)) + (ly:music-property expr 'tags)))) -(define-public (music->lily-string expr) +(define-public (music->lily-string expr parser) "Print expr, a music expression, in LilyPond syntax" (if (ly:music? expr) (let* ((music-type (ly:music-property expr 'name)) @@ -88,7 +89,7 @@ display method will be called." music-type '()) 'display-methods)) (result-string (and procs (any (lambda (proc) - (proc expr)) + (proc expr parser)) procs)))) (if result-string (format #f "~a~a" @@ -98,13 +99,6 @@ display method will be called." music-type))) (format #f "%{ expecting a music expression: ~a %}" expr))) -(define*-public (display-lily-music expr #:key force-duration) - (parameterize ((*indent* 0) - (*previous-duration* (ly:make-duration 2)) - (*force-duration* force-duration)) - (display (music->lily-string expr)) - (newline))) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Music pattern matching @@ -138,7 +132,7 @@ display method will be called." (define (gen-condition expr pattern) "Helper function for `with-music-match'. Generate an form that checks if the properties of `expr' -match thoses desscribed in `pattern'." +match thoses described in `pattern'." (let* (;; all (property . value) found at the first depth in pattern, ;; including a (name . ) pair. (pat-all-props (cons (cons 'name (second pattern)) @@ -267,13 +261,13 @@ inside body." ;;; ;;; indentation -(define *indent* (make-parameter 0)) +(define-public *indent* (make-parameter 0)) ;;; set to #t to force duration printing -(define *force-duration* (make-parameter #f)) +(define-public *force-duration* (make-parameter #f)) ;;; last duration found -(define *previous-duration* (make-parameter (ly:make-duration 2))) +(define-public *previous-duration* (make-parameter (ly:make-duration 2))) ;;; Set to #t to force a line break with some kinds of expressions (eg sequential music) (define *force-line-break* (make-parameter #t)) @@ -283,8 +277,6 @@ inside body." (define *time-factor-denominator* (make-parameter #f)) (define *time-factor-numerator* (make-parameter #f)) -(define *parser* (make-parameter #f)) - (define *current-context* (make-parameter 'Bottom)) (define *explicit-mode* (make-parameter #t))