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