Implements litanies visual partition for ${L} marker
This commit is contained in:
parent
c846552574
commit
7d1e02078f
4 changed files with 66 additions and 9 deletions
|
|
@ -32,6 +32,7 @@ class PTemplate (val template: String, val separatorAfter: String, private val m
|
||||||
prefix + it.code.replace(Regex("^\\$\\{([abd-z]:)?(.*)\\}"), "$2")
|
prefix + it.code.replace(Regex("^\\$\\{([abd-z]:)?(.*)\\}"), "$2")
|
||||||
.replace("\$Q", "\uD834\uDD10")
|
.replace("\$Q", "\uD834\uDD10")
|
||||||
.replace(Regex("^[<=>]$"), "")
|
.replace(Regex("^[<=>]$"), "")
|
||||||
|
.replace(Regex("^L$"), "")
|
||||||
.replace($$"$T", "")
|
.replace($$"$T", "")
|
||||||
.replace(Regex("^c:(.*)"), "Do dia $1")
|
.replace(Regex("^c:(.*)"), "Do dia $1")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
val REGEX_NOTE_TODROP = Regex("([drmfsltz][ia]?|[―])([₄₃₂₁¹²³⁴',]*)<")
|
val REGEX_NOTE_TODROP = Regex("([drmfsltz][ia]?|[―])([₄₃₂₁¹²³⁴',]*)<")
|
||||||
val REGEX_NOTE_SPLIT = Regex("\\$\\{[Ss]:([^\\}]+)\\}([drmfsltDRFSTz][,']*)")
|
val REGEX_NOTE_SPLIT = Regex("\\$\\{[Ss]:([^\\}]+)\\}([drmfsltDRFSTz][,']*)")
|
||||||
val REGEX_DC_REFRAIN = Regex("""\$\{R=\}\$\{D:(.*?)\}""")
|
val REGEX_DC_REFRAIN = Regex("""\$\{R=\}\$\{D:(.*?)\}""")
|
||||||
|
val KEEP_MARKERS = listOf("\${L}", "\$T")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun parseNoteSplit(input: String): String {
|
fun parseNoteSplit(input: String): String {
|
||||||
|
|
@ -1166,7 +1167,11 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
|
|
||||||
/* On ne ré-insere pas la même marker*/
|
/* On ne ré-insere pas la même marker*/
|
||||||
val markerRegex = Regex("""\$\{.*?\}|\$.""")
|
val markerRegex = Regex("""\$\{.*?\}|\$.""")
|
||||||
val blockWithoutOldMarkers = rawBlockText.replace(markerRegex, "")
|
val blockWithoutOldMarkers = if (anyNoteModified) {
|
||||||
|
rawBlockText.replace(markerRegex, "")
|
||||||
|
} else {
|
||||||
|
rawBlockText.replace(markerRegex) { if (it.value in KEEP_MARKERS) it.value else "" }
|
||||||
|
}
|
||||||
|
|
||||||
val leadingCloseParentheses = blockWithoutOldMarkers.takeWhile { it == ')' }
|
val leadingCloseParentheses = blockWithoutOldMarkers.takeWhile { it == ')' }
|
||||||
val oldCleaned = blockWithoutOldMarkers.substring(leadingCloseParentheses.length)
|
val oldCleaned = blockWithoutOldMarkers.substring(leadingCloseParentheses.length)
|
||||||
|
|
@ -1192,7 +1197,14 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
} else {
|
} else {
|
||||||
oldCleaned
|
oldCleaned
|
||||||
}
|
}
|
||||||
val rawProcessed = separat + leadingCloseParentheses + newMarkerValue + bodyContent
|
|
||||||
|
val keepMarkers = if (anyNoteModified) {
|
||||||
|
KEEP_MARKERS
|
||||||
|
.filter { rawBlockText.contains(it) && !newMarkerValue.contains(it) && !bodyContent.contains(it) }
|
||||||
|
.joinToString("")
|
||||||
|
} else ""
|
||||||
|
|
||||||
|
val rawProcessed = separat + leadingCloseParentheses + newMarkerValue + keepMarkers + bodyContent
|
||||||
|
|
||||||
var cleanedProcessed = rawProcessed
|
var cleanedProcessed = rawProcessed
|
||||||
while (cleanedProcessed.contains("((") || cleanedProcessed.contains("))")) {
|
while (cleanedProcessed.contains("((") || cleanedProcessed.contains("))")) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package mg.dot.feufaro.solfa
|
||||||
|
|
||||||
|
|
||||||
|
object SolfaLabels {
|
||||||
|
private val LABELS: Map<String, String> = mapOf(
|
||||||
|
"d" to "DÔ",
|
||||||
|
"di" to "DI",
|
||||||
|
"r" to "RÉ",
|
||||||
|
"ri" to "RI",
|
||||||
|
"m" to "MI",
|
||||||
|
"f" to "FA",
|
||||||
|
"fi" to "FI",
|
||||||
|
"s" to "SÔ",
|
||||||
|
"si" to "SI",
|
||||||
|
"l" to "LA",
|
||||||
|
"ta" to "TA",
|
||||||
|
"t" to "TI",
|
||||||
|
)
|
||||||
|
fun toLabels(text: String): String {
|
||||||
|
return LABELS.entries
|
||||||
|
.sortedByDescending { it.key.length }
|
||||||
|
.fold(text) { result, (key, value) ->
|
||||||
|
result.replace(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun extraChars(text: String, endExclusive: Int): Int {
|
||||||
|
val prefix = text.take(endExclusive.coerceAtLeast(0))
|
||||||
|
|
||||||
|
return LABELS.keys.sumOf { key ->
|
||||||
|
prefix.windowed(key.length).count { it == key } * (key.length - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -141,6 +141,8 @@ class TimeUnitObject (val pTemplate: PTemplate, val prevTUO: TimeUnitObject?, co
|
||||||
fun isTriolet(): Boolean {
|
fun isTriolet(): Boolean {
|
||||||
return pTemplate.hasMarker($$"$T")
|
return pTemplate.hasMarker($$"$T")
|
||||||
}
|
}
|
||||||
|
fun isLitany(): Boolean = pTemplate.hasMarker($$"${L}")
|
||||||
|
|
||||||
fun addLyrics(lyricsIn: POneStanzaLyrics) {
|
fun addLyrics(lyricsIn: POneStanzaLyrics) {
|
||||||
lyrics.add(lyricsIn)
|
lyrics.add(lyricsIn)
|
||||||
}
|
}
|
||||||
|
|
@ -311,11 +313,15 @@ fun TimeUnitComposable(
|
||||||
)
|
)
|
||||||
|
|
||||||
val focusRequesters = remember { List(4) { FocusRequester() } }
|
val focusRequesters = remember { List(4) { FocusRequester() } }
|
||||||
|
val isLitany = tuo.isLitany()
|
||||||
|
|
||||||
// Mettre en cache les annotations et les chaînes transposées
|
// Mettre en cache les annotations et les chaînes transposées
|
||||||
val multiLineText = remember(tuo, transpositionInterval) {
|
val rawText = remember(tuo, transpositionInterval) {
|
||||||
val notes = tuo.noteAsMultiString()
|
Transpose.transposeText(text = tuo.noteAsMultiString(), interval = transpositionInterval)
|
||||||
Transpose.transposeText(text = notes, interval = transpositionInterval)
|
}
|
||||||
|
val rawLines = remember(rawText) { rawText.lines() }
|
||||||
|
val multiLineText = remember(rawText, isLitany) {
|
||||||
|
if (isLitany) SolfaLabels.toLabels(rawText) else rawText
|
||||||
}
|
}
|
||||||
|
|
||||||
val annotationsCache = remember(tuo, transpositionInterval) {
|
val annotationsCache = remember(tuo, transpositionInterval) {
|
||||||
|
|
@ -368,9 +374,11 @@ fun TimeUnitComposable(
|
||||||
val leftMarginUnderline = with(currentDensity) {
|
val leftMarginUnderline = with(currentDensity) {
|
||||||
leftMarginUnderlineDp.toPx()
|
leftMarginUnderlineDp.toPx()
|
||||||
}
|
}
|
||||||
|
val rawLine = rawLines.getOrNull(ta.voiceNumber - 1).orEmpty()
|
||||||
|
fun shifted(idx: Int) = if (isLitany) idx + SolfaLabels.extraChars(rawLine, idx) else idx
|
||||||
if (us.x > -1) {
|
if (us.x > -1) {
|
||||||
val lineGlobalStartOffset = textLayoutResult?.getLineStart(ta.voiceNumber - 1) ?: 0
|
val lineGlobalStartOffset = textLayoutResult?.getLineStart(ta.voiceNumber - 1) ?: 0
|
||||||
val globalStartIndex = lineGlobalStartOffset + us.x
|
val globalStartIndex = lineGlobalStartOffset + shifted(us.x)
|
||||||
xStart = textLayoutResult?.getCursorRect(globalStartIndex)?.left ?: 0f
|
xStart = textLayoutResult?.getCursorRect(globalStartIndex)?.left ?: 0f
|
||||||
if (us.isNewParen) {
|
if (us.isNewParen) {
|
||||||
xStart += leftMarginUnderline
|
xStart += leftMarginUnderline
|
||||||
|
|
@ -380,7 +388,7 @@ fun TimeUnitComposable(
|
||||||
if (us.y > -1 ) {
|
if (us.y > -1 ) {
|
||||||
val lineGlobalStartOffset = textLayoutResult?.getLineStart(ta.voiceNumber - 1) ?: 0
|
val lineGlobalStartOffset = textLayoutResult?.getLineStart(ta.voiceNumber - 1) ?: 0
|
||||||
// don't ask me why + 1 here makes it work, but it works.
|
// don't ask me why + 1 here makes it work, but it works.
|
||||||
val globalEndIndex = min(lineGlobalStartOffset + us.y + separatorLength + 1, multiLineText.length)
|
val globalEndIndex = min(lineGlobalStartOffset + shifted(us.y + separatorLength + 1), multiLineText.length)
|
||||||
|
|
||||||
xEnd = textLayoutResult?.getCursorRect(globalEndIndex)?.right ?: size.width
|
xEnd = textLayoutResult?.getCursorRect(globalEndIndex)?.right ?: size.width
|
||||||
}
|
}
|
||||||
|
|
@ -470,8 +478,10 @@ fun bestTUOWidth(
|
||||||
// println("=== [DEBUG TUO] Début mesure de ${items.size} blocs TUO ===")
|
// println("=== [DEBUG TUO] Début mesure de ${items.size} blocs TUO ===")
|
||||||
|
|
||||||
items.forEach { tuo ->
|
items.forEach { tuo ->
|
||||||
val rawNotes = tuo.noteAsMultiString()
|
val rawNotes = Transpose.transposeText(
|
||||||
val transposedNotes = Transpose.transposeText(text = rawNotes, interval = transpositionInterval)
|
text = tuo.noteAsMultiString(), interval = transpositionInterval
|
||||||
|
)
|
||||||
|
val transposedNotes = if (tuo.isLitany()) SolfaLabels.toLabels(rawNotes) else rawNotes
|
||||||
val noteLines = transposedNotes.lines()
|
val noteLines = transposedNotes.lines()
|
||||||
var maxNoteWidthPx = 0
|
var maxNoteWidthPx = 0
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue