]> git.donarmstrong.com Git - lilypond.git/blob - scm/output-socket.scm
Merge branch 'lilypond/translation' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / scm / output-socket.scm
1
2 (define-module (scm output-socket)
3   #:re-export (quote)
4   )
5
6 (use-modules (guile)
7              (srfi srfi-1)
8              (srfi srfi-13)
9              (lily))
10
11
12 (define-public (draw-line thick x1 y1 x2 y2)
13   (format "drawline ~a ~a ~a ~a ~a"
14           thick x1 y2 x2 y2))
15
16 (define-public (polygon xy-coords blot do-fill)
17   (format "polygon ~a ~a ~a"
18           blot
19           (if do-fill "True" "False")
20           (string-join
21            (map number->string xy-coords))
22   ))
23
24 (define-public (named-glyph font glyph)
25   (format "glyphshow ~a \"~a\" ~a \"~a\""
26           (ly:font-glyph-name-to-charcode font glyph)
27           (ly:font-name font)
28           (modified-font-metric-font-scaling font)
29           glyph
30           ))
31
32 (define-public (placebox x y s) 
33   (if (not (string-null? s))
34       (format "at ~a ~a ~a\n" x y s)
35       ""))
36
37 (define-public (round-filled-box  breapth width depth height blot-diameter)
38   (format "draw_round_box ~a ~a ~a ~a ~a"
39           breapth width depth height blot-diameter
40           ))
41
42 (define (event-cause grob)
43   (let*
44       ((cause (ly:grob-property  grob 'cause)))
45
46     (cond
47      ((ly:stream-event? cause) cause)
48      (else
49       #f))))
50
51 (define (grob-bbox grob offset)
52   (let*
53       ((x-ext (ly:grob-extent grob grob X))
54        (y-ext (ly:grob-extent grob grob Y))
55        (x (car offset))
56        (y (cdr offset)))
57
58     (if (interval-empty? x-ext)
59         (set! x-ext '(0 . 0)))
60
61     (if (interval-empty? y-ext)
62         (set! y-ext '(0 . 0)))
63     
64     (list (+ x (car x-ext))
65           (+ y (car y-ext))
66           (+ x (cdr x-ext))
67           (+ y (cdr y-ext))
68           )))
69
70 (define-public (no-origin)
71   "nocause\n")
72
73 (define-public (grob-cause offset grob)
74   (let*
75       ((cause (event-cause grob))
76        (tag (if (and cause (integer? (ly:event-property cause 'input-tag)))
77                 (ly:event-property cause 'input-tag)
78                 -1))
79        (name (cdr (assoc 'name (ly:grob-property grob 'meta))))
80        )
81     
82     (apply format
83            (append (list "cause ~a \"~a\" ~a ~a ~a ~a\n"
84                          tag name)
85            
86                    (grob-bbox grob offset))
87           )))
88
89
90 (define (escape-string str)
91   (string-regexp-substitute
92    " " "\\040" 
93    (string-regexp-substitute "\"" "\\\"" str)))
94   
95 (define-public (utf-8-string
96                 descr
97                 string)
98   
99   (format "utf-8 \"~a\" \"~a\""
100           (escape-string descr)
101
102           ;; don't want unescaped spaces.
103           (escape-string string)
104           ))
105
106
107 (define (bezier-sandwich lst thick)
108   (format
109    #f
110    "bezier_sandwich ~a [~a]"
111    thick
112    (string-append 
113     (string-join (map (lambda (x) (format "(~a,~a)" (car x) (cdr x)))
114                       lst) ","))))