SessionCtl // Optimize setValue(), init(), and inputMode().

This commit is contained in:
ShikiSuen 2022-11-04 17:02:10 +08:00
parent c9c2ab9064
commit af218e9e7c
1 changed files with 11 additions and 9 deletions

View File

@ -108,6 +108,7 @@ public class SessionCtl: IMKInputController {
PrefMgr.shared.mostRecentInputMode = newValue.rawValue
}
didSet {
if PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModel(inputMode) }
if oldValue != inputMode, inputMode != .imeModeNULL {
UserDefaults.standard.synchronize()
inputHandler.clear() // handle State.Empty()
@ -119,9 +120,8 @@ public class SessionCtl: IMKInputController {
inputHandler.ensureKeyboardParser()
///
syncBaseLMPrefs()
// ----------------------------
Self.isVerticalTyping = isVerticalTyping
switchState(IMEState.ofEmpty())
/// 調
resetInputHandler()
}
}
}
@ -138,9 +138,9 @@ public class SessionCtl: IMKInputController {
super.init(server: server, delegate: delegate, client: inputClient)
inputHandler.delegate = self
syncBaseLMPrefs()
//
//
activateServer(inputClient)
if PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModel(IMEApp.currentInputMode) }
inputMode = .init(rawValue: PrefMgr.shared.mostRecentInputMode) ?? .imeModeNULL
}
}
@ -189,7 +189,7 @@ extension SessionCtl {
// activateServer nil
//
if inputHandler.delegate == nil { inputHandler.delegate = self }
// setValue() IMK activateServer() setValue()
// setValue() IMK activateServer() setValue()
inputHandler.clear() // handle State.Empty()
inputHandler.ensureKeyboardParser()
@ -220,6 +220,8 @@ extension SessionCtl {
}
///
/// - Remark: activateServer() setValue()
/// activateServer() setValue()
/// - Parameters:
/// - value: identifier bundle identifier info.plist
/// - tag: 使
@ -227,9 +229,9 @@ extension SessionCtl {
public override func setValue(_ value: Any!, forTag tag: Int, client sender: Any!) {
_ = tag //
_ = sender //
let newInputMode: Shared.InputMode = .init(rawValue: value as? String ?? "") ?? .imeModeNULL
if PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModel(newInputMode) }
inputMode = newInputMode
let mostRecentInputMode = PrefMgr.shared.mostRecentInputMode
inputMode = .init(rawValue: value as? String ?? mostRecentInputMode) ?? .imeModeNULL
Self.isVerticalTyping = isVerticalTyping
}
///