mgrPrefs // Let IME remember its most recent input mode.
This commit is contained in:
parent
77a4b47ba3
commit
f2ca6ed5c9
|
@ -112,11 +112,11 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
||||||
|
|
||||||
// 緊接著將新的簡繁輸入模式提報給 ctlInputMethod:
|
// 緊接著將新的簡繁輸入模式提報給 ctlInputMethod:
|
||||||
ctlInputMethod.currentInputMode = isCHS ? imeModeCHS : imeModeCHT;
|
ctlInputMethod.currentInputMode = isCHS ? imeModeCHS : imeModeCHT;
|
||||||
|
mgrPrefs.mostRecentInputMode = ctlInputMethod.currentInputMode;
|
||||||
|
|
||||||
// 拿當前的 _inputMode 與 ctlInputMethod 的提報結果對比,不同的話則套用新設定:
|
// 拿當前的 _inputMode 與 ctlInputMethod 的提報結果對比,不同的話則套用新設定:
|
||||||
if (![_inputMode isEqualToString:ctlInputMethod.currentInputMode])
|
if (![_inputMode isEqualToString:ctlInputMethod.currentInputMode])
|
||||||
{
|
{
|
||||||
|
|
||||||
// Reinitiate language models if necessary
|
// Reinitiate language models if necessary
|
||||||
[self setInputModesToLM:isCHS];
|
[self setInputModesToLM:isCHS];
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ class ctlInputMethod: IMKInputController {
|
||||||
// 所以才需要「currentKeyHandler」這個假 keyHandler。
|
// 所以才需要「currentKeyHandler」這個假 keyHandler。
|
||||||
// 這個「currentKeyHandler」僅用來讓其他模組知道當前的輸入模式是什麼模式,除此之外別無屌用。
|
// 這個「currentKeyHandler」僅用來讓其他模組知道當前的輸入模式是什麼模式,除此之外別無屌用。
|
||||||
static var currentKeyHandler: KeyHandler = KeyHandler()
|
static var currentKeyHandler: KeyHandler = KeyHandler()
|
||||||
@objc static var currentInputMode = ""
|
@objc static var currentInputMode = mgrPrefs.mostRecentInputMode
|
||||||
|
|
||||||
// MARK: - Keyboard Layout Specifier
|
// MARK: - Keyboard Layout Specifier
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import Cocoa
|
||||||
|
|
||||||
struct UserDef {
|
struct UserDef {
|
||||||
static let kIsDebugModeEnabled = "_DebugMode"
|
static let kIsDebugModeEnabled = "_DebugMode"
|
||||||
|
static let kMostRecentInputMode = "MostRecentInputMode"
|
||||||
static let kUserDataFolderSpecified = "UserDataFolderSpecified"
|
static let kUserDataFolderSpecified = "UserDataFolderSpecified"
|
||||||
static let kCheckUpdateAutomatically = "CheckUpdateAutomatically"
|
static let kCheckUpdateAutomatically = "CheckUpdateAutomatically"
|
||||||
static let kMandarinParser = "MandarinParser"
|
static let kMandarinParser = "MandarinParser"
|
||||||
|
@ -204,6 +205,7 @@ public class mgrPrefs: NSObject {
|
||||||
static var allKeys: [String] {
|
static var allKeys: [String] {
|
||||||
[
|
[
|
||||||
UserDef.kIsDebugModeEnabled,
|
UserDef.kIsDebugModeEnabled,
|
||||||
|
UserDef.kMostRecentInputMode,
|
||||||
UserDef.kUserDataFolderSpecified,
|
UserDef.kUserDataFolderSpecified,
|
||||||
UserDef.kMandarinParser,
|
UserDef.kMandarinParser,
|
||||||
UserDef.kBasicKeyboardLayout,
|
UserDef.kBasicKeyboardLayout,
|
||||||
|
@ -238,6 +240,7 @@ public class mgrPrefs: NSObject {
|
||||||
// MARK: - 既然 Preferences Module 的預設屬性不自動寫入 plist,那這邊就先寫入了。
|
// MARK: - 既然 Preferences Module 的預設屬性不自動寫入 plist,那這邊就先寫入了。
|
||||||
@objc public static func setMissingDefaults() {
|
@objc public static func setMissingDefaults() {
|
||||||
UserDefaults.standard.setDefault(mgrPrefs.isDebugModeEnabled, forKey: UserDef.kIsDebugModeEnabled)
|
UserDefaults.standard.setDefault(mgrPrefs.isDebugModeEnabled, forKey: UserDef.kIsDebugModeEnabled)
|
||||||
|
UserDefaults.standard.setDefault(mgrPrefs.mostRecentInputMode, forKey: UserDef.kMostRecentInputMode)
|
||||||
UserDefaults.standard.setDefault(mgrPrefs.checkUpdateAutomatically, forKey: UserDef.kCheckUpdateAutomatically)
|
UserDefaults.standard.setDefault(mgrPrefs.checkUpdateAutomatically, forKey: UserDef.kCheckUpdateAutomatically)
|
||||||
UserDefaults.standard.setDefault(
|
UserDefaults.standard.setDefault(
|
||||||
mgrPrefs.showPageButtonsInCandidateWindow, forKey: UserDef.kShowPageButtonsInCandidateWindow)
|
mgrPrefs.showPageButtonsInCandidateWindow, forKey: UserDef.kShowPageButtonsInCandidateWindow)
|
||||||
|
@ -271,6 +274,9 @@ public class mgrPrefs: NSObject {
|
||||||
@UserDefault(key: UserDef.kIsDebugModeEnabled, defaultValue: false)
|
@UserDefault(key: UserDef.kIsDebugModeEnabled, defaultValue: false)
|
||||||
@objc static var isDebugModeEnabled: Bool
|
@objc static var isDebugModeEnabled: Bool
|
||||||
|
|
||||||
|
@UserDefault(key: UserDef.kMostRecentInputMode, defaultValue: "")
|
||||||
|
@objc static var mostRecentInputMode: String
|
||||||
|
|
||||||
@UserDefault(key: UserDef.kCheckUpdateAutomatically, defaultValue: false)
|
@UserDefault(key: UserDef.kCheckUpdateAutomatically, defaultValue: false)
|
||||||
@objc static var checkUpdateAutomatically: Bool
|
@objc static var checkUpdateAutomatically: Bool
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue