Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen committed Mar 12, 2024
1 parent 0f04e78 commit 09bcb57
Showing 1 changed file with 9 additions and 35 deletions.
44 changes: 9 additions & 35 deletions Sources/Tekkon/Tekkon_SyllableComposer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,8 @@ public extension Tekkon {
receiveKey(fromPhonabet: translate(key: input))
return
}
if mapArayuruPinyinIntonation.keys.contains(input) {
if let theTone = mapArayuruPinyinIntonation[input] {
intonation = Phonabet(theTone)
}
if let theTone = mapArayuruPinyinIntonation[input] {
intonation = Phonabet(theTone)
} else {
// 為了防止 romajiBuffer 越敲越長帶來算力負擔,這裡讓它在要溢出時自動丟掉最早輸入的音頭。
let maxCount: Int = (parser == .ofWadeGilesPinyin) ? 7 : 6
Expand Down Expand Up @@ -430,35 +428,11 @@ public extension Tekkon {
// 處理特殊情形。
switch incomingPhonabet.type {
case .semivowel:
switch consonant {
case "":
switch incomingPhonabet {
// 這裡不處理「ㄍㄧ」到「ㄑㄧ」的轉換,因為只有倚天26需要處理這個。
case "": consonant = "" // ㄍㄨ
case "": consonant = "" // ㄑㄩ
default: break
}
case "":
switch incomingPhonabet {
case "": consonant = "" // ㄐㄧ
case "": consonant = "" // ㄓㄨ
case "": consonant = "" // ㄐㄩ
default: break
}
case "":
switch incomingPhonabet {
case "": consonant = "" // ㄐㄧ
case "": consonant = "" // ㄓㄨ
case "": consonant = "" // ㄐㄩ
default: break
}
case "":
switch incomingPhonabet {
case "": consonant = "" // ㄒㄧ
case "": consonant = "" // ㄕㄨ
case "": consonant = "" // ㄒㄩ
default: break
}
// 這裡不處理「ㄍㄧ」到「ㄑㄧ」的轉換,因為只有倚天26需要處理這個。
switch (consonant, incomingPhonabet) {
case ("", ""), ("", ""): consonant = ""
case ("", ""), ("", ""), ("", ""): consonant = ""
case ("", ""), ("", ""): consonant = ""
default: break
}
if incomingPhonabet == "" {
Expand Down Expand Up @@ -671,10 +645,10 @@ public extension Tekkon {
} else if semivowel != "", vowel == "" {
vowel.clear()
strReturn = ""
} else if !semivowel.isEmpty {
} else if !semivowel.isEmpty || !"ㄐㄑㄒ".doesHave(consonant.value) {
strReturn = ""
} else {
strReturn = "ㄐㄑㄒ".doesHave(consonant.value) ? "" : ""
strReturn = ""
}
case "u":
if semivowel == "", vowel != "" {
Expand Down

0 comments on commit 09bcb57

Please sign in to comment.