From 59983948f63c1faeee3615d6a277a3d97bf618b8 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 8 Dec 2002 23:01:01 +0000 Subject: [PATCH] use new syntax. --- ChangeLog | 19 ++++ input/regression/new-markup-syntax.ly | 4 + input/test/chord-markup.ly | 8 +- input/test/dynamic-extra.ly | 4 +- input/test/markup.ly | 70 ++++--------- input/test/metronome.ly | 12 ++- input/test/new-markup.ly | 15 --- input/test/script-priority.ly | 6 +- input/test/super-sub.ly | 32 ------ input/test/textscript.ly | 21 ++-- lily/molecule-scheme.cc | 16 ++- lily/parser.yy | 14 ++- ly/params-init.ly | 5 +- scm/new-markup.scm | 140 ++++++++++++++++++++------ tex/lilyponddefs.tex | 4 +- 15 files changed, 211 insertions(+), 159 deletions(-) delete mode 100644 input/test/new-markup.ly delete mode 100644 input/test/super-sub.ly diff --git a/ChangeLog b/ChangeLog index f49f6842a6..8433ef7762 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2002-12-09 Han-Wen Nienhuys + + * input/test/markup.ly: use new syntax. + +2002-12-08 Han-Wen Nienhuys + + * ly/params-init.ly (interscoreline): add word-space + + * input/test/metronome.ly (eighthNote): idem. + + * input/test/script-priority.ly: use new markup + + * lily/parser.yy (markup): allow HEAD markup0 markup1 + + * lily/molecule-scheme.cc (ly:molecule-translate): new function. + + * lily/parser.yy (gen_text_def): bugfix. + (full_markup): allow markup identifier. + 2002-12-09 Heikki Junes * lilypond-mode.el (LilyPond-kill-job): Kill all Lilypond compiling diff --git a/input/regression/new-markup-syntax.ly b/input/regression/new-markup-syntax.ly index b9a482aef6..9235105a2b 100644 --- a/input/regression/new-markup-syntax.ly +++ b/input/regression/new-markup-syntax.ly @@ -17,6 +17,10 @@ texidoc = "New markup syntax." \lookup #"noteheads-0" \char #53 } + + \combine "X" "+" + \combine "o" "/" + "$\\emptyset$" \italic Norsk \dynamic sfzp } diff --git a/input/test/chord-markup.ly b/input/test/chord-markup.ly index e60b94d751..8304d904e5 100644 --- a/input/test/chord-markup.ly +++ b/input/test/chord-markup.ly @@ -8,14 +8,14 @@ \score{ < \context Staff \notes \relative c'' { - c^#'(columns "foe" ((raise . 3) "bar")) + c^\markup { "foe" \raise #3 "bar" } c - c^#'(columns "foe" (super "12") (sub "3 4")) + c^\markup { "foe" \super "12" \sub { "3 4" } } c %% broken for now - %% c^#`(columns (lines "" ";" "") (lines "1" (bold "2") "3")) - c^#`(columns (lines "" ";" "") (lines "1" (columns (bold "2")) "3")) + c^\markup { \column < "" ";" "" > + \column < "1" { \bold "2" "3" } > } } \context ChordNames \chords { c:7+.9-^3.5 diff --git a/input/test/dynamic-extra.ly b/input/test/dynamic-extra.ly index 8bc998acb9..552a5ddd29 100644 --- a/input/test/dynamic-extra.ly +++ b/input/test/dynamic-extra.ly @@ -3,12 +3,10 @@ texidoc = "Additional tricks for dynamics. Pi`u forte dynamic script" } -piuf = #'(columns (italic "pi\\`u") " " (dynamic "f")) +piuf = \markup { \italic "pi\\`u" \dynamic "f" } \score{ \notes\relative c''{ - c4-#'(italic "pi\\`u")-\f - c-#'(columns (italic "pi\\`u") " " (dynamic "f")) c-\piuf c c2\< \! c2 diff --git a/input/test/markup.ly b/input/test/markup.ly index 45ae734ef8..2e5fcab5e7 100644 --- a/input/test/markup.ly +++ b/input/test/markup.ly @@ -1,65 +1,37 @@ \version "1.7.6" \header { - texidoc ="Test font selection and scm text markup" + texidoc ="Test font selection and scm text markup +" } \score{ \notes\relative c''{ \stemUp - % { a-"text" - b-#"texta" - c-#'(bold "textb") + b-"texta" + c-\markup \bold "textb" + + d-\markup { "one" "two" "three" } | + e1-\markup { \column < \bold "one" + { "and" "there" "is" \override #'(font-family . number) "2" } + \italic "three" > } + e2. + f4-\markup \teeny \number "3" + f2. + b4-\markup { "a" \hspace #-8 \raise #2 "b" "c" } + b4-\markup { "1" \raise #-2 \hspace #-1 "2" "3" } + d4-\markup { \column < "Violoncello" " e" "Contrabasso" > } + d4_\markup {\override #'(baseline-skip . 0.0) + \override #'(word-space . 1.5) + \column < "Violoncello" " e" "Contrabasso" > } - d-#'(lines "one" "two" "three") - e-#'(lines (bold "one") - (columns "and" "there" "is" ((font-family . number) "2")) - (italic "three")) - f-#'(finger "3") - g-#'(music (named "noteheads-2" - ((kern . -0.1) "flags-stem") - (((kern . -0.1) (raise . 3.5)) "flags-u3"))) - b-#'(columns "a" (((kern . 3) (raise . 2)) "b") "c") - c-#'(columns "1" (((raise . -2) (kern . -1)) "2") "3") - % } - d-#'(lines "Violoncello" " e" "Contrabasso") - e-#'((lines (baselineskip . 0) (kern . 1.5)) "Violoncello" " e" "Contrabasso") - e-#'(((baselineskip . 0) (kern . 1.5) lines) "Violoncello" " e" "Contrabasso") - g-"ÅÖÄÜÇÕ" - c,, - c1 c1 - - \stemUp - c4^#'(lines "1" "" "2") - c^#'(lines "3" "4" "5") - \stemDown - c_#'(lines "6" "" "7") - c_#'(lines "8" "9" "0") - \stemUp - c4^#'(lines "1" "") - c^#'(lines "2" "3") - \stemDown - c_#'(lines "" "4") - c_#'(lines "5" "6") + g1-"ÅÖÄÜÇÕ" + c,, + c1 - c^#'(columns "foe" ((raise . 3) "bar")) - c^#'(columns "foe" (super "12") (sub "3 4")) - %% UGHUGH - c^#'(columns "foe" (super ((raise . 1) "12")) (sub ((raise . -1) "3 4"))) - c^#'(columns "foe" (super (overstrike "o") "/") (sub "x")) - c^#'(columns "foe" (overstrike "o") "/") - c^#'(columns "foe" ((bold roman overstrike) "o") "/") - c^#'(columns "foe" ((extent . (0 . 0)) "o") "/") - c^#'(columns "foo" (super "bar" (super "baz"))) - c - %% c^#`(columns (lines "" ";" "") (lines "1" ((bold) "2") "3")) - c^#`(columns (lines "" ";" "") (lines "1" "2" "3")) - c^#`(columns (lines "" ";" "") (lines "1" (bold "2") "3")) - c^#`(columns (lines "" ";" "") (lines "1" (columns (bold "2")) "3")) - } \paper{ diff --git a/input/test/metronome.ly b/input/test/metronome.ly index 65fd4ee4dc..3325a056f6 100644 --- a/input/test/metronome.ly +++ b/input/test/metronome.ly @@ -13,13 +13,17 @@ % % FIXME: put in an item, and typeset by an engraver. -#(define note '(columns (music "noteheads-2" ((kern . -0.1) "flags-stem")))) -#(define eight-note `(columns ,note ((kern . -0.1) (music ((raise . 3.5) "flags-u3"))))) -#(define dotted-eight-note `(columns ,eight-note (music "dots-dot"))) +eigthStem = \markup \combine + \musicglyph #"flags-stem" + \translate #'(0.0 . 3.5) \musicglyph #"flags-u3" +eighthNote = \markup + \override #'(word-space . 0.0) + { \musicglyph #"noteheads-2" + \translate #'(-0.05 . 0.1) \eigthStem } \score { \notes\relative c'' { - a1^#`((columns (font-relative-size . -1)) ,dotted-eight-note " = 64") + a1^\markup { \magnify #0.9 \eighthNote " = 64" } } \paper { linewidth = -1. diff --git a/input/test/new-markup.ly b/input/test/new-markup.ly deleted file mode 100644 index 3dca2cd8eb..0000000000 --- a/input/test/new-markup.ly +++ /dev/null @@ -1,15 +0,0 @@ -\version "1.7.7" -\header { - texidoc =" New markup scheme. Semantically more sane. We haven't - invented a nice syntax yet." -} - -\score { - \notes \context Voice { - \property Voice.TextScript \set #'molecule-callback = #brew-new-markup-molecule - c4^#`(,simple-markup "foo") - c4^#`(,column-markup ( - (,bold-markup (,simple-markup "foo")) - (,simple-markup "bar"))) - } -} diff --git a/input/test/script-priority.ly b/input/test/script-priority.ly index 7f4606d5c5..62be41769f 100644 --- a/input/test/script-priority.ly +++ b/input/test/script-priority.ly @@ -4,17 +4,19 @@ by overriding script-priority." } \paper { linewidth = -1. } + \score{ \context Staff \notes \relative g''{ \property Score.TextScript \override #'script-priority = #-100 - a4^\prall^#'((music (font-relative-size . -2)) "accidentals-1") + a4^\prall^\markup \fontsize #-2 \musicglyph #"accidentals-1" \property Score.Script \override #'script-priority = #-100 \property Score.TextScript \revert #'script-priority - a4^\prall^#'((music (font-relative-size . -2)) "accidentals-1") + a4^\prall^\markup \fontsize #-2 \musicglyph #"accidentals-1" } } + %% new-chords-done %% diff --git a/input/test/super-sub.ly b/input/test/super-sub.ly deleted file mode 100644 index d68dba83ec..0000000000 --- a/input/test/super-sub.ly +++ /dev/null @@ -1,32 +0,0 @@ -\version "1.7.6" -\header { -texidoc="Test super/sub, raise and overstrike." -} - - - -\score { - \notes \relative a'' { - c^#'("bar") - c^#'(("bar")) - c^#'((("bar"))) - c^#'(bold "bar") - c^#'((bold) "bar") - c^#'(((bold)) "bar") - c^#'(bold ("bar")) - c^#'(bold "bar") - c^#'(columns "foe" ((raise . 3) "bar")) - c^#'(columns "foe" (((raise . 3) "bar"))) - c^#'(columns "foe" (((raise . 3)) "bar")) - c^#'(columns "foe" (super "12") (sub "3 4")) - c^#'(columns "foe" (super (overstrike "o") "/") (sub "x")) - c^#'(columns "foe" (overstrike "o") "/") - c^#'(columns "foe" ((bold roman overstrike) "o") "/") - c^#'(columns "foe" ((extent . (0 . 0)) "o") "/") - c^#'(columns "foo" (super "bar" (super "baz"))) - c - %% Hmm - c^#`(columns (lines "" ";" "") (lines "1" ((bold) "2") "3")) - c^#`(columns (lines "" ";" "") (lines "1" (columns (bold "2")) "3")) - } -}%% new-chords-done %% diff --git a/input/test/textscript.ly b/input/test/textscript.ly index 96efbdd31d..753a10fd00 100644 --- a/input/test/textscript.ly +++ b/input/test/textscript.ly @@ -1,23 +1,16 @@ \version "1.7.6" - - -% -% Test font selection and scm text markup -% +\header { +texidoc = "Test font selection and scm text markup" +} \score{ \notes\relative c''{ - c'1^#'(columns (dynamic "p") " ma sosten.") - c^#'(bold "ABCD") - c^#'(columns "Dal " (music "scripts-segno")) - c^#'(Large "ABCD") - \break \property Voice . TextScript \override #'font-shape = #'upright - c1^#'(columns (dynamic "p") " ma sosten.") - c^#'(bold "ABCD") + c1^\markup { \dynamic "p" "ma sosten." } + c^\markup \Large "ABCD" \property Voice . TextScript \override #'font-series = #'bold - c^#'(columns "Dal " (music "scripts-segno")) - c^#'(Large "ABCD") + c^\markup { \bold "Dal" " " \raise #0.8 \musicglyph #"scripts-segno" } + c^\markup \huge "ABCD" } } %% new-chords-done %% diff --git a/lily/molecule-scheme.cc b/lily/molecule-scheme.cc index 353b9a589d..312de70b1e 100644 --- a/lily/molecule-scheme.cc +++ b/lily/molecule-scheme.cc @@ -30,7 +30,7 @@ LY_DEFINE(ly_set_molecule_extent_x,"ly:set-molecule-extent!", 3 , 0, 0, } -LY_DEFINE(ly_translate_molecule,"ly:molecule-translate-axis", 3, 0, 0, +LY_DEFINE(ly_translate_molecule_axis,"ly:molecule-translate-axis", 3, 0, 0, (SCM mol, SCM amount, SCM axis), "Return a @var{mol}, but translated by @var{amount} in @var{axis} direction") { @@ -46,6 +46,20 @@ LY_DEFINE(ly_translate_molecule,"ly:molecule-translate-axis", 3, 0, 0, return q.smobbed_copy(); } +LY_DEFINE(ly_translate_molecule,"ly:molecule-translate", 2, 0, 0, + (SCM mol, SCM offset), + "Return a @var{mol}, but translated by @var{offset} (a pair of numbers).") +{ + Molecule* m = unsmob_molecule (mol); + SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "molecule"); + SCM_ASSERT_TYPE (ly_number_pair_p (offset), offset, SCM_ARG2, __FUNCTION__, "number pair"); + Offset o = ly_scm2offset (offset); + + Molecule q (*m); + q.translate (o); + return q.smobbed_copy(); +} + LY_DEFINE(ly_get_molecule_extent, "ly:get-molecule-extent", 2 , 0, 0, (SCM mol, SCM axis), "Return a pair of numbers signifying the extent of @var{mol} in " diff --git a/lily/parser.yy b/lily/parser.yy index 174e84ac2c..3483bbc3f6 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1648,7 +1648,11 @@ gen_text_def: $$ = t; } | string { - $$ = make_simple_markup ($1); + Music *t = MY_MAKE_MUSIC("TextScriptEvent"); + t->set_mus_property ("text", make_simple_markup ($1)); + t->set_spot (THIS->here_input ()); + $$ = t; + } | DIGIT { Music * t = MY_MAKE_MUSIC("FingerEvent"); @@ -2169,7 +2173,10 @@ questions: full_markup: - MARKUP + MARKUP_IDENTIFIER { + $$ = $1; + } + | MARKUP { THIS->lexer_->push_markup_state (); } markup { $$ = $3; @@ -2184,6 +2191,9 @@ markup: | MARKUP_HEAD_MARKUP0 markup { $$ = scm_list_n ($1, $2, SCM_UNDEFINED); } + | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup { + $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED); + } | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup { $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED); } diff --git a/ly/params-init.ly b/ly/params-init.ly index 555a5dd71b..e45871fd43 100644 --- a/ly/params-init.ly +++ b/ly/params-init.ly @@ -53,13 +53,14 @@ interscoreline = 4. \mm %% -%% TODO: baseline-skip should come from the font. +%% TODO: baseline-skip, word-space should come from the font. %% #(define font-defaults '((font-family . music) (font-relative-size . 0) (font-shape . upright) - (baseline-skip . 2) + (baseline-skip . 2) + (word-space . 0.6) (font-series . medium) )) diff --git a/scm/new-markup.scm b/scm/new-markup.scm index 5f90f7f3e0..7e3b37b635 100644 --- a/scm/new-markup.scm +++ b/scm/new-markup.scm @@ -2,9 +2,26 @@ (Text_item::text_to_molecule grob props (car rest)) ) +(define-public (stack-molecule-line space molecules) + (if (pair? molecules) + (if (pair? (cdr molecules)) + (let* ( + (tail (stack-molecule-line space (cdr molecules))) + (head (car molecules)) + (xoff (+ space (cdr (ly:get-molecule-extent head X)))) + ) + + (ly:add-molecule + head + (ly:molecule-translate-axis tail xoff X)) + ) + (car molecules)) + '()) + ) + (define-public (line-markup grob props . rest) - (stack-molecules - X 1 1.0 + (stack-molecule-line + (cdr (chain-assoc 'word-space props)) (map (lambda (x) (interpret-markup grob props x)) (car rest))) ) @@ -14,7 +31,11 @@ )) (define-public (combine-markup grob props . rest) - (combine-molecule-list (map (lambda (x) (interpret-markup grob props x)) (car rest)))) + (ly:add-molecule + (interpret-markup grob props (car rest)) + (interpret-markup grob props (cadr rest)))) + +; (combine-molecule-list (map (lambda (x) (interpret-markup grob props x)) (car rest)))) (define (font-markup qualifier value) (lambda (grob props . rest) @@ -22,15 +43,35 @@ )) -(define-public (magnify-markup grob props . rest ) - (interpret-markup grob - (cons (cons `(font-magnification . ,(car rest)) - (car props)) (cdr props)) - (cadr rest)) - ) + +(define-public (set-property-markup qualifier) + (lambda (grob props . rest ) + (interpret-markup grob + (cons (cons `(,qualifier . ,(car rest)) + (car props)) (cdr props)) + (cadr rest)) + )) + + +(define-public fontsize-markup (set-property-markup 'font-relative-size)) +(define-public magnify-markup (set-property-markup 'font-magnification)) (define-public bold-markup (font-markup 'font-series 'bold)) +(define-public number-markup + (font-markup 'font-family 'number)) + + +(define-public huge-markup + (font-markup 'font-relative-size 2)) +(define-public large-markup + (font-markup 'font-relative-size 1)) +(define-public small-markup + (font-markup 'font-relative-size -1)) +(define-public tiny-markup + (font-markup 'font-relative-size -2)) +(define-public teeny-markup + (font-markup 'font-relative-size -3)) (define-public dynamic-markup (font-markup 'font-family 'dynamic)) (define-public italic-markup @@ -44,7 +85,7 @@ (map (lambda (x) (interpret-markup grob props x)) (car rest))) ) -(define-public (music-markup grob props . rest) +(define-public (musicglyph-markup grob props . rest) (ly:find-glyph-by-name (ly:get-font grob (cons '((font-family . music)) props)) (car rest)) @@ -58,19 +99,47 @@ ) (define-public (char-markup grob props . rest) + "Syntax: \\char NUMBER. " (ly:get-glyph (ly:get-font grob props) (car rest)) ) (define-public (raise-markup grob props . rest) + "Syntax: \\raise AMOUNT MARKUP. " (ly:molecule-translate-axis (interpret-markup grob props (cadr rest)) (car rest) Y) ) -;; this is too simplistic: doesn't do backup for negative dimensions. -(define (hspace-markup grob props . rest) - (ly:make-molecule "" (cons 0 (car rest)) '(-1 . 1) ) +(define-public (super-markup grob props . rest) + "Syntax: \\super MARKUP. " + (ly:molecule-translate-axis (interpret-markup grob props (car rest)) + (* 0.5 (cdr (chain-assoc 'baseline-skip props))) + Y) ) +(define-public (translate-markup grob props . rest) + "Syntax: \\translate OFFSET MARKUP. " + (ly:molecule-translate (interpret-markup grob props (cadr rest)) + (car rest)) + + ) + +(define-public (sub-markup grob props . rest) + "Syntax: \\sub MARKUP." + (ly:molecule-translate-axis (interpret-markup grob props (car rest)) + (* -0.5 (cdr (chain-assoc 'baseline-skip props))) + Y) + ) + +;; todo: fix negative space +(define (hspace-markup grob props . rest) + "Syntax: \\hspace NUMBER." + (let* + ((amount (car rest))) + (if (> amount 0) + (ly:make-molecule "" (cons 0 amount) '(-1 . 1) ) + (ly:make-molecule "" (cons amount amount) '(-1 . 1))) + )) + (define-public (override-markup grob props . rest) "Tack the 1st args in REST onto PROPS." (interpret-markup grob (cons (list (car rest)) props) @@ -79,21 +148,36 @@ (map (lambda (x) (set-object-property! (car x) 'markup-signature (cdr x)) ) - (list (cons bold-markup 'markup0) - (cons column-markup 'markup-list0) - (cons line-markup 'markup-list0) - (cons combine-markup 'markup0-markup1) - (cons simple-markup 'markup0) - (cons music-markup 'scm0) - (cons override-markup 'scm0-markup1) - (cons lookup-markup 'scm0) - (cons raise-markup 'scm0-markup1) - (cons italic-markup 'markup0) - (cons dynamic-markup 'markup0) - (cons char-markup 'scm0) - (cons hspace-markup 'scm0) - (cons magnify-markup 'scm0-markup1) - )) + (list + (cons bold-markup 'markup0) + (cons teeny-markup 'markup0) + (cons tiny-markup 'markup0) + (cons small-markup 'markup0) + (cons italic-markup 'markup0) + (cons dynamic-markup 'markup0) + (cons large-markup 'markup0) + (cons huge-markup 'markup0) + (cons sub-markup 'markup0) + (cons super-markup 'markup0) + (cons number-markup 'markup0) + + (cons column-markup 'markup-list0) + (cons line-markup 'markup-list0) + + (cons combine-markup 'markup0-markup1) + + (cons simple-markup 'markup0) + (cons musicglyph-markup 'scm0) + (cons translate-markup 'scm0-markup1) + (cons override-markup 'scm0-markup1) + (cons lookup-markup 'scm0) + (cons raise-markup 'scm0-markup1) + (cons char-markup 'scm0) + (cons hspace-markup 'scm0) + (cons magnify-markup 'scm0-markup1) + (cons fontsize-markup 'scm0-markup1) + (cons translate-markup 'scm0-markup1) + )) (define markup-module (current-module)) diff --git a/tex/lilyponddefs.tex b/tex/lilyponddefs.tex index 8f6bae4167..880545417f 100644 --- a/tex/lilyponddefs.tex +++ b/tex/lilyponddefs.tex @@ -123,8 +123,6 @@ \lilypondnext } -\newread\lilypondinput - % the following macro is executed only once \gdef\lilypondspecial{ \special{header=music-drawing-routines.ps} @@ -189,7 +187,7 @@ {\input lily-ps-defs } { \pdfoutput = 1 - \input lily-pdf-defs + \input lily-pdf-defs % } } {} -- 2.39.5