]> git.donarmstrong.com Git - lilypond.git/blob - scm/define-markup-commands.scm
* lily/paper-score.cc (process): Do not show progress newline.
[lilypond.git] / scm / define-markup-commands.scm
1 ;;;; define-markup-commands.scm -- markup commands
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c)  2000--2004  Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;;                  Jan Nieuwenhuizen <janneke@gnu.org>
7
8 ;;; markup commands
9 ;;; TODO:
10 ;;;  * each markup function should have a doc string with
11 ;;     syntax, description and example. 
12
13
14 (def-markup-command (stencil paper props stil) (ly:stencil?)
15   "Stencil as markup"
16   stil)
17
18
19 (def-markup-command (score paper props score) (ly:score?)
20   (let*
21       ((systems (ly:score-embedded-format score paper))
22        (1st (vector-ref systems 0))
23        (stencil (ly:paper-system-stencil 1st)) )
24
25     (ly:stencil-align-to! stencil Y CENTER)
26     (display (ly:stencil-extent stencil X))
27     (display (ly:stencil-extent stencil Y))
28 ;    (set! stencil (ly:stencil-translate-axis stencil -20 X))
29 ;    (set! stencil (ly:stencil-translate-axis stencil 20 Y))
30     stencil))
31
32 (def-markup-command (simple paper props str) (string?)
33   "A simple text string; @code{\\markup @{ foo @}} is equivalent with
34 @code{\\markup @{ \\simple #\"foo\" @}}."
35     (interpret-markup paper props str))
36
37 (def-markup-command (encoded-simple paper props sym str) (symbol? string?)
38   "A text string, encoded with encoding @var{sym}. "
39   (Text_item::interpret_string paper
40                                props sym str))
41
42 ;; TODO: use font recoding.
43 ;;                    (make-line-markup
44 ;;                     (map make-word-markup (string-tokenize str)))))
45
46 (define-public empty-markup
47   (make-simple-markup ""))
48
49 ;;(def-markup-command (fill-line paper props line-width markups)
50 ;;  (number? markup-list?)
51 ;; no parser tag -- should make number? markuk-list? thingy
52 (def-markup-command (fill-line paper props markups)
53   (markup-list?)
54   "Put @var{markups} in a horizontal line of width @var{line-width}.
55    The markups are spaced/flushed to fill the entire line."
56
57   (let* ((stencils (map (lambda (x) (interpret-markup paper props x))
58                         markups))
59          (text-width (apply + (map interval-length
60                                    (map (lambda (x)
61                                           (ly:stencil-extent x X))
62                                         stencils))))
63         (word-count (length markups))
64         (word-space (chain-assoc-get 'word-space props))
65         (line-width (chain-assoc-get 'linewidth props))
66         (fill-space (if (< line-width text-width)
67                         word-space
68                         (/ (- line-width text-width)
69                            (if (= word-count 1) 2 (- word-count 1)))))
70         (line-stencils (if (= word-count 1)
71                            (map (lambda (x) (interpret-markup paper props x))
72                                 (list (make-simple-markup "")
73                                       (make-stencil-markup (car stencils))
74                                       (make-simple-markup "")))
75                                 stencils)))
76     (stack-stencil-line fill-space line-stencils)))
77   
78 (define (font-markup qualifier value)
79   (lambda (paper props arg)
80     (interpret-markup paper
81                       (prepend-alist-chain qualifier value props)
82                       arg)))
83
84 (def-markup-command (line paper props args) (markup-list?)
85   "Put @var{args} in a horizontal line.  The property @code{word-space}
86 determines the space between each markup in @var{args}."
87   (stack-stencil-line
88    (chain-assoc-get 'word-space props)
89    (map (lambda (m) (interpret-markup paper props m)) args)))
90
91 (def-markup-command (combine paper props m1 m2) (markup? markup?)
92   "Print two markups on top of each other."
93   (let*
94       ((s1 (interpret-markup paper props m1))
95        (s2 (interpret-markup paper props m2)))
96              
97     (ly:stencil-add s1 s2)))
98
99 (def-markup-command (finger paper props arg) (markup?)
100   "Set the argument as small numbers."
101   (interpret-markup paper
102                     (cons '((font-size . -5) (font-family . number)) props)
103                     arg))
104
105 (def-markup-command (fontsize paper props mag arg) (number? markup?)
106   "This sets the relative font size, e.g.
107 @example
108 A \\fontsize #2 @{ B C @} D
109 @end example
110
111
112 This will enlarge the B and the C by two steps.
113 "
114   (interpret-markup
115    paper 
116    (prepend-alist-chain 'font-size mag props)
117    arg))
118
119 (def-markup-command (magnify paper props sz arg) (number? markup?)
120   "This sets the font magnification for the its argument. In the following
121 example, the middle A will be 10% larger:
122 @example
123 A \\magnify #1.1 @{ A @} A
124 @end example
125
126 Note: magnification only works if a font-name is explicitly selected.
127 Use @code{\\fontsize} otherwise."
128
129   (interpret-markup
130    paper 
131    (prepend-alist-chain 'font-magnification sz props)
132    arg))
133
134 (def-markup-command (bold paper props arg) (markup?)
135   "Switch to bold font-series"
136   (interpret-markup paper (prepend-alist-chain 'font-series 'bold props) arg))
137
138 (def-markup-command (sans paper props arg) (markup?)
139   "Switch to the sans-serif family"
140   (interpret-markup paper (prepend-alist-chain 'font-family 'sans props) arg))
141
142 (def-markup-command (number paper props arg) (markup?)
143   "Set font family to @code{number}, which yields the font used for
144 time signatures and fingerings.  This font only contains numbers and
145 some punctuation. It doesn't have any letters.  "
146   (interpret-markup paper (prepend-alist-chain 'font-encoding 'fetaNumber props) arg))
147
148 (def-markup-command (roman paper props arg) (markup?)
149   "Set font family to @code{roman}."
150   (interpret-markup paper (prepend-alist-chain 'font-family 'roman props) arg))
151
152 (def-markup-command (huge paper props arg) (markup?)
153   "Set font size to +2."
154   (interpret-markup paper (prepend-alist-chain 'font-size 2 props) arg))
155
156 (def-markup-command (large paper props arg) (markup?)
157   "Set font size to +1."
158   (interpret-markup paper (prepend-alist-chain 'font-size 1 props) arg))
159
160 (def-markup-command (normalsize paper props arg) (markup?)
161   "Set font size to default."
162   (interpret-markup paper (prepend-alist-chain 'font-size 0 props) arg))
163
164 (def-markup-command (small paper props arg) (markup?)
165   "Set font size to -1."
166   (interpret-markup paper (prepend-alist-chain 'font-size -1 props) arg))
167
168 (def-markup-command (tiny paper props arg) (markup?)
169   "Set font size to -2."
170   (interpret-markup paper (prepend-alist-chain 'font-size -2 props) arg))
171
172 (def-markup-command (teeny paper props arg) (markup?)
173   "Set font size to -3."
174   (interpret-markup paper (prepend-alist-chain 'font-size -3 props) arg))
175
176 (def-markup-command (caps paper props arg) (markup?)
177   "Set font shape to @code{caps}."
178   (interpret-markup paper (prepend-alist-chain 'font-shape 'caps props) arg))
179
180 (def-markup-command (latin-i paper props arg) (markup?)
181   "TEST latin1 encoding."
182   (interpret-markup paper (prepend-alist-chain 'font-shape 'latin1 props) arg))
183
184 (def-markup-command (dynamic paper props arg) (markup?)
185   "Use the dynamic font.  This font only contains @b{s}, @b{f}, @b{m},
186 @b{z}, @b{p}, and @b{r}.  When producing phrases, like ``pi@`{u} @b{f}'', the
187 normal words (like ``pi@`{u}'') should be done in a different font.  The
188 recommend font for this is bold and italic"
189   (interpret-markup
190    paper (prepend-alist-chain 'font-encoding 'fetaDynamic props) arg))
191
192 (def-markup-command (italic paper props arg) (markup?)
193   "Use italic @code{font-shape} for @var{arg}. "
194   (interpret-markup paper (prepend-alist-chain 'font-shape 'italic props) arg))
195
196 (def-markup-command (typewriter paper props arg) (markup?)
197   "Use @code{font-family} typewriter for @var{arg}."
198   (interpret-markup
199    paper (prepend-alist-chain 'font-family 'typewriter props) arg))
200
201 (def-markup-command (upright paper props arg) (markup?)
202   "Set font shape to @code{upright}."
203   (interpret-markup
204    paper (prepend-alist-chain 'font-shape 'upright props) arg))
205
206 (def-markup-command (doublesharp paper props) ()
207   "Draw a double sharp symbol."
208
209   (interpret-markup paper props (markup #:musicglyph "accidentals-4")))
210 (def-markup-command (sesquisharp paper props) ()
211   "Draw a 3/2 sharp symbol."
212   (interpret-markup paper props (markup #:musicglyph "accidentals-3")))
213
214 (def-markup-command (sharp paper props) ()
215   "Draw a sharp symbol."
216   (interpret-markup paper props (markup #:musicglyph "accidentals-2")))
217 (def-markup-command (semisharp paper props) ()
218   "Draw a semi sharp symbol."
219   (interpret-markup paper props (markup #:musicglyph "accidentals-1")))
220 (def-markup-command (natural paper props) ()
221   "Draw a natural symbol."
222
223   (interpret-markup paper props (markup #:musicglyph "accidentals-0")))
224 (def-markup-command (semiflat paper props) ()
225   "Draw a semiflat."
226   (interpret-markup paper props (markup #:musicglyph "accidentals--1")))
227 (def-markup-command (flat paper props) ()
228   "Draw a flat symbol."
229   
230   (interpret-markup paper props (markup #:musicglyph "accidentals--2")))
231 (def-markup-command (sesquiflat paper props) ()
232   "Draw a 3/2 flat symbol."
233   
234   (interpret-markup paper props (markup #:musicglyph "accidentals--3")))
235 (def-markup-command (doubleflat paper props) ()
236   "Draw a double flat symbol."
237
238   (interpret-markup paper props (markup #:musicglyph "accidentals--4")))
239
240
241 (def-markup-command (column paper props args) (markup-list?)
242   "Stack the markups in @var{args} vertically."
243   (stack-lines
244    -1 0.0 (chain-assoc-get 'baseline-skip props)
245    (map (lambda (m) (interpret-markup paper props m)) args)))
246
247 (def-markup-command (dir-column paper props args) (markup-list?)
248   "Make a column of args, going up or down, depending on the setting
249 of the @code{#'direction} layout property."
250   (let* ((dir (chain-assoc-get 'direction props)))
251     (stack-lines
252      (if (number? dir) dir -1)
253      0.0
254       (chain-assoc-get 'baseline-skip props)
255      (map (lambda (x) (interpret-markup paper props x)) args))))
256
257 (def-markup-command (center-align paper props args) (markup-list?)
258   "Put @code{args} in a centered column. "
259   (let* ((mols (map (lambda (x) (interpret-markup paper props x)) args))
260          (cmols (map (lambda (x) (ly:stencil-align-to! x X CENTER)) mols)))
261     (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) mols)))
262
263 (def-markup-command (vcenter paper props arg) (markup?)
264   "Align @code{arg} to its center. "
265   (let* ((mol (interpret-markup paper props arg)))
266     (ly:stencil-align-to! mol Y CENTER)
267     mol))
268
269 (def-markup-command (right-align paper props arg) (markup?)
270   (let* ((m (interpret-markup paper props arg)))
271     (ly:stencil-align-to! m X RIGHT)
272     m))
273
274 (def-markup-command (left-align paper props arg) (markup?)
275   "Align @var{arg} on its left edge. "
276   
277   (let* ((m (interpret-markup paper props arg)))
278     (ly:stencil-align-to! m X LEFT)
279     m))
280
281 (def-markup-command (halign paper props dir arg) (number? markup?)
282   "Set horizontal alignment. If @var{dir} is -1, then it is
283 left-aligned, while+1 is right. Values in between interpolate alignment
284 accordingly."
285
286   
287   (let* ((m (interpret-markup paper props arg)))
288     (ly:stencil-align-to! m X dir)
289     m))
290
291 (def-markup-command (musicglyph paper props glyph-name) (string?)
292   "This is converted to a musical symbol, e.g. @code{\\musicglyph
293 #\"accidentals-0\"} will select the natural sign from the music font.
294 See @usermanref{The Feta font} for  a complete listing of the possible glyphs.
295 "
296   (ly:find-glyph-by-name
297    (ly:paper-get-font paper (cons '((font-encoding . fetaMusic))
298                                   props))
299    glyph-name))
300
301
302 (def-markup-command (lookup paper props glyph-name) (string?)
303   "Lookup a glyph by name."
304   (ly:find-glyph-by-name (ly:paper-get-font paper props)
305                          glyph-name))
306
307 (def-markup-command (char paper props num) (integer?)
308   "This produces a single character, e.g. @code{\\char #65} produces the 
309 letter 'A'."
310   (ly:get-glyph (ly:paper-get-font paper props) num))
311
312 (def-markup-command (raise paper props amount arg) (number? markup?)
313   "
314 This  raises  @var{arg}, by the distance @var{amount}.
315 A negative @var{amount} indicates lowering:
316 @c
317 @lilypond[verbatim,fragment,relative=1]
318  c1^\\markup { C \\small \\raise #1.0 \\bold { \"9/7+\" }}
319 @end lilypond
320 The argument to @code{\\raise} is the vertical displacement amount,
321 measured in (global) staff spaces.  @code{\\raise} and @code{\\super}
322 raise objects in relation to their surrounding markups.
323
324 If the text object itself is positioned above or below the staff, then
325 @code{\\raise} cannot be used to move it, since the mechanism that
326 positions it next to the staff cancels any shift made with
327 @code{\\raise}. For vertical positioning, use the @code{padding}
328 and/or @code{extra-offset} properties. "
329
330   
331   (ly:stencil-translate-axis (interpret-markup paper props arg)
332                               amount Y))
333
334 (def-markup-command (fraction paper props arg1 arg2) (markup? markup?)
335   "Make a fraction of two markups."
336   
337   (let* ((m1 (interpret-markup paper props arg1))
338          (m2 (interpret-markup paper props arg2)))
339     (ly:stencil-align-to! m1 X CENTER)
340     (ly:stencil-align-to! m2 X CENTER)    
341     (let* ((x1 (ly:stencil-extent m1 X))
342            (x2 (ly:stencil-extent m2 X))
343            (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
344            ;; should stack mols separately, to maintain LINE on baseline
345            (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
346       (ly:stencil-align-to! stack Y CENTER)
347       (ly:stencil-align-to! stack X LEFT)
348       ;; should have EX dimension
349       ;; empirical anyway
350       (ly:stencil-translate-axis stack 0.75 Y))))
351
352
353 ;; TODO: better syntax.
354
355 (def-markup-command (note-by-number paper props log dot-count dir) (number? number? number?)
356   "Construct a note symbol, with stem.  By using fractional values for
357 @var{dir}, you can obtain longer or shorter stems."
358   
359   (let* ((font (ly:paper-get-font paper (cons '((font-encoding . fetaMusic)) props)))
360          (stemlen (max 3 (- log 1)))
361          (headgl (ly:find-glyph-by-name
362                   font
363                   (string-append "noteheads-" (number->string (min log 2)))))
364          (stemth 0.13)
365          (stemy (* dir stemlen))
366          (attachx (if (> dir 0)
367                       (- (cdr (ly:stencil-extent headgl X)) stemth)
368                       0))
369          (attachy (* dir 0.28))
370          (stemgl (and (> log 0)
371                       (ly:round-filled-box
372                        (cons attachx (+ attachx  stemth))
373                        (cons (min stemy attachy)
374                              (max stemy attachy))
375                        (/ stemth 3))))
376          (dot (ly:find-glyph-by-name font "dots-dot"))
377          (dotwid (interval-length (ly:stencil-extent dot X)))
378          (dots (and (> dot-count 0)
379                     (apply ly:stencil-add
380                            (map (lambda (x)
381                                   (ly:stencil-translate-axis
382                                    dot  (* (+ 1 (* 2 x)) dotwid) X) )
383                                 (iota dot-count 1)))))
384          (flaggl (and (> log 2)
385                       (ly:stencil-translate
386                        (ly:find-glyph-by-name font
387                                               (string-append "flags-"
388                                                              (if (> dir 0) "u" "d")
389                                                              (number->string log)))
390                        (cons (+ attachx (/ stemth 2)) stemy)))))
391     (if flaggl
392         (set! stemgl (ly:stencil-add flaggl stemgl)))
393     (if (ly:stencil? stemgl)
394         (set! stemgl (ly:stencil-add stemgl headgl))
395         (set! stemgl headgl))
396     (if (ly:stencil? dots)
397         (set! stemgl
398               (ly:stencil-add
399                (ly:stencil-translate-axis dots
400                                            (+ (if (and (> dir 0) (> log 2))
401                                                   (* 1.5 dotwid)
402                                                   0)
403                                               ;; huh ? why not necessary?
404                                               ;;(cdr (ly:stencil-extent headgl X))
405                                               dotwid)
406                                            X)
407                stemgl)))
408     stemgl))
409
410 (use-modules (ice-9 regex))
411
412 (define-public log2 
413   (let ((divisor (log 2)))
414     (lambda (z) (inexact->exact (/ (log z) divisor)))))
415
416 (define (parse-simple-duration duration-string)
417   "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
418   (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
419     (if (and match (string=? duration-string (match:substring match 0)))
420         (let ((len  (match:substring match 1))
421               (dots (match:substring match 2)))
422           (list (cond ((string=? len "breve")  -1)
423                       ((string=? len "longa")  -2)
424                       ((string=? len "maxima") -3)
425                       (else (log2 (string->number len))))
426                 (if dots (string-length dots) 0)))
427         (error "This is not a valid duration string:" duration-string))))
428
429 (def-markup-command (note paper props duration dir) (string? number?)
430   "This produces a note with a stem pointing in @var{dir} direction, with
431 the @var{duration} for the note head type and augmentation dots. For
432 example, @code{\\note #\"4.\" #-0.75} creates a dotted quarter note, with
433 a shortened down stem."
434   
435   (let ((parsed (parse-simple-duration duration)))
436     (note-by-number-markup paper props (car parsed) (cadr parsed) dir)))
437
438 (def-markup-command (normal-size-super paper props arg) (markup?)
439   "A superscript which does not use a smaller font."
440   
441   (ly:stencil-translate-axis (interpret-markup
442                                paper
443                                props arg)
444                               (* 0.5  (chain-assoc-get 'baseline-skip props))
445                               Y))
446
447 (def-markup-command (super paper props arg) (markup?)
448   "
449 @cindex raising text
450 @cindex lowering text
451 @cindex moving text
452 @cindex translating text
453
454 @cindex @code{\\super}
455
456
457 Raising and lowering texts can be done with @code{\\super} and
458 @code{\\sub}:
459
460 @lilypond[verbatim,fragment,relative=1]
461  c1^\\markup { E \"=\" mc \\super \"2\" }
462 @end lilypond
463
464 "
465   
466   (ly:stencil-translate-axis
467    (interpret-markup
468     paper
469     (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
470     arg)
471    (* 0.5 (chain-assoc-get 'baseline-skip props))
472    Y))
473
474 (def-markup-command (translate paper props offset arg) (number-pair? markup?)
475   "This translates an object. Its first argument is a cons of numbers
476 @example
477 A \\translate #(cons 2 -3) @{ B C @} D
478 @end example
479 This moves `B C' 2 spaces to the right, and 3 down, relative to its
480 surroundings. This command cannot be used to move isolated scripts
481 vertically, for the same reason that @code{\\raise} cannot be used for
482 that.
483
484 . "
485   (ly:stencil-translate (interpret-markup  paper props arg)
486                          offset))
487
488 (def-markup-command (sub paper props arg) (markup?)
489   "Set @var{arg} in subscript."
490   
491   (ly:stencil-translate-axis
492    (interpret-markup
493     paper
494     (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
495     arg)
496    (* -0.5 (chain-assoc-get 'baseline-skip props))
497    Y))
498
499 (def-markup-command (normal-size-sub paper props arg) (markup?)
500   "Set @var{arg} in subscript, in a normal font size."
501
502   (ly:stencil-translate-axis
503    (interpret-markup paper props arg)
504    (* -0.5 (chain-assoc-get 'baseline-skip props))
505    Y))
506
507 (def-markup-command (hbracket paper props arg) (markup?)
508   "Draw horizontal brackets around @var{arg}."  
509   (let ((th 0.1) ;; todo: take from GROB.
510         (m (interpret-markup paper props arg)))
511     (bracketify-stencil m X th (* 2.5 th) th)))
512
513 (def-markup-command (bracket paper props arg) (markup?)
514   "Draw vertical brackets around @var{arg}."  
515   (let ((th 0.1) ;; todo: take from GROB.
516         (m (interpret-markup paper props arg)))
517     (bracketify-stencil m Y th (* 2.5 th) th)))
518
519 ;; todo: fix negative space
520 (def-markup-command (hspace paper props amount) (number?)
521   "This produces a invisible object taking horizontal space.
522 @example 
523 \\markup @{ A \\hspace #2.0 B @} 
524 @end example
525 will put extra space between A and B, on top of the space that is
526 normally inserted before elements on a line.
527 "
528   (if (> amount 0)
529       (ly:make-stencil "" (cons 0 amount) '(-1 . 1) )
530       (ly:make-stencil "" (cons amount amount) '(-1 . 1))))
531
532 (def-markup-command (override paper props new-prop arg) (pair? markup?)
533   "Add the first argument in to the property list.  Properties may be
534 any sort of property supported by @internalsref{font-interface} and
535 @internalsref{text-interface}, for example
536
537 @verbatim
538 \\override #'(font-family . married) \"bla\"
539 @end verbatim
540
541 "
542   (interpret-markup paper (cons (list new-prop) props) arg))
543
544 (def-markup-command (smaller paper props arg) (markup?)
545   "Decrease the font size relative to current setting"
546   (let* ((fs (chain-assoc-get 'font-size props 0))
547          (entry (cons 'font-size (- fs 1))))
548     (interpret-markup paper (cons (list entry) props) arg)))
549
550
551 (def-markup-command (bigger paper props arg) (markup?)
552   "Increase the font size relative to current setting"
553   (let* ((fs (chain-assoc-get 'font-size props 0))
554          (entry (cons 'font-size (+ fs 1))))
555     (interpret-markup paper (cons (list entry) props) arg)))
556
557 (def-markup-command larger (markup?)
558   bigger-markup)
559
560 (def-markup-command (box paper props arg) (markup?)
561   "Draw a box round @var{arg}"
562   
563   (let ((th 0.1)
564         (pad 0.2)
565         (m (interpret-markup paper props arg)))
566     (box-stencil m th pad)))
567
568 (def-markup-command (strut paper props) ()
569   
570   "Create a box of the same height as the space in the current font.
571
572 FIXME: is this working? 
573 "
574   
575   (let ((m (Text_item::interpret_markup paper props " ")))
576     (ly:stencil-set-extent! m X '(1000 . -1000))
577     m))
578
579 (define number->mark-letter-vector (make-vector 25 #\A))
580
581 (do ((i 0 (1+ i))
582      (j 0 (1+ j)))
583     ((>= i 26))
584   (if (= i (- (char->integer #\I) (char->integer #\A)))
585       (set! i (1+ i)))
586   (vector-set! number->mark-letter-vector j
587                (integer->char (+ i (char->integer #\A)))))
588
589 (define (number->markletter-string n)
590   "Double letters for big marks."
591   (let*
592       ((l (vector-length number->mark-letter-vector)))
593     
594   (if (>= n l)
595       (string-append (number->markletter-string (1- (quotient n l)))
596                      (number->markletter-string (remainder n l)))
597       (make-string 1 (vector-ref number->mark-letter-vector n)))))
598
599
600 (def-markup-command (markletter paper props num) (integer?)
601    "Make a markup letter for @var{num}.  The letters start with A to Z
602  (skipping I), and continues with double letters."
603  
604    (Text_item::interpret_markup paper props (number->markletter-string num)))
605
606
607
608
609 (def-markup-command (bracketed-y-column paper props indices args)
610   (list? markup-list?)
611   "Make a column of the markups in @var{args}, putting brackets around
612 the elements marked in @var{indices}, which is a list of numbers."
613
614     (define (sublist l start stop)
615     (take (drop l start)  (- (1+ stop) start)) )
616
617   (define (stencil-list-extent ss axis)
618     (cons
619      (apply min (map (lambda (x) (car (ly:stencil-extent x axis))) ss))
620      (apply max (map (lambda (x) (cdr (ly:stencil-extent x axis))) ss))))
621             
622   (define (stack-stencils stencils bskip last-stencil)
623     (cond
624      ((null? stencils) '())
625      ((not last-stencil)
626       (cons (car stencils)
627             (stack-stencils (cdr stencils) bskip (car stencils))))
628      (else
629       (let*
630           ((orig (car stencils))
631            (dir (chain-assoc-get 'direction  props DOWN))
632            (new (ly:stencil-moved-to-edge last-stencil Y dir
633                                           orig
634                                           0.1 bskip))
635            )
636
637         (cons new (stack-stencils (cdr stencils) bskip new))))
638     ))
639
640   (define (make-brackets stencils indices acc)
641     (if (and stencils
642              (pair? indices)
643              (pair? (cdr indices)))
644         (let*
645             ((encl (sublist stencils (car indices) (cadr indices)))
646              (x-ext (stencil-list-extent encl X))
647              (y-ext (stencil-list-extent encl Y))
648              (thick 0.10)
649              (pad 0.35)
650              (protusion (* 2.5 thick))
651              (lb
652               (ly:stencil-translate-axis 
653                (ly:bracket Y y-ext thick protusion)
654                (- (car x-ext) pad) X))
655              (rb (ly:stencil-translate-axis
656                   (ly:bracket Y y-ext thick (- protusion))
657                   (+ (cdr x-ext) pad) X))
658              )
659
660           (make-brackets
661            stencils (cddr indices)
662            (append
663             (list lb rb)
664              acc)))
665         acc))
666
667   (let*
668       ((stencils
669         (map (lambda (x)
670                (interpret-markup
671                 paper
672                 props
673                 x)) args))
674        (leading
675          (chain-assoc-get 'baseline-skip props))
676        (stacked (stack-stencils stencils 1.25 #f))
677        (brackets (make-brackets stacked indices '()))
678        )
679
680     (apply ly:stencil-add
681            (append stacked brackets)
682            )))
683
684
685              
686
687   
688   
689
690