From 583f99188b734a56ec239687e117fc5d8299546d Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 20 Jun 2004 21:13:27 +0000 Subject: [PATCH] * lily/stencil.cc (interpret_stencil_expression): add grob-cause stencil expression. Junk define-origin. * scm/lily.scm (collect-scores-for-book): new function. * ly/init.ly: print collected scores/musics. --- ChangeLog | 3 +++ lily/grob.cc | 19 ++----------------- lily/stencil.cc | 29 +++++++++++------------------ ly/init.ly | 1 + scm/lily.scm | 6 +++--- scm/output-ps.scm | 9 ++++----- scm/output-tex.scm | 25 ++++++++++++++++++++----- 7 files changed, 44 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index e220bc8905..5032c50a36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2004-06-20 Han-Wen Nienhuys + * lily/stencil.cc (interpret_stencil_expression): add grob-cause + stencil expression. Junk define-origin. + * lily/my-lily-parser.cc (parse_string): init parser variable when lexer_ is set, ie. in parse_string and parse_file. diff --git a/lily/grob.cc b/lily/grob.cc index 4775770663..a2f74e1040 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -237,23 +237,8 @@ Grob::get_uncached_stencil ()const mol = Stencil (m->extent_box (), SCM_EOL).smobbed_copy (); else { - SCM origin = ly_symbol2scm ("no-origin"); - - if (store_locations_global_b) - { - SCM cause = get_property ("cause"); - if (Music*m = unsmob_music (cause)) - { - SCM music_origin = m->get_property ("origin"); - if (unsmob_input (music_origin)) - origin = music_origin; - } - } - - // ugr. - mol = Stencil (m->extent_box (), - scm_list_n (origin, m->expr (), SCM_UNDEFINED) - ). smobbed_copy (); + SCM expr = scm_list_3 (ly_symbol2scm ("grob-cause"), self_scm(), m->expr ()); + mol = Stencil (m->extent_box (),expr). smobbed_copy (); } } diff --git a/lily/stencil.cc b/lily/stencil.cc index 3d7420efac..e81e228bed 100644 --- a/lily/stencil.cc +++ b/lily/stencil.cc @@ -201,24 +201,9 @@ interpret_stencil_expression (SCM expr, if (!ly_c_pair_p (expr)) return; - SCM head =ly_car (expr); - if (unsmob_input (head)) - { - Input *ip = unsmob_input (head); - (*func) (func_arg, - scm_list_4 (ly_symbol2scm ("define-origin"), - scm_makfrom0str (ip->file_string () - .to_str0 ()), - scm_int2num (ip->line_number ()), - scm_int2num (ip->column_number ()))); - expr = ly_cadr (expr); - } - else if (head == ly_symbol2scm ("no-origin")) - { - (*func) (func_arg, scm_list_1 (head)); - expr = ly_cadr (expr); - } - else if (head == ly_symbol2scm ("translate-stencil")) + SCM head = ly_car (expr); + + if (head == ly_symbol2scm ("translate-stencil")) { o += ly_scm2offset (ly_cadr (expr)); expr = ly_caddr (expr); @@ -229,6 +214,14 @@ interpret_stencil_expression (SCM expr, interpret_stencil_expression (ly_car (x), func, func_arg, o); return; } + else if (head == ly_symbol2scm ("grob-cause")) + { + SCM grob = ly_cadr (expr); + + (*func) (func_arg, scm_list_2 (head, grob)); + interpret_stencil_expression (ly_caddr (expr), func, func_arg, o); + (*func) (func_arg, scm_list_1 (ly_symbol2scm ("no-origin"))); + } else { (*func) (func_arg, diff --git a/ly/init.ly b/ly/init.ly index 4bfdb7fb0e..d718f81ac3 100644 --- a/ly/init.ly +++ b/ly/init.ly @@ -12,6 +12,7 @@ #(ly:set-option 'new-relative) #(ly:set-point-and-click #f) #(define toplevel-scores '()) +#(define $globalheader #f) \maininput % there is a problem at the end of the input file diff --git a/scm/lily.scm b/scm/lily.scm index 57a5f337c7..558da6d475 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -29,12 +29,12 @@ (debug-enable 'backtrace) (read-enable 'positions))) -(define-public (line-column-location line col file) +(define-public (line-column-location file line col) "Print an input location, including column number ." (string-append (number->string line) ":" (number->string col) " " file)) -(define-public (line-location line col file) +(define-public (line-location file line col) "Print an input location, without column number ." (string-append (number->string line) " " file)) @@ -119,7 +119,7 @@ )) (define-public (collect-music-for-book parser music) - (collect-scores-for-book parser (score (ly:music-scorify music)))) + (collect-scores-for-book parser (ly:music-scorify music))) ;;;;;;;;;;;;;;;; ; alist diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 5b00dfe908..aa36662364 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -140,8 +140,6 @@ -(define (define-origin file line col) "") - (define (dot x y radius) (string-append " " @@ -186,9 +184,6 @@ (string-append "/" key " {" val "} bind def\n") (string-append "/" key " (" val ") def\n")))) -(define (no-origin) "") - - (define (placebox x y s) (string-append @@ -268,3 +263,7 @@ (ly:number->string dx) " " (ly:number->string dy) " draw_zigzag_line")) + + +(define (grob-cause grob) + "") diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 74f2943d38..80b3bea144 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -45,6 +45,7 @@ draw-line define-origin no-origin + grob-cause )) (use-modules (ice-9 regex) @@ -178,11 +179,25 @@ (embedded-ps (list 'draw-line thick fx fy tx ty))) (define (define-origin file line col) - (if (procedure? point-and-click) - (string-append "\\special{src:" ;;; \\string ? - (point-and-click line col file) - "}" ) - "")) + "") ;; no-origin not yet supported by Xdvi (define (no-origin) "") + +(define (grob-cause grob) + (if (procedure? point-and-click) + + (let* + ((cause (ly:grob-property grob 'cause)) + (music-origin (if (ly:music? cause) + (ly:music-property cause 'origin) + #f)) + (location (if (ly:input-location? music-origin) + (ly:input-location music-origin) + #f))) + + (if (pair? location) + (string-append "\\special{src:" ;;; \\string ? + (apply point-and-click location) "}") + "")) + "")) -- 2.39.2