167 lines
7.2 KiB
Plaintext
167 lines
7.2 KiB
Plaintext
% parsing line by line
|
|
#(define-markup-command (wrap-newline layout props text) (string?)
|
|
"Text Zeile für Zeile parsen"
|
|
(interpret-markup layout props
|
|
#{ \markup { \column {
|
|
$(let ((verse-markup-string (
|
|
string-append "\\line { "
|
|
(ly:regex-replace (ly:make-regex "\n") text " } \\line { ")
|
|
" \\size-box-to-box ##f ##t \"\" \"Agj\" }" )))
|
|
(ly:parser-include-string verse-markup-string))
|
|
}}#}
|
|
)
|
|
)
|
|
|
|
#(define-markup-command (size-box-to-box layout props use-x use-y abox bbox)
|
|
(boolean? boolean? markup? markup?)
|
|
(let* ((ma (interpret-markup layout props abox))
|
|
(mb (interpret-markup layout props bbox))
|
|
(ax (ly:stencil-extent ma X))
|
|
(ay (ly:stencil-extent ma Y))
|
|
(bx (ly:stencil-extent mb X))
|
|
(by (ly:stencil-extent mb Y))
|
|
(halfdiffabx (* (- (interval-length bx) (interval-length ax)) 0.5)))
|
|
(ly:stencil-translate (ly:make-stencil (ly:stencil-expr ma)
|
|
(if use-x
|
|
(if (< halfdiffabx 0)
|
|
(cons
|
|
(- (interval-bound ax DOWN) halfdiffabx)
|
|
(+ (interval-bound ax UP) halfdiffabx))
|
|
bx)
|
|
ax)
|
|
(if use-y by ay))
|
|
(cons (if (and use-x (< halfdiffabx 0)) halfdiffabx 0) 0) )))
|
|
|
|
#(define-markup-command (size-box-to-box-left-aligned layout props use-x use-y abox bbox)
|
|
(boolean? boolean? markup? markup?)
|
|
(let* ((ma (interpret-markup layout props abox))
|
|
(mb (interpret-markup layout props bbox))
|
|
(ax (ly:stencil-extent ma X))
|
|
(ay (ly:stencil-extent ma Y))
|
|
(bx (ly:stencil-extent mb X))
|
|
(by (ly:stencil-extent mb Y)))
|
|
(ly:make-stencil (ly:stencil-expr ma)
|
|
(if use-x bx ax)
|
|
(if use-y by ay))
|
|
))
|
|
|
|
#(define-markup-command (size-box-to-box-style-dependent layout props use-x use-y abox bbox)
|
|
(boolean? boolean? markup? markup?)
|
|
(interpret-markup layout props
|
|
(case songTextChordAlignment
|
|
((center) (make-size-box-to-box-markup use-x use-y abox bbox))
|
|
((left) (make-size-box-to-box-left-aligned-markup use-x use-y abox bbox)))))
|
|
|
|
% Akkorde in Strophen transponieren
|
|
#(define-markup-list-command (transpose layout props from to markuplist)
|
|
(markup? markup? markup-list?)
|
|
(interpret-markup-list layout (prepend-alist-chain 'transposition (cons from to) props) markuplist))
|
|
|
|
#(define-markup-command (chord-alignment-style-dependent layout props chord-with-text) (markup?)
|
|
(interpret-markup layout props
|
|
(case songTextChordAlignment
|
|
((center) (make-center-align-markup chord-with-text))
|
|
((left) (make-left-align-markup chord-with-text)))))
|
|
|
|
% Text über Text mittig darstellen
|
|
#(define-markup-command (textup layout props text uptext) (markup? markup?)
|
|
"Markup über Text mittig darstellen."
|
|
(interpret-markup layout props
|
|
#{\markup {
|
|
\size-box-to-box-style-dependent ##t ##f
|
|
\general-align #X #LEFT \override #`(direction . ,UP) \override #'(baseline-skip . 1.0) \dir-column \chord-alignment-style-dependent {
|
|
\pad-to-box #'(0 . 0) #'(0 . 2.0) { #text }
|
|
\size-box-to-box ##f ##t #uptext \score { \chords { g4:m a } \layout { \generalLayout } }
|
|
}
|
|
#text
|
|
}
|
|
#}
|
|
))
|
|
|
|
#(define-markup-command (anchor-x-between layout props arga argb)
|
|
(markup? markup?)
|
|
(let* ((la (interval-length (ly:stencil-extent (interpret-markup layout props arga) X)))
|
|
(m (interpret-markup layout props (markup #:general-align Y DOWN arga argb (make-size-box-to-box-markup #t #t (markup #:null) arga))))
|
|
(l (interval-length (ly:stencil-extent m X))))
|
|
(ly:stencil-aligned-to m X (- (/ (* la 2) l) 1))
|
|
))
|
|
|
|
#(define-markup-command (stanza-raw layout props arg)
|
|
(markup?)
|
|
(interpret-markup layout props
|
|
(if (and (string? arg) (string-null? arg))
|
|
" "
|
|
#{\markup
|
|
\score { \new Lyrics { \lyricmode { \set stanza = #arg "" } } \layout { \generalLayout } }
|
|
#}
|
|
)))
|
|
|
|
#(define-markup-command (stanza layout props arg)
|
|
(markup?)
|
|
(interpret-markup layout props
|
|
(make-size-box-to-box-markup #f #t (make-stanza-raw-markup arg) (make-stanza-raw-markup "x"))))
|
|
|
|
% Kompletten Vers mit Akkorden
|
|
#(define-markup-command (chordverse layout props stanza verse) (markup? string?)
|
|
#:properties ((intraverse-vspace 0))
|
|
"Vers mit Akkorden"
|
|
(let* ((fromto (chain-assoc-get 'transposition props #f))
|
|
(transp (if fromto
|
|
(string-append "\\transpose " (car fromto) " " (cdr fromto))
|
|
"")))
|
|
(interpret-markup layout props
|
|
(markup #:override `(baseline-skip . ,(+ intraverse-vspace songTextLineHeigth)) #:anchor-x-between #:stanza stanza
|
|
(make-wrap-newline-markup
|
|
(ly:regex-replace (ly:make-regex "\\(( *)([^,()]*)( *),([^)]*)\\)")
|
|
(ly:regex-replace (ly:make-regex "(([^ \n]*\\([^()]*,[^()]+\\)[^ \n(]*)+)") verse " \\concat { " 1 " } ")
|
|
"\\textup \\line { \"" 1 "\" " 2 " \"" 3 "\" } \\score { \\transposable " transp " \\chords { s4 " 4 " } \\layout { \\verseChordLayout } }")
|
|
)
|
|
))))
|
|
|
|
% Kompletter Vers aus dem Akkorde entfernt werden
|
|
#(define-markup-command (nochordverse layout props stanza verse) (markup? string?)
|
|
#:properties ((intraverse-vspace 0))
|
|
"Vers ohne Akkorde"
|
|
(interpret-markup layout props
|
|
(markup #:override `(baseline-skip . ,(+ intraverse-vspace 3.0)) #:anchor-x-between #:stanza stanza
|
|
#:wrap-newline (ly:regex-replace (ly:make-regex "\\(([^,]*),([^)]*)\\)") verse 1)
|
|
)
|
|
)
|
|
)
|
|
|
|
#(define-markup-command (verseformat layout props verse) (markup?)
|
|
"Textformatierung für Strophen"
|
|
(interpret-markup layout props
|
|
(make-sans-markup (make-fontsize-markup (ly:output-def-lookup layout 'lyric-size) verse))
|
|
)
|
|
)
|
|
|
|
#(define-markup-command (group-verses layout props versegroup) (markup-list?)
|
|
#:properties ((verse-cols 1)
|
|
(verse-vspace 1)
|
|
(verse-hspace 1)
|
|
(verse-ordering-horizontal #f))
|
|
"Gruppiere Strophen in einem Markup auf Wunsch spaltenweise"
|
|
(let ((h (make-hash-table verse-cols))
|
|
(index 0)
|
|
(column-item-count (ceiling (/ (length versegroup) verse-cols))))
|
|
(for-each (lambda (el)
|
|
(let ((i (if verse-ordering-horizontal
|
|
(modulo index verse-cols)
|
|
(floor (/ index column-item-count)))))
|
|
(hashv-set! h i (cons el (hashv-ref h i (list)))) (set! index (+ index 1))))
|
|
versegroup)
|
|
(interpret-markup layout props
|
|
(make-fill-line-markup (cons (make-verseformat-markup (make-line-markup
|
|
(reverse (hash-fold (lambda (key value l)
|
|
(cons (make-column-markup
|
|
(fold (lambda (v verses)
|
|
(cons v (if (null? verses)
|
|
verses
|
|
(cons (make-vspace-markup verse-vspace) verses))))
|
|
(list) value))
|
|
(if (null-list? l)
|
|
l
|
|
(cons (make-hspace-markup verse-hspace) l))))
|
|
(list) h))))
|
|
(list)))))) |