X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Foutput-socket.scm;h=c86047815ade2ecc0a9ea9aec2074a91a58f77ef;hb=96435729b49bd7cb9bb5008cb93a81ba95b4ad02;hp=ab38e62967bc6c60b5cef2a08efa61d9a394659c;hpb=77135a6a36935d2ecaca9238660486c4388bfdf1;p=lilypond.git diff --git a/scm/output-socket.scm b/scm/output-socket.scm index ab38e62967..c86047815a 100644 --- a/scm/output-socket.scm +++ b/scm/output-socket.scm @@ -1,7 +1,9 @@ +;;;; output-socket.scm +;;;; +;;;; implement network-based output (socket) in Scheme (define-module (scm output-socket) - #:re-export (quote) - ) + #:re-export (quote)) (use-modules (guile) (srfi srfi-1) @@ -9,106 +11,96 @@ (lily)) -(define-public (draw-line thick x1 y1 x2 y2) - (format "drawline ~a ~a ~a ~a ~a" - thick x1 y2 x2 y2)) - -(define-public (polygon xy-coords blot do-fill) - (format "polygon ~a ~a ~a" - blot - (if do-fill "True" "False") - (string-join - (map number->string xy-coords)) - )) - -(define-public (named-glyph font glyph) - (format "glyphshow ~a \"~a\" ~a \"~a\"" - (ly:font-glyph-name-to-charcode font glyph) - (ly:font-name font) - (modified-font-metric-font-scaling font) - glyph - )) - -(define-public (placebox x y s) - (if (not (string-null? s)) - (format "at ~a ~a ~a\n" x y s) - "")) - -(define-public (round-filled-box breapth width depth height blot-diameter) - (format "draw_round_box ~a ~a ~a ~a ~a" - breapth width depth height blot-diameter - )) +(define format ergonomic-simple-format) (define (event-cause grob) (let* - ((cause (ly:grob-property grob 'cause))) + ((cause (ly:grob-property grob 'cause))) - (cond - ((ly:stream-event? cause) cause) - (else - #f)))) + (if (ly:stream-event? cause) + cause + #f))) (define (grob-bbox grob offset) (let* - ((x-ext (ly:grob-extent grob grob X)) - (y-ext (ly:grob-extent grob grob Y)) - (x (car offset)) - (y (cdr offset))) + ((x-ext (ly:grob-extent grob grob X)) + (y-ext (ly:grob-extent grob grob Y)) + (x (car offset)) + (y (cdr offset))) (if (interval-empty? x-ext) (set! x-ext '(0 . 0))) (if (interval-empty? y-ext) (set! y-ext '(0 . 0))) - + (list (+ x (car x-ext)) (+ y (car y-ext)) (+ x (cdr x-ext)) - (+ y (cdr y-ext)) - ))) + (+ y (cdr y-ext))))) -(define-public (no-origin) - "nocause\n") +(define (escape-string str) + (string-regexp-substitute + " " "\\040" + (string-regexp-substitute "\"" "\\\"" str))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; stencil commands +;;; -(define-public (grob-cause offset grob) +(define (bezier-sandwich lst thick) + (format "bezier_sandwich ~a [~a]" + thick + (string-append + (string-join (map + (lambda (x) + (format "(~a,~a)" (car x) (cdr x))) + lst) + ",")))) + +(define (draw-line thick x1 y1 x2 y2) + (format "drawline ~a ~a ~a ~a ~a" + thick x1 y2 x2 y2)) + +(define (grob-cause offset grob) (let* - ((cause (event-cause grob)) - (tag (if (and cause (integer? (ly:event-property cause 'input-tag))) - (ly:event-property cause 'input-tag) - -1)) - (name (cdr (assoc 'name (ly:grob-property grob 'meta)))) - ) - + ((cause (event-cause grob)) + (tag (if (and cause (integer? (ly:event-property cause 'input-tag))) + (ly:event-property cause 'input-tag) + -1)) + (name (assoc-get 'name (ly:grob-property grob 'meta)))) + (apply format - (append (list "cause ~a \"~a\" ~a ~a ~a ~a\n" - tag name) - - (grob-bbox grob offset)) - ))) + (append (list "cause ~a \"~a\" ~a ~a ~a ~a\n" tag name) + (grob-bbox grob offset))))) +(define (named-glyph font glyph) + (format "glyphshow ~a \"~a\" ~a \"~a\"" + (ly:font-glyph-name-to-charcode font glyph) + (ly:font-name font) + (modified-font-metric-font-scaling font) + glyph)) -(define (escape-string str) - (string-regexp-substitute - " " "\\040" - (string-regexp-substitute "\"" "\\\"" str))) - -(define-public (utf-8-string - descr - string) - - (format "utf-8 \"~a\" \"~a\"" - (escape-string descr) +(define (no-origin) + "nocause\n") - ;; don't want unescaped spaces. - (escape-string string) - )) +(define (placebox x y s) + (if (not (string-null? s)) + (format "at ~a ~a ~a\n" x y s) + "")) + +(define (polygon xy-coords blot do-fill) + (format "polygon ~a ~a ~a" + blot + (if do-fill "True" "False") + (string-join (map number->string xy-coords)))) +(define (round-filled-box breapth width depth height blot-diameter) + (format "draw_round_box ~a ~a ~a ~a ~a" + breapth width depth height blot-diameter)) -(define (bezier-sandwich lst thick) - (format - #f - "bezier_sandwich ~a [~a]" - thick - (string-append - (string-join (map (lambda (x) (format "(~a,~a)" (car x) (cdr x))) - lst) ",")))) +(define (utf-8-string descr string) + (format "utf-8 \"~a\" \"~a\"" + (escape-string descr) + ;; don't want unescaped spaces. + (escape-string string)))