]> git.donarmstrong.com Git - lilypond.git/blob - scm/lily.scm
* VERSION (MY_PATCH_LEVEL): make 1.7.0
[lilypond.git] / scm / lily.scm
1 ;;;; lily.scm -- implement Scheme output routines for TeX and PostScript
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8 ;;; Library functions
9
10 (use-modules (ice-9 regex))
11
12 ;;(write standalone (current-error-port))
13
14
15 ;;; General settings
16 ;; debugging evaluator is slower.
17
18 ;(debug-enable 'debug)
19 ;(debug-enable 'backtrace)
20 ;(read-enable 'positions)
21
22
23
24 (define point-and-click #f)
25 (define security-paranoia #f)
26 (define midi-debug #f)
27
28 (define (line-column-location line col file)
29   "Print an input location, including column number ."
30   (string-append (number->string line) ":"
31                  (number->string col) " " file)
32   )
33
34 (define (line-location line col file)
35   "Print an input location, without column number ."
36   (string-append (number->string line) " " file)
37   )
38
39 ;; cpp hack to get useful error message
40 (define ifdef "First run this through cpp.")
41 (define ifndef "First run this through cpp.")
42   
43 (define default-script-alist '())
44 (define font-name-alist  '())
45
46 (if (not (defined? 'standalone))
47     (define standalone (not (defined? 'ly-gulp-file))))
48
49 ;; The regex module may not be available, or may be broken.
50 (define use-regex
51   (let ((os (string-downcase (vector-ref (uname) 0))))
52     (not (equal? "cygwin" (substring os 0 (min 6 (string-length os)))))))
53
54 ;; If you have trouble with regex, define #f
55 (define use-regex #t)
56 ;;(define use-regex #f)
57
58
59 ;;; Un-assorted stuff
60
61 ;; URG guile-1.4/1.4.x compatibility
62 (if (not (defined? 'primitive-eval))
63     (define (primitive-eval form)
64       (eval2 form #f)))
65
66 (define (sign x)
67   (if (= x 0)
68       0
69       (if (< x 0) -1 1)))
70
71 (define (write-me n x)
72   (display n)
73   (write x)
74   (newline)
75   x)
76
77 (define (empty? x)
78   (equal? x '()))
79
80 (define (!= l r)
81   (not (= l r)))
82
83 (define (filter-list pred? list)
84   "return that part of LIST for which PRED is true."
85   (if (null? list) '()
86       (let* ((rest  (filter-list pred? (cdr list))))
87         (if (pred?  (car list))
88             (cons (car list)  rest)
89             rest))))
90
91 (define (filter-out-list pred? list)
92   "return that part of LIST for which PRED is true."
93   (if (null? list) '()
94       (let* ((rest  (filter-list pred? (cdr list))))
95         (if (not (pred?  (car list)))
96             (cons (car list)  rest)
97             rest))))
98
99 (define (uniqued-alist  alist acc)
100   (if (null? alist) acc
101       (if (assoc (caar alist) acc)
102           (uniqued-alist (cdr alist) acc)
103           (uniqued-alist (cdr alist) (cons (car alist) acc)))))
104
105 (define (uniq-list list)
106   (if (null? list) '()
107       (if (null? (cdr list))
108           list
109           (if (equal? (car list) (cadr list))
110               (uniq-list (cdr list))
111               (cons (car list) (uniq-list (cdr list)))))))
112
113 (define (alist<? x y)
114   (string<? (symbol->string (car x))
115             (symbol->string (car y))))
116
117 (define (ly-load x)
118   (let* ((fn (%search-load-path x)))
119     (if (ly-verbose)
120         (format (current-error-port) "[~A]" fn))
121     (primitive-load fn)))
122
123
124 (use-modules (scm tex)
125              (scm ps)
126              (scm pysk)
127              (scm ascii-script)
128              (scm sketch)
129              (scm pdftex)
130              )
131
132 (define output-alist
133   `(
134     ("tex" . ("TeX output. The default output form." ,tex-output-expression))
135     ("ps" . ("Direct postscript. Requires setting GS_LIB and GS_FONTPATH" ,ps-output-expression))
136     ("scm" . ("Scheme dump: debug scheme molecule expressions" ,write))
137     ("as" . ("Asci-script. Postprocess with as2txt to get ascii art"  ,as-output-expression))
138     ("sketch" . ("Bare bones Sketch output. Requires sketch 0.7" ,sketch-output-expression))
139     ("pdftex" . ("PDFTeX output. Was last seen nonfunctioning." ,pdftex-output-expression))
140     ))
141
142 (define (pad-string-to str wid)
143   (string-append str (make-string (max (- wid (string-length str)) 0) #\ ))
144   )
145
146 (define (document-format-dumpers)
147   (map
148    (lambda (x)
149      (display (string-append  (pad-string-to 5 (car x)) (cadr x) "\n"))
150      output-alist)
151    ))
152
153 (define (find-dumper format )
154   (let*
155       ((d (assoc format output-alist)))
156     
157     (if (pair? d)
158         (caddr d)
159         (scm-error "Could not find dumper for format ~s" format))
160     ))
161
162 (define X 0)
163 (define Y 1)
164 (define LEFT -1)
165 (define RIGHT 1)
166 (define UP 1)
167 (define DOWN -1)
168 (define CENTER 0)
169
170 (if (not standalone)
171     (map ly-load
172                                         ; load-from-path
173          '("output-lib.scm"
174            "c++.scm"
175            "molecule.scm"
176            "bass-figure.scm"
177            "grob-property-description.scm"
178            "context-description.scm"
179            "interface-description.scm"
180            "beam.scm"
181            "clef.scm"
182            "slur.scm"
183            "font.scm"
184            "music-functions.scm"
185            "music-property-description.scm"
186            "auto-beam.scm"
187            "basic-properties.scm"
188            "chord-name.scm"
189            "grob-description.scm"
190            "translator-property-description.scm"
191            "script.scm"
192            "drums.scm"
193            "midi.scm"
194            )))
195