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