Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / ly / toc-init.ly
blobdda4f31ab4d13250336decea7f2c3e57c87485e6
1 \version "2.12.0"
3 %% defined later, in a closure
4 #(define-public (add-toc-item! markup-symbol text)
5 #f)
6 #(define-public (toc-items)
7 #f)
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))))
24 \paper {
25 tocTitleMarkup = \markup \huge \column {
26 \fill-line { \null "Table of Contents" \null }
27 \hspace #1
29 tocItemMarkup = \markup \fill-line {
30 \fromproperty #'toc:text \fromproperty #'toc:page
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)))))
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))