X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fdefine-markup-commands.scm;h=858ea7f3a55330c68ac35ffececb45824bcd1d74;hb=4493eb4584f92123ebacf51541ace8c0e20f5e5a;hp=76d8f2441ad0207ba7e7d85af1c0263e609eeb46;hpb=60b4f9c7372dbed592f8c3b592d19872fad8adda;p=lilypond.git diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 76d8f2441a..858ea7f3a5 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -1,6 +1,6 @@ ;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; Copyright (C) 2000--2011 Han-Wen Nienhuys +;;;; Copyright (C) 2000--2012 Han-Wen Nienhuys ;;;; Jan Nieuwenhuizen ;;;; ;;;; LilyPond is free software: you can redistribute it and/or modify @@ -297,7 +297,7 @@ only works in the PDF backend. @lilypond[verbatim,quote] \\markup { - \\with-link #\"label\" { + \\with-link #'label { \\italic { This links to the page containing the label... } } } @@ -940,7 +940,7 @@ Like simple-markup, but use tie characters for @q{~} tilde symbols. \\markup \\column { \\tied-lyric #\"Siam navi~all'onde~algenti Lasciate~in abbandono\" \\tied-lyric #\"Impetuosi venti I nostri~affetti sono\" - \\tied-lyric #\"Ogni diletto~è scoglio Tutta la vita~è~un mar.\" + \\tied-lyric #\"Ogni diletto~e scoglio Tutta la vita~e~un mar.\" } @end lilypond" (define (replace-ties tie str) @@ -956,40 +956,26 @@ Like simple-markup, but use tie characters for @q{~} tilde symbols. str)) (define short-tie-regexp (make-regexp "~[^.]~")) - (define long-tie-regexp (make-regexp "\\w{3,}+~+\\w{3,}")) (define (match-short str) (regexp-exec short-tie-regexp str)) - (define (match-long str) (regexp-exec long-tie-regexp str)) (define (replace-short str mkp) (let ((match (match-short str))) (if (not match) (make-concat-markup (list mkp - (replace-ties "ties.lyric.medium" str))) + (replace-ties "ties.lyric.default" str))) (let ((new-str (match:suffix match)) (new-mkp (make-concat-markup (list mkp - (replace-ties "ties.lyric.medium" + (replace-ties "ties.lyric.default" (match:prefix match)) (replace-ties "ties.lyric.short" (match:substring match)))))) (replace-short new-str new-mkp))))) - (define (replace-long str mkp) - (let ((match (match-long str))) - (if (not match) - (replace-short str mkp) - (let ((new-str (match:suffix match)) - (new-mkp (make-concat-markup (list - (replace-short (match:prefix match) - mkp) - (replace-ties "ties.lyric.long" - (match:substring match)))))) - (replace-long new-str new-mkp))))) - (interpret-markup layout props - (replace-long str (markup)))) + (replace-short str (markup)))) (define-public empty-markup (make-simple-markup "")) @@ -1897,6 +1883,14 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction. ;; property ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define-markup-command (property-recursive layout props symbol) + (symbol?) + #:category other + "Print out a warning when a header field markup contains some recursive +markup definition." + (ly:warning "Recursive definition of property ~a detected!" symbol) + empty-stencil) + (define-markup-command (fromproperty layout props symbol) (symbol?) #:category other @@ -1919,11 +1913,12 @@ returns an empty markup. @end lilypond" (let ((m (chain-assoc-get symbol props))) (if (markup? m) - (interpret-markup layout props m) + ;; prevent infinite loops by clearing the interpreted property: + (interpret-markup layout (cons (list (cons symbol `(,property-recursive-markup ,symbol))) props) m) empty-stencil))) (define-markup-command (on-the-fly layout props procedure arg) - (symbol? markup?) + (procedure? markup?) #:category other "Apply the @var{procedure} markup command to @var{arg}. @var{procedure} should take a single argument." @@ -1934,6 +1929,29 @@ returns an empty markup. (interpret-markup layout props (list anonymous-with-signature arg)))) (define-markup-command (footnote layout props mkup note) + (markup? markup?) + #:category other + "Have footnote @var{note} act as an annotation to the markup @var{mkup}. + +@lilypond[verbatim,quote] +\\markup { + \\auto-footnote a b + \\override #'(padding . 0.2) + \\auto-footnote c d +} +@end lilypond +The footnote will not be annotated automatically." + (ly:stencil-combine-at-edge + (interpret-markup layout props mkup) + X + RIGHT + (ly:make-stencil + `(footnote (gensym "footnote") #f ,(interpret-markup layout props note)) + '(0 . 0) + '(0 . 0)) + 0.0)) + +(define-markup-command (auto-footnote layout props mkup note) (markup? markup?) #:category other #:properties ((raise 0.5) @@ -1942,59 +1960,50 @@ returns an empty markup. @lilypond[verbatim,quote] \\markup { - \\footnote a b + \\auto-footnote a b \\override #'(padding . 0.2) - \\footnote c d + \\auto-footnote c d } -@end lilypond" +@end lilypond +The footnote will be annotated automatically." (let* ((markup-stencil (interpret-markup layout props mkup)) - (auto-numbering (ly:output-def-lookup layout - 'footnote-auto-numbering)) (footnote-hash (gensym "footnote")) (stencil-seed 0) - (gauge-stencil (if auto-numbering - (interpret-markup - layout - props - ((ly:output-def-lookup - layout - 'footnote-numbering-function) - stencil-seed)) - empty-stencil)) - (x-ext (if auto-numbering - (ly:stencil-extent gauge-stencil X) - '(0 . 0))) - (y-ext (if auto-numbering - (ly:stencil-extent gauge-stencil Y) - '(0 . 0))) + (gauge-stencil (interpret-markup + layout + props + ((ly:output-def-lookup + layout + 'footnote-numbering-function) + stencil-seed))) + (x-ext (ly:stencil-extent gauge-stencil X)) + (y-ext (ly:stencil-extent gauge-stencil Y)) (footnote-number - (if auto-numbering - `(delay-stencil-evaluation - ,(delay - (ly:stencil-expr - (let* ((table - (ly:output-def-lookup layout - 'number-footnote-table)) - (footnote-stencil (if (list? table) - (assoc-get footnote-hash - table) - empty-stencil)) - (footnote-stencil (if (ly:stencil? footnote-stencil) - footnote-stencil - (begin - (ly:programming-error + `(delay-stencil-evaluation + ,(delay + (ly:stencil-expr + (let* ((table + (ly:output-def-lookup layout + 'number-footnote-table)) + (footnote-stencil (if (list? table) + (assoc-get footnote-hash + table) + empty-stencil)) + (footnote-stencil (if (ly:stencil? footnote-stencil) + footnote-stencil + (begin + (ly:programming-error "Cannot find correct footnote for a markup object.") - empty-stencil))) - (gap (- (interval-length x-ext) - (interval-length - (ly:stencil-extent footnote-stencil X)))) - (y-trans (- (+ (cdr y-ext) - raise) - (cdr (ly:stencil-extent footnote-stencil - Y))))) - (ly:stencil-translate footnote-stencil - (cons gap y-trans)))))) - '())) + empty-stencil))) + (gap (- (interval-length x-ext) + (interval-length + (ly:stencil-extent footnote-stencil X)))) + (y-trans (- (+ (cdr y-ext) + raise) + (cdr (ly:stencil-extent footnote-stencil + Y))))) + (ly:stencil-translate footnote-stencil + (cons gap y-trans))))))) (main-stencil (ly:stencil-combine-at-edge markup-stencil X @@ -2004,7 +2013,7 @@ returns an empty markup. (ly:stencil-add main-stencil (ly:make-stencil - `(footnote ,footnote-hash ,(interpret-markup layout props note)) + `(footnote ,footnote-hash #t ,(interpret-markup layout props note)) '(0 . 0) '(0 . 0))))) @@ -2139,13 +2148,13 @@ Adjusts @code{baseline-skip} and @code{word-space} accordingly. (ref-baseline (chain-assoc-get 'baseline-skip text-props 3)) (magnification (/ size ref-size))) (interpret-markup - layout - (cons - `((baseline-skip . ,(* magnification ref-baseline)) - (word-space . ,(* magnification ref-word-space)) - (font-size . ,(magnification->font-size magnification))) - props) - arg))) + layout + (cons + `((baseline-skip . ,(* magnification ref-baseline)) + (word-space . ,(* magnification ref-word-space)) + (font-size . ,(magnification->font-size magnification))) + props) + arg))) (define-markup-command (fontsize layout props increment arg) (number? markup?) @@ -2165,13 +2174,13 @@ accordingly. } @end lilypond" (interpret-markup - layout - (cons - `((baseline-skip . ,(* baseline-skip (magstep increment))) - (word-space . ,(* word-space (magstep increment))) - (font-size . ,(+ font-size increment))) - props) - arg)) + layout + (cons + `((baseline-skip . ,(* baseline-skip (magstep increment))) + (word-space . ,(* word-space (magstep increment))) + (font-size . ,(+ font-size increment))) + props) + arg)) (define-markup-command (magnify layout props sz arg) (number? markup?) @@ -3692,11 +3701,11 @@ The @code{key} is the string to be replaced by the @code{value} string. \\markup \\replace #'((\"thx\" . \"Thanks!\")) thx @end lilypond" (interpret-markup - layout - (internal-add-text-replacements - props - replacements) - (markup arg))) + layout + (internal-add-text-replacements + props + replacements) + (markup arg))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Markup list commands