|
|
|
@@ -155,50 +155,83 @@ romanStanza =
|
|
|
|
|
#(define-music-function (parser location) ()
|
|
|
|
|
#{ \override StanzaNumber.style = #'roman #})
|
|
|
|
|
|
|
|
|
|
#(define (number-or-number-list? x) (or (number? x) (number-list? x)))
|
|
|
|
|
|
|
|
|
|
% "1,4" -> (1 4); Einträge, die keine Zahl sind, bleiben Strings ("1b,2b" -> ("1b" "2b"))
|
|
|
|
|
#(define (stanza-numbers-from-string str)
|
|
|
|
|
(map (lambda (s) (or (string->number s) s))
|
|
|
|
|
(remove string-null? (map string-trim-both (string-split str #\,)))))
|
|
|
|
|
|
|
|
|
|
% Kein number? hier, sonst kann der Parser 1,4 nicht mehr als Liste lesen
|
|
|
|
|
#(define (stanza-numbers? x) (or (number-list? x) (string? x)))
|
|
|
|
|
|
|
|
|
|
override-stanza =
|
|
|
|
|
#(define-music-function (parser location stanzanumbers) (number-list?)
|
|
|
|
|
#(define-music-function (stanzanumbers) (number-or-number-list?)
|
|
|
|
|
#{
|
|
|
|
|
\once \override StanzaNumber.details.custom-stanzanumber-override = #stanzanumbers
|
|
|
|
|
\once \override StanzaNumber.details.custom-stanzanumber-override = #(if (number? stanzanumbers) (list stanzanumbers) stanzanumbers)
|
|
|
|
|
#}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#(define (handle-stanza-numbers context numbers number-formater)
|
|
|
|
|
(let* ((stanzanumbers (ly:assoc-get 'custom-stanzanumber-override (ly:assoc-get 'details (ly:context-grob-definition context 'StanzaNumber) '()) numbers))
|
|
|
|
|
(stanza-style (ly:assoc-get 'style (ly:context-grob-definition context 'StanzaNumber)))
|
|
|
|
|
(roman-format (lambda (stanzanumber) (format #f "~@r" stanzanumber))))
|
|
|
|
|
(ly:context-set-property! context 'stanza
|
|
|
|
|
(make-pad-left-markup 1
|
|
|
|
|
(number-formater
|
|
|
|
|
(if (eq? stanza-style 'roman)
|
|
|
|
|
(map roman-format stanzanumbers)
|
|
|
|
|
stanzanumbers))))))
|
|
|
|
|
#(define (romanize-stanza-numbers numbers style)
|
|
|
|
|
(if (eq? style 'roman)
|
|
|
|
|
(map (lambda (n) (if (number? n) (format #f "~@r" n) n)) numbers)
|
|
|
|
|
numbers))
|
|
|
|
|
|
|
|
|
|
#(define (stanza . stanzanumbers)
|
|
|
|
|
#(define (format-stanza-numbers numbers style)
|
|
|
|
|
(string-join
|
|
|
|
|
(map (lambda (n) (format #f stanzaFormat n)) (romanize-stanza-numbers numbers style))
|
|
|
|
|
", "))
|
|
|
|
|
|
|
|
|
|
% Strophennummer, die erst beim Setzen aus den Eigenschaften des StanzaNumber-Grobs gebaut wird
|
|
|
|
|
% (details.custom-stanza-type, details.custom-stanza-numbers, style, details.custom-inline-text).
|
|
|
|
|
% So können \fstanza, \ref, \bridge und \repStartWithTag im selben Zeitschritt kombiniert werden.
|
|
|
|
|
#(define-markup-command (formatted-stanza layout props) ()
|
|
|
|
|
#:properties ((details '()) (style #f))
|
|
|
|
|
(let* ((realstanza (ly:assoc-get 'custom-realstanza details #f))
|
|
|
|
|
(type (ly:assoc-get 'custom-stanza-type details 'verse))
|
|
|
|
|
(numbers (ly:assoc-get 'custom-stanzanumber-override details
|
|
|
|
|
(ly:assoc-get 'custom-stanza-numbers details '())))
|
|
|
|
|
(inline-text (ly:assoc-get 'custom-inline-text details #f))
|
|
|
|
|
(inline-direction (ly:assoc-get 'custom-inline-direction details CENTER))
|
|
|
|
|
(rep-start (and inline-text (eqv? inline-direction LEFT)))
|
|
|
|
|
(roman-numbers (romanize-stanza-numbers numbers style))
|
|
|
|
|
(stanza-stencil
|
|
|
|
|
(and realstanza
|
|
|
|
|
(case type
|
|
|
|
|
((ref) ((ly:output-def-lookup layout 'refMarkupFormatter) layout props roman-numbers))
|
|
|
|
|
((bridge) ((ly:output-def-lookup layout 'bridgeMarkupFormatter) layout props roman-numbers))
|
|
|
|
|
(else (interpret-markup layout props (format-stanza-numbers numbers style))))))
|
|
|
|
|
(padded-stanza-stencil
|
|
|
|
|
(and stanza-stencil
|
|
|
|
|
(interpret-markup layout props (make-pad-left-markup 1 (make-stencil-markup stanza-stencil))))))
|
|
|
|
|
(if rep-start
|
|
|
|
|
(interpret-markup layout props
|
|
|
|
|
(make-concat-markup
|
|
|
|
|
(append
|
|
|
|
|
(if padded-stanza-stencil (list (make-stencil-markup padded-stanza-stencil) (make-hspace-markup 1)) '())
|
|
|
|
|
(list (make-override-markup '(font-series . normal) inline-text)))))
|
|
|
|
|
(or padded-stanza-stencil empty-stencil))))
|
|
|
|
|
|
|
|
|
|
#(define (formatted-stanza-music type stanzanumbers)
|
|
|
|
|
#{
|
|
|
|
|
\once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs
|
|
|
|
|
\once \override StanzaNumber.details.custom-stanza-type = #'verse
|
|
|
|
|
\once \override StanzaNumber.details.custom-stanza-type = #type
|
|
|
|
|
\once \override StanzaNumber.details.custom-stanza-numbers = #stanzanumbers
|
|
|
|
|
\applyContext
|
|
|
|
|
#(lambda (context)
|
|
|
|
|
(handle-stanza-numbers context stanzanumbers
|
|
|
|
|
(lambda (numbers) (string-join (map (lambda (n) (format #f stanzaFormat n)) numbers) ", "))))
|
|
|
|
|
#}
|
|
|
|
|
)
|
|
|
|
|
\stanza \markup \formatted-stanza
|
|
|
|
|
#})
|
|
|
|
|
|
|
|
|
|
% \fstanza 1 -> "1."
|
|
|
|
|
% \fstanza 1,4 -> "1., 4." (nur im Notenmodus, z.B. \chordverse { \fstanza 1,4 } ...)
|
|
|
|
|
% \fstanza "1,4" -> "1., 4." (auch im \lyricmode, dort versteht LilyPond 1,4 nicht als Liste)
|
|
|
|
|
fstanza =
|
|
|
|
|
#(define-music-function (stanzanumbers) (stanza-numbers?)
|
|
|
|
|
(formatted-stanza-music 'verse
|
|
|
|
|
(if (string? stanzanumbers) (stanza-numbers-from-string stanzanumbers) stanzanumbers)))
|
|
|
|
|
|
|
|
|
|
ref =
|
|
|
|
|
#(define-music-function (stanzanumbers lyrics) ((number-list? (list)) ly:music?)
|
|
|
|
|
#{ \lyricmode {
|
|
|
|
|
\once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs
|
|
|
|
|
\once \override StanzaNumber.details.custom-stanza-type = #'ref
|
|
|
|
|
\once \override StanzaNumber.details.custom-stanza-numbers = #stanzanumbers
|
|
|
|
|
\applyContext
|
|
|
|
|
#(lambda (context)
|
|
|
|
|
(handle-stanza-numbers context stanzanumbers
|
|
|
|
|
(lambda (numbers)
|
|
|
|
|
(make-on-the-fly-markup
|
|
|
|
|
(lambda (layout props m)
|
|
|
|
|
((ly:output-def-lookup layout 'refMarkupFormatter) layout props numbers))
|
|
|
|
|
(make-null-markup)))))
|
|
|
|
|
#(formatted-stanza-music 'ref stanzanumbers)
|
|
|
|
|
#lyrics
|
|
|
|
|
}
|
|
|
|
|
#}
|
|
|
|
@@ -207,43 +240,24 @@ ref =
|
|
|
|
|
bridge =
|
|
|
|
|
#(define-music-function (stanzanumbers lyrics) ((number-list? (list)) ly:music?)
|
|
|
|
|
#{ \lyricmode {
|
|
|
|
|
\once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs
|
|
|
|
|
\once \override StanzaNumber.details.custom-stanza-type = #'bridge
|
|
|
|
|
\once \override StanzaNumber.details.custom-stanza-numbers = #stanzanumbers
|
|
|
|
|
\applyContext
|
|
|
|
|
#(lambda (context)
|
|
|
|
|
(handle-stanza-numbers context stanzanumbers
|
|
|
|
|
(lambda (numbers)
|
|
|
|
|
(make-on-the-fly-markup
|
|
|
|
|
(lambda (layout props m)
|
|
|
|
|
((ly:output-def-lookup layout 'bridgeMarkupFormatter) layout props numbers))
|
|
|
|
|
(make-null-markup)))))
|
|
|
|
|
#(formatted-stanza-music 'bridge stanzanumbers)
|
|
|
|
|
#lyrics
|
|
|
|
|
}
|
|
|
|
|
#}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
% prints a repStart Sign as stanza if the tag 'repeats is kept.
|
|
|
|
|
% if there was a stanza already set by the stanza function with StanzaNumber.details.custom-realstanza = ##t we set that also as stanza.
|
|
|
|
|
% if there is a stanza set by \fstanza in the same moment, \formatted-stanza prints both.
|
|
|
|
|
% Sets custom-inline-text for ChordPro export so it can collect the repeat sign separately
|
|
|
|
|
repStartWithTag = \lyricmode {
|
|
|
|
|
repStartWithTag =
|
|
|
|
|
#(define-music-function () ()
|
|
|
|
|
#{ \lyricmode {
|
|
|
|
|
\tag #'repeats {
|
|
|
|
|
\once \override StanzaNumber.details.custom-inline-text = \repStart
|
|
|
|
|
\once \override StanzaNumber.details.custom-inline-direction = #LEFT
|
|
|
|
|
\applyContext
|
|
|
|
|
#(lambda (context)
|
|
|
|
|
(let ((lastStanza (ly:context-property context 'stanza))
|
|
|
|
|
(printLastStanza (ly:assoc-get 'custom-realstanza (ly:assoc-get 'details (ly:context-grob-definition context 'StanzaNumber) '()) #f))
|
|
|
|
|
(stanzaFontSeries (ly:assoc-get 'font-series (ly:context-grob-definition context 'StanzaNumber) 'normal)))
|
|
|
|
|
(ly:context-set-property! context 'stanza
|
|
|
|
|
(make-concat-markup
|
|
|
|
|
(if printLastStanza
|
|
|
|
|
(list (make-override-markup `(font-series . ,stanzaFontSeries) lastStanza) (make-hspace-markup 1) repStart)
|
|
|
|
|
(list repStart)
|
|
|
|
|
)))))
|
|
|
|
|
\once \override StanzaNumber.font-series = #'normal
|
|
|
|
|
\stanza \markup \formatted-stanza
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} #})
|
|
|
|
|
|
|
|
|
|
repStopWithTag = \lyricmode {
|
|
|
|
|
\tag #'repeats {
|
|
|
|
@@ -251,19 +265,19 @@ repStopWithTag = \lyricmode {
|
|
|
|
|
\once \override StanzaNumber.details.custom-inline-direction = #RIGHT
|
|
|
|
|
\once \override StanzaNumber.font-series = #'normal
|
|
|
|
|
\once \override StanzaNumber.direction = 1
|
|
|
|
|
\set stanza = \markup { \pad-x-right #1 \repStop }
|
|
|
|
|
\stanza \markup { \pad-x-right #1 \repStop }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rightHyphen = \lyricmode {
|
|
|
|
|
\once \override StanzaNumber.font-series = #'normal
|
|
|
|
|
\once \override StanzaNumber.direction = 1
|
|
|
|
|
\set stanza = "-"
|
|
|
|
|
\stanza "-"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leftHyphen = \lyricmode {
|
|
|
|
|
\once \override StanzaNumber.font-series = #'normal
|
|
|
|
|
\set stanza = "-"
|
|
|
|
|
\stanza "-"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
multiVerseSkips =
|
|
|
|
@@ -329,7 +343,7 @@ rufWithMarkup =
|
|
|
|
|
\lyricmode {
|
|
|
|
|
\once \override StanzaNumber.font-series = #'normal
|
|
|
|
|
\once \override StanzaNumber.direction = 1
|
|
|
|
|
\set stanza = #text
|
|
|
|
|
\stanza #text
|
|
|
|
|
}
|
|
|
|
|
#})
|
|
|
|
|
ruf =
|
|
|
|
|