+ (cons (min 0 delta-y)
+ (max 0 delta-y)))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; grace spacing
+
+
+(define-public (grace-spacing::calc-shortest-duration grob)
+ (let*
+ ((cols (ly:grob-object grob 'columns))
+ (get-difference
+ (lambda (idx)
+ (ly:moment-sub (ly:grob-property (ly:grob-array-ref cols (1+ idx)) 'when)
+ (ly:grob-property (ly:grob-array-ref cols idx) 'when))))
+
+ (moment-min (lambda (x y)
+ (cond
+ ((and x y)
+ (if (ly:moment<? x y)
+ x
+ y))
+ (x x)
+ (y y)))))
+
+ (fold moment-min #f (map get-difference
+ (iota (1- (ly:grob-array-length cols)))))))
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; fingering
+
+(define-public (fingering::calc-text grob)
+ (let*
+ ((event (event-cause grob))
+ (digit (ly:event-property event 'digit)))
+
+ (if (> digit 5)
+ (ly:input-message (ly:event-property event 'origin)
+ "Music for the martians"))
+
+ (number->string digit 10)
+ ))
+
+(define-public (string-number::calc-text grob)
+ (let*
+ ((digit (ly:event-property (event-cause grob) 'string-number)))
+
+ (number->string digit 10)
+ ))
+
+(define-public (string-finger::calc-text grob)
+ (let*
+ ((text (ly:event-property (event-cause grob) 'text)))
+
+ text))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; dynamics
+(define-public (hairpin::calc-grow-direction grob)
+ (if (eq? (ly:event-property (event-cause grob) 'class) 'decrescendo-event)
+ START
+ STOP
+ ))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; lyrics
+
+(define-public (lyric-text::print grob)
+ "Allow interpretation of tildes as lyric tieing marks."
+
+ (let*
+ ((text (ly:grob-property grob 'text))
+ (layout (ly:grob-layout grob))
+ (defs (ly:output-def-lookup layout 'text-font-defaults))
+ (props (ly:grob-alist-chain grob defs)))
+
+ (ly:text-interface::interpret-markup layout
+ props
+ (if (string? text)
+ (make-tied-lyric-markup text)
+ text))))
+
+(define-public (lyric-text::calc-text grob)
+ (ly:event-property (event-cause grob) 'text))