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.
21 ;; If you have trouble with regex, define #f
22 ;;(define use-regex #t)
23 ;;(define use-regex #f)
26 (let ((os (string-downcase (vector-ref (uname) 0))))
27 (not (equal? "cygwin" (substring os 0 (min 6 (string-length os)))))))
29 ;; do nothing in .scm output
30 (define (comment s) "")
36 (define (cons-map f x)
37 (cons (f (car x)) (f (cdr x))))
39 (define (reduce operator list)
40 (if (null? (cdr list)) (car list)
41 (operator (car list) (reduce operator (cdr list)))
46 (define (numbers->string l)
47 (apply string-append (map ly-number->string l)))
49 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
51 (define (number->octal-string x)
52 (let* ((n (inexact->exact x))
54 (n8 (quotient (- n (* n64 64)) 8)))
58 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
60 (define (inexact->string x radix)
61 (let ((n (inexact->exact x)))
62 (number->string n radix)))
65 (define (control->string c)
66 (string-append (number->string (car c)) " "
67 (number->string (cdr c)) " "))
73 (make-string 1 (integer->char (+ (char->integer #\A) i)))
78 (define (scm-scm action-name)
81 (define security-paranoia #f)
84 ;; See documentation of Item::visibility_lambda_
85 (define (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t)))
86 (define (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
87 (define (all-visible d) '(#f . #f))
88 (define (all-invisible d) '(#t . #t))
89 (define (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
90 (define (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
93 (define mark-visibility end-of-line-invisible)
95 ;; Spacing constants for prefatory matter.
97 ;; rules for this spacing are much more complicated than this. See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
101 ;; (Measured in staff space)
104 ((none Instrument_name) . (extra-space 1.0))
105 ((Instrument_name Left_edge_item) . (extra-space 1.0))
106 ((Left_edge_item Clef_item) . (extra-space 1.0))
107 ((Left_edge_item Key_item) . (extra-space 0.0))
108 ((Left_edge_item begin-of-note) . (extra-space 1.0))
109 ((none Left_edge_item) . (extra-space 0.0))
110 ((Left_edge_item Staff_bar) . (extra-space 0.0))
111 ; ((none Left_edge_item) . (extra-space -15.0))
112 ; ((none Left_edge_item) . (extra-space -15.0))
113 ((none Clef_item) . (minimum-space 1.0))
114 ((none Staff_bar) . (minimum-space 0.0))
115 ((none Clef_item) . (minimum-space 1.0))
116 ((none Key_item) . (minimum-space 0.5))
117 ((none Time_signature) . (extra-space 0.0))
118 ((none begin-of-note) . (minimum-space 1.5))
119 ((Clef_item Key_item) . (minimum-space 4.0))
120 ((Key_item Time_signature) . (extra-space 1.0))
121 ((Clef_item Time_signature) . (minimum-space 3.5))
122 ((Staff_bar Clef_item) . (minimum-space 1.0))
123 ((Clef_item Staff_bar) . (minimum-space 3.7))
124 ((Time_signature Staff_bar) . (minimum-space 2.0))
125 ((Key_item Staff_bar) . (extra-space 1.0))
126 ((Staff_bar Time_signature) . (minimum-space 1.5)) ;double check this.
127 ((Time_signature begin-of-note) . (extra-space 2.0)) ;double check this.
128 ((Key_item begin-of-note) . (extra-space 2.5))
129 ((Staff_bar begin-of-note) . (extra-space 1.0))
130 ((Clef_item begin-of-note) . (minimum-space 5.0))
131 ((none Breathing_sign) . (minimum-space 0.0))
132 ((Breathing_sign Key_item) . (minimum-space 1.5))
133 ((Breathing_sign begin-of-note) . (minimum-space 1.0))
134 ((Breathing_sign Staff_bar) . (minimum-space 1.5))
135 ((Breathing_sign Clef_item) . (minimum-space 2.0))
140 (define (find-notehead-symbol duration style)
143 ((harmonic) "0mensural")
145 (string-append (number->string duration)
146 (if (< duration 0) "mensural" "")))
147 ((default) (number->string duration))
149 (string-append (number->string duration) (symbol->string style)))))
154 ;; this is silly, can't we use something like
155 ;; roman-0, roman-1 roman+1 ?
158 ("brace" . "feta-braces")
159 ("default" . "cmr10")
160 ("dynamic" . "feta-din")
164 ("typewriter" . "cmtt")
171 ("mark" . "feta-nummer")
172 ("finger" . "feta-nummer")
173 ("timesig" . "feta-nummer")
174 ("number" . "feta-nummer")
175 ("volta" . "feta-nummer"))
178 (define (string-encode-integer i)
181 ((< i 0) (string-append "n" (string-encode-integer (- i))))
183 (make-string 1 (integer->char (+ 65 (modulo i 26))))
184 (string-encode-integer (quotient i 26))
191 (cdr (assoc i '((-4 . 482)
204 (define script-alist '())
206 (define font-name-alist '())
207 (define (font-command name-mag)
209 (string-append "magfont"
210 (string-encode-integer (hashq (car name-mag) 1000000))
212 (string-encode-integer (cdr name-mag)))
216 (define (define-fonts names)
217 (set! font-name-alist (map font-command names))
220 (font-load-command (car x) (cdr x))) font-name-alist)
223 (define (fontify name exp)
224 (string-append (select-font name)
231 ; Make a function that checks score element for being of a specific type.
232 (define (make-type-checker symbol)
235 ; (eq? #t (ly-get-elt-property elt symbol))
236 (not (eq? #f (memq symbol (ly-get-elt-property elt 'interfaces))))
240 ;;;;;;;;;;;;;;;;;;; TeX output
241 (define (tex-scm action-name)
246 (define (select-font font-name-symbol)
249 (c (assoc font-name-symbol font-name-alist))
254 (ly-warn (string-append
255 "Programming error: No such font known " (car font-name-symbol)))
256 "") ; issue no command
257 (string-append "\\" (cdr c)))
262 (define (beam width slope thick)
263 (embedded-ps ((ps-scm 'beam) width slope thick)))
265 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
266 (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
268 (define (dashed-slur thick dash l)
269 (embedded-ps ((ps-scm 'dashed-slur) thick dash l)))
271 (define (crescendo thick w h cont)
272 (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
275 (string-append "\\char" (inexact->string i 10) " "))
277 (define (dashed-line thick dash w)
278 (embedded-ps ((ps-scm 'dashed-line) thick dash w)))
280 (define (decrescendo thick w h cont)
281 (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
283 (define (font-load-command name-mag command)
285 "\\font\\" command "="
286 (symbol->string (car name-mag))
288 (number->string (magstep (cdr name-mag)))
291 (define (embedded-ps s)
292 (string-append "\\embeddedps{" s "}"))
295 (string-append "% " s))
299 ; uncomment for some stats about lily memory
300 ; (display (gc-stats))
301 (string-append "\n\\EndLilyPondOutput"
305 (define (experimental-on)
308 (define (font-switch i)
312 (define (font-def i s)
314 "\\font" (font-switch i) "=" s "\n"))
320 ;; URG: ly-gulp-file: now we can't use scm output without Lily
322 ;; fixed in 1.3.4 for powerpc -- broken on Windows
323 (regexp-substitute/global #f "\n"
324 (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
325 (ly-gulp-file "lily.ps"))
327 "\\input lilyponddefs \\turnOnPostScript"))
329 (define (header creator generate)
331 "%created by: " creator generate "\n"))
333 (define (invoke-char s i)
335 "\n\\" s "{" (inexact->string i 10) "}" ))
337 (define (invoke-dim1 s d)
339 "\n\\" s "{" (number->dim d) "}"))
344 ;; need to do something to make this really safe.
346 (define (output-tex-string s)
347 (if security-paranoia
349 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
350 (begin (display "warning: not paranoid") (newline) s))
353 (define (lily-def key val)
357 ;; fixed in 1.3.4 for powerpc -- broken on Windows
358 (regexp-substitute/global #f "_"
359 (output-tex-string key) 'pre "X" 'post)
360 (output-tex-string key))
361 "{" (output-tex-string val) "}\n"))
363 (define (number->dim x)
365 (ly-number->string x) " pt "))
367 (define (placebox x y s)
370 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
372 (define (bezier-sandwich l thick)
373 (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
375 (define (start-line ht)
376 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
379 "}\\vss}\\interscoreline\n")
380 (define (stop-last-line)
382 (define (filledbox breapth width depth height)
384 "\\kern" (number->dim (- breapth))
385 "\\vrule width " (number->dim (+ breapth width))
386 "depth " (number->dim depth)
387 "height " (number->dim height) " "))
390 (string-append "\\hbox{" (output-tex-string s) "}"))
392 (define (tuplet ht gapx dx dy thick dir)
393 (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
395 (define (volta h w thick vert_start vert_end)
396 (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
398 (define (define-origin file line col)
399 ; use this for column positions
400 (string-append "\\special{src:" (number->string line) ":"
401 (number->string col) " " file "}")
404 ;(string-append "\\special{src:" (number->string line) " " file "}")
406 ; no-origin not yet supported by Xdvi
407 (define (no-origin) "")
410 ;; The procedures listed below form the public interface of TeX-scm.
411 ;; (should merge the 2 lists)
412 (cond ((eq? action-name 'all-definitions)
414 (define font-load-command ,font-load-command)
416 (define bezier-sandwich ,bezier-sandwich)
417 (define bracket ,bracket)
419 (define crescendo ,crescendo)
420 (define dashed-line ,dashed-line)
421 (define dashed-slur ,dashed-slur)
422 (define decrescendo ,decrescendo)
423 (define end-output ,end-output)
424 (define experimental-on ,experimental-on)
425 (define filledbox ,filledbox)
426 (define font-def ,font-def)
427 (define font-switch ,font-switch)
428 (define header-end ,header-end)
429 (define lily-def ,lily-def)
430 (define header ,header)
431 (define invoke-char ,invoke-char)
432 (define invoke-dim1 ,invoke-dim1)
433 (define placebox ,placebox)
434 (define select-font ,select-font)
435 (define start-line ,start-line)
436 (define stop-line ,stop-line)
437 (define stop-last-line ,stop-last-line)
439 (define tuplet ,tuplet)
440 (define volta ,volta)
441 (define define-origin ,define-origin)
442 (define no-origin ,no-origin)
445 ((eq? action-name 'beam) beam)
446 ((eq? action-name 'tuplet) tuplet)
447 ((eq? action-name 'bracket) bracket)
448 ((eq? action-name 'crescendo) crescendo)
449 ((eq? action-name 'dashed-line) dashed-line)
450 ((eq? action-name 'dashed-slur) dashed-slur)
451 ((eq? action-name 'decrescendo) decrescendo)
452 ((eq? action-name 'end-output) end-output)
453 ((eq? action-name 'experimental-on) experimental-on)
454 ((eq? action-name 'font-def) font-def)
455 ((eq? action-name 'font-switch) font-switch)
456 ((eq? action-name 'header-end) header-end)
457 ((eq? action-name 'lily-def) lily-def)
458 ((eq? action-name 'header) header)
459 ((eq? action-name 'invoke-char) invoke-char)
460 ((eq? action-name 'invoke-dim1) invoke-dim1)
461 ((eq? action-name 'placebox) placebox)
462 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
463 ((eq? action-name 'start-line) start-line)
464 ((eq? action-name 'stem) stem)
465 ((eq? action-name 'stop-line) stop-line)
466 ((eq? action-name 'stop-last-line) stop-last-line)
467 ((eq? action-name 'volta) volta)
468 (else (error "unknown tag -- PS-TEX " action-name))
474 (define (ps-scm action-name)
476 ;; alist containing fontname -> fontcommand assoc (both strings)
477 (define font-alist '())
478 (define font-count 0)
479 (define current-font "")
482 (define (cached-fontname i)
485 (make-string 1 (integer->char (+ 65 i)))))
487 (define (mag-to-size m)
488 (number->string (case m
491 (2 14) ; really: 14.400
492 (3 17) ; really: 17.280
493 (4 21) ; really: 20.736
494 (5 24) ; really: 24.888
495 (6 30) ; really: 29.856
499 (define (select-font font-name-symbol)
502 (c (assoc font-name-symbol font-name-alist))
507 (ly-warn (string-append
508 "Programming error: No such font known " (car font-name-symbol)))
509 "") ; issue no command
510 (string-append " " (cdr c) " "))
515 (define (font-load-command name-mag command)
519 (symbol->string (car name-mag))
521 (number->string (magstep (cdr name-mag)))
522 " 1000 div 12 mul scalefont setfont } bind def "
526 (define (beam width slope thick)
528 (numbers->string (list width slope thick)) " draw_beam" ))
531 (string-append "% " s))
533 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
535 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
538 (invoke-char " show" i))
540 (define (crescendo thick w h cont )
542 (numbers->string (list w h (inexact->exact cont) thick))
545 ;; what the heck is this interface ?
546 (define (dashed-slur thick dash l)
548 (apply string-append (map control->string l))
549 (number->string thick)
551 (number->string dash)
553 (number->string (* 10 thick)) ;UGH. 10 ?
554 " ] 0 draw_dashed_slur"))
556 (define (dashed-line thick dash width)
558 (number->string width)
560 (number->string thick)
562 (number->string dash)
564 (number->string dash)
565 " ] 0 draw_dashed_line"))
567 (define (decrescendo thick w h cont)
569 (numbers->string (list w h (inexact->exact cont) thick))
570 " draw_decrescendo"))
576 (define (experimental-on) "")
578 (define (filledbox breapth width depth height)
579 (string-append (numbers->string (list breapth width depth height))
583 (define (font-def i s)
586 (substring s 0 (- (string-length s) 4))
587 " findfont 12 scalefont setfont} bind def \n"))
589 (define (font-switch i)
590 (string-append (font i) " "))
594 ;; URG: now we can't use scm output without Lily
595 (ly-gulp-file "lilyponddefs.ps")
596 " {exch pop //systemdict /run get exec} "
597 (ly-gulp-file "lily.ps")
598 "{ exch pop //systemdict /run get exec } "
601 (define (lily-def key val)
603 (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
604 (string-append "/" key " {" val "} bind def\n")
605 (string-append "/" key " (" val ") def\n")
609 (define (header creator generate)
612 "%%Creator: " creator generate "\n"))
614 (define (invoke-char s i)
616 "(\\" (inexact->string i 8) ") " s " " ))
618 (define (invoke-dim1 s d)
620 (number->string (* d (/ 72.27 72))) " " s ))
622 (define (placebox x y s)
624 (number->string x) " " (number->string y) " {" s "} placebox "))
626 (define (bezier-sandwich l thick)
628 (apply string-append (map control->string l))
629 (number->string thick)
630 " draw_bezier_sandwich"))
632 (define (start-line height)
635 (define (stem breapth width depth height)
636 (string-append (numbers->string (list breapth width depth height))
643 (string-append "(" s ") show "))
646 (define (volta h w thick vert_start vert_end)
648 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
651 (define (tuplet ht gap dx dy thick dir)
653 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
661 (define (define-origin a b c ) "")
662 (define (no-origin) "")
665 (cond ((eq? action-name 'all-definitions)
668 (define tuplet ,tuplet)
669 (define bracket ,bracket)
671 (define crescendo ,crescendo)
672 (define volta ,volta)
673 (define bezier-sandwich ,bezier-sandwich)
674 (define dashed-line ,dashed-line)
675 (define dashed-slur ,dashed-slur)
676 (define decrescendo ,decrescendo)
677 (define end-output ,end-output)
678 (define experimental-on ,experimental-on)
679 (define filledbox ,filledbox)
680 (define font-def ,font-def)
681 (define font-switch ,font-switch)
682 (define header-end ,header-end)
683 (define lily-def ,lily-def)
684 (define font-load-command ,font-load-command)
685 (define header ,header)
686 (define invoke-char ,invoke-char)
687 (define invoke-dim1 ,invoke-dim1)
688 (define placebox ,placebox)
689 (define select-font ,select-font)
690 (define start-line ,start-line)
692 (define stop-line ,stop-line)
693 (define stop-last-line ,stop-line)
695 (define no-origin ,no-origin)
696 (define define-origin ,define-origin)
698 ((eq? action-name 'tuplet) tuplet)
699 ((eq? action-name 'beam) beam)
700 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
701 ((eq? action-name 'bracket) bracket)
702 ((eq? action-name 'char) char)
703 ((eq? action-name 'crescendo) crescendo)
704 ((eq? action-name 'dashed-line) dashed-line)
705 ((eq? action-name 'dashed-slur) dashed-slur)
706 ((eq? action-name 'decrescendo) decrescendo)
707 ((eq? action-name 'experimental-on) experimental-on)
708 ((eq? action-name 'filledbox) filledbox)
709 ((eq? action-name 'select-font) select-font)
710 ((eq? action-name 'volta) volta)
711 (else (error "unknown tag -- PS-SCM " action-name))
716 (define (arg->string arg)
717 (cond ((number? arg) (inexact->string arg 10))
718 ((string? arg) (string-append "\"" arg "\""))
719 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
721 (define (func name . args)
727 (map (lambda (x) (string-append " " (arg->string x))) args)))
733 (inexact->exact (/ x (abs x)))))
736 (define (as-scm action-name)
738 (define (beam width slope thick)
740 (func "set-line-char" "#")
741 (func "rline-to" width (* width slope))
745 (define (bezier-sandwich l thick)
752 (dy (- (cdr c3) (cdr c0)))
754 (c1-dx (- (car c1) x))
755 (c1-line-y (+ (cdr c0) (* c1-dx rc)))
756 (dir (if (< c1-line-y (cdr c1)) 1 -1))
757 (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3)))))))
759 (func "rmove-to" x y)
760 (func "put" (if (< 0 dir) "/" "\\\\"))
761 (func "rmove-to" 1 (if (< 0 dir) 1 0))
762 (func "set-line-char" "_")
763 (func "h-line" (- dx 1))
764 (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0))
765 (func "put" (if (< 0 dir) "\\\\" "/"))))))
767 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
769 (func "rmove-to" (+ width 1) (- (/ height -2) 1))
771 (func "set-line-char" "|")
772 (func "rmove-to" 0 1)
773 (func "v-line" (+ height 1))
774 (func "rmove-to" 0 (+ height 1))
781 (define (define-origin a b c ) "")
786 (define (experimental-on)
789 (define (filledbox breapth width depth height)
790 (let ((dx (+ width breapth))
791 (dy (+ depth height)))
793 (func "rmove-to" (* -1 breapth) (* -1 depth))
796 (func "set-line-char"
797 (if (<= dx 1) "|" "#"))
800 (func "set-line-char"
801 (if (<= dy 1) "-" "="))
802 (func "h-line" dx))))))
804 (define (font-load-command name-mag command)
805 (func "load-font" (car name-mag) (magstep (cdr name-mag))))
807 (define (header creator generate)
808 (func "header" creator generate))
813 ;; urg: this is good for half of as2text's execution time
814 (define (xlily-def key val)
815 (string-append "(define " key " " (arg->string val) ")\n"))
817 (define (lily-def key val)
819 (or (equal? key "mudelapaperlinewidth")
820 (equal? key "mudelapaperstaffheight"))
821 (string-append "(define " key " " (arg->string val) ")\n")
824 (define (no-origin) "")
826 (define (placebox x y s)
827 (let ((ey (inexact->exact y)))
828 (string-append "(move-to " (number->string (inexact->exact x)) " "
829 (if (= 0.5 (- (abs y) (abs ey)))
834 (define (select-font font-name-symbol)
835 (let* ((c (assoc font-name-symbol font-name-alist)))
840 "Programming error: No such font known "
841 (car font-name-symbol)))
842 "") ; issue no command
843 (func "select-font" (car font-name-symbol)))))
845 (define (start-line height)
846 (func "start-line" height))
854 (define (tuplet ht gap dx dy thick dir) "")
856 (define (volta h w thick vert-start vert-end)
859 (func "set-line-char" "|")
860 (func "rmove-to" 0 -4)
861 ;; definition strange-way around
865 (func "rmove-to" 1 h)
866 (func "set-line-char" "_")
867 (func "h-line" (- w 1))
868 (func "set-line-char" "|")
871 (func "rmove-to" (- w 1) (* -1 h))
872 (func "v-line" (* -1 h)))
875 (cond ((eq? action-name 'all-definitions)
878 (define bracket ,bracket)
880 (define define-origin ,define-origin)
881 ;;(define crescendo ,crescendo)
882 (define bezier-sandwich ,bezier-sandwich)
883 ;;(define dashed-slur ,dashed-slur)
884 ;;(define decrescendo ,decrescendo)
885 (define end-output ,end-output)
886 (define experimental-on ,experimental-on)
887 (define filledbox ,filledbox)
888 ;;(define font-def ,font-def)
889 (define font-load-command ,font-load-command)
890 ;;(define font-switch ,font-switch)
891 (define header ,header)
892 (define header-end ,header-end)
893 (define lily-def ,lily-def)
894 ;;(define invoke-char ,invoke-char)
895 ;;(define invoke-dim1 ,invoke-dim1)
896 (define no-origin ,no-origin)
897 (define placebox ,placebox)
898 (define select-font ,select-font)
899 (define start-line ,start-line)
900 ;;(define stem ,stem)
901 (define stop-line ,stop-line)
902 (define stop-last-line ,stop-line)
904 (define tuplet ,tuplet)
905 (define volta ,volta)
907 ((eq? action-name 'tuplet) tuplet)
908 ;;((eq? action-name 'beam) beam)
909 ;;((eq? action-name 'bezier-sandwich) bezier-sandwich)
910 ;;((eq? action-name 'bracket) bracket)
911 ((eq? action-name 'char) char)
912 ;;((eq? action-name 'crescendo) crescendo)
913 ;;((eq? action-name 'dashed-slur) dashed-slur)
914 ;;((eq? action-name 'decrescendo) decrescendo)
915 ;;((eq? action-name 'experimental-on) experimental-on)
916 ((eq? action-name 'filledbox) filledbox)
917 ((eq? action-name 'select-font) select-font)
918 ;;((eq? action-name 'volta) volta)
919 (else (error "unknown tag -- MUSA-SCM " action-name))
924 (define (gulp-file name)
925 (let* ((port (open-file name "r"))
926 (content (let loop ((text ""))
927 (let ((line (read-line port)))
928 (if (or (eof-object? line)
931 (loop (string-append text line "\n")))))))
935 ;; urg: Use when standalone, do:
936 ;; (define ly-gulp-file scm-gulp-file)
937 (define (scm-gulp-file name)
939 (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
940 (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
942 (let ((path (%search-load-path name)))
947 (define (scm-tex-output)
948 (eval (tex-scm 'all-definitions)))
950 (define (scm-ps-output)
951 (eval (ps-scm 'all-definitions)))
953 (define (scm-as-output)
954 (eval (as-scm 'all-definitions)))
956 (define (index-cell cell dir)
962 ; How should a bar line behave at a break?
964 (define (break-barline glyph dir)
965 (let ((result (assoc glyph
966 '((":|:" . (":|" . "|:"))
969 ("|:" . ("|" . "|:"))
970 ("|." . ("|." . nil))
971 (".|" . (nil . ".|"))
972 (":|" . (":|" . nil))
973 ("||" . ("||" . nil))
974 (".|." . (".|." . nil))
975 ("scorebar" . (nil . "scorepostbreak"))
976 ("brace" . (nil . "brace"))
977 ("bracket" . (nil . "bracket"))
981 (if (equal? result #f)
982 (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
983 (index-cell (cdr result) dir))