Tekkon // Upgrade to v1.2.3 for better BoPoMoFo handling.

This commit is contained in:
ShikiSuen 2022-07-02 13:42:27 +08:00
parent 53bb837174
commit 952216d438
2 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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