Tekkon // Fix fundamental errors in handling dynamic layouts.

This commit is contained in:
ShikiSuen 2023-04-12 23:45:24 +08:00
parent 846d3d45ea
commit 43774247c1
1 changed files with 53 additions and 31 deletions

View File

@ -165,6 +165,31 @@ public extension Tekkon {
romajiBuffer = Tekkon.cnvPhonaToHanyuPinyin(targetJoined: consonant.value + semivowel.value + vowel.value)
}
///
/// - Parameters:
/// - strOf:
/// - strWith:
mutating func fixValue(_ strOf: String, _ strWith: String = "") {
let theOld = Phonabet(strOf)
if !strOf.isEmpty {
switch theOld.type {
case .consonant where consonant == theOld: consonant.clear()
case .semivowel where semivowel == theOld: semivowel.clear()
case .vowel where vowel == theOld: vowel.clear()
case .intonation where intonation == theOld: intonation.clear()
default: return
}
}
let theNew = Phonabet(strWith)
switch theNew.type {
case .consonant: consonant = theNew
case .semivowel: semivowel = theNew
case .vowel: vowel = theNew
case .intonation: intonation = theNew
case .null: return
}
}
/// String
/// UniChar
///
@ -412,9 +437,9 @@ public extension Tekkon {
}
case .vowel:
if semivowel.isEmpty {
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
}
default: break
}
@ -447,7 +472,7 @@ public extension Tekkon {
} else if consonant.isEmpty, semivowel == "" {
vowel = ""
} else if consonant.isEmpty {
vowel = ""
consonant = ""
} else {
vowel = ""
}
@ -460,12 +485,12 @@ public extension Tekkon {
if "dfjk ".contains(key),
!consonant.isEmpty, semivowel.isEmpty, vowel.isEmpty
{
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
}
//
@ -522,24 +547,21 @@ public extension Tekkon {
if "dfjs ".contains(key) {
if !consonant.isEmpty, semivowel.isEmpty, vowel.isEmpty {
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
}
if !consonant.isEmpty, vowel.isEmpty {
consonant.selfReplace("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
}
if "ㄢㄣㄤㄥ".contains(vowel.value), semivowel.isEmpty {
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
}
if "ㄐㄑㄒ".contains(consonant.value), semivowel.isEmpty {
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
}
if consonant == "", semivowel.isEmpty, vowel.isEmpty {
consonant.clear()
@ -582,13 +604,13 @@ public extension Tekkon {
if "67890 ".contains(key) {
if !consonant.isEmpty, semivowel.isEmpty, vowel.isEmpty {
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
consonant.selfReplace("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
fixValue("", "")
}
}