1 ;;;; lily.scm -- implement Scheme output routines for TeX and PostScript
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2002 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 (use-modules (ice-9 regex))
15 ;; debugging evaluator is slower.
18 ;(debug-enable 'backtrace)
19 (read-enable 'positions)
22 (define-public (line-column-location line col file)
23 "Print an input location, including column number ."
24 (string-append (number->string line) ":"
25 (number->string col) " " file)
28 (define-public (line-location line col file)
29 "Print an input location, without column number ."
30 (string-append (number->string line) " " file)
33 (define-public point-and-click #f)
35 ;; cpp hack to get useful error message
36 (define ifdef "First run this through cpp.")
37 (define ifndef "First run this through cpp.")
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45 (define-public START -1)
46 (define-public STOP 1)
47 (define-public LEFT -1)
48 (define-public RIGHT 1)
50 (define-public DOWN -1)
51 (define-public CENTER 0)
53 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
54 ;; lily specific variables.
55 (define-public default-script-alist '())
57 (define-public security-paranoia #f)
59 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
60 ;;; Unassorted utility functions.
62 (define (uniqued-alist alist acc)
64 (if (assoc (caar alist) acc)
65 (uniqued-alist (cdr alist) acc)
66 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
68 (define (other-axis a)
69 (remainder (+ a 1) 2))
72 (define-public (widen-interval iv amount)
73 (cons (- (car iv) amount)
79 (define (index-cell cell dir)
84 (define (cons-map f x)
85 "map F to contents of X"
86 (cons (f (car x)) (f (cdr x))))
89 (define-public (reduce operator list)
90 "reduce OP [A, B, C, D, ... ] =
93 (if (null? (cdr list)) (car list)
94 (operator (car list) (reduce operator (cdr list)))))
96 (define (take-from-list-until todo gathered crit?)
97 "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
98 is the first to satisfy CRIT
100 (take-from-list-until '(1 2 3 4 5) '() (lambda (x) (eq? x 3)))
107 (if (crit? (car todo))
108 (cons (cons (car todo) gathered) (cdr todo))
109 (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
118 (define (write-me n x)
127 (define-public (filter-list pred? list)
128 "return that part of LIST for which PRED is true."
130 (let* ((rest (filter-list pred? (cdr list))))
131 (if (pred? (car list))
132 (cons (car list) rest)
135 (define-public (filter-out-list pred? list)
136 "return that part of LIST for which PRED is true."
138 (let* ((rest (filter-list pred? (cdr list))))
139 (if (not (pred? (car list)))
140 (cons (car list) rest)
143 (define-public (uniqued-alist alist acc)
144 (if (null? alist) acc
145 (if (assoc (caar alist) acc)
146 (uniqued-alist (cdr alist) acc)
147 (uniqued-alist (cdr alist) (cons (car alist) acc)))))
149 (define-public (uniq-list list)
151 (if (null? (cdr list))
153 (if (equal? (car list) (cadr list))
154 (uniq-list (cdr list))
155 (cons (car list) (uniq-list (cdr list)))))))
157 (define-public (alist<? x y)
158 (string<? (symbol->string (car x))
159 (symbol->string (car y))))
161 (define-public (pad-string-to str wid)
162 (string-append str (make-string (max (- wid (string-length str)) 0) #\ ))
165 (define-public (ly:load x)
167 (fn (%search-load-path x))
171 (format (current-error-port) "[~A]" fn))
172 (primitive-load fn)))
175 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
177 (use-modules (scm tex)
188 ("tex" . ("TeX output. The default output form." ,tex-output-expression))
189 ("ps" . ("Direct postscript. Requires setting GS_LIB and GS_FONTPATH" ,ps-output-expression))
190 ("scm" . ("Scheme dump: debug scheme molecule expressions" ,write))
191 ("as" . ("Asci-script. Postprocess with as2txt to get ascii art" ,as-output-expression))
192 ("sketch" . ("Bare bones Sketch output." ,sketch-output-expression))
193 ("sodipodi" . ("Bare bones Sodipodi output." ,sodipodi-output-expression))
194 ("pdftex" . ("PDFTeX output. Was last seen nonfunctioning." ,pdftex-output-expression))
198 (define (document-format-dumpers)
201 (display (string-append (pad-string-to 5 (car x)) (cadr x) "\n"))
205 (define-public (find-dumper format )
207 ((d (assoc format output-alist)))
211 (scm-error "Could not find dumper for format ~s" format))
214 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
224 "grob-property-description.scm"
225 "context-description.scm"
226 "interface-description.scm"
231 "music-functions.scm"
232 "music-property-description.scm"
234 "basic-properties.scm"
236 "grob-description.scm"
237 "translator-property-description.scm"