X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=ly%2Ftoc-init.ly;h=ef1f18fe8b2497dbaa9a0bb4fcc99e6e63920880;hb=96878a6d45fadb44725c34699157f490b7833d7a;hp=55b48b96c2fec65040489667e5768e86ff093d21;hpb=2f320e9722ec20d6f13ec567d007763cc912c5da;p=lilypond.git diff --git a/ly/toc-init.ly b/ly/toc-init.ly index 55b48b96c2..ef1f18fe8b 100644 --- a/ly/toc-init.ly +++ b/ly/toc-init.ly @@ -1,4 +1,4 @@ -\version "2.14.0" +\version "2.16.0" %% defined later, in a closure #(define-public (add-toc-item! markup-symbol text) @@ -7,24 +7,25 @@ #f) #(let ((toc-item-list (list))) + (call-after-session (lambda () (set! toc-item-list '()))) (set! add-toc-item! - (lambda (markup-symbol text) - (let ((label (gensym "toc"))) - (set! toc-item-list - (cons (list label markup-symbol text) - toc-item-list)) - (make-music 'EventChord - 'page-marker #t - 'page-label label - 'elements (list (make-music 'LabelEvent - 'page-label label)))))) + (lambda (markup-symbol text) + (let ((label (gensym "toc"))) + (set! toc-item-list + (cons (list label markup-symbol text) + toc-item-list)) + (make-music 'EventChord + 'page-marker #t + 'page-label label + 'elements (list (make-music 'LabelEvent + 'page-label label)))))) (set! toc-items (lambda () - (reverse toc-item-list)))) + (reverse toc-item-list)))) \paper { tocTitleMarkup = \markup \huge \column { \fill-line { \null "Table of Contents" \null } - \hspace #1 + \null } tocItemMarkup = \markup \fill-line { \fromproperty #'toc:text \fromproperty #'toc:page @@ -38,25 +39,25 @@ tocItemWithDotsMarkup = \markup \fill-with-pattern #1 #RIGHT . ( _i "Outputs the table of contents, using the paper variable @code{tocTitleMarkup} for its title, then the list of lines built using the @code{tocItem} music function -Usage: @code{\\markuplines \\table-of-contents}" ) +Usage: @code{\\markuplist \\table-of-contents}" ) (cons (interpret-markup layout props - (ly:output-def-lookup layout 'tocTitleMarkup)) - (space-lines (chain-assoc-get 'baseline-skip props) - (map (lambda (toc-item) - (let ((label (car toc-item)) - (toc-markup (cadr toc-item)) - (text (caddr toc-item))) - (interpret-markup - layout - (cons (list (cons 'toc:page - (markup #:with-link label #:page-ref label "XXX" "?")) - (cons 'toc:text (markup #:with-link label text)) - (cons 'toc:label label)) - props) - (ly:output-def-lookup layout toc-markup)))) - (toc-items))))) + (ly:output-def-lookup layout 'tocTitleMarkup)) + (space-lines (chain-assoc-get 'baseline-skip props) + (map (lambda (toc-item) + (let ((label (car toc-item)) + (toc-markup (cadr toc-item)) + (text (caddr toc-item))) + (interpret-markup + layout + (cons (list (cons 'toc:page + (markup #:with-link label #:page-ref label "XXX" "?")) + (cons 'toc:text (markup #:with-link label text)) + (cons 'toc:label label)) + props) + (ly:output-def-lookup layout toc-markup)))) + (toc-items))))) -tocItem = +tocItem = #(define-music-function (parser location text) (markup?) "Add a line to the table of content, using the @code{tocItemMarkup} paper variable markup"