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