KeyHandler // Documentation fix.

This commit is contained in:
ShikiSuen 2022-06-29 10:25:38 +08:00
parent 4bdb528f2d
commit dbe54d7a8b
4 changed files with 21 additions and 10 deletions

View File

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

View File

@ -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: "")

View File

@ -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()
} }

View File

@ -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())) {