Always edit whole words

This commit is contained in:
Matthias Neeracher 2008-03-29 21:00:35 +00:00
parent 34745acfde
commit 2e9f3cc857

View File

@ -1375,7 +1375,11 @@ void VLSong::SetWord(size_t stanza, size_t measure, VLFraction at, std::string w
AddMeasure(); AddMeasure();
uint8_t kind = 0; uint8_t kind = 0;
bool cleanup = false; enum State {
kFindFirst,
kOverwrite,
kCleanup
} state = kFindFirst;
do { do {
VLMeasure & meas = fMeasures[measure]; VLMeasure & meas = fMeasures[measure];
@ -1384,24 +1388,15 @@ void VLSong::SetWord(size_t stanza, size_t measure, VLFraction at, std::string w
VLFraction now(0); VLFraction now(0);
while (note != meas.fMelody.end()) { while (note != meas.fMelody.end()) {
if (now >= at && note->fPitch != VLNote::kNoPitch switch (state) {
&& !(note->fTied & VLNote::kTiedWithPrev) case kFindFirst:
) { if (now < at || note->fPitch == VLNote::kNoPitch
if (cleanup) { || (note->fTied & VLNote::kTiedWithPrev)
// )
// Make sure that following syllable doesn't have break; // Not yet there, skip this note
// kHasPrev set state = kOverwrite;
// // Fall through
if (note->fLyrics.size() >= stanza) case kOverwrite: {
note->fLyrics[stanza-1].fKind &= ~VLSyllable::kHasPrev;
if (nextMeas)
*nextMeas = measure;
if (nextAt)
*nextAt = now;
return;
}
if (note->fLyrics.size()<stanza) if (note->fLyrics.size()<stanza)
note->fLyrics.resize(stanza); note->fLyrics.resize(stanza);
size_t sep = word.find_first_of(" \t-"); size_t sep = word.find_first_of(" \t-");
@ -1426,7 +1421,7 @@ void VLSong::SetWord(size_t stanza, size_t measure, VLFraction at, std::string w
// Last syllable in text // Last syllable in text
// //
kind &= ~VLSyllable::kHasNext; kind &= ~VLSyllable::kHasNext;
cleanup = true; state = kCleanup;
break; break;
case ' ': case ' ':
// //
@ -1444,6 +1439,26 @@ void VLSong::SetWord(size_t stanza, size_t measure, VLFraction at, std::string w
kind |= VLSyllable::kHasPrev; kind |= VLSyllable::kHasPrev;
else else
kind &= ~VLSyllable::kHasPrev; kind &= ~VLSyllable::kHasPrev;
break; }
case kCleanup:
if (nextMeas) {
*nextMeas = measure;
nextMeas = 0;
}
if (nextAt) {
*nextAt = now;
nextAt = 0;
}
//
// Delete all subsequent syllables with kHasPrev set
//
if (note->fLyrics.size() >= stanza
&& (note->fLyrics[stanza-1].fKind & VLSyllable::kHasPrev)
) {
note->fLyrics[stanza-1].fText = "";
note->fLyrics[stanza-1].fKind = 0;
} else
return;
} }
now += note->fDuration; now += note->fDuration;
++note; ++note;