From 9e857b80d499b61b20c4209c97a2e4b97216264e Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 21 Oct 2022 08:46:40 +0800 Subject: [PATCH] Repo // Turn currentLM and currentUOM into dynamic var. --- Source/Modules/LMMgr.swift | 4 ++-- Source/Modules/SessionCtl_Core.swift | 18 +++++++++--------- Source/Modules/SessionCtl_Menu.swift | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/Modules/LMMgr.swift b/Source/Modules/LMMgr.swift index 3c4b21ab..5cbafb48 100644 --- a/Source/Modules/LMMgr.swift +++ b/Source/Modules/LMMgr.swift @@ -27,7 +27,7 @@ public enum LMMgr { public private(set) static var uomCHT = vChewingLM.LMUserOverride( dataURL: Self.userOverrideModelDataURL(.imeModeCHT)) - public static func currentLM() -> vChewingLM.LMInstantiator { + public static var currentLM: vChewingLM.LMInstantiator { switch IMEApp.currentInputMode { case .imeModeCHS: return Self.lmCHS @@ -38,7 +38,7 @@ public enum LMMgr { } } - public static func currentUOM() -> vChewingLM.LMUserOverride { + public static var currentUOM: vChewingLM.LMUserOverride { switch IMEApp.currentInputMode { case .imeModeCHS: return Self.uomCHS diff --git a/Source/Modules/SessionCtl_Core.swift b/Source/Modules/SessionCtl_Core.swift index 4abee057..d750ff79 100644 --- a/Source/Modules/SessionCtl_Core.swift +++ b/Source/Modules/SessionCtl_Core.swift @@ -63,7 +63,7 @@ public class SessionCtl: IMKInputController { /// 輸入調度模組的副本。 var inputHandler: InputHandlerProtocol = InputHandler( - lm: LMMgr.currentLM(), uom: LMMgr.currentUOM(), pref: PrefMgr.shared + lm: LMMgr.currentLM, uom: LMMgr.currentUOM, pref: PrefMgr.shared ) /// 用以記錄當前輸入法狀態的變數。 public var state: IMEStateProtocol = IMEState.ofEmpty() { @@ -110,8 +110,8 @@ public class SessionCtl: IMKInputController { inputHandler.clear() // 這句不要砍,因為後面 handle State.Empty() 不一定執行。 // ---------------------------- /// 重設所有語言模組。這裡不需要做按需重設,因為對運算量沒有影響。 - inputHandler.currentLM = LMMgr.currentLM() // 會自動更新組字引擎內的模組。 - inputHandler.currentUOM = LMMgr.currentUOM() + inputHandler.currentLM = LMMgr.currentLM // 會自動更新組字引擎內的模組。 + inputHandler.currentUOM = LMMgr.currentUOM /// 清空注拼槽+同步最新的注拼槽排列設定。 inputHandler.ensureKeyboardParser() /// 將輸入法偏好設定同步至語言模組內。 @@ -241,12 +241,12 @@ extension SessionCtl { /// 將輸入法偏好設定同步至語言模組內。 public func syncBaseLMPrefs() { - LMMgr.currentLM().isPhraseReplacementEnabled = PrefMgr.shared.phraseReplacementEnabled - LMMgr.currentLM().isCNSEnabled = PrefMgr.shared.cns11643Enabled - LMMgr.currentLM().isSymbolEnabled = PrefMgr.shared.symbolInputEnabled - LMMgr.currentLM().isSCPCEnabled = PrefMgr.shared.useSCPCTypingMode - LMMgr.currentLM().isCassetteEnabled = PrefMgr.shared.cassetteEnabled - LMMgr.currentLM().deltaOfCalendarYears = PrefMgr.shared.deltaOfCalendarYears + LMMgr.currentLM.isPhraseReplacementEnabled = PrefMgr.shared.phraseReplacementEnabled + LMMgr.currentLM.isCNSEnabled = PrefMgr.shared.cns11643Enabled + LMMgr.currentLM.isSymbolEnabled = PrefMgr.shared.symbolInputEnabled + LMMgr.currentLM.isSCPCEnabled = PrefMgr.shared.useSCPCTypingMode + LMMgr.currentLM.isCassetteEnabled = PrefMgr.shared.cassetteEnabled + LMMgr.currentLM.deltaOfCalendarYears = PrefMgr.shared.deltaOfCalendarYears } } diff --git a/Source/Modules/SessionCtl_Menu.swift b/Source/Modules/SessionCtl_Menu.swift index e55d3865..7f605b8d 100644 --- a/Source/Modules/SessionCtl_Menu.swift +++ b/Source/Modules/SessionCtl_Menu.swift @@ -250,7 +250,7 @@ extension SessionCtl { ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")) ) - if !LMMgr.currentLM().currentCassette.isLoaded { + if !LMMgr.currentLM.currentCassette.isLoaded { LMMgr.loadCassetteData() } }