diff --git a/Source/AppDelegate.swift b/Source/AppDelegate.swift index 1d80bbd0..b1c3391b 100644 --- a/Source/AppDelegate.swift +++ b/Source/AppDelegate.swift @@ -62,7 +62,7 @@ struct VersionUpdateApi { static func check(forced: Bool, callback: @escaping (Result) -> ()) -> URLSessionTask? { guard let infoDict = Bundle.main.infoDictionary, let updateInfoURLString = infoDict[kUpdateInfoEndpointKey] as? String, - let updateInfoURL = URL(string:(updateInfoURLString + (forced ? "?manual=yes" : ""))) else { + let updateInfoURL = URL(string: (updateInfoURLString + (forced ? "?manual=yes" : ""))) else { return nil } @@ -80,8 +80,7 @@ struct VersionUpdateApi { do { guard let plist = try PropertyListSerialization.propertyList(from: data ?? Data(), options: [], format: nil) as? [AnyHashable: Any], let remoteVersion = plist[kCFBundleVersionKey] as? String, - let infoDict = Bundle.main.infoDictionary - else { + let infoDict = Bundle.main.infoDictionary else { DispatchQueue.main.async { forced ? callback(.success(.noNeedToUpdate)) : callback(.success(.ignored)) } @@ -102,8 +101,7 @@ struct VersionUpdateApi { } guard let siteInfoURLString = plist[kUpdateInfoSiteKey] as? String, - let siteInfoURL = URL(string: siteInfoURLString) - else { + let siteInfoURL = URL(string: siteInfoURLString) else { DispatchQueue.main.async { forced ? callback(.success(.noNeedToUpdate)) : callback(.success(.ignored)) } @@ -235,7 +233,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NonModalAlertWindowControlle report.versionDescription) NonModalAlertWindowController.shared.show(title: NSLocalizedString("New Version Available", comment: ""), content: content, confirmButtonTitle: NSLocalizedString("Visit Website", comment: ""), cancelButtonTitle: NSLocalizedString("Not Now", comment: ""), cancelAsDefault: false, delegate: self) case .noNeedToUpdate: - NonModalAlertWindowController.shared.show(title:NSLocalizedString("Check for Update Completed", comment: ""), content:NSLocalizedString("McBopomofo is up to date.", comment: ""), confirmButtonTitle:NSLocalizedString("OK", comment: ""), cancelButtonTitle:nil, cancelAsDefault: false, delegate: self) + NonModalAlertWindowController.shared.show(title: NSLocalizedString("Check for Update Completed", comment: ""), content: NSLocalizedString("McBopomofo is up to date.", comment: ""), confirmButtonTitle: NSLocalizedString("OK", comment: ""), cancelButtonTitle: nil, cancelAsDefault: false, delegate: self) case .ignored: break } diff --git a/Source/Base.lproj/preferences.xib b/Source/Base.lproj/preferences.xib index 4970c723..337b0e2f 100644 --- a/Source/Base.lproj/preferences.xib +++ b/Source/Base.lproj/preferences.xib @@ -1,8 +1,8 @@ - + - + @@ -28,7 +28,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -69,19 +69,19 @@ - - + + @@ -99,7 +99,7 @@ - + @@ -137,7 +137,7 @@ - + @@ -145,7 +145,7 @@ - + @@ -153,7 +153,7 @@ - + @@ -251,18 +251,18 @@ - + @@ -298,7 +298,7 @@ - + @@ -385,19 +385,21 @@ - + - - + + + - - + + + @@ -421,16 +423,18 @@ - - + + + - - + + + @@ -454,25 +458,29 @@ + + + + + - - - - - - - - - - - - + - + @@ -500,7 +508,7 @@ - + @@ -512,7 +520,7 @@ - + @@ -545,7 +553,7 @@ - + @@ -563,7 +571,7 @@ - + @@ -574,7 +582,7 @@ - + @@ -582,7 +590,7 @@ - + diff --git a/Source/KeyHandler.mm b/Source/KeyHandler.mm index f8b7c5f2..24acadbd 100644 --- a/Source/KeyHandler.mm +++ b/Source/KeyHandler.mm @@ -491,21 +491,26 @@ - (BOOL)handleInput:(KeyHandlerInput *)input state:(InputState *)inState stateCa } // MARK: Enter Big5 code mode + if ([input isControlHold] && (charCode == '`')) { - [self clear]; - if ([state isKindOfClass:[InputStateInputting class]]) { - InputStateInputting *current = (InputStateInputting *)state; - NSString *composingBuffer = current.composingBuffer; - InputStateCommitting *committing = [[InputStateCommitting alloc] initWithPoppedText:composingBuffer]; - stateCallback(committing); + if (Preferences.big5InputEnabled) { + [self clear]; + if ([state isKindOfClass:[InputStateInputting class]]) { + InputStateInputting *current = (InputStateInputting *)state; + NSString *composingBuffer = current.composingBuffer; + InputStateCommitting *committing = [[InputStateCommitting alloc] initWithPoppedText:composingBuffer]; + stateCallback(committing); + } + InputStateBig5 *big5 = [[InputStateBig5 alloc] initWithCode:@""]; + stateCallback(big5); + return YES; } - InputStateBig5 *big5 = [[InputStateBig5 alloc] initWithCode:@""]; - stateCallback(big5); - return YES; } // MARK: Punctuation list - if ((char)charCode == '`') { + if ((char)charCode == '`' && + !([input isControlHold] || [input isCommandHold] || [input isOptionHold]) + ) { if (_languageModel->hasUnigrams("_punctuation_list")) { if (_bpmfReadingBuffer->isEmpty()) { _grid->insertReading("_punctuation_list"); diff --git a/Source/Preferences.swift b/Source/Preferences.swift index a572875c..3b421c07 100644 --- a/Source/Preferences.swift +++ b/Source/Preferences.swift @@ -63,6 +63,7 @@ private let kAddPhraseHookEnabledKey = "AddPhraseHookEnabled" private let kAddPhraseHookPath = "AddPhraseHookPath" private let kSelectCandidateWithNumericKeypad = "SelectCandidateWithNumericKeypad" +private let kBig5InputEnabledKey = "Big5InputEnabled" // MARK: Property wrappers @@ -187,7 +188,7 @@ struct CandidateListTextSize { // MARK: - class Preferences: NSObject { - static var allKeys:[String] { + static var allKeys: [String] { [kKeyboardLayoutPreferenceKey, kBasisKeyboardLayoutPreferenceKey, kFunctionKeyKeyboardLayoutPreferenceKey, @@ -333,7 +334,6 @@ class Preferences: NSObject { } } - } extension Preferences { @@ -420,7 +420,7 @@ extension Preferences { } return customUserPhraseLocation }() - let notification = Notification(name: .userPhraseLocationDidChange, object: self, userInfo: [ + let notification = Notification(name: .userPhraseLocationDidChange, object: self, userInfo: [ "location": location ]) NotificationQueue.default.dequeueNotifications(matching: notification, coalesceMask: 0) @@ -458,7 +458,12 @@ extension Preferences { } extension Preferences { - @UserDefault(key: kSelectCandidateWithNumericKeypad, defaultValue: false) @objc static var selectCandidateWithNumericKeypad: Bool } + + +extension Preferences { + @UserDefault(key: kBig5InputEnabledKey, defaultValue: true) + @objc static var big5InputEnabled: Bool +} diff --git a/Source/zh-Hant.lproj/preferences.xib b/Source/zh-Hant.lproj/preferences.xib index e0c79447..f9b7fb3f 100644 --- a/Source/zh-Hant.lproj/preferences.xib +++ b/Source/zh-Hant.lproj/preferences.xib @@ -1,8 +1,8 @@ - + - + @@ -28,7 +28,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -62,8 +62,8 @@ - - + + @@ -71,7 +71,7 @@ - + @@ -81,24 +81,24 @@ - - + + - - + + - - + + @@ -153,7 +153,7 @@ - - + + @@ -178,8 +178,8 @@ - - + + @@ -197,8 +197,8 @@ - - + + @@ -206,7 +206,7 @@ - + @@ -265,7 +265,7 @@ - + @@ -357,11 +357,11 @@ - + - - + + @@ -369,7 +369,7 @@ - + @@ -393,8 +393,8 @@ - - + + @@ -402,7 +402,7 @@ - + @@ -426,27 +426,44 @@ + + + + + + + + - + - - + + @@ -454,7 +471,7 @@ - + @@ -471,7 +488,7 @@ - + @@ -483,8 +500,8 @@ - - + + @@ -495,7 +512,7 @@ - + @@ -522,7 +539,7 @@ - + @@ -536,7 +553,7 @@ - + @@ -545,7 +562,7 @@ - + - +