IME // Deprecating alphanumerical mode.

- Caps Lock is enough.
This commit is contained in:
ShikiSuen 2022-03-11 13:13:24 +08:00
parent 33f96b5a7c
commit 5d9420650f
3 changed files with 3 additions and 41 deletions

View File

@ -276,11 +276,11 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
return NO; return NO;
} }
// Caps Lock processing: if Caps Lock is on or Preferences.isAlphanumericalModeEnabled, temporarily disable bopomofo. // Caps Lock processing: if Caps Lock is ON, temporarily disable bopomofo.
// Also: Alphanumerical mode processing. // Note: Alphanumerical mode processing.
if ([input isBackSpace] || [input isEnter] || [input isAbsorbedArrowKey] || [input isExtraChooseCandidateKey] || [input isExtraChooseCandidateKeyReverse] || [input isCursorForward] || [input isCursorBackward]) { 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 // 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. // process all possible combination, we hope.
[self clear]; [self clear];
InputStateEmpty *emptyState = [[InputStateEmpty alloc] init]; InputStateEmpty *emptyState = [[InputStateEmpty alloc] init];

View File

@ -20,7 +20,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
import Cocoa import Cocoa
private let kIsDebugModeEnabled = "_DebugMode" private let kIsDebugModeEnabled = "_DebugMode"
private let kIsAlphanumericalModeEnabled = "IsAlphanumericalModeEnabled"
private let kCheckUpdateAutomatically = "CheckUpdateAutomatically" private let kCheckUpdateAutomatically = "CheckUpdateAutomatically"
private let kKeyboardLayoutPreference = "KeyboardLayout" private let kKeyboardLayoutPreference = "KeyboardLayout"
private let kBasisKeyboardLayoutPreference = "BasisKeyboardLayout" private let kBasisKeyboardLayoutPreference = "BasisKeyboardLayout"
@ -217,7 +216,6 @@ struct ComposingBufferSize {
@objc public class Preferences: NSObject { @objc public class Preferences: NSObject {
static var allKeys:[String] { static var allKeys:[String] {
[kIsDebugModeEnabled, [kIsDebugModeEnabled,
kIsAlphanumericalModeEnabled,
kKeyboardLayoutPreference, kKeyboardLayoutPreference,
kBasisKeyboardLayoutPreference, kBasisKeyboardLayoutPreference,
kFunctionKeyKeyboardLayoutPreference, kFunctionKeyKeyboardLayoutPreference,
@ -259,11 +257,6 @@ struct ComposingBufferSize {
UserDefaults.standard.set(Preferences.isDebugModeEnabled, forKey: kIsDebugModeEnabled) 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 { if UserDefaults.standard.object(forKey: kCheckUpdateAutomatically) == nil {
UserDefaults.standard.set(false, forKey: kCheckUpdateAutomatically) UserDefaults.standard.set(false, forKey: kCheckUpdateAutomatically)
@ -360,16 +353,6 @@ struct ComposingBufferSize {
@UserDefault(key: kIsDebugModeEnabled, defaultValue: false) @UserDefault(key: kIsDebugModeEnabled, defaultValue: false)
@objc static var isDebugModeEnabled: Bool @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: []) @UserDefault(key: kAppleLanguagesPreferences, defaultValue: [])
@objc static var appleLanguages: Array<String> @objc static var appleLanguages: Array<String>

View File

@ -97,10 +97,6 @@ class ctlInputMethod: IMKInputController {
userAssociatedPhrasesItem.keyEquivalentModifierMask = [.command, .control] userAssociatedPhrasesItem.keyEquivalentModifierMask = [.command, .control]
userAssociatedPhrasesItem.state = Preferences.associatedPhrasesEnabled.state 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 { if optionKeyPressed {
let phaseReplacementItem = menu.addItem(withTitle: NSLocalizedString("Use Phrase Replacement", comment: ""), action: #selector(togglePhraseReplacement(_:)), keyEquivalent: "") let phaseReplacementItem = menu.addItem(withTitle: NSLocalizedString("Use Phrase Replacement", comment: ""), action: #selector(togglePhraseReplacement(_:)), keyEquivalent: "")
phaseReplacementItem.state = Preferences.phraseReplacementEnabled.state phaseReplacementItem.state = Preferences.phraseReplacementEnabled.state
@ -191,11 +187,6 @@ class ctlInputMethod: IMKInputController {
override func handle(_ event: NSEvent!, client: Any!) -> Bool { override func handle(_ event: NSEvent!, client: Any!) -> Bool {
if (Preferences.isAlphanumericalModeEnabled) {
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: Preferences.functionKeyboardLayout)
return false
}
if event.type == .flagsChanged { if event.type == .flagsChanged {
let functionKeyKeyboardLayoutID = Preferences.functionKeyboardLayout let functionKeyKeyboardLayoutID = Preferences.functionKeyboardLayout
let basisKeyboardLayoutID = Preferences.basisKeyboardLayout let basisKeyboardLayoutID = Preferences.basisKeyboardLayout
@ -207,14 +198,6 @@ class ctlInputMethod: IMKInputController {
let includeShift = Preferences.functionKeyKeyboardLayoutOverrideIncludeShiftKey let includeShift = Preferences.functionKeyKeyboardLayoutOverrideIncludeShiftKey
let notShift = NSEvent.ModifierFlags(rawValue: ~(NSEvent.ModifierFlags.shift.rawValue)) 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) || if event.modifierFlags.contains(notShift) ||
(event.modifierFlags.contains(.shift) && includeShift) { (event.modifierFlags.contains(.shift) && includeShift) {
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: functionKeyKeyboardLayoutID) (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: ""))) 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?) { @objc func togglePhraseReplacement(_ sender: Any?) {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Use Phrase Replacement", comment: ""), "\n", Preferences.togglePhraseReplacementEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Use Phrase Replacement", comment: ""), "\n", Preferences.togglePhraseReplacementEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }