From 4f205f35f0de0c15d6a313978ae7f7aede706399 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 14 Jun 2022 18:33:42 +0800 Subject: [PATCH] Tekkon // Upgrade to v1.1.6 release, etc. --- .../ControllerModules/KeyHandler_Core.swift | 8 +-- .../ControllerModules/SyllableComposer.swift | 65 ++++++++++--------- Source/Modules/IMEModules/mgrPrefs.swift | 8 +-- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler_Core.swift b/Source/Modules/ControllerModules/KeyHandler_Core.swift index 447da1a2..1697188d 100644 --- a/Source/Modules/ControllerModules/KeyHandler_Core.swift +++ b/Source/Modules/ControllerModules/KeyHandler_Core.swift @@ -276,12 +276,12 @@ class KeyHandler { _composer.ensureParser(arrange: .ofDachen) case MandarinParser.ofDachen26.rawValue: _composer.ensureParser(arrange: .ofDachen26) - case MandarinParser.ofEten.rawValue: - _composer.ensureParser(arrange: .ofEten) + case MandarinParser.ofETen.rawValue: + _composer.ensureParser(arrange: .ofETen) case MandarinParser.ofHsu.rawValue: _composer.ensureParser(arrange: .ofHsu) - case MandarinParser.ofEten26.rawValue: - _composer.ensureParser(arrange: .ofEten26) + case MandarinParser.ofETen26.rawValue: + _composer.ensureParser(arrange: .ofETen26) case MandarinParser.ofIBM.rawValue: _composer.ensureParser(arrange: .ofIBM) case MandarinParser.ofMiTAC.rawValue: diff --git a/Source/Modules/ControllerModules/SyllableComposer.swift b/Source/Modules/ControllerModules/SyllableComposer.swift index 13758b40..4816a70d 100644 --- a/Source/Modules/ControllerModules/SyllableComposer.swift +++ b/Source/Modules/ControllerModules/SyllableComposer.swift @@ -41,8 +41,8 @@ public struct Tekkon { public enum MandarinParser: Int { case ofDachen = 0 case ofDachen26 = 1 - case ofEten = 2 - case ofEten26 = 3 + case ofETen = 2 + case ofETen26 = 3 case ofHsu = 4 case ofIBM = 5 case ofMiTAC = 6 @@ -60,11 +60,11 @@ public struct Tekkon { return "Dachen" case .ofDachen26: return "Dachen26" - case .ofEten: + case .ofETen: return "ETen" case .ofHsu: return "Hsu" - case .ofEten26: + case .ofETen26: return "ETen26" case .ofIBM: return "IBM" @@ -140,6 +140,7 @@ public struct Tekkon { /// 自我清空內容。 public mutating func clear() { valueStorage = "" + type = .null } /// 自我變換資料值。 @@ -214,7 +215,7 @@ public struct Tekkon { /// 聲調。 public var intonation: Phonabet = "" - /// 為拉丁字母專用的組音區 + /// 為拉丁字母專用的組音區。 public var romajiBuffer: String = "" /// 注音排列種類。預設情況下是大千排列(Windows / macOS 預設注音排列)。 @@ -279,7 +280,7 @@ public struct Tekkon { } } - /// 注拼槽內容是否為空。 + /// 注拼槽內容是否可唸。 public var isPronouncable: Bool { !vowel.isEmpty || !semivowel.isEmpty || !consonant.isEmpty } @@ -321,12 +322,12 @@ public struct Tekkon { return Tekkon.mapQwertyDachen[input] != nil case .ofDachen26: return Tekkon.mapDachenCP26StaticKeys[input] != nil - case .ofEten: - return Tekkon.mapQwertyEtenTraditional[input] != nil + case .ofETen: + return Tekkon.mapQwertyETenTraditional[input] != nil case .ofHsu: return Tekkon.mapHsuStaticKeys[input] != nil - case .ofEten26: - return Tekkon.mapEten26StaticKeys[input] != nil + case .ofETen26: + return Tekkon.mapETen26StaticKeys[input] != nil case .ofIBM: return Tekkon.mapQwertyIBM[input] != nil case .ofMiTAC: @@ -356,7 +357,7 @@ public struct Tekkon { intonation = Phonabet(theTone) } } else { - // 為了防止 romajiBuffer 越敲越長帶來算力負擔,這裡讓它在要溢出時自動丟掉先取音頭。 + // 為了防止 romajiBuffer 越敲越長帶來算力負擔,這裡讓它在要溢出時自動丟掉最早輸入的音頭。 if romajiBuffer.count > 5 { romajiBuffer = String(romajiBuffer.dropFirst()) } @@ -364,7 +365,7 @@ public struct Tekkon { receiveSequence(romajiBufferBackup, isRomaji: true) romajiBuffer = romajiBufferBackup } - default: receiveKey(fromPhonabet: translate(key: String(input))) + default: receiveKey(fromPhonabet: translate(key: input)) } } @@ -506,12 +507,12 @@ public struct Tekkon { return Tekkon.mapQwertyDachen[key] ?? "" case .ofDachen26: return handleDachen26(key: key) - case .ofEten: - return Tekkon.mapQwertyEtenTraditional[key] ?? "" + case .ofETen: + return Tekkon.mapQwertyETenTraditional[key] ?? "" case .ofHsu: return handleHsu(key: key) - case .ofEten26: - return handleEten26(key: key) + case .ofETen26: + return handleETen26(key: key) case .ofIBM: return Tekkon.mapQwertyIBM[key] ?? "" case .ofMiTAC: @@ -531,9 +532,8 @@ public struct Tekkon { /// 回傳結果是空字串的話,不要緊,因為該函數內部已經處理過分配過程了。 /// - Parameters: /// - key: 傳入的 String 訊號。 - mutating func handleEten26(key: String = "") -> String { - var strReturn = "" - strReturn = Tekkon.mapEten26StaticKeys[key] ?? "" + mutating func handleETen26(key: String = "") -> String { + var strReturn = Tekkon.mapETen26StaticKeys[key] ?? "" let incomingPhonabet = Phonabet(strReturn) switch key { @@ -616,12 +616,11 @@ public struct Tekkon { /// - Parameters: /// - key: 傳入的 String 訊號。 mutating func handleHsu(key: String = "") -> String { - var strReturn = "" - strReturn = Tekkon.mapHsuStaticKeys[key] ?? "" + var strReturn = Tekkon.mapHsuStaticKeys[key] ?? "" let incomingPhonabet = Phonabet(strReturn) if key == " ", value == "ㄋ" { - consonant = "" + consonant.clear() vowel = "ㄣ" } @@ -719,7 +718,7 @@ public struct Tekkon { consonant.selfReplace("ㄒ", "ㄕ") } if consonant == "ㄏ", semivowel.isEmpty, vowel.isEmpty { - consonant = "" + consonant.clear() vowel = "ㄛ" } } @@ -740,8 +739,7 @@ public struct Tekkon { /// - Parameters: /// - key: 傳入的 String 訊號。 mutating func handleDachen26(key: String = "") -> String { - var strReturn = "" - strReturn = Tekkon.mapDachenCP26StaticKeys[key] ?? "" + var strReturn = Tekkon.mapDachenCP26StaticKeys[key] ?? "" switch key { case "e": if isPronouncable { intonation = "ˊ" } else { consonant = "ㄍ" } @@ -759,11 +757,11 @@ public struct Tekkon { case "w": if consonant.isEmpty || consonant == "ㄉ" { consonant = "ㄊ" } else { consonant = "ㄉ" } case "m": if semivowel == "ㄩ", vowel != "ㄡ" { - semivowel = "" + semivowel.clear() vowel = "ㄡ" } else if semivowel != "ㄩ", vowel == "ㄡ" { semivowel = "ㄩ" - vowel = "" + vowel.clear() } else if !semivowel.isEmpty { vowel = "ㄡ" } else { @@ -771,13 +769,13 @@ public struct Tekkon { } case "u": if semivowel == "ㄧ", vowel != "ㄚ" { - semivowel = "" + semivowel.clear() vowel = "ㄚ" } else if semivowel != "ㄧ", vowel == "ㄚ" { semivowel = "ㄧ" } else if semivowel == "ㄧ", vowel == "ㄚ" { - semivowel = "" - vowel = "" + semivowel.clear() + vowel.clear() } else if !semivowel.isEmpty { vowel = "ㄚ" } else { @@ -834,6 +832,9 @@ public struct Tekkon { return targetConverted } + /// 漢語拼音數字標調式轉漢語拼音教科書格式,要求陰平必須是數字 1。 + /// - Parameters: + /// - target: 傳入的 String 對象物件。 static func cnvHanyuPinyinToTextbookStyle(target: String) -> String { var targetConverted = target for pair in arrHanyuPinyinTextbookStyleConversionTable { @@ -1296,14 +1297,14 @@ public struct Tekkon { /// /// 在這裡將二十六個字母寫全,也只是為了方便做 validity check。 /// 這裡提前對ㄓ/ㄍ/ㄕ做處理,然後再用程式判斷介母類型、據此判斷是否需要換成ㄒ/ㄑ/ㄐ。 - static let mapEten26StaticKeys: [String: String] = [ + static let mapETen26StaticKeys: [String: String] = [ "a": "ㄚ", "b": "ㄅ", "c": "ㄕ", "d": "ㄉ", "e": "ㄧ", "f": "ㄈ", "g": "ㄓ", "h": "ㄏ", "i": "ㄞ", "j": "ㄖ", "k": "ㄎ", "l": "ㄌ", "m": "ㄇ", "n": "ㄋ", "o": "ㄛ", "p": "ㄆ", "q": "ㄗ", "r": "ㄜ", "s": "ㄙ", "t": "ㄊ", "u": "ㄩ", "v": "ㄍ", "w": "ㄘ", "x": "ㄨ", "y": "ㄔ", "z": "ㄠ", " ": " ", ] /// 倚天傳統排列專用處理陣列。 - static let mapQwertyEtenTraditional: [String: String] = [ + static let mapQwertyETenTraditional: [String: String] = [ "'": "ㄘ", ",": "ㄓ", "-": "ㄥ", ".": "ㄔ", "/": "ㄕ", "0": "ㄤ", "1": "˙", "2": "ˊ", "3": "ˇ", "4": "ˋ", "7": "ㄑ", "8": "ㄢ", "9": "ㄣ", ";": "ㄗ", "=": "ㄦ", "a": "ㄚ", "b": "ㄅ", "c": "ㄒ", "d": "ㄉ", "e": "ㄧ", "f": "ㄈ", "g": "ㄐ", "h": "ㄏ", "i": "ㄞ", "j": "ㄖ", "k": "ㄎ", "l": "ㄌ", "m": "ㄇ", "n": "ㄋ", "o": "ㄛ", "p": "ㄆ", "q": "ㄟ", "r": "ㄜ", diff --git a/Source/Modules/IMEModules/mgrPrefs.swift b/Source/Modules/IMEModules/mgrPrefs.swift index 1105d627..5247e038 100644 --- a/Source/Modules/IMEModules/mgrPrefs.swift +++ b/Source/Modules/IMEModules/mgrPrefs.swift @@ -176,9 +176,9 @@ struct ComposingBufferSize { enum MandarinParser: Int { case ofStandard = 0 - case ofEten = 1 + case ofETen = 1 case ofHsu = 2 - case ofEten26 = 3 + case ofETen26 = 3 case ofIBM = 4 case ofMiTAC = 5 case ofFakeSeigyou = 6 @@ -193,11 +193,11 @@ enum MandarinParser: Int { switch self { case .ofStandard: return "Standard" - case .ofEten: + case .ofETen: return "ETen" case .ofHsu: return "Hsu" - case .ofEten26: + case .ofETen26: return "ETen26" case .ofIBM: return "IBM"