Tekkon // Upgrade to v1.2.3 for better BoPoMoFo handling.
This commit is contained in:
parent
53bb837174
commit
952216d438
|
@ -107,7 +107,7 @@ extension KeyHandler {
|
||||||
/// 現在呢,咱們拿到了游標前後的 stringview 資料,準備著手生成要在組字區內顯示用的內容。
|
/// 現在呢,咱們拿到了游標前後的 stringview 資料,準備著手生成要在組字區內顯示用的內容。
|
||||||
/// 在這對前後資料當中插入目前正在輸入的讀音資料即可。
|
/// 在這對前後資料當中插入目前正在輸入的讀音資料即可。
|
||||||
let head = String(utf16CodeUnits: arrHead, count: arrHead.count)
|
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 tail = String(utf16CodeUnits: arrTail, count: arrTail.count)
|
||||||
let composedText = head + reading + tail
|
let composedText = head + reading + tail
|
||||||
let cursorIndex = composedStringCursorIndex + reading.utf16.count
|
let cursorIndex = composedStringCursorIndex + reading.utf16.count
|
||||||
|
|
|
@ -254,7 +254,7 @@ public struct Tekkon {
|
||||||
// 該函式僅用來獲取給 macOS InputMethod Kit 的內文組字區使用的顯示字串。
|
// 該函式僅用來獲取給 macOS InputMethod Kit 的內文組字區使用的顯示字串。
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - isHanyuPinyin: 是否將輸出結果轉成漢語拼音。
|
/// - isHanyuPinyin: 是否將輸出結果轉成漢語拼音。
|
||||||
public func getInlineCompositionForIMK(isHanyuPinyin: Bool = false) -> String {
|
public func getInlineCompositionForDisplay(isHanyuPinyin: Bool = false) -> String {
|
||||||
switch parser {
|
switch parser {
|
||||||
case .ofHanyuPinyin, .ofSecondaryPinyin, .ofYalePinyin, .ofHualuoPinyin, .ofUniversalPinyin:
|
case .ofHanyuPinyin, .ofSecondaryPinyin, .ofYalePinyin, .ofHualuoPinyin, .ofUniversalPinyin:
|
||||||
var toneReturned = ""
|
var toneReturned = ""
|
||||||
|
@ -387,6 +387,15 @@ public struct Tekkon {
|
||||||
/// - fromPhonabet: 傳入的單個注音符號字串。
|
/// - fromPhonabet: 傳入的單個注音符號字串。
|
||||||
public mutating func receiveKey(fromPhonabet phonabet: String = "") {
|
public mutating func receiveKey(fromPhonabet phonabet: String = "") {
|
||||||
let thePhone: Phonabet = .init(phonabet)
|
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 {
|
switch thePhone.type {
|
||||||
case .consonant: consonant = thePhone
|
case .consonant: consonant = thePhone
|
||||||
case .semivowel: semivowel = thePhone
|
case .semivowel: semivowel = thePhone
|
||||||
|
|
Loading…
Reference in New Issue