Tab conversion into 4 spaces
This commit is contained in:
parent
8e5c540597
commit
0d8e1ae20f
|
@ -56,7 +56,7 @@ static const NSTimeInterval kNextCheckInterval = 86400.0;
|
|||
- (void)applicationDidFinishLaunching:(NSNotification *)inNotification
|
||||
{
|
||||
LTLoadLanguageModel();
|
||||
|
||||
|
||||
[self checkForUpdate];
|
||||
}
|
||||
|
||||
|
@ -70,36 +70,36 @@ static const NSTimeInterval kNextCheckInterval = 86400.0;
|
|||
if ([(NSDate *)[NSDate date] compare:date] == NSOrderedAscending) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NSDate *nextUpdateDate = [NSDate dateWithTimeInterval:kNextCheckInterval sinceDate:[NSDate date]];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:nextUpdateDate forKey:kNextUpdateCheckDateKey];
|
||||
|
||||
|
||||
if (_updateCheckConnection) {
|
||||
[_updateCheckConnection release];
|
||||
_updateCheckConnection = nil;
|
||||
}
|
||||
|
||||
|
||||
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
|
||||
NSString *updateInfoURLString = [infoDict objectForKey:kUpdateInfoEndpointKey];
|
||||
|
||||
|
||||
if (![updateInfoURLString length]) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NSURL *updateInfoURL = [NSURL URLWithString:updateInfoURLString];
|
||||
if (!updateInfoURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:updateInfoURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:kTimeoutInterval];
|
||||
|
||||
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
#if DEBUG
|
||||
NSLog(@"about to request update url %@ ",updateInfoURL);
|
||||
#endif
|
||||
|
||||
|
||||
_updateCheckConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
|
||||
[_updateCheckConnection start];
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ NSLog(@"error");
|
|||
if (!plist) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NSString *remoteVersion = [plist objectForKey:(id)kCFBundleVersionKey];
|
||||
#if DEBUG
|
||||
NSLog(@"the remoteversion is %@",remoteVersion);
|
||||
|
@ -126,10 +126,10 @@ NSLog(@"error");
|
|||
if (!remoteVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Validate info (e.g. bundle identifier)
|
||||
// TODO: Use HTML to display change log, need a new key like UpdateInfoChangeLogURL for this
|
||||
|
||||
|
||||
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
|
||||
NSString *currentVersion = [infoDict objectForKey:(id)kCFBundleVersionKey];
|
||||
NSComparisonResult result = [currentVersion compare:remoteVersion options:NSNumericSearch];
|
||||
|
@ -137,25 +137,25 @@ NSLog(@"error");
|
|||
if (result != NSOrderedAscending) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
NSString *siteInfoURLString = [plist objectForKey:kUpdateInfoSiteKey];
|
||||
if (!siteInfoURLString) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NSURL *siteInfoURL = [NSURL URLWithString:siteInfoURLString];
|
||||
if (!siteInfoURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (_updateNotificationController) {
|
||||
[_updateNotificationController release], _updateNotificationController = nil;
|
||||
}
|
||||
|
||||
|
||||
_updateNotificationController = [[UpdateNotificationController alloc] initWithWindowNibName:@"UpdateNotificationController"];
|
||||
|
||||
|
||||
_updateNotificationController.siteURL = siteInfoURL;
|
||||
_updateNotificationController.infoText = [NSString stringWithFormat:NSLocalizedString(@"You are running version %@ (%@), and the new version %@ (%@) is now available.\n\nVisit the website to download it?", @""),
|
||||
[infoDict objectForKey:@"CFBundleShortVersionString"],
|
||||
|
@ -163,7 +163,7 @@ NSLog(@"error");
|
|||
[plist objectForKey:@"CFBundleShortVersionString"],
|
||||
[plist objectForKey:(id)kCFBundleVersionKey],
|
||||
nil];
|
||||
|
||||
|
||||
[_updateNotificationController showWindow:self];
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
|
|
@ -42,19 +42,19 @@
|
|||
@private
|
||||
// the reading buffer that takes user input
|
||||
Formosa::Mandarin::BopomofoReadingBuffer* _bpmfReadingBuffer;
|
||||
|
||||
|
||||
// the grid (lattice) builder for the unigrams (and bigrams)
|
||||
Formosa::Gramambular::BlockReadingBuilder* _builder;
|
||||
|
||||
|
||||
// latest walked path (trellis) using the Viterbi algorithm
|
||||
std::vector<Formosa::Gramambular::NodeAnchor> _walkedNodes;
|
||||
|
||||
|
||||
// the latest composing buffer that is updated to the foreground app
|
||||
NSMutableString *_composingBuffer;
|
||||
|
||||
|
||||
// the current text input client; we need to keep this when candidate panel is on
|
||||
id _currentCandidateClient;
|
||||
|
||||
|
||||
// a special deferred client for Terminal.app fix
|
||||
id _currentDeferredClient;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
|||
// OVInputSourceHelper.m
|
||||
//
|
||||
// Copyright (c) 2010-2011 Lukhnos D. Liu (lukhnos at lukhnos dot org)
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
|
@ -30,55 +30,55 @@
|
|||
@implementation OVInputSourceHelper
|
||||
+ (NSArray *)allInstalledInputSources
|
||||
{
|
||||
CFArrayRef list = TISCreateInputSourceList(NULL, true);
|
||||
return [NSMakeCollectable(list) autorelease];
|
||||
CFArrayRef list = TISCreateInputSourceList(NULL, true);
|
||||
return [NSMakeCollectable(list) autorelease];
|
||||
}
|
||||
|
||||
+ (TISInputSourceRef)inputSourceForProperty:(CFStringRef)inPropertyKey stringValue:(NSString *)inValue
|
||||
{
|
||||
|
||||
CFTypeID stringID = CFStringGetTypeID();
|
||||
|
||||
for (id source in [self allInstalledInputSources]) {
|
||||
CFTypeRef property = TISGetInputSourceProperty((TISInputSourceRef)source, inPropertyKey);
|
||||
if (!property || CFGetTypeID(property) != stringID) {
|
||||
continue;
|
||||
}
|
||||
CFTypeID stringID = CFStringGetTypeID();
|
||||
|
||||
if (inValue && [inValue compare:(NSString *)property] == NSOrderedSame) {
|
||||
return (TISInputSourceRef)source;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
for (id source in [self allInstalledInputSources]) {
|
||||
CFTypeRef property = TISGetInputSourceProperty((TISInputSourceRef)source, inPropertyKey);
|
||||
if (!property || CFGetTypeID(property) != stringID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inValue && [inValue compare:(NSString *)property] == NSOrderedSame) {
|
||||
return (TISInputSourceRef)source;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+ (TISInputSourceRef)inputSourceForInputSourceID:(NSString *)inID
|
||||
{
|
||||
return [self inputSourceForProperty:kTISPropertyInputSourceID stringValue:inID];
|
||||
return [self inputSourceForProperty:kTISPropertyInputSourceID stringValue:inID];
|
||||
}
|
||||
|
||||
+ (BOOL)inputSourceEnabled:(TISInputSourceRef)inInputSource
|
||||
{
|
||||
CFBooleanRef value = TISGetInputSourceProperty(inInputSource, kTISPropertyInputSourceIsEnabled);
|
||||
return value ? (BOOL)CFBooleanGetValue(value) : NO;
|
||||
CFBooleanRef value = TISGetInputSourceProperty(inInputSource, kTISPropertyInputSourceIsEnabled);
|
||||
return value ? (BOOL)CFBooleanGetValue(value) : NO;
|
||||
}
|
||||
|
||||
+ (BOOL)enableInputSource:(TISInputSourceRef)inInputSource
|
||||
{
|
||||
OSStatus status = TISEnableInputSource(inInputSource);
|
||||
return status == noErr;
|
||||
OSStatus status = TISEnableInputSource(inInputSource);
|
||||
return status == noErr;
|
||||
}
|
||||
|
||||
+ (BOOL)disableInputSource:(TISInputSourceRef)inInputSource
|
||||
{
|
||||
OSStatus status = TISDisableInputSource(inInputSource);
|
||||
return status == noErr;
|
||||
OSStatus status = TISDisableInputSource(inInputSource);
|
||||
return status == noErr;
|
||||
}
|
||||
|
||||
+ (BOOL)registerInputSource:(NSURL *)inBundleURL
|
||||
{
|
||||
OSStatus status = TISRegisterInputSource((CFURLRef)inBundleURL);
|
||||
return status == noErr;
|
||||
OSStatus status = TISRegisterInputSource((CFURLRef)inBundleURL);
|
||||
return status == noErr;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -42,13 +42,13 @@
|
|||
// if (![[NSApplication sharedApplication] respondsToSelector:@selector(disableRelaunchOnLogin)]) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
NSMenu *menu = [_fontSizePopUpButton menu];
|
||||
NSArray *menuItems = [menu itemArray];
|
||||
|
||||
|
||||
for (NSMenuItem *item in menuItems) {
|
||||
NSUInteger tag = [item tag];
|
||||
|
||||
|
||||
if (tag != 14 && tag != 24) {
|
||||
[menu removeItem:item];
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
NSButton *_visitButton;
|
||||
NSButton *_laterButton;
|
||||
NSTextField *_infoTextField;
|
||||
|
||||
|
||||
NSURL *_siteURL;
|
||||
NSString *_infoText;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
if (self) {
|
||||
_infoText = @"Version info here";
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -64,14 +64,14 @@
|
|||
[_visitButton setTitle:NSLocalizedString(@"Visit Website", @"")];
|
||||
[_laterButton setTitle:NSLocalizedString(@"Check Later", @"")];
|
||||
[_infoTextField setStringValue:_infoText];
|
||||
|
||||
|
||||
[[self window] makeFirstResponder:_visitButton];
|
||||
}
|
||||
|
||||
- (void)windowDidLoad
|
||||
{
|
||||
[super windowDidLoad];
|
||||
|
||||
|
||||
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
//
|
||||
// Based on the Syrup Project and the Formosana Library
|
||||
// by Lukhnos Liu (@lukhnos).
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
|
@ -41,7 +41,7 @@ IMKCandidates *LTSharedCandidates = nil;
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
|
||||
// register and enable the input source (along with all its input modes)
|
||||
if (argc > 1 && !strcmp(argv[1], "install")) {
|
||||
NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
|
||||
|
@ -54,35 +54,35 @@ int main(int argc, char *argv[])
|
|||
// For Mac OS X 10.5
|
||||
bundleURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
|
||||
}
|
||||
|
||||
|
||||
TISInputSourceRef inputSource = [OVInputSourceHelper inputSourceForInputSourceID:bundleID];
|
||||
|
||||
// if this IME name is not found in the list of available IMEs
|
||||
if (!inputSource) {
|
||||
NSLog(@"Registering input source %@ at %@.", bundleID, [bundleURL absoluteString]);
|
||||
// then register
|
||||
BOOL status = [OVInputSourceHelper registerInputSource:bundleURL];
|
||||
|
||||
BOOL status = [OVInputSourceHelper registerInputSource:bundleURL];
|
||||
|
||||
if (!status) {
|
||||
NSLog(@"Fatal error: Cannot register input source %@ at %@.", bundleID, [bundleURL absoluteString]);
|
||||
[pool drain];
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
inputSource = [OVInputSourceHelper inputSourceForInputSourceID:bundleID];
|
||||
// if it still doesn't register successfully, bail.
|
||||
if (!inputSource) {
|
||||
NSLog(@"Fatal error: Cannot find input source %@ after registration.", bundleID);
|
||||
[pool drain];
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if it's not enabled, just enabled it
|
||||
if (inputSource && ![OVInputSourceHelper inputSourceEnabled:inputSource]) {
|
||||
if (inputSource && ![OVInputSourceHelper inputSourceEnabled:inputSource]) {
|
||||
NSLog(@"Enabling input source %@ at %@.", bundleID, [bundleURL absoluteString]);
|
||||
BOOL status = [OVInputSourceHelper enableInputSource:inputSource];
|
||||
|
||||
|
||||
if (!status != noErr) {
|
||||
NSLog(@"Fatal error: Cannot enable input source %@.", bundleID);
|
||||
[pool drain];
|
||||
|
@ -94,42 +94,42 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
NSString *mainNibName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"NSMainNibFile"];
|
||||
if (!mainNibName) {
|
||||
NSLog(@"Fatal error: NSMainNibFile key not defined in Info.plist.");
|
||||
[pool drain];
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
|
||||
BOOL loadResult = [NSBundle loadNibNamed:mainNibName owner:[NSApplication sharedApplication]];
|
||||
if (!loadResult) {
|
||||
NSLog(@"Fatal error: Cannot load %@.", mainNibName);
|
||||
[pool drain];
|
||||
return -1;
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
IMKServer *server = [[IMKServer alloc] initWithName:kConnectionName bundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
|
||||
if (!server) {
|
||||
NSLog(@"Fatal error: Cannot initialize input method server with connection %@.", kConnectionName);
|
||||
[pool drain];
|
||||
return -1;
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
LTSharedCandidates = [[IMKCandidates alloc] initWithServer:server panelType:kIMKSingleColumnScrollingCandidatePanel];
|
||||
if (!LTSharedCandidates) {
|
||||
NSLog(@"Fatal error: Cannot initialize shared candidate panel with connection %@.", kConnectionName);
|
||||
[server release];
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
|
||||
[[NSApplication sharedApplication] run];
|
||||
[server release];
|
||||
[server release];
|
||||
[pool drain];
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue