From 08bfc5231f319373ded486c5d99fbebc428b9415 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 25 Jan 2006 12:13:29 +0000 Subject: [PATCH] (get_voice_to_lyrics): use NPOS everywhere. --- ChangeLog | 13 +++++-- lily/lyric-engraver.cc | 2 +- lily/main.cc | 2 +- lily/midi-stream.cc | 2 +- lily/misc.cc | 2 +- lily/pango-font.cc | 6 ++-- ly/music-functions-init.ly | 13 +++++-- scm/layout-page-layout.scm | 69 ++++++++++++++++++++++++++++---------- 8 files changed, 81 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d86f5d9d5..c6d840e6aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-01-25 Han-Wen Nienhuys + + * lily/lyric-engraver.cc (get_voice_to_lyrics): use NPOS everywhere. + 2006-01-25 Jan Nieuwenhuizen * flower/include/std-string.hh: String/std::string compatibility: @@ -27,6 +31,9 @@ 2006-01-25 Han-Wen Nienhuys + * scm/layout-page-layout.scm (write-page-breaks): write + \spacingTweaks #ALIST. Handle grace timing. + * scm/: more imports. * scm/page.scm (make-page): add footer/header. @@ -36,9 +43,11 @@ * scm/layout-page-layout.scm (write-page-breaks): preliminary version of the system/spacing/linebreak hack writing to the output - * lily/prob-scheme.cc (LY_DEFINE): take optional 'key val args in ly:make-prob. + * lily/prob-scheme.cc (LY_DEFINE): take optional 'key val args in + ly:make-prob. - * lily/grob-scheme.cc (LY_DEFINE): ly:spanner-get-bound -> ly:spanner-bound + * lily/grob-scheme.cc (LY_DEFINE): ly:spanner-get-bound -> + ly:spanner-bound 2006-01-24 Han-Wen Nienhuys diff --git a/lily/lyric-engraver.cc b/lily/lyric-engraver.cc index fd08fa16dc..484167c109 100644 --- a/lily/lyric-engraver.cc +++ b/lily/lyric-engraver.cc @@ -90,7 +90,7 @@ get_voice_to_lyrics (Context *lyrics) else { int idx = nm.index_last ('-'); - if (idx >= 0) + if (idx != NPOS) nm = nm.left_string (idx); } diff --git a/lily/main.cc b/lily/main.cc index fa0d356f0a..36ae928b47 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -499,7 +499,7 @@ parse_argv (int argc, char **argv) String key = arg; String val = "#t"; - if (eq >= 0) + if (eq != NPOS) { key = arg.left_string (eq); val = arg.right_string (arg.length () - eq - 1); diff --git a/lily/midi-stream.cc b/lily/midi-stream.cc index 7af7a10649..b139c8239e 100644 --- a/lily/midi-stream.cc +++ b/lily/midi-stream.cc @@ -55,7 +55,7 @@ Midi_stream::operator << (Midi_item const &midi_c_r) if (do_midi_debugging_global) { str = String_convert::bin2hex (str) + "\n"; - for (int i = str.index ("0a"); i >= 0; i = str.index ("0a")) + for (int i = str.index ("0a"); i != NPOS; i = str.index ("0a")) { str[i] = '\n'; str[i + 1] = '\t'; diff --git a/lily/misc.cc b/lily/misc.cc index a85b43ae57..d605eb88a5 100644 --- a/lily/misc.cc +++ b/lily/misc.cc @@ -49,7 +49,7 @@ split_string (String s, char c) continue; } - if (i < 0) + if (i == NPOS) i = s.length (); rv.push (s.cut_string (0, i)); diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 35eb6cb01c..e97c914b24 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -157,8 +157,8 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, String str) const String ps_name; if (!ps_name_str0 && file_name != "" - && (file_name.index (".otf") >= 0 - || file_name.index (".cff") >= 0)) + && (file_name.index (".otf") != NPOS + || file_name.index (".cff") != NPOS)) { /* UGH: kludge a PS name for OTF/CFF fonts. */ @@ -169,7 +169,7 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, String str) const name = name.left_string (idx); int slash_idx = name.index_last ('/'); - if (slash_idx >= 0) + if (slash_idx != NPOS) name = name.right_string (name.length () - slash_idx - 1); String initial = name.cut_string (0, 1); diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 8a8e24706d..77bdedc9fb 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -309,7 +309,8 @@ assertBeamSlope = (append (list chain-grob-member-functions `(,cons 0 0)) (check-slope-callbacks comp)))))) - + + parallelMusic = #(def-music-function (parser location voice-ids music) (list? ly:music?) "Define parallel music sequences, separated by '|' (bar check signs), @@ -396,4 +397,12 @@ Example: 'elements voice))) voice-ids voices)) ;; Return an empty sequence. this function is actually a "void" function. - (make-music 'SequentialMusic 'void #t)) \ No newline at end of file + (make-music 'SequentialMusic 'void #t)) + + + + +%% this is a stub. Write your own to suit the spacing tweak output. +spacingTweaks = +#(def-music-function (parser location parameters) (list?) + (make-music 'SequentialMusic 'void #t)) diff --git a/scm/layout-page-layout.scm b/scm/layout-page-layout.scm index 1dcf9033e5..96b1265d4a 100644 --- a/scm/layout-page-layout.scm +++ b/scm/layout-page-layout.scm @@ -21,12 +21,27 @@ (set! tweaks (acons when property-pairs tweaks))) - + (define (graceless-moment mom) + (ly:make-moment + (ly:moment-main-numerator mom) + (ly:moment-main-denominator mom) + 0 0)) + (define (moment->skip mom) - (format "s1*~a/~a" - (ly:moment-main-numerator mom) - (ly:moment-main-denominator mom))) - + (let* + ((main (if (> (ly:moment-main-numerator mom) 0) + (format "\\skip 1*~a/~a" + (ly:moment-main-numerator mom) + (ly:moment-main-denominator mom)) + "")) + (grace (if (< (ly:moment-grace-numerator mom) 0) + (format "\\grace { \\skip 1*~a/~a }" + (- (ly:moment-grace-numerator mom)) + (ly:moment-grace-denominator mom)) + ""))) + + (format "~a~a" main grace))) + (define (dump-tweaks out-port tweak-list last-moment) (if (not (null? tweak-list)) (let* @@ -34,31 +49,51 @@ (diff (ly:moment-sub now last-moment)) (these-tweaks (cdar tweak-list)) (skip (moment->skip diff)) - - (base (format "\\overrideProperty - #\"Score.NonMusicalPaperColumn\" - #'line-break-system-details - #'~a" these-tweaks)) + (line-break-str (if (assoc-get 'line-break these-tweaks #f) + "\\break\n" + "")) + (page-break-str (if (assoc-get 'page-break these-tweaks #f) + "\\pageBreak\n" + "")) + (space-tweaks (format "\\spacingTweaks #'~a\n" + (with-output-to-string + (lambda () + (pretty-print + + (assoc-get 'spacing-parameters these-tweaks '())))) + )) + (base (format "~a~a~a" + line-break-str + page-break-str + space-tweaks)) ) - (format out-port "\\skip ~a\n~a\n" skip base) - (dump-tweaks out-port (cdr tweak-list) now) - ) - - )) + (format out-port "~a\n~a\n" skip base) + (dump-tweaks out-port (cdr tweak-list) (graceless-moment now)) + ))) (define (handle-page page) + (define index 0) (define (handle-system sys) (let* - ((props '((line-break . #t)))) + ((props `((line-break . #t) + (spacing-parameters + . ((system-Y-extent . ,(paper-system-extent sys Y)) + (system-refpoint-Y-extent . ,(paper-system-staff-extents sys)) + (system-index . ,index) + (page-system-count . ,(length (page-lines page))) + (page-printable-height . ,(page-printable-height page)) + (page-space-left . ,(page-property page 'space-left)))) + ))) (if (equal? (car (page-lines page)) sys) (set! props (cons '(page-break . #t) props))) - (if (not (ly:prob-property? sys 'is-title)) (record (ly:grob-property (ly:spanner-bound (ly:prob-property sys 'system-grob) LEFT) 'when) props)) + + (set! index (1+ index)) )) (for-each handle-system (page-lines page))) -- 2.39.5