1 ; lily.scm -- implement Scheme output routines for TeX and PostScript
3 ; source file of the GNU LilyPond music typesetter
5 ; (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
9 ; This file contains various routines in Scheme that are easier to
10 ; do here than in C++. At present it is an unorganised mess. Sorry.
14 ;(debug-enable 'backtrace)
18 (use-modules (ice-9 regex))
20 ;; The regex module may not be available, or may be broken.
22 (let ((os (string-downcase (vector-ref (uname) 0))))
23 (not (equal? "cygwin" (substring os 0 (min 6 (string-length os)))))))
25 ;; If you have trouble with regex, define #f
27 ;;(define use-regex #f)
29 ;; do nothing in .scm output
30 (define (comment s) "")
32 ;; URG guile-1.3/1.4 compatibility
33 (define (ly-eval x) (eval2 x #f))
35 (define (comment s) "")
41 (define (cons-map f x)
42 (cons (f (car x)) (f (cdr x))))
44 (define (reduce operator list)
45 (if (null? (cdr list)) (car list)
46 (operator (car list) (reduce operator (cdr list)))
51 (define (numbers->string l)
52 (apply string-append (map ly-number->string l)))
54 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
56 (define (number->octal-string x)
57 (let* ((n (inexact->exact x))
59 (n8 (quotient (- n (* n64 64)) 8)))
63 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
65 (define (inexact->string x radix)
66 (let ((n (inexact->exact x)))
67 (number->string n radix)))
70 (define (control->string c)
71 (string-append (number->string (car c)) " "
72 (number->string (cdr c)) " "))
78 (make-string 1 (integer->char (+ (char->integer #\A) i)))
83 (define (scm-scm action-name)
86 (define security-paranoia #f)
89 ;; See documentation of Item::visibility_lambda_
90 (define (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t)))
91 (define (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
92 (define (all-visible d) '(#f . #f))
93 (define (all-invisible d) '(#t . #t))
94 (define (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
95 (define (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
98 (define mark-visibility end-of-line-invisible)
100 ;; Spacing constants for prefatory matter.
102 ;; rules for this spacing are much more complicated than this. See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
106 ;; (Measured in staff space)
109 ((none Instrument_name) . (extra-space 1.0))
110 ((Instrument_name Left_edge_item) . (extra-space 1.0))
111 ((Left_edge_item Clef_item) . (extra-space 1.0))
112 ((Left_edge_item Key_item) . (extra-space 0.0))
113 ((Left_edge_item begin-of-note) . (extra-space 1.0))
114 ((none Left_edge_item) . (extra-space 0.0))
115 ((Left_edge_item Staff_bar) . (extra-space 0.0))
116 ; ((none Left_edge_item) . (extra-space -15.0))
117 ; ((none Left_edge_item) . (extra-space -15.0))
118 ((none Clef_item) . (minimum-space 1.0))
119 ((none Staff_bar) . (minimum-space 0.0))
120 ((none Clef_item) . (minimum-space 1.0))
121 ((none Key_item) . (minimum-space 0.5))
122 ((none Time_signature) . (extra-space 0.0))
123 ((none begin-of-note) . (minimum-space 1.5))
124 ((Clef_item Key_item) . (minimum-space 4.0))
125 ((Key_item Time_signature) . (extra-space 1.0))
126 ((Clef_item Time_signature) . (minimum-space 3.5))
127 ((Staff_bar Clef_item) . (minimum-space 1.0))
128 ((Clef_item Staff_bar) . (minimum-space 3.7))
129 ((Time_signature Staff_bar) . (minimum-space 2.0))
130 ((Key_item Staff_bar) . (extra-space 1.0))
131 ((Staff_bar Time_signature) . (minimum-space 1.5)) ;double check this.
132 ((Time_signature begin-of-note) . (extra-space 2.0)) ;double check this.
133 ((Key_item begin-of-note) . (extra-space 2.5))
134 ((Staff_bar begin-of-note) . (extra-space 1.0))
135 ((Clef_item begin-of-note) . (minimum-space 5.0))
136 ((none Breathing_sign) . (minimum-space 0.0))
137 ((Breathing_sign Key_item) . (minimum-space 1.5))
138 ((Breathing_sign begin-of-note) . (minimum-space 1.0))
139 ((Breathing_sign Staff_bar) . (minimum-space 1.5))
140 ((Breathing_sign Clef_item) . (minimum-space 2.0))
145 (define (find-notehead-symbol duration style)
148 ((harmonic) "0mensural")
150 (string-append (number->string duration)
151 (if (< duration 0) "mensural" "")))
152 ((default) (number->string duration))
154 (string-append (number->string duration) (symbol->string style)))))
159 ;; this is silly, can't we use something like
160 ;; roman-0, roman-1 roman+1 ?
163 ("brace" . "feta-braces")
164 ("default" . "cmr10")
165 ("dynamic" . "feta-din")
169 ("typewriter" . "cmtt")
176 ("mark" . "feta-nummer")
177 ("finger" . "feta-nummer")
178 ("timesig" . "feta-nummer")
179 ("number" . "feta-nummer")
180 ("volta" . "feta-nummer"))
183 (define (string-encode-integer i)
186 ((< i 0) (string-append "n" (string-encode-integer (- i))))
188 (make-string 1 (integer->char (+ 65 (modulo i 26))))
189 (string-encode-integer (quotient i 26))
196 (cdr (assoc i '((-4 . 482)
209 (define script-alist '())
211 (define font-name-alist '())
212 (define (font-command name-mag)
214 (string-append "magfont"
215 (string-encode-integer (hashq (car name-mag) 1000000))
217 (string-encode-integer (cdr name-mag)))
221 (define (define-fonts names)
222 (set! font-name-alist (map font-command names))
225 (font-load-command (car x) (cdr x))) font-name-alist)
228 (define (fontify name exp)
229 (string-append (select-font name)
236 ; Make a function that checks score element for being of a specific type.
237 (define (make-type-checker symbol)
240 ; (eq? #t (ly-get-elt-property elt symbol))
241 (not (eq? #f (memq symbol (ly-get-elt-property elt 'interfaces))))
245 ;;;;;;;;;;;;;;;;;;; TeX output
246 (define (tex-scm action-name)
251 (define (select-font font-name-symbol)
254 (c (assoc font-name-symbol font-name-alist))
259 (ly-warn (string-append
260 "Programming error: No such font known " (car font-name-symbol)))
261 "") ; issue no command
262 (string-append "\\" (cdr c)))
267 (define (beam width slope thick)
268 (embedded-ps ((ps-scm 'beam) width slope thick)))
270 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
271 (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
273 (define (dashed-slur thick dash l)
274 (embedded-ps ((ps-scm 'dashed-slur) thick dash l)))
276 (define (crescendo thick w h cont)
277 (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
280 (string-append "\\char" (inexact->string i 10) " "))
282 (define (dashed-line thick dash w)
283 (embedded-ps ((ps-scm 'dashed-line) thick dash w)))
285 (define (decrescendo thick w h cont)
286 (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
288 (define (font-load-command name-mag command)
290 "\\font\\" command "="
291 (symbol->string (car name-mag))
293 (number->string (magstep (cdr name-mag)))
296 (define (embedded-ps s)
297 (string-append "\\embeddedps{" s "}"))
300 (string-append "% " s))
304 ; uncomment for some stats about lily memory
305 ; (display (gc-stats))
306 (string-append "\n\\EndLilyPondOutput"
310 (define (experimental-on)
313 (define (font-switch i)
317 (define (font-def i s)
319 "\\font" (font-switch i) "=" s "\n"))
325 ;; URG: ly-gulp-file: now we can't use scm output without Lily
327 ;; fixed in 1.3.4 for powerpc -- broken on Windows
328 (regexp-substitute/global #f "\n"
329 (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
330 (ly-gulp-file "lily.ps"))
332 "\\input lilyponddefs \\turnOnPostScript"))
334 (define (header creator generate)
336 "%created by: " creator generate "\n"))
338 (define (invoke-char s i)
340 "\n\\" s "{" (inexact->string i 10) "}" ))
342 (define (invoke-dim1 s d)
344 "\n\\" s "{" (number->dim d) "}"))
349 ;; need to do something to make this really safe.
351 (define (output-tex-string s)
352 (if security-paranoia
354 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
355 (begin (display "warning: not paranoid") (newline) s))
358 (define (lily-def key val)
362 ;; fixed in 1.3.4 for powerpc -- broken on Windows
363 (regexp-substitute/global #f "_"
364 (output-tex-string key) 'pre "X" 'post)
365 (output-tex-string key))
366 "{" (output-tex-string val) "}\n"))
368 (define (number->dim x)
370 (ly-number->string x) " pt "))
372 (define (placebox x y s)
375 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
377 (define (bezier-sandwich l thick)
378 (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
380 (define (start-line ht)
381 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
384 "}\\vss}\\interscoreline\n")
385 (define (stop-last-line)
387 (define (filledbox breapth width depth height)
389 "\\kern" (number->dim (- breapth))
390 "\\vrule width " (number->dim (+ breapth width))
391 "depth " (number->dim depth)
392 "height " (number->dim height) " "))
395 (string-append "\\hbox{" (output-tex-string s) "}"))
397 (define (tuplet ht gapx dx dy thick dir)
398 (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
400 (define (volta h w thick vert_start vert_end)
401 (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
403 (define (define-origin file line col)
404 ; use this for column positions
405 (string-append "\\special{src:" (number->string line) ":"
406 (number->string col) " " file "}")
409 ;(string-append "\\special{src:" (number->string line) " " file "}")
411 ; no-origin not yet supported by Xdvi
412 (define (no-origin) "")
415 ;; The procedures listed below form the public interface of TeX-scm.
416 ;; (should merge the 2 lists)
417 (cond ((eq? action-name 'all-definitions)
419 (define font-load-command ,font-load-command)
421 (define bezier-sandwich ,bezier-sandwich)
422 (define bracket ,bracket)
424 (define crescendo ,crescendo)
425 (define dashed-line ,dashed-line)
426 (define dashed-slur ,dashed-slur)
427 (define decrescendo ,decrescendo)
428 (define end-output ,end-output)
429 (define experimental-on ,experimental-on)
430 (define filledbox ,filledbox)
431 (define font-def ,font-def)
432 (define font-switch ,font-switch)
433 (define header-end ,header-end)
434 (define lily-def ,lily-def)
435 (define header ,header)
436 (define invoke-char ,invoke-char)
437 (define invoke-dim1 ,invoke-dim1)
438 (define placebox ,placebox)
439 (define select-font ,select-font)
440 (define start-line ,start-line)
441 (define stop-line ,stop-line)
442 (define stop-last-line ,stop-last-line)
444 (define tuplet ,tuplet)
445 (define volta ,volta)
446 (define define-origin ,define-origin)
447 (define no-origin ,no-origin)
450 ((eq? action-name 'beam) beam)
451 ((eq? action-name 'tuplet) tuplet)
452 ((eq? action-name 'bracket) bracket)
453 ((eq? action-name 'crescendo) crescendo)
454 ((eq? action-name 'dashed-line) dashed-line)
455 ((eq? action-name 'dashed-slur) dashed-slur)
456 ((eq? action-name 'decrescendo) decrescendo)
457 ((eq? action-name 'end-output) end-output)
458 ((eq? action-name 'experimental-on) experimental-on)
459 ((eq? action-name 'font-def) font-def)
460 ((eq? action-name 'font-switch) font-switch)
461 ((eq? action-name 'header-end) header-end)
462 ((eq? action-name 'lily-def) lily-def)
463 ((eq? action-name 'header) header)
464 ((eq? action-name 'invoke-char) invoke-char)
465 ((eq? action-name 'invoke-dim1) invoke-dim1)
466 ((eq? action-name 'placebox) placebox)
467 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
468 ((eq? action-name 'start-line) start-line)
469 ((eq? action-name 'stem) stem)
470 ((eq? action-name 'stop-line) stop-line)
471 ((eq? action-name 'stop-last-line) stop-last-line)
472 ((eq? action-name 'volta) volta)
473 (else (error "unknown tag -- PS-TEX " action-name))
479 (define (ps-scm action-name)
481 ;; alist containing fontname -> fontcommand assoc (both strings)
482 (define font-alist '())
483 (define font-count 0)
484 (define current-font "")
487 (define (cached-fontname i)
490 (make-string 1 (integer->char (+ 65 i)))))
492 (define (mag-to-size m)
493 (number->string (case m
496 (2 14) ; really: 14.400
497 (3 17) ; really: 17.280
498 (4 21) ; really: 20.736
499 (5 24) ; really: 24.888
500 (6 30) ; really: 29.856
504 (define (select-font font-name-symbol)
507 (c (assoc font-name-symbol font-name-alist))
512 (ly-warn (string-append
513 "Programming error: No such font known " (car font-name-symbol)))
514 "") ; issue no command
515 (string-append " " (cdr c) " "))
520 (define (font-load-command name-mag command)
524 (symbol->string (car name-mag))
526 (number->string (magstep (cdr name-mag)))
527 " 1000 div 12 mul scalefont setfont } bind def "
531 (define (beam width slope thick)
533 (numbers->string (list width slope thick)) " draw_beam" ))
536 (string-append "% " s))
538 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
540 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
543 (invoke-char " show" i))
545 (define (crescendo thick w h cont )
547 (numbers->string (list w h (inexact->exact cont) thick))
550 ;; what the heck is this interface ?
551 (define (dashed-slur thick dash l)
553 (apply string-append (map control->string l))
554 (number->string thick)
556 (number->string dash)
558 (number->string (* 10 thick)) ;UGH. 10 ?
559 " ] 0 draw_dashed_slur"))
561 (define (dashed-line thick dash width)
563 (number->string width)
565 (number->string thick)
567 (number->string dash)
569 (number->string dash)
570 " ] 0 draw_dashed_line"))
572 (define (decrescendo thick w h cont)
574 (numbers->string (list w h (inexact->exact cont) thick))
575 " draw_decrescendo"))
581 (define (experimental-on) "")
583 (define (filledbox breapth width depth height)
584 (string-append (numbers->string (list breapth width depth height))
588 (define (font-def i s)
591 (substring s 0 (- (string-length s) 4))
592 " findfont 12 scalefont setfont} bind def \n"))
594 (define (font-switch i)
595 (string-append (font i) " "))
599 ;; URG: now we can't use scm output without Lily
600 (ly-gulp-file "lilyponddefs.ps")
601 " {exch pop //systemdict /run get exec} "
602 (ly-gulp-file "lily.ps")
603 "{ exch pop //systemdict /run get exec } "
606 (define (lily-def key val)
608 (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
609 (string-append "/" key " {" val "} bind def\n")
610 (string-append "/" key " (" val ") def\n")
614 (define (header creator generate)
617 "%%Creator: " creator generate "\n"))
619 (define (invoke-char s i)
621 "(\\" (inexact->string i 8) ") " s " " ))
623 (define (invoke-dim1 s d)
625 (number->string (* d (/ 72.27 72))) " " s ))
627 (define (placebox x y s)
629 (number->string x) " " (number->string y) " {" s "} placebox "))
631 (define (bezier-sandwich l thick)
633 (apply string-append (map control->string l))
634 (number->string thick)
635 " draw_bezier_sandwich"))
637 (define (start-line height)
640 (define (stem breapth width depth height)
641 (string-append (numbers->string (list breapth width depth height))
648 (string-append "(" s ") show "))
651 (define (volta h w thick vert_start vert_end)
653 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
656 (define (tuplet ht gap dx dy thick dir)
658 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
666 (define (define-origin a b c ) "")
667 (define (no-origin) "")
670 (cond ((eq? action-name 'all-definitions)
673 (define tuplet ,tuplet)
674 (define bracket ,bracket)
676 (define crescendo ,crescendo)
677 (define volta ,volta)
678 (define bezier-sandwich ,bezier-sandwich)
679 (define dashed-line ,dashed-line)
680 (define dashed-slur ,dashed-slur)
681 (define decrescendo ,decrescendo)
682 (define end-output ,end-output)
683 (define experimental-on ,experimental-on)
684 (define filledbox ,filledbox)
685 (define font-def ,font-def)
686 (define font-switch ,font-switch)
687 (define header-end ,header-end)
688 (define lily-def ,lily-def)
689 (define font-load-command ,font-load-command)
690 (define header ,header)
691 (define invoke-char ,invoke-char)
692 (define invoke-dim1 ,invoke-dim1)
693 (define placebox ,placebox)
694 (define select-font ,select-font)
695 (define start-line ,start-line)
697 (define stop-line ,stop-line)
698 (define stop-last-line ,stop-line)
700 (define no-origin ,no-origin)
701 (define define-origin ,define-origin)
703 ((eq? action-name 'tuplet) tuplet)
704 ((eq? action-name 'beam) beam)
705 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
706 ((eq? action-name 'bracket) bracket)
707 ((eq? action-name 'char) char)
708 ((eq? action-name 'crescendo) crescendo)
709 ((eq? action-name 'dashed-line) dashed-line)
710 ((eq? action-name 'dashed-slur) dashed-slur)
711 ((eq? action-name 'decrescendo) decrescendo)
712 ((eq? action-name 'experimental-on) experimental-on)
713 ((eq? action-name 'filledbox) filledbox)
714 ((eq? action-name 'select-font) select-font)
715 ((eq? action-name 'volta) volta)
716 (else (error "unknown tag -- PS-SCM " action-name))
721 (define (arg->string arg)
722 (cond ((number? arg) (inexact->string arg 10))
723 ((string? arg) (string-append "\"" arg "\""))
724 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
726 (define (func name . args)
732 (map (lambda (x) (string-append " " (arg->string x))) args)))
738 (inexact->exact (/ x (abs x)))))
741 (define (as-scm action-name)
743 (define (beam width slope thick)
745 (func "set-line-char" "#")
746 (func "rline-to" width (* width slope))
750 (define (bezier-sandwich l thick)
757 (dy (- (cdr c3) (cdr c0)))
759 (c1-dx (- (car c1) x))
760 (c1-line-y (+ (cdr c0) (* c1-dx rc)))
761 (dir (if (< c1-line-y (cdr c1)) 1 -1))
762 (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3)))))))
764 (func "rmove-to" x y)
765 (func "put" (if (< 0 dir) "/" "\\\\"))
766 (func "rmove-to" 1 (if (< 0 dir) 1 0))
767 (func "set-line-char" "_")
768 (func "h-line" (- dx 1))
769 (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0))
770 (func "put" (if (< 0 dir) "\\\\" "/"))))))
772 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
774 (func "rmove-to" (+ width 1) (- (/ height -2) 1))
776 (func "set-line-char" "|")
777 (func "rmove-to" 0 1)
778 (func "v-line" (+ height 1))
779 (func "rmove-to" 0 (+ height 1))
786 (define (define-origin a b c ) "")
791 (define (experimental-on)
794 (define (filledbox breapth width depth height)
795 (let ((dx (+ width breapth))
796 (dy (+ depth height)))
798 (func "rmove-to" (* -1 breapth) (* -1 depth))
801 (func "set-line-char"
802 (if (<= dx 1) "|" "#"))
805 (func "set-line-char"
806 (if (<= dy 1) "-" "="))
807 (func "h-line" dx))))))
809 (define (font-load-command name-mag command)
810 (func "load-font" (car name-mag) (magstep (cdr name-mag))))
812 (define (header creator generate)
813 (func "header" creator generate))
818 ;; urg: this is good for half of as2text's execution time
819 (define (xlily-def key val)
820 (string-append "(define " key " " (arg->string val) ")\n"))
822 (define (lily-def key val)
824 (or (equal? key "mudelapaperlinewidth")
825 (equal? key "mudelapaperstaffheight"))
826 (string-append "(define " key " " (arg->string val) ")\n")
829 (define (no-origin) "")
831 (define (placebox x y s)
832 (let ((ey (inexact->exact y)))
833 (string-append "(move-to " (number->string (inexact->exact x)) " "
834 (if (= 0.5 (- (abs y) (abs ey)))
839 (define (select-font font-name-symbol)
840 (let* ((c (assoc font-name-symbol font-name-alist)))
845 "Programming error: No such font known "
846 (car font-name-symbol)))
847 "") ; issue no command
848 (func "select-font" (car font-name-symbol)))))
850 (define (start-line height)
851 (func "start-line" height))
859 (define (tuplet ht gap dx dy thick dir) "")
861 (define (volta h w thick vert-start vert-end)
864 (func "set-line-char" "|")
865 (func "rmove-to" 0 -4)
866 ;; definition strange-way around
870 (func "rmove-to" 1 h)
871 (func "set-line-char" "_")
872 (func "h-line" (- w 1))
873 (func "set-line-char" "|")
876 (func "rmove-to" (- w 1) (* -1 h))
877 (func "v-line" (* -1 h)))
880 (cond ((eq? action-name 'all-definitions)
883 (define bracket ,bracket)
885 (define define-origin ,define-origin)
886 ;;(define crescendo ,crescendo)
887 (define bezier-sandwich ,bezier-sandwich)
888 ;;(define dashed-slur ,dashed-slur)
889 ;;(define decrescendo ,decrescendo)
890 (define end-output ,end-output)
891 (define experimental-on ,experimental-on)
892 (define filledbox ,filledbox)
893 ;;(define font-def ,font-def)
894 (define font-load-command ,font-load-command)
895 ;;(define font-switch ,font-switch)
896 (define header ,header)
897 (define header-end ,header-end)
898 (define lily-def ,lily-def)
899 ;;(define invoke-char ,invoke-char)
900 ;;(define invoke-dim1 ,invoke-dim1)
901 (define no-origin ,no-origin)
902 (define placebox ,placebox)
903 (define select-font ,select-font)
904 (define start-line ,start-line)
905 ;;(define stem ,stem)
906 (define stop-line ,stop-line)
907 (define stop-last-line ,stop-line)
909 (define tuplet ,tuplet)
910 (define volta ,volta)
912 ((eq? action-name 'tuplet) tuplet)
913 ;;((eq? action-name 'beam) beam)
914 ;;((eq? action-name 'bezier-sandwich) bezier-sandwich)
915 ;;((eq? action-name 'bracket) bracket)
916 ((eq? action-name 'char) char)
917 ;;((eq? action-name 'crescendo) crescendo)
918 ;;((eq? action-name 'dashed-slur) dashed-slur)
919 ;;((eq? action-name 'decrescendo) decrescendo)
920 ;;((eq? action-name 'experimental-on) experimental-on)
921 ((eq? action-name 'filledbox) filledbox)
922 ((eq? action-name 'select-font) select-font)
923 ;;((eq? action-name 'volta) volta)
924 (else (error "unknown tag -- MUSA-SCM " action-name))
929 (define (gulp-file name)
930 (let* ((port (open-file name "r"))
931 (content (let loop ((text ""))
932 (let ((line (read-line port)))
933 (if (or (eof-object? line)
936 (loop (string-append text line "\n")))))))
940 ;; urg: Use when standalone, do:
941 ;; (define ly-gulp-file scm-gulp-file)
942 (define (scm-gulp-file name)
944 (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
945 (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
947 (let ((path (%search-load-path name)))
952 (define (scm-tex-output)
953 (ly-eval (tex-scm 'all-definitions)))
955 (define (scm-ps-output)
956 (ly-eval (ps-scm 'all-definitions)))
958 (define (scm-as-output)
959 (ly-eval (as-scm 'all-definitions)))
961 (define (index-cell cell dir)
967 ; How should a bar line behave at a break?
969 (define (break-barline glyph dir)
970 (let ((result (assoc glyph
971 '((":|:" . (":|" . "|:"))
974 ("|:" . ("|" . "|:"))
975 ("|." . ("|." . nil))
976 (".|" . (nil . ".|"))
977 (":|" . (":|" . nil))
978 ("||" . ("||" . nil))
979 (".|." . (".|." . nil))
980 ("scorebar" . (nil . "scorepostbreak"))
981 ("brace" . (nil . "brace"))
982 ("bracket" . (nil . "bracket"))
986 (if (equal? result #f)
987 (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
988 (index-cell (cdr result) dir))