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