diff --git a/.clang-format b/.clang-format
index 5cb45537d..f0b9df629 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,2 +1,2 @@
BasedOnStyle: Chromium
-SortIncludes: false
+SortIncludes: false
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 9d1758a9e..f2314cea0 100644
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ $(RIME_DEPS):
$(MAKE) -C librime deps
librime: $(RIME_DEPS)
- $(MAKE) -C librime install
+ $(MAKE) -C librime release install
$(MAKE) copy-rime-binaries
copy-rime-binaries:
diff --git a/Squirrel.entitlements b/Squirrel.entitlements
deleted file mode 100644
index 4e847e0c5..000000000
--- a/Squirrel.entitlements
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
- com.apple.security.temporary-exception.files.home-relative-path.read-write
-
- /Library/Rime/
-
- com.apple.security.temporary-exception.mach-register.global-name
- Squirrel_1_Connection
- com.apple.security.files.bookmarks.app-scope
-
- com.apple.security.app-sandbox
-
- com.apple.security.files.user-selected.read-write
-
- com.apple.security.network.client
-
-
-
diff --git a/Squirrel.xcodeproj/project.pbxproj b/Squirrel.xcodeproj/project.pbxproj
index 937b7297f..78acaa4b2 100644
--- a/Squirrel.xcodeproj/project.pbxproj
+++ b/Squirrel.xcodeproj/project.pbxproj
@@ -84,6 +84,7 @@
A4FC48CB0F6530EF0069BE81 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A4FC48C90F6530EF0069BE81 /* Localizable.strings */; };
D26434552706A15100857391 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D26434542706A15100857391 /* QuartzCore.framework */; };
E93074B70A5C264700470842 /* InputMethodKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E93074B60A5C264700470842 /* InputMethodKit.framework */; };
+ F45E005F2B8CA81C00179B75 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F45E005E2B8CA81C00179B75 /* UserNotifications.framework */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -232,7 +233,6 @@
44F84AD614E94C490005D70B /* SquirrelPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SquirrelPanel.m; sourceTree = ""; };
44FA4D891685997300116C1F /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; };
44FA4D8E16859B2900116C1F /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = ""; };
- 5BCE17192B81D03D008C8D9E /* Squirrel.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Squirrel.entitlements; sourceTree = ""; };
77AA67DC2588916300A592E2 /* HKVariants.ocd2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = HKVariants.ocd2; sourceTree = ""; };
77AA67DD2588916300A592E2 /* t2s.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = t2s.json; sourceTree = ""; };
77AA67DE2588916300A592E2 /* t2tw.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = t2tw.json; sourceTree = ""; };
@@ -279,6 +279,7 @@
A4FC48CA0F6530EF0069BE81 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; };
D26434542706A15100857391 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
E93074B60A5C264700470842 /* InputMethodKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = InputMethodKit.framework; path = /System/Library/Frameworks/InputMethodKit.framework; sourceTree = ""; };
+ F45E005E2B8CA81C00179B75 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -288,6 +289,7 @@
files = (
D26434552706A15100857391 /* QuartzCore.framework in Frameworks */,
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
+ F45E005F2B8CA81C00179B75 /* UserNotifications.framework in Frameworks */,
E93074B70A5C264700470842 /* InputMethodKit.framework in Frameworks */,
A4B8E1B30F645B870094E08B /* Carbon.framework in Frameworks */,
447765C925C30E97002415AF /* Sparkle.framework in Frameworks */,
@@ -349,7 +351,6 @@
29B97314FDCFA39411CA2CEA /* Squirrel */ = {
isa = PBXGroup;
children = (
- 5BCE17192B81D03D008C8D9E /* Squirrel.entitlements */,
442C648F1F7A40180027EFBE /* bin */,
44DA7A4214DD598900C1ED3B /* SharedSupport */,
080E96DDFE201D6D7F000001 /* Sources */,
@@ -381,6 +382,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
+ F45E005E2B8CA81C00179B75 /* UserNotifications.framework */,
D26434542706A15100857391 /* QuartzCore.framework */,
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
@@ -605,7 +607,6 @@
buildSettings = {
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
- CODE_SIGN_ENTITLEMENTS = Squirrel.entitlements;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
@@ -656,7 +657,6 @@
buildSettings = {
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
- CODE_SIGN_ENTITLEMENTS = Squirrel.entitlements;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.16.2u;
diff --git a/SquirrelApplicationDelegate.m b/SquirrelApplicationDelegate.m
index 22143a74a..ae4591fa6 100644
--- a/SquirrelApplicationDelegate.m
+++ b/SquirrelApplicationDelegate.m
@@ -32,54 +32,42 @@ - (IBAction)openWiki:(id)sender {
}
void show_notification(const char* msg_text) {
- if (@available(macOS 10.14, *)) {
- UNUserNotificationCenter* center =
- UNUserNotificationCenter.currentNotificationCenter;
- [center
- requestAuthorizationWithOptions:UNAuthorizationOptionAlert |
- UNAuthorizationOptionProvisional
- completionHandler:^(BOOL granted,
- NSError* _Nullable error) {
- if (error) {
- NSLog(@"User notification authorization error: %@",
- error.debugDescription);
- }
- }];
- [center getNotificationSettingsWithCompletionHandler:^(
- UNNotificationSettings* _Nonnull settings) {
- if ((settings.authorizationStatus == UNAuthorizationStatusAuthorized ||
- settings.authorizationStatus == UNAuthorizationStatusProvisional) &&
- (settings.alertSetting == UNNotificationSettingEnabled)) {
- UNMutableNotificationContent* content =
- [[UNMutableNotificationContent alloc] init];
- content.title = NSLocalizedString(@"Squirrel", nil);
- content.subtitle = NSLocalizedString(@(msg_text), nil);
- if (@available(macOS 12.0, *)) {
- content.interruptionLevel = UNNotificationInterruptionLevelActive;
- }
- UNNotificationRequest* request =
- [UNNotificationRequest requestWithIdentifier:@"SquirrelNotification"
- content:content
- trigger:nil];
- [center addNotificationRequest:request
- withCompletionHandler:^(NSError* _Nullable error) {
- if (error) {
- NSLog(@"User notification request error: %@",
- error.debugDescription);
- }
- }];
+ UNUserNotificationCenter* center =
+ UNUserNotificationCenter.currentNotificationCenter;
+ [center requestAuthorizationWithOptions:UNAuthorizationOptionAlert |
+ UNAuthorizationOptionProvisional
+ completionHandler:^(BOOL granted,
+ NSError* _Nullable error) {
+ if (error) {
+ NSLog(@"User notification authorization error: %@",
+ error.debugDescription);
+ }
+ }];
+ [center getNotificationSettingsWithCompletionHandler:^(
+ UNNotificationSettings* _Nonnull settings) {
+ if ((settings.authorizationStatus == UNAuthorizationStatusAuthorized ||
+ settings.authorizationStatus == UNAuthorizationStatusProvisional) &&
+ (settings.alertSetting == UNNotificationSettingEnabled)) {
+ UNMutableNotificationContent* content =
+ [[UNMutableNotificationContent alloc] init];
+ content.title = NSLocalizedString(@"Squirrel", nil);
+ content.subtitle = NSLocalizedString(@(msg_text), nil);
+ if (@available(macOS 12.0, *)) {
+ content.interruptionLevel = UNNotificationInterruptionLevelActive;
}
- }];
- } else {
- NSUserNotification* notification = [[NSUserNotification alloc] init];
- notification.title = NSLocalizedString(@"Squirrel", nil);
- notification.subtitle = NSLocalizedString(@(msg_text), nil);
-
- NSUserNotificationCenter* notificationCenter =
- NSUserNotificationCenter.defaultUserNotificationCenter;
- [notificationCenter removeAllDeliveredNotifications];
- [notificationCenter deliverNotification:notification];
- }
+ UNNotificationRequest* request =
+ [UNNotificationRequest requestWithIdentifier:@"SquirrelNotification"
+ content:content
+ trigger:nil];
+ [center addNotificationRequest:request
+ withCompletionHandler:^(NSError* _Nullable error) {
+ if (error) {
+ NSLog(@"User notification request error: %@",
+ error.debugDescription);
+ }
+ }];
+ }
+ }];
}
static void show_status(const char* msg_text_long, const char* msg_text_short) {
@@ -150,13 +138,13 @@ static void notification_handler(void* context_object,
}
- (void)setupRime {
- NSString* userDataDir = (@"~/Library/Rime").stringByStandardizingPath;
+ NSString* userDataDir = @"~/Library/Rime".stringByExpandingTildeInPath;
NSFileManager* fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:userDataDir]) {
if (![fileManager createDirectoryAtPath:userDataDir
withIntermediateDirectories:YES
attributes:nil
- error:NULL]) {
+ error:nil]) {
NSLog(@"Error creating user data directory: %@", userDataDir);
}
}
@@ -168,8 +156,8 @@ - (void)setupRime {
squirrel_traits.user_data_dir = userDataDir.UTF8String;
squirrel_traits.distribution_code_name = "Squirrel";
squirrel_traits.distribution_name = "鼠鬚管";
- squirrel_traits.distribution_version =
- [[NSBundle mainBundle].infoDictionary[@"CFBundleVersion"] UTF8String];
+ squirrel_traits.distribution_version = [[[NSBundle mainBundle]
+ objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey] UTF8String];
squirrel_traits.app_name = "rime.squirrel";
rime_get_api()->setup(&squirrel_traits);
}
@@ -295,9 +283,7 @@ - (BOOL)problematicLaunchDetected {
NSData* record = [NSKeyedArchiver archivedDataWithRootObject:now
requiringSecureCoding:NO
error:nil];
- NSFileHandle* fileHandle = [NSFileHandle fileHandleForWritingToURL:logfile
- error:nil];
- [fileHandle writeData:record];
+ [record writeToURL:logfile atomically:NO];
return detected;
}
@@ -350,9 +336,7 @@ - (void)awakeFromNib {
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
- if (_panel) {
- [_panel hide];
- }
+ [_panel hide];
}
@end // SquirrelApplicationDelegate
diff --git a/SquirrelConfig.m b/SquirrelConfig.m
index 4395ebb04..d4e0a7f61 100644
--- a/SquirrelConfig.m
+++ b/SquirrelConfig.m
@@ -137,22 +137,22 @@ - (BOOL)hasSection:(NSString*)section {
return NO;
}
-- (BOOL)setBool:(bool)value forOption:(NSString*)option {
+- (BOOL)setOption:(NSString*)option withBool:(bool)value {
return (BOOL)(rime_get_api()->config_set_bool(&_config, option.UTF8String,
value));
}
-- (BOOL)setInt:(int)value forOption:(NSString*)option {
+- (BOOL)setOption:(NSString*)option withInt:(int)value {
return (
BOOL)(rime_get_api()->config_set_int(&_config, option.UTF8String, value));
}
-- (BOOL)setDouble:(double)value forOption:(NSString*)option {
+- (BOOL)setOption:(NSString*)option withDouble:(double)value {
return (BOOL)(rime_get_api()->config_set_double(&_config, option.UTF8String,
value));
}
-- (BOOL)setString:(NSString*)value forOption:(NSString*)option {
+- (BOOL)setOption:(NSString*)option withString:(NSString*)value {
return (BOOL)(rime_get_api()->config_set_string(&_config, option.UTF8String,
value.UTF8String));
}
diff --git a/SquirrelInputController.m b/SquirrelInputController.m
index e9278ed51..34f64549e 100644
--- a/SquirrelInputController.m
+++ b/SquirrelInputController.m
@@ -19,14 +19,13 @@ - (void)updateAppOptions;
static NSString* const kFullWidthSpace = @" ";
@implementation SquirrelInputController {
- id _currentClient;
NSMutableAttributedString* _preeditString;
NSString* _originalString;
NSString* _composedString;
NSRange _selRange;
NSUInteger _caretPos;
- NSArray* _candidates;
- NSUInteger _lastModifiers;
+ NSArray* _candidates;
+ NSEventModifierFlags _lastModifiers;
NSEventType _lastEventType;
NSUInteger _lastPageNum;
RimeSessionId _session;
@@ -55,9 +54,7 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender {
// system will not deliver a key down event to the application.
// Returning NO means the original key down will be passed on to the client.
- _currentClient = sender;
-
- NSUInteger modifiers = event.modifierFlags;
+ NSEventModifierFlags modifiers = event.modifierFlags;
BOOL handled = NO;
@@ -69,7 +66,7 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender {
}
}
- NSString* app = [_currentClient bundleIdentifier];
+ NSString* app = [sender bundleIdentifier];
if (![_currentApp isEqualToString:app]) {
_currentApp = [app copy];
@@ -88,15 +85,16 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender {
int rime_keycode = 0;
// For flags-changed event, keyCode is available since macOS 10.15
// (#715)
- Bool keyCodeAvailable = NO;
+ BOOL keyCodeAvailable = NO;
if (@available(macOS 10.15, *)) {
keyCodeAvailable = YES;
- rime_keycode = osx_keycode_to_rime_keycode(event.keyCode, 0, 0, 0);
+ rime_keycode =
+ osx_keycode_to_rime_keycode((int)event.keyCode, 0, 0, 0);
// NSLog(@"keyCode: %d", event.keyCode);
}
int release_mask = 0;
NSUInteger changes = _lastModifiers ^ modifiers;
- if (changes & OSX_CAPITAL_MASK) {
+ if (changes & NSEventModifierFlagCapsLock) {
if (!keyCodeAvailable) {
rime_keycode = XK_Caps_Lock;
}
@@ -106,35 +104,39 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender {
rime_modifiers ^= kLockMask;
[self processKey:rime_keycode modifiers:rime_modifiers];
}
- if (changes & OSX_SHIFT_MASK) {
+ if (changes & NSEventModifierFlagShift) {
if (!keyCodeAvailable) {
rime_keycode = XK_Shift_L;
}
- release_mask = modifiers & OSX_SHIFT_MASK ? 0 : kReleaseMask;
+ release_mask =
+ modifiers & NSEventModifierFlagShift ? 0 : kReleaseMask;
[self processKey:rime_keycode
modifiers:(rime_modifiers | release_mask)];
}
- if (changes & OSX_CTRL_MASK) {
+ if (changes & NSEventModifierFlagControl) {
if (!keyCodeAvailable) {
rime_keycode = XK_Control_L;
}
- release_mask = modifiers & OSX_CTRL_MASK ? 0 : kReleaseMask;
+ release_mask =
+ modifiers & NSEventModifierFlagControl ? 0 : kReleaseMask;
[self processKey:rime_keycode
modifiers:(rime_modifiers | release_mask)];
}
- if (changes & OSX_ALT_MASK) {
+ if (changes & NSEventModifierFlagOption) {
if (!keyCodeAvailable) {
rime_keycode = XK_Alt_L;
}
- release_mask = modifiers & OSX_ALT_MASK ? 0 : kReleaseMask;
+ release_mask =
+ modifiers & NSEventModifierFlagOption ? 0 : kReleaseMask;
[self processKey:rime_keycode
modifiers:(rime_modifiers | release_mask)];
}
- if (changes & OSX_COMMAND_MASK) {
+ if (changes & NSEventModifierFlagCommand) {
if (!keyCodeAvailable) {
rime_keycode = XK_Super_L;
}
- release_mask = modifiers & OSX_COMMAND_MASK ? 0 : kReleaseMask;
+ release_mask =
+ modifiers & NSEventModifierFlagCommand ? 0 : kReleaseMask;
[self processKey:rime_keycode
modifiers:(rime_modifiers | release_mask)];
// do not update UI when using Command key
@@ -144,10 +146,11 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender {
} break;
case NSEventTypeKeyDown: {
// ignore Command+X hotkeys.
- if (modifiers & OSX_COMMAND_MASK)
+ if (modifiers & NSEventModifierFlagCommand) {
break;
+ }
- int keyCode = event.keyCode;
+ ushort keyCode = event.keyCode;
NSString* keyChars = event.charactersIgnoringModifiers;
if (!isalpha(keyChars.UTF8String[0])) {
keyChars = event.characters;
@@ -158,8 +161,9 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender {
// translate osx keyevents to rime keyevents
int rime_keycode = osx_keycode_to_rime_keycode(
- keyCode, keyChars.UTF8String[0], modifiers & OSX_SHIFT_MASK,
- modifiers & OSX_CAPITAL_MASK);
+ (int)keyCode, (int)keyChars.UTF8String[0],
+ (int)modifiers & NSEventModifierFlagShift,
+ (int)modifiers & NSEventModifierFlagCapsLock);
if (rime_keycode) {
int rime_modifiers = osx_modifiers_to_rime_modifiers(modifiers);
handled = [self processKey:rime_keycode modifiers:rime_modifiers];
@@ -404,7 +408,7 @@ - (void)updateChord:(int)keycode modifiers:(int)modifiers {
_chordModifiers[_chordKeyCount] = modifiers;
++_chordKeyCount;
// reset timer
- if (_chordTimer && _chordTimer.valid) {
+ if (_chordTimer.valid) {
[_chordTimer invalidate];
}
_chordDuration = 0.1;
@@ -422,10 +426,8 @@ - (void)updateChord:(int)keycode modifiers:(int)modifiers {
- (void)clearChord {
_chordKeyCount = 0;
- if (_chordTimer) {
- if (_chordTimer.valid) {
- [_chordTimer invalidate];
- }
+ if (_chordTimer.valid) {
+ [_chordTimer invalidate];
_chordTimer = nil;
}
}
@@ -532,6 +534,7 @@ - (instancetype)initWithServer:(IMKServer*)server
- (void)deactivateServer:(id)sender {
// NSLog(@"deactivateServer:");
+ [self hidePalettes];
[self commitComposition:sender];
[super deactivateServer:sender];
}
diff --git a/input_source.m b/input_source.m
index 2807dd7d2..224f74462 100644
--- a/input_source.m
+++ b/input_source.m
@@ -14,7 +14,7 @@ typedef NS_OPTIONS(int, RimeInputMode) {
void RegisterInputSource(void) {
CFURLRef installedLocationURL = CFURLCreateFromFileSystemRepresentation(
- NULL, (UTF8Char*)kInstallLocation, strlen(kInstallLocation), false);
+ NULL, (UInt8*)kInstallLocation, (CFIndex)strlen(kInstallLocation), false);
if (installedLocationURL) {
TISRegisterInputSource(installedLocationURL);
CFRelease(installedLocationURL);
@@ -26,9 +26,9 @@ void ActivateInputSource(int enabled_modes) {
CFArrayRef sourceList = TISCreateInputSourceList(NULL, true);
for (CFIndex i = 0; i < CFArrayGetCount(sourceList); ++i) {
TISInputSourceRef inputSource =
- (TISInputSourceRef)(CFArrayGetValueAtIndex(sourceList, i));
- CFStringRef sourceID = (CFStringRef)(TISGetInputSourceProperty(
- inputSource, kTISPropertyInputSourceID));
+ (TISInputSourceRef)CFArrayGetValueAtIndex(sourceList, i);
+ CFStringRef sourceID = (CFStringRef)TISGetInputSourceProperty(
+ inputSource, kTISPropertyInputSourceID);
// NSLog(@"Examining input source: %@", sourceID);
if ((!CFStringCompare(sourceID, kHansInputModeID, 0) &&
((enabled_modes & HANS_INPUT_MODE) != 0)) ||
@@ -51,14 +51,14 @@ void DeactivateInputSource(void) {
CFArrayRef sourceList = TISCreateInputSourceList(NULL, true);
for (CFIndex i = CFArrayGetCount(sourceList); i > 0; --i) {
TISInputSourceRef inputSource =
- (TISInputSourceRef)(CFArrayGetValueAtIndex(sourceList, i - 1));
- CFStringRef sourceID = (CFStringRef)(TISGetInputSourceProperty(
- inputSource, kTISPropertyInputSourceID));
+ (TISInputSourceRef)CFArrayGetValueAtIndex(sourceList, i - 1);
+ CFStringRef sourceID = (CFStringRef)TISGetInputSourceProperty(
+ inputSource, kTISPropertyInputSourceID);
// NSLog(@"Examining input source: %@", sourceID);
if (!CFStringCompare(sourceID, kHansInputModeID, 0) ||
!CFStringCompare(sourceID, kHantInputModeID, 0)) {
- CFBooleanRef isEnabled = (CFBooleanRef)(TISGetInputSourceProperty(
- inputSource, kTISPropertyInputSourceIsEnabled));
+ CFBooleanRef isEnabled = (CFBooleanRef)TISGetInputSourceProperty(
+ inputSource, kTISPropertyInputSourceIsEnabled);
if (CFBooleanGetValue(isEnabled)) {
TISDisableInputSource(inputSource);
NSLog(@"Disabled input source: %@", sourceID);
@@ -68,24 +68,25 @@ void DeactivateInputSource(void) {
CFRelease(sourceList);
}
-int GetEnabledInputModes(void) {
- int input_modes = 0;
+RimeInputMode GetEnabledInputModes(void) {
+ RimeInputMode input_modes = 0;
CFArrayRef sourceList = TISCreateInputSourceList(NULL, true);
for (CFIndex i = 0; i < CFArrayGetCount(sourceList); ++i) {
TISInputSourceRef inputSource =
- (TISInputSourceRef)(CFArrayGetValueAtIndex(sourceList, i));
- CFStringRef sourceID = (CFStringRef)(TISGetInputSourceProperty(
- inputSource, kTISPropertyInputSourceID));
+ (TISInputSourceRef)CFArrayGetValueAtIndex(sourceList, i);
+ CFStringRef sourceID = (CFStringRef)TISGetInputSourceProperty(
+ inputSource, kTISPropertyInputSourceID);
// NSLog(@"Examining input source: %@", sourceID);
if (!CFStringCompare(sourceID, kHansInputModeID, 0) ||
!CFStringCompare(sourceID, kHantInputModeID, 0)) {
- CFBooleanRef isEnabled = (CFBooleanRef)(TISGetInputSourceProperty(
- inputSource, kTISPropertyInputSourceIsEnabled));
+ CFBooleanRef isEnabled = (CFBooleanRef)TISGetInputSourceProperty(
+ inputSource, kTISPropertyInputSourceIsEnabled);
if (CFBooleanGetValue(isEnabled)) {
- if (!CFStringCompare(sourceID, kHansInputModeID, 0))
+ if (!CFStringCompare(sourceID, kHansInputModeID, 0)) {
input_modes |= HANS_INPUT_MODE;
- else if (!CFStringCompare(sourceID, kHantInputModeID, 0))
+ } else if (!CFStringCompare(sourceID, kHantInputModeID, 0)) {
input_modes |= HANT_INPUT_MODE;
+ }
}
}
}
diff --git a/main.m b/main.m
index 19d85a52d..3bcefda74 100644
--- a/main.m
+++ b/main.m
@@ -22,7 +22,7 @@ typedef NS_OPTIONS(int, RimeInputMode) {
int main(int argc, char* argv[]) {
if (argc > 1 && !strcmp("--quit", argv[1])) {
NSString* bundleId = [NSBundle mainBundle].bundleIdentifier;
- NSArray* runningSquirrels =
+ NSArray* runningSquirrels =
[NSRunningApplication runningApplicationsWithBundleIdentifier:bundleId];
for (NSRunningApplication* squirrelApp in runningSquirrels) {
[squirrelApp terminate];
@@ -42,7 +42,7 @@ int main(int argc, char* argv[]) {
RegisterInputSource();
int input_modes = GetEnabledInputModes();
DeactivateInputSource();
- ActivateInputSource(input_modes ? input_modes : DEFAULT_INPUT_MODE);
+ ActivateInputSource(input_modes ?: DEFAULT_INPUT_MODE);
return 0;
}
@@ -86,10 +86,15 @@ int main(int argc, char* argv[]) {
NSArray* args = @[ @"Problematic launch detected! \
Squirrel may be suffering a crash due to imporper configuration. \
Revert previous modifications to see if the problem recurs." ];
- [NSTask launchedTaskWithLaunchPath:@"/usr/bin/say" arguments:args];
+ [NSTask
+ launchedTaskWithExecutableURL:[NSURL fileURLWithPath:@"/usr/bin/say"
+ isDirectory:NO]
+ arguments:args
+ error:nil
+ terminationHandler:nil];
} else {
[NSApp.squirrelAppDelegate setupRime];
- [NSApp.squirrelAppDelegate startRimeWithFullCheck:NO];
+ [NSApp.squirrelAppDelegate startRimeWithFullCheck:false];
[NSApp.squirrelAppDelegate loadSettings];
NSLog(@"Squirrel reporting!");
}