Midi: always set instrument for new track. Unconfuses some midi players.
[lilypond/patrick.git] / ly / toc-init.ly
blob488e22ba2a6eb823a43f048dac5bdcfef344abec
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 tocItemWithDotsMarkup = \markup \fill-with-pattern #1 #RIGHT .
35 \fromproperty #'toc:text \fromproperty #'toc:page
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{\\markuplines \\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 #:page-ref label "XXX" "?"))
53 (cons 'toc:text text))
54 props)
55 (ly:output-def-lookup layout toc-markup))))
56 (toc-items)))))
58 tocItem =
59 #(define-music-function (parser location text) (markup?)
60 "Add a line to the table of content, using the @code{tocItemMarkup} paper
61 variable markup"
62 (add-toc-item! 'tocItemMarkup text))