Nitpick: ly:spanner-bound grob name slur -> spanner.
[lilypond.git] / scm / output-socket.scm
blob083d5a081be223493612e8be276aa4f366de2664
2 (define-module (scm output-socket)
3   #:re-export (quote)
4   )
6 (use-modules (guile)
7              (srfi srfi-1)
8              (srfi srfi-13)
9              (lily))
11 (define (dummy . rest)
12   "")
14 (display (ly:all-stencil-expressions))
15 (for-each
16  (lambda (x) 
17    (module-define! (current-module)
18                    x
19                    dummy))
21  (ly:all-stencil-expressions))
24 (define-public (draw-line thick x1 y1 x2 y2)
25   (format "drawline ~a ~a ~a ~a ~a"
26           thick x1 y2 x2 y2))
28 (define-public (polygon xy-coords blot do-fill)
29   (format "polygon ~a ~a ~a"
30           blot
31           (if do-fill "True" "False")
32           (string-join
33            (map number->string xy-coords))
34   ))
36 (define-public (named-glyph font glyph)
37   (format "glyphshow ~a \"~a\" ~a \"~a\""
38           (ly:font-glyph-name-to-charcode font glyph)
39           (ly:font-name font)
40           (modified-font-metric-font-scaling font)
41           glyph
42           ))
44 (define-public (placebox x y s) 
45   (format "at ~a ~a ~a\n" x y s))
47 (define-public (round-filled-box  breapth width depth height blot-diameter)
48   (format "draw_round_box ~a ~a ~a ~a ~a"
49           breapth width depth height blot-diameter
50           ))
52 (define (event-cause grob)
53   (let*
54       ((cause (ly:grob-property  grob 'cause)))
56     (cond
57      ((ly:stream-event? cause) cause)
58      (else
59       #f))))
61 (define (grob-bbox grob offset)
62   (let*
63       ((x-ext (ly:grob-extent grob grob X))
64        (y-ext (ly:grob-extent grob grob Y))
65        (x (car offset))
66        (y (cdr offset)))
68     (if (interval-empty? x-ext)
69         (set! x-ext '(0 . 0)))
71     (if (interval-empty? y-ext)
72         (set! y-ext '(0 . 0)))
73     
74     (list (+ x (car x-ext))
75           (+ y (car y-ext))
76           (+ x (cdr x-ext))
77           (+ y (cdr y-ext))
78           )))
80 (define-public (no-origin)
81   "nocause\n")
83 (define-public (grob-cause offset grob)
84   (let*
85       ((cause (event-cause grob))
86        (tag (if (and cause (integer? (ly:event-property cause 'input-tag)))
87                 (ly:event-property cause 'input-tag)
88                 -1))
89        (name (cdr (assoc 'name (ly:grob-property grob 'meta))))
90        )
91     
92     (apply format
93            (append (list "cause ~a \"~a\" ~a ~a ~a ~a\n"
94                          tag name)
95            
96                    (grob-bbox grob offset))
97           )))
100 (define (escape-string str)
101   (string-regexp-substitute
102    " " "\\040" 
103    (string-regexp-substitute "\"" "\\\"" str)))
104   
105 (define-public (utf-8-string
106                 descr
107                 string)
108   
109   (format "utf-8 \"~a\" \"~a\""
110           (escape-string descr)
112           ;; don't want unescaped spaces.
113           (escape-string string)
114           ))
117 (define (bezier-sandwich lst thick)
118   (format
119    #f
120    "bezier_sandwich ~a [~a]"
121    thick
122    (string-append 
123     (string-join (map (lambda (x) (format "(~a,~a)" (car x) (cdr x)))
124                       lst) ","))))