]> git.donarmstrong.com Git - lilypond.git/blob - ly/toc-init.ly
Merge commit 'origin/dev/jneeman' into systems-per-page
[lilypond.git] / ly / toc-init.ly
1 \version "2.12.0"
2
3 %% defined later, in a closure
4 #(define-public (add-toc-item! markup-symbol text)
5   #f)
6 #(define-public (toc-items)
7   #f)
8
9 #(let ((toc-item-list (list)))
10    (set! add-toc-item!
11          (lambda (markup-symbol text)
12            (let ((label (gensym "toc")))
13              (set! toc-item-list
14                    (cons (list label markup-symbol text)
15                          toc-item-list))
16              (make-music 'EventChord
17                'page-marker #t
18                'page-label label
19                'elements (list (make-music 'LabelEvent
20                                  'page-label label))))))
21    (set! toc-items (lambda ()
22                      (reverse toc-item-list))))
23
24 \paper {
25   tocTitleMarkup = \markup \huge \column {
26     \fill-line { \null "Table of Contents" \null }
27     \hspace #1
28   }
29   tocItemMarkup = \markup \fill-line {
30     \fromproperty #'toc:text \fromproperty #'toc:page
31   }
32 }
33
34 #(define-markup-list-command (table-of-contents layout props) ()
35   ( _i "Outputs the table of contents, using the paper variable
36 @code{tocTitleMarkup} for its title, then the list of lines
37 built using the @code{tocItem} music function
38 Usage: @code{\\markuplines \\table-of-contents}" )
39   (cons (interpret-markup layout props
40                           (ly:output-def-lookup layout 'tocTitleMarkup))
41         (space-lines (chain-assoc-get 'baseline-skip props)
42                     (map (lambda (toc-item)
43                            (let ((label (car toc-item))
44                                  (toc-markup (cadr toc-item))
45                                  (text (caddr toc-item)))
46                              (interpret-markup
47                                layout
48                                (cons (list (cons 'toc:page 
49                                             (markup #:page-ref label "XXX" "?"))
50                                            (cons 'toc:text text))
51                                      props)
52                                (ly:output-def-lookup layout toc-markup))))
53                          (toc-items)))))
54
55 tocItem = 
56 #(define-music-function (parser location text) (markup?)
57    "Add a line to the table of content, using the @code{tocItemMarkup} paper
58 variable markup"
59    (add-toc-item! 'tocItemMarkup text))