]> git.donarmstrong.com Git - lilypond.git/blob - ly/toc-init.ly
Merge branch 'lilypond/translation'
[lilypond.git] / ly / toc-init.ly
1 \version "2.15.17"
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 tocItemWithDotsMarkup = \markup \fill-with-pattern #1 #RIGHT .
35   \fromproperty #'toc:text \fromproperty #'toc:page
36
37 #(define-markup-list-command (table-of-contents layout props) ()
38   ( _i "Outputs the table of contents, using the paper variable
39 @code{tocTitleMarkup} for its title, then the list of lines
40 built using the @code{tocItem} music function
41 Usage: @code{\\markuplist \\table-of-contents}" )
42   (cons (interpret-markup layout props
43                           (ly:output-def-lookup layout 'tocTitleMarkup))
44         (space-lines (chain-assoc-get 'baseline-skip props)
45                     (map (lambda (toc-item)
46                            (let ((label (car toc-item))
47                                  (toc-markup (cadr toc-item))
48                                  (text (caddr toc-item)))
49                              (interpret-markup
50                                layout
51                                (cons (list (cons 'toc:page
52                                             (markup #:with-link label #:page-ref label "XXX" "?"))
53                                            (cons 'toc:text (markup #:with-link label text))
54                                            (cons 'toc:label label))
55                                      props)
56                                (ly:output-def-lookup layout toc-markup))))
57                          (toc-items)))))
58
59 tocItem = 
60 #(define-music-function (parser location text) (markup?)
61    "Add a line to the table of content, using the @code{tocItemMarkup} paper
62 variable markup"
63    (add-toc-item! 'tocItemMarkup text))