From 692c3cf5567073b37aef2eb63c3d88afca9da66c Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 11 Mar 2022 13:13:24 +0800 Subject: [PATCH] IME // Deprecating alphanumerical mode. - Caps Lock is enough. --- .../Modules/ControllerModules/KeyHandler.mm | 6 +++--- .../IMEModules/PreferencesModule.swift | 17 --------------- .../Modules/IMEModules/ctlInputMethod.swift | 21 ------------------- 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 5760db1b..2eafc2eb 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -276,11 +276,11 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; return NO; } - // Caps Lock processing: if Caps Lock is on or Preferences.isAlphanumericalModeEnabled, temporarily disable bopomofo. - // Also: Alphanumerical mode processing. + // Caps Lock processing: if Caps Lock is ON, temporarily disable bopomofo. + // Note: Alphanumerical mode processing. if ([input isBackSpace] || [input isEnter] || [input isAbsorbedArrowKey] || [input isExtraChooseCandidateKey] || [input isExtraChooseCandidateKeyReverse] || [input isCursorForward] || [input isCursorBackward]) { // do nothing if backspace is pressed -- we ignore the key - } else if (Preferences.isAlphanumericalModeEnabled || [input isCapsLockOn]) { + } else if ([input isCapsLockOn]) { // process all possible combination, we hope. [self clear]; InputStateEmpty *emptyState = [[InputStateEmpty alloc] init]; diff --git a/Source/Modules/IMEModules/PreferencesModule.swift b/Source/Modules/IMEModules/PreferencesModule.swift index 050a4e34..95684357 100644 --- a/Source/Modules/IMEModules/PreferencesModule.swift +++ b/Source/Modules/IMEModules/PreferencesModule.swift @@ -20,7 +20,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH import Cocoa private let kIsDebugModeEnabled = "_DebugMode" -private let kIsAlphanumericalModeEnabled = "IsAlphanumericalModeEnabled" private let kCheckUpdateAutomatically = "CheckUpdateAutomatically" private let kKeyboardLayoutPreference = "KeyboardLayout" private let kBasisKeyboardLayoutPreference = "BasisKeyboardLayout" @@ -217,7 +216,6 @@ struct ComposingBufferSize { @objc public class Preferences: NSObject { static var allKeys:[String] { [kIsDebugModeEnabled, - kIsAlphanumericalModeEnabled, kKeyboardLayoutPreference, kBasisKeyboardLayoutPreference, kFunctionKeyKeyboardLayoutPreference, @@ -259,11 +257,6 @@ struct ComposingBufferSize { UserDefaults.standard.set(Preferences.isDebugModeEnabled, forKey: kIsDebugModeEnabled) } - // 首次啟用輸入法時不要啟用英數模式。 - if UserDefaults.standard.object(forKey: kIsAlphanumericalModeEnabled) == nil { - UserDefaults.standard.set(Preferences.isAlphanumericalModeEnabled, forKey: kIsAlphanumericalModeEnabled) - } - // 首次啟用輸入法時設定不要自動更新,免得在某些要隔絕外部網路連線的保密機構內觸犯資安規則。 if UserDefaults.standard.object(forKey: kCheckUpdateAutomatically) == nil { UserDefaults.standard.set(false, forKey: kCheckUpdateAutomatically) @@ -360,16 +353,6 @@ struct ComposingBufferSize { @UserDefault(key: kIsDebugModeEnabled, defaultValue: false) @objc static var isDebugModeEnabled: Bool - @UserDefault(key: kIsAlphanumericalModeEnabled, defaultValue: false) - @objc static var isAlphanumericalModeEnabled: Bool - - @objc @discardableResult static func toggleAlphanumericalModeEnabled() -> Bool { - isAlphanumericalModeEnabled = !isAlphanumericalModeEnabled - UserDefaults.standard.set(isAlphanumericalModeEnabled, forKey: kIsAlphanumericalModeEnabled) - NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Alphanumerical Input Mode", comment: ""), "\n", isAlphanumericalModeEnabled ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) - return isAlphanumericalModeEnabled - } - @UserDefault(key: kAppleLanguagesPreferences, defaultValue: []) @objc static var appleLanguages: Array diff --git a/Source/Modules/IMEModules/ctlInputMethod.swift b/Source/Modules/IMEModules/ctlInputMethod.swift index 56f485ed..da16d850 100644 --- a/Source/Modules/IMEModules/ctlInputMethod.swift +++ b/Source/Modules/IMEModules/ctlInputMethod.swift @@ -97,10 +97,6 @@ class ctlInputMethod: IMKInputController { userAssociatedPhrasesItem.keyEquivalentModifierMask = [.command, .control] userAssociatedPhrasesItem.state = Preferences.associatedPhrasesEnabled.state - let alphaNumericalModeItem = menu.addItem(withTitle: NSLocalizedString("Alphanumerical Input Mode", comment: ""), action: #selector(toggleAlphanumericalModeEnabled(_:)), keyEquivalent: "I") - alphaNumericalModeItem.keyEquivalentModifierMask = [.command, .control] - alphaNumericalModeItem.state = Preferences.isAlphanumericalModeEnabled.state - if optionKeyPressed { let phaseReplacementItem = menu.addItem(withTitle: NSLocalizedString("Use Phrase Replacement", comment: ""), action: #selector(togglePhraseReplacement(_:)), keyEquivalent: "") phaseReplacementItem.state = Preferences.phraseReplacementEnabled.state @@ -191,11 +187,6 @@ class ctlInputMethod: IMKInputController { override func handle(_ event: NSEvent!, client: Any!) -> Bool { - if (Preferences.isAlphanumericalModeEnabled) { - (client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: Preferences.functionKeyboardLayout) - return false - } - if event.type == .flagsChanged { let functionKeyKeyboardLayoutID = Preferences.functionKeyboardLayout let basisKeyboardLayoutID = Preferences.basisKeyboardLayout @@ -207,14 +198,6 @@ class ctlInputMethod: IMKInputController { let includeShift = Preferences.functionKeyKeyboardLayoutOverrideIncludeShiftKey let notShift = NSEvent.ModifierFlags(rawValue: ~(NSEvent.ModifierFlags.shift.rawValue)) - // Shift Click Handling: Toggling Alphanumerical Mode. // STILL BUGGY, hence being commented out. - // if !event.modifierFlags.contains(.shift) - // && event.modifierFlags == .init(rawValue: 0) - // && !event.modifierFlags.contains(notShift) - // && (event.keyCode == KeyCode.leftShift.rawValue || event.keyCode == KeyCode.rightShift.rawValue) { - // Preferences.toggleAlphanumericalModeEnabled() - // } - if event.modifierFlags.contains(notShift) || (event.modifierFlags.contains(.shift) && includeShift) { (client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: functionKeyKeyboardLayoutID) @@ -279,10 +262,6 @@ class ctlInputMethod: IMKInputController { NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Associated Phrases", comment: ""), "\n", Preferences.toggleAssociatedPhrasesEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) } - @objc func toggleAlphanumericalModeEnabled(_ sender: Any?) { - Preferences.toggleAlphanumericalModeEnabled() - } - @objc func togglePhraseReplacement(_ sender: Any?) { NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Use Phrase Replacement", comment: ""), "\n", Preferences.togglePhraseReplacementEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) }