KeyHandler // Documentation fix.
This commit is contained in:
parent
4bdb528f2d
commit
dbe54d7a8b
|
@ -66,7 +66,7 @@ class KeyHandler {
|
||||||
willSet {
|
willSet {
|
||||||
// 這個標籤在下文會用到。
|
// 這個標籤在下文會用到。
|
||||||
let isCHS: Bool = (newValue == InputMode.imeModeCHS)
|
let isCHS: Bool = (newValue == InputMode.imeModeCHS)
|
||||||
/// 將新的簡繁輸入模式提報給 ctlInputMethod 與 IME 模組。
|
/// 將新的簡繁輸入模式提報給 Prefs 與 IME 模組。
|
||||||
IME.currentInputMode = newValue
|
IME.currentInputMode = newValue
|
||||||
mgrPrefs.mostRecentInputMode = IME.currentInputMode.rawValue
|
mgrPrefs.mostRecentInputMode = IME.currentInputMode.rawValue
|
||||||
/// 重設所有語言模組。這裡不需要做按需重設,因為對運算量沒有影響。
|
/// 重設所有語言模組。這裡不需要做按需重設,因為對運算量沒有影響。
|
||||||
|
@ -176,8 +176,8 @@ class KeyHandler {
|
||||||
)
|
)
|
||||||
// 不要針對逐字選字模式啟用臨時半衰記憶模型。
|
// 不要針對逐字選字模式啟用臨時半衰記憶模型。
|
||||||
if !mgrPrefs.useSCPCTypingMode {
|
if !mgrPrefs.useSCPCTypingMode {
|
||||||
// 所有讀音數與字符數不匹配的情況均不得塞入半衰記憶模組。
|
|
||||||
var addToUserOverrideModel = true
|
var addToUserOverrideModel = true
|
||||||
|
// 所有讀音數與字符數不匹配的情況均不得塞入半衰記憶模組。
|
||||||
if selectedNode.spanningLength != value.count {
|
if selectedNode.spanningLength != value.count {
|
||||||
IME.prtDebugIntel("UOM: SpanningLength != value.count, dismissing.")
|
IME.prtDebugIntel("UOM: SpanningLength != value.count, dismissing.")
|
||||||
addToUserOverrideModel = false
|
addToUserOverrideModel = false
|
||||||
|
|
|
@ -31,6 +31,13 @@ import Cocoa
|
||||||
// MARK: - § 對選字狀態進行調度 (Handle Candidate State).
|
// MARK: - § 對選字狀態進行調度 (Handle Candidate State).
|
||||||
|
|
||||||
extension KeyHandler {
|
extension KeyHandler {
|
||||||
|
/// 當且僅當選字窗出現時,對於經過初次篩選處理的輸入訊號的處理均藉由此函式來進行。
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: 輸入訊號。
|
||||||
|
/// - state: 給定狀態(通常為當前狀態)。
|
||||||
|
/// - stateCallback: 狀態回呼,交給對應的型別內的專有函數來處理。
|
||||||
|
/// - errorCallback: 錯誤回呼。
|
||||||
|
/// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。
|
||||||
func handleCandidate(
|
func handleCandidate(
|
||||||
state: InputStateProtocol,
|
state: InputStateProtocol,
|
||||||
input: InputSignal,
|
input: InputSignal,
|
||||||
|
@ -352,7 +359,7 @@ extension KeyHandler {
|
||||||
]
|
]
|
||||||
let customPunctuation: String = arrCustomPunctuations.joined(separator: "")
|
let customPunctuation: String = arrCustomPunctuations.joined(separator: "")
|
||||||
|
|
||||||
/// 如果仍無匹配結果的話,看看這個輸入是否是不需要修飾鍵的那種標點鍵輸入。
|
/// 看看這個輸入是否是不需要修飾鍵的那種標點鍵輸入。
|
||||||
|
|
||||||
let arrPunctuations: [String] = [punctuationNamePrefix, String(format: "%c", CChar(charCode))]
|
let arrPunctuations: [String] = [punctuationNamePrefix, String(format: "%c", CChar(charCode))]
|
||||||
let punctuation: String = arrPunctuations.joined(separator: "")
|
let punctuation: String = arrPunctuations.joined(separator: "")
|
||||||
|
|
|
@ -32,6 +32,13 @@ import Cocoa
|
||||||
// MARK: - § 根據狀態調度按鍵輸入 (Handle Input with States)
|
// MARK: - § 根據狀態調度按鍵輸入 (Handle Input with States)
|
||||||
|
|
||||||
extension KeyHandler {
|
extension KeyHandler {
|
||||||
|
/// 對於輸入訊號的第一關處理均藉由此函式來進行。
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: 輸入訊號。
|
||||||
|
/// - state: 給定狀態(通常為當前狀態)。
|
||||||
|
/// - stateCallback: 狀態回呼,交給對應的型別內的專有函數來處理。
|
||||||
|
/// - errorCallback: 錯誤回呼。
|
||||||
|
/// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。
|
||||||
func handle(
|
func handle(
|
||||||
input: InputSignal,
|
input: InputSignal,
|
||||||
state: InputStateProtocol,
|
state: InputStateProtocol,
|
||||||
|
@ -78,7 +85,7 @@ extension KeyHandler {
|
||||||
{
|
{
|
||||||
// 略過對 BackSpace 的處理。
|
// 略過對 BackSpace 的處理。
|
||||||
} else if input.isCapsLockOn {
|
} else if input.isCapsLockOn {
|
||||||
// 但願能夠處理這種情況下所有可能的案件組合。
|
// 但願能夠處理這種情況下所有可能的按鍵組合。
|
||||||
clear()
|
clear()
|
||||||
stateCallback(InputState.Empty())
|
stateCallback(InputState.Empty())
|
||||||
|
|
||||||
|
@ -256,9 +263,7 @@ extension KeyHandler {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Calling candidate window using Up / Down or PageUp / PageDn.
|
// MARK: 用上下左右鍵呼叫選字窗 (Calling candidate window using Up / Down or PageUp / PageDn.)
|
||||||
|
|
||||||
// 用上下左右鍵呼叫選字窗。
|
|
||||||
|
|
||||||
if let currentState = state as? InputState.NotEmpty, composer.isEmpty,
|
if let currentState = state as? InputState.NotEmpty, composer.isEmpty,
|
||||||
input.isExtraChooseCandidateKey || input.isExtraChooseCandidateKeyReverse || input.isSpace
|
input.isExtraChooseCandidateKey || input.isExtraChooseCandidateKeyReverse || input.isSpace
|
||||||
|
@ -394,7 +399,7 @@ extension KeyHandler {
|
||||||
inputting.textToCommit = textToCommit
|
inputting.textToCommit = textToCommit
|
||||||
stateCallback(inputting)
|
stateCallback(inputting)
|
||||||
stateCallback(buildCandidate(state: inputting, isTypingVertical: input.isTypingVertical))
|
stateCallback(buildCandidate(state: inputting, isTypingVertical: input.isTypingVertical))
|
||||||
} else { // If there is still unfinished bpmf reading, ignore the punctuation
|
} else { // 不要在注音沒敲完整的情況下叫出統合符號選單。
|
||||||
IME.prtDebugIntel("17446655")
|
IME.prtDebugIntel("17446655")
|
||||||
errorCallback()
|
errorCallback()
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,9 +113,8 @@ extension KeyHandler {
|
||||||
let composedText = head + reading + tail
|
let composedText = head + reading + tail
|
||||||
let cursorIndex = composedStringCursorIndex + reading.utf16.count
|
let cursorIndex = composedStringCursorIndex + reading.utf16.count
|
||||||
|
|
||||||
var cleanedComposition = ""
|
|
||||||
|
|
||||||
// 防止組字區內出現不可列印的字元。
|
// 防止組字區內出現不可列印的字元。
|
||||||
|
var cleanedComposition = ""
|
||||||
for theChar in composedText {
|
for theChar in composedText {
|
||||||
if let charCode = theChar.utf16.first {
|
if let charCode = theChar.utf16.first {
|
||||||
if !(theChar.isASCII && !(charCode.isPrintable())) {
|
if !(theChar.isASCII && !(charCode.isPrintable())) {
|
||||||
|
|
Loading…
Reference in New Issue