diff --git a/Source/Modules/ControllerModules/KeyHandler_States.swift b/Source/Modules/ControllerModules/KeyHandler_States.swift index c1913d93..13e49af1 100644 --- a/Source/Modules/ControllerModules/KeyHandler_States.swift +++ b/Source/Modules/ControllerModules/KeyHandler_States.swift @@ -107,7 +107,7 @@ extension KeyHandler { /// 現在呢,咱們拿到了游標前後的 stringview 資料,準備著手生成要在組字區內顯示用的內容。 /// 在這對前後資料當中插入目前正在輸入的讀音資料即可。 let head = String(utf16CodeUnits: arrHead, count: arrHead.count) - let reading = composer.getInlineCompositionForIMK(isHanyuPinyin: mgrPrefs.showHanyuPinyinInCompositionBuffer) + let reading = composer.getInlineCompositionForDisplay(isHanyuPinyin: mgrPrefs.showHanyuPinyinInCompositionBuffer) let tail = String(utf16CodeUnits: arrTail, count: arrTail.count) let composedText = head + reading + tail let cursorIndex = composedStringCursorIndex + reading.utf16.count diff --git a/Source/Modules/ControllerModules/SyllableComposer.swift b/Source/Modules/ControllerModules/SyllableComposer.swift index 825808ea..5807d6d3 100644 --- a/Source/Modules/ControllerModules/SyllableComposer.swift +++ b/Source/Modules/ControllerModules/SyllableComposer.swift @@ -254,7 +254,7 @@ public struct Tekkon { // 該函式僅用來獲取給 macOS InputMethod Kit 的內文組字區使用的顯示字串。 /// - Parameters: /// - isHanyuPinyin: 是否將輸出結果轉成漢語拼音。 - public func getInlineCompositionForIMK(isHanyuPinyin: Bool = false) -> String { + public func getInlineCompositionForDisplay(isHanyuPinyin: Bool = false) -> String { switch parser { case .ofHanyuPinyin, .ofSecondaryPinyin, .ofYalePinyin, .ofHualuoPinyin, .ofUniversalPinyin: var toneReturned = "" @@ -387,6 +387,15 @@ public struct Tekkon { /// - fromPhonabet: 傳入的單個注音符號字串。 public mutating func receiveKey(fromPhonabet phonabet: String = "") { let thePhone: Phonabet = .init(phonabet) + switch phonabet { + case "ㄛ", "ㄥ": + if "ㄅㄆㄇㄈ".contains(consonant.value), semivowel.value == "ㄨ" { semivowel.clear() } + case "ㄨ": + if "ㄅㄆㄇㄈ".contains(consonant.value), "ㄛㄥ".contains(vowel.value) { vowel.clear() } + case "ㄅ", "ㄆ", "ㄇ", "ㄈ": + if ["ㄨㄛ", "ㄨㄥ"].contains(semivowel.value + vowel.value) { semivowel.clear() } + default: break + } switch thePhone.type { case .consonant: consonant = thePhone case .semivowel: semivowel = thePhone