]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-markup-commands.scm
Web: remove non-Free software from Easier Editing
[lilypond.git] / scm / define-markup-commands.scm
index aa022974e38adaa9637d5d1c512d12bb3e54b6f7..0f5329658430ebd23b7efb41f20e81348126b6f4 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; This file is part of LilyPond, the GNU music typesetter.
 ;;;;
-;;;; Copyright (C) 2000--2011  Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;; Copyright (C) 2000--2012  Han-Wen Nienhuys <hanwen@xs4all.nl>
 ;;;;                  Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;;
 ;;;; LilyPond is free software: you can redistribute it and/or modify
@@ -249,7 +249,7 @@ the PDF backend.
 
 @lilypond[verbatim,quote]
 \\markup {
-  \\with-url #\"http://lilypond.org/web/\" {
+  \\with-url #\"http://lilypond.org/\" {
     LilyPond ... \\italic {
       music notation for everyone
     }
@@ -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... }
   }
 }
@@ -1967,53 +1967,43 @@ The footnote will not be annotated automatically."
 @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
@@ -2153,16 +2143,18 @@ Adjusts @code{baseline-skip} and @code{word-space} accordingly.
 }
 @end lilypond"
   (let* ((ref-size (ly:output-def-lookup layout 'text-font-size 12))
-        (text-props (list (ly:output-def-lookup layout 'text-font-defaults)))
-        (ref-word-space (chain-assoc-get 'word-space text-props 0.6))
-        (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)))
+         (text-props (list (ly:output-def-lookup layout 'text-font-defaults)))
+         (ref-word-space (chain-assoc-get 'word-space text-props 0.6))
+         (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)))
 
 (define-markup-command (fontsize layout props increment arg)
   (number? markup?)
@@ -2181,11 +2173,14 @@ accordingly.
   smaller
 }
 @end lilypond"
-  (let ((entries (list
-                  (cons 'baseline-skip (* baseline-skip (magstep increment)))
-                  (cons 'word-space (* word-space (magstep increment)))
-                  (cons 'font-size (+ font-size increment)))))
-    (interpret-markup layout (cons entries props) arg)))
+  (interpret-markup
+   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?)
@@ -3690,6 +3685,28 @@ Patterns are aligned to the @var{dir} markup.
                               #:pattern (1+ count) X space pattern
                               right))))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Replacements
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define-markup-command (replace layout props replacements arg)
+  (list? markup?)
+  #:category font
+  "
+Used to automatically replace a string by another in the markup @var{arg}.
+Each pair of the alist @var{replacements} specifies what should be replaced.
+The @code{key} is the string to be replaced by the @code{value} string.
+
+@lilypond[verbatim, quote]
+\\markup \\replace #'((\"thx\" . \"Thanks!\")) thx
+@end lilypond"
+  (interpret-markup
+   layout
+   (internal-add-text-replacements
+    props
+    replacements)
+   (markup arg)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Markup list commands
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;