-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
支持命令行切换中英文模式 #797
Open
PangPangPangPangPang
wants to merge
3
commits into
rime:master
Choose a base branch
from
PangPangPangPangPang:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
支持命令行切换中英文模式 #797
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
init
- Loading branch information
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
#import "SquirrelApplicationDelegate.h" | ||
#include <Foundation/Foundation.h> | ||
#import <Cocoa/Cocoa.h> | ||
#import <InputMethodKit/InputMethodKit.h> | ||
#import <rime_api.h> | ||
|
@@ -61,6 +62,22 @@ int main(int argc, char *argv[]) { | |
return 0; | ||
} | ||
|
||
if (argc > 2 && !strcmp("--ascii_mode", argv[1])) { | ||
[[NSDistributedNotificationCenter defaultCenter] | ||
postNotificationName:@"SquirrelChangeNotification" | ||
object: nil | ||
userInfo:@{@"ascii_mode" : [NSString stringWithFormat:@"%s", argv[2]]}]; | ||
return 0; | ||
} | ||
|
||
if (argc > 1 && !strcmp("--ascii_mode_prev", argv[1])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the caller keep track of which state should be put back in? |
||
[[NSDistributedNotificationCenter defaultCenter] | ||
postNotificationName:@"SquirrelChangePrevNotification" | ||
object: nil]; | ||
return 0; | ||
} | ||
|
||
|
||
@autoreleasepool { | ||
// find the bundle identifier and then initialize the input method server | ||
NSBundle *main = [NSBundle mainBundle]; | ||
|
@@ -70,19 +87,19 @@ int main(int argc, char *argv[]) { | |
|
||
// load the bundle explicitly because in this case the input method is a | ||
// background only application | ||
[main loadNibNamed:@"MainMenu" owner:[NSApplication sharedApplication] topLevelObjects:NULL]; | ||
[main loadNibNamed:@"MainMenu" | ||
owner:[NSApplication sharedApplication] | ||
topLevelObjects:NULL]; | ||
|
||
// opencc will be configured with relative dictionary paths | ||
[[NSFileManager defaultManager] | ||
changeCurrentDirectoryPath:main.sharedSupportPath]; | ||
|
||
if (NSApp.squirrelAppDelegate.problematicLaunchDetected) { | ||
NSLog(@"Problematic launch detected!"); | ||
NSArray *args = @[ | ||
@"Problematic launch detected! \ | ||
NSArray *args = @[ @"Problematic launch detected! \ | ||
Squirrel may be suffering a crash due to imporper configuration. \ | ||
Revert previous modifications to see if the problem recurs." | ||
]; | ||
Revert previous modifications to see if the problem recurs." ]; | ||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/say" arguments:args]; | ||
} else { | ||
[NSApp.squirrelAppDelegate setupRime]; | ||
|
@@ -94,6 +111,7 @@ int main(int argc, char *argv[]) { | |
// finally run everything | ||
[[NSApplication sharedApplication] run]; | ||
|
||
|
||
NSLog(@"Squirrel is quitting..."); | ||
rime_get_api()->finalize(); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_prev
does not sync with the current status from the rime session.Between last call to
changeToAscii
and this one, theascii_mode
value could have changed by the user.