diff --git a/composeApp/src/commonMain/composeResources/files/ews-1.txt b/composeApp/src/commonMain/composeResources/files/ews-1.txt index ba2f6f7..279a59f 100644 --- a/composeApp/src/commonMain/composeResources/files/ews-1.txt +++ b/composeApp/src/commonMain/composeResources/files/ews-1.txt @@ -1,4 +1,4 @@ -M0:|c:D|m:4/4|r:8.8 L.M.|t:EWS 1 - From all that dwell below the sky|n:15|l:10|a:John Warrington Hatton (1793: 1710-1793)|h:Isaac Watts (1719)|x:https://hymnary.org/tune/duke_street_hatton +M0:|c:D|m:4/4|r:8.8 L.M.|t:EWS 1 - From all that dwell below the sky|n:15|l:10|a:John Warrington Hatton (1793: 1710-1793)|h:Isaac Watts (1719)|u:https://hymnary.org/tune/duke_street_hatton T0:{|D:-!M:F|S:-!(L:T)|D:-!(T:L)|S:-!-:-/S:-!S:S|L:-!(S:S)|(F:T)!M:-|R:-!-:-/M:-!M:R|(D:M)!(S:D)|(L:R)!(F:M)|R:-!-:-/S:-!L:T|(D:-.F!S):D|D:-!T:-|D:-!-:-} N1:dmfsltd'tls/sssls-f-mr/mmrdmsd'lsfmr/sltd'--fmrd N2:ddt,ddfmrdt,/d5s,l,t,dt,/ddt,s,dd-d-t,dt,/ddrmrdrdt,d diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt index 62226fe..2f21e48 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt @@ -167,17 +167,9 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository stateSettings.saveLastUsedDir(path) try { - val fileName = path.substringAfterLast(File.separatorChar) - - val content = fileRepository.readFileContent(path) - - fileRepository.saveLocalFile(fileName, content.encodeToByteArray()) - sharedScreenModel.loadItems() - parse("${fileRepository.getAppPublicFolder()}/$fileName") - - println("Fichier copié avec succès vers : Documents/Feufaro") + parse(path) } catch (e: Exception) { - println("Erreur lors de la copie du fichier : ${e.message}") + println("Erreur lors de l'ouverture du fichier : ${e.message}") } } } else { @@ -755,8 +747,12 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository val overrideIterator: MutableMap> = mutableMapOf() try { val lyrics = getLyricsComments(lyrics) + val positionDS = ArrayDeque() val arrayLyrics = lyrics.split(Regex("[/_]")) arrayLyrics.forEachIndexed { i, lyricsItem -> + if (lyricsItem.contains($$"${x:}")) { + positionDS.add(i) + } val originalLyrics = REGEX_STRIP_DC.replace(lyricsItem, "") val REGEX_OVERRIDE = Regex(".*\\$\\{O:(\\d+)\\}.*") if (REGEX_OVERRIDE.matches(lyricsItem)) { @@ -807,24 +803,26 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository val lyricsIterator = lyricsComment.iterator() while (lyricsIterator.hasNext()) { var item = lyricsIterator.next() - var positionDS = 0 // @todo: if item == ${O:...} // ${D:xxx} lyrics of DC and DSs - val isDS = Regex("^\\$\\{D([^:]*):").find(item) + val isDS = Regex("\\$\\{D([^:]*):").find(item) if (isDS != null) { item = item.replace(REGEX_LYRICS_COMMENT, "$2") val signDS = isDS.groupValues[1] - //todo: calculate positionDS val item = when (smartLyricsType) { "E" -> smartELyrics(item.replace(" _", " ")) "Y" -> smartYLyrics(item) else -> item } + var pDS = positionDS.removeFirstOrNull() ?: 0 + if (signDS != "S") { + pDS = 0 + } item .addHyphens() .split(Regex("[_/]")) .forEachIndexed { i, xval -> - appendLyricsItem(stanzaNumber, i + positionDS, xval) + appendLyricsItem(stanzaNumber, i + pDS, xval) } lyricsIterator.remove() } @@ -892,7 +890,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository if (matchResult.isNotEmpty()) { lyricsComment.addAll(matchResult) } - return REGEX_STRIP_DC.replace(lyrics, "") + return REGEX_STRIP_DC.replace(lyrics, $$"\\${x:}") } private fun defineRefrainFrom(tuoNumber: Int) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8361737..b9b7ff8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,7 +17,7 @@ kotlin = "2.2.0" kotlinx-coroutines = "1.10.2" #20250704 koin = "4.0.4" -core = "0.91.1" +core = "0.91.3" kmpObservableviewmodelCore = "1.0.0-BETA-3" kotlinxSerializationJson = "1.8.1" material3 = "1.3.2"