Tab conversion into 4 spaces

This commit is contained in:
Mengjuei 2012-02-26 20:53:51 -08:00
parent 8e5c540597
commit 0d8e1ae20f
8 changed files with 343 additions and 343 deletions

View File

@ -56,7 +56,7 @@ static const NSTimeInterval kNextCheckInterval = 86400.0;
- (void)applicationDidFinishLaunching:(NSNotification *)inNotification - (void)applicationDidFinishLaunching:(NSNotification *)inNotification
{ {
LTLoadLanguageModel(); LTLoadLanguageModel();
[self checkForUpdate]; [self checkForUpdate];
} }
@ -70,36 +70,36 @@ static const NSTimeInterval kNextCheckInterval = 86400.0;
if ([(NSDate *)[NSDate date] compare:date] == NSOrderedAscending) { if ([(NSDate *)[NSDate date] compare:date] == NSOrderedAscending) {
return; return;
} }
NSDate *nextUpdateDate = [NSDate dateWithTimeInterval:kNextCheckInterval sinceDate:[NSDate date]]; NSDate *nextUpdateDate = [NSDate dateWithTimeInterval:kNextCheckInterval sinceDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:nextUpdateDate forKey:kNextUpdateCheckDateKey]; [[NSUserDefaults standardUserDefaults] setObject:nextUpdateDate forKey:kNextUpdateCheckDateKey];
if (_updateCheckConnection) { if (_updateCheckConnection) {
[_updateCheckConnection release]; [_updateCheckConnection release];
_updateCheckConnection = nil; _updateCheckConnection = nil;
} }
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSString *updateInfoURLString = [infoDict objectForKey:kUpdateInfoEndpointKey]; NSString *updateInfoURLString = [infoDict objectForKey:kUpdateInfoEndpointKey];
if (![updateInfoURLString length]) { if (![updateInfoURLString length]) {
return; return;
} }
NSURL *updateInfoURL = [NSURL URLWithString:updateInfoURLString]; NSURL *updateInfoURL = [NSURL URLWithString:updateInfoURLString];
if (!updateInfoURL) { if (!updateInfoURL) {
return; return;
} }
NSURLRequest *request = [NSURLRequest requestWithURL:updateInfoURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:kTimeoutInterval]; NSURLRequest *request = [NSURLRequest requestWithURL:updateInfoURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:kTimeoutInterval];
if (!request) { if (!request) {
return; return;
} }
#if DEBUG #if DEBUG
NSLog(@"about to request update url %@ ",updateInfoURL); NSLog(@"about to request update url %@ ",updateInfoURL);
#endif #endif
_updateCheckConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; _updateCheckConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[_updateCheckConnection start]; [_updateCheckConnection start];
} }
@ -118,7 +118,7 @@ NSLog(@"error");
if (!plist) { if (!plist) {
return; return;
} }
NSString *remoteVersion = [plist objectForKey:(id)kCFBundleVersionKey]; NSString *remoteVersion = [plist objectForKey:(id)kCFBundleVersionKey];
#if DEBUG #if DEBUG
NSLog(@"the remoteversion is %@",remoteVersion); NSLog(@"the remoteversion is %@",remoteVersion);
@ -126,10 +126,10 @@ NSLog(@"error");
if (!remoteVersion) { if (!remoteVersion) {
return; return;
} }
// TODO: Validate info (e.g. bundle identifier) // TODO: Validate info (e.g. bundle identifier)
// TODO: Use HTML to display change log, need a new key like UpdateInfoChangeLogURL for this // TODO: Use HTML to display change log, need a new key like UpdateInfoChangeLogURL for this
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [infoDict objectForKey:(id)kCFBundleVersionKey]; NSString *currentVersion = [infoDict objectForKey:(id)kCFBundleVersionKey];
NSComparisonResult result = [currentVersion compare:remoteVersion options:NSNumericSearch]; NSComparisonResult result = [currentVersion compare:remoteVersion options:NSNumericSearch];
@ -137,25 +137,25 @@ NSLog(@"error");
if (result != NSOrderedAscending) { if (result != NSOrderedAscending) {
return; return;
} }
NSString *siteInfoURLString = [plist objectForKey:kUpdateInfoSiteKey]; NSString *siteInfoURLString = [plist objectForKey:kUpdateInfoSiteKey];
if (!siteInfoURLString) { if (!siteInfoURLString) {
return; return;
} }
NSURL *siteInfoURL = [NSURL URLWithString:siteInfoURLString]; NSURL *siteInfoURL = [NSURL URLWithString:siteInfoURLString];
if (!siteInfoURL) { if (!siteInfoURL) {
return; return;
} }
if (_updateNotificationController) { if (_updateNotificationController) {
[_updateNotificationController release], _updateNotificationController = nil; [_updateNotificationController release], _updateNotificationController = nil;
} }
_updateNotificationController = [[UpdateNotificationController alloc] initWithWindowNibName:@"UpdateNotificationController"]; _updateNotificationController = [[UpdateNotificationController alloc] initWithWindowNibName:@"UpdateNotificationController"];
_updateNotificationController.siteURL = siteInfoURL; _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?", @""), _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"], [infoDict objectForKey:@"CFBundleShortVersionString"],
@ -163,7 +163,7 @@ NSLog(@"error");
[plist objectForKey:@"CFBundleShortVersionString"], [plist objectForKey:@"CFBundleShortVersionString"],
[plist objectForKey:(id)kCFBundleVersionKey], [plist objectForKey:(id)kCFBundleVersionKey],
nil]; nil];
[_updateNotificationController showWindow:self]; [_updateNotificationController showWindow:self];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
} }

View File

@ -42,19 +42,19 @@
@private @private
// the reading buffer that takes user input // the reading buffer that takes user input
Formosa::Mandarin::BopomofoReadingBuffer* _bpmfReadingBuffer; Formosa::Mandarin::BopomofoReadingBuffer* _bpmfReadingBuffer;
// the grid (lattice) builder for the unigrams (and bigrams) // the grid (lattice) builder for the unigrams (and bigrams)
Formosa::Gramambular::BlockReadingBuilder* _builder; Formosa::Gramambular::BlockReadingBuilder* _builder;
// latest walked path (trellis) using the Viterbi algorithm // latest walked path (trellis) using the Viterbi algorithm
std::vector<Formosa::Gramambular::NodeAnchor> _walkedNodes; std::vector<Formosa::Gramambular::NodeAnchor> _walkedNodes;
// the latest composing buffer that is updated to the foreground app // the latest composing buffer that is updated to the foreground app
NSMutableString *_composingBuffer; NSMutableString *_composingBuffer;
// the current text input client; we need to keep this when candidate panel is on // the current text input client; we need to keep this when candidate panel is on
id _currentCandidateClient; id _currentCandidateClient;
// a special deferred client for Terminal.app fix // a special deferred client for Terminal.app fix
id _currentDeferredClient; id _currentDeferredClient;
} }

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
// OVInputSourceHelper.m // OVInputSourceHelper.m
// //
// Copyright (c) 2010-2011 Lukhnos D. Liu (lukhnos at lukhnos dot org) // Copyright (c) 2010-2011 Lukhnos D. Liu (lukhnos at lukhnos dot org)
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without // files (the "Software"), to deal in the Software without
@ -30,55 +30,55 @@
@implementation OVInputSourceHelper @implementation OVInputSourceHelper
+ (NSArray *)allInstalledInputSources + (NSArray *)allInstalledInputSources
{ {
CFArrayRef list = TISCreateInputSourceList(NULL, true); CFArrayRef list = TISCreateInputSourceList(NULL, true);
return [NSMakeCollectable(list) autorelease]; return [NSMakeCollectable(list) autorelease];
} }
+ (TISInputSourceRef)inputSourceForProperty:(CFStringRef)inPropertyKey stringValue:(NSString *)inValue + (TISInputSourceRef)inputSourceForProperty:(CFStringRef)inPropertyKey stringValue:(NSString *)inValue
{ {
CFTypeID stringID = CFStringGetTypeID();
for (id source in [self allInstalledInputSources]) { CFTypeID stringID = CFStringGetTypeID();
CFTypeRef property = TISGetInputSourceProperty((TISInputSourceRef)source, inPropertyKey);
if (!property || CFGetTypeID(property) != stringID) {
continue;
}
if (inValue && [inValue compare:(NSString *)property] == NSOrderedSame) { for (id source in [self allInstalledInputSources]) {
return (TISInputSourceRef)source; CFTypeRef property = TISGetInputSourceProperty((TISInputSourceRef)source, inPropertyKey);
} if (!property || CFGetTypeID(property) != stringID) {
} continue;
}
return NULL;
if (inValue && [inValue compare:(NSString *)property] == NSOrderedSame) {
return (TISInputSourceRef)source;
}
}
return NULL;
} }
+ (TISInputSourceRef)inputSourceForInputSourceID:(NSString *)inID + (TISInputSourceRef)inputSourceForInputSourceID:(NSString *)inID
{ {
return [self inputSourceForProperty:kTISPropertyInputSourceID stringValue:inID]; return [self inputSourceForProperty:kTISPropertyInputSourceID stringValue:inID];
} }
+ (BOOL)inputSourceEnabled:(TISInputSourceRef)inInputSource + (BOOL)inputSourceEnabled:(TISInputSourceRef)inInputSource
{ {
CFBooleanRef value = TISGetInputSourceProperty(inInputSource, kTISPropertyInputSourceIsEnabled); CFBooleanRef value = TISGetInputSourceProperty(inInputSource, kTISPropertyInputSourceIsEnabled);
return value ? (BOOL)CFBooleanGetValue(value) : NO; return value ? (BOOL)CFBooleanGetValue(value) : NO;
} }
+ (BOOL)enableInputSource:(TISInputSourceRef)inInputSource + (BOOL)enableInputSource:(TISInputSourceRef)inInputSource
{ {
OSStatus status = TISEnableInputSource(inInputSource); OSStatus status = TISEnableInputSource(inInputSource);
return status == noErr; return status == noErr;
} }
+ (BOOL)disableInputSource:(TISInputSourceRef)inInputSource + (BOOL)disableInputSource:(TISInputSourceRef)inInputSource
{ {
OSStatus status = TISDisableInputSource(inInputSource); OSStatus status = TISDisableInputSource(inInputSource);
return status == noErr; return status == noErr;
} }
+ (BOOL)registerInputSource:(NSURL *)inBundleURL + (BOOL)registerInputSource:(NSURL *)inBundleURL
{ {
OSStatus status = TISRegisterInputSource((CFURLRef)inBundleURL); OSStatus status = TISRegisterInputSource((CFURLRef)inBundleURL);
return status == noErr; return status == noErr;
} }
@end @end

View File

@ -42,13 +42,13 @@
// if (![[NSApplication sharedApplication] respondsToSelector:@selector(disableRelaunchOnLogin)]) { // if (![[NSApplication sharedApplication] respondsToSelector:@selector(disableRelaunchOnLogin)]) {
// return; // return;
// } // }
NSMenu *menu = [_fontSizePopUpButton menu]; NSMenu *menu = [_fontSizePopUpButton menu];
NSArray *menuItems = [menu itemArray]; NSArray *menuItems = [menu itemArray];
for (NSMenuItem *item in menuItems) { for (NSMenuItem *item in menuItems) {
NSUInteger tag = [item tag]; NSUInteger tag = [item tag];
if (tag != 14 && tag != 24) { if (tag != 14 && tag != 24) {
[menu removeItem:item]; [menu removeItem:item];
} }

View File

@ -39,7 +39,7 @@
NSButton *_visitButton; NSButton *_visitButton;
NSButton *_laterButton; NSButton *_laterButton;
NSTextField *_infoTextField; NSTextField *_infoTextField;
NSURL *_siteURL; NSURL *_siteURL;
NSString *_infoText; NSString *_infoText;
} }

View File

@ -47,7 +47,7 @@
if (self) { if (self) {
_infoText = @"Version info here"; _infoText = @"Version info here";
} }
return self; return self;
} }
@ -64,14 +64,14 @@
[_visitButton setTitle:NSLocalizedString(@"Visit Website", @"")]; [_visitButton setTitle:NSLocalizedString(@"Visit Website", @"")];
[_laterButton setTitle:NSLocalizedString(@"Check Later", @"")]; [_laterButton setTitle:NSLocalizedString(@"Check Later", @"")];
[_infoTextField setStringValue:_infoText]; [_infoTextField setStringValue:_infoText];
[[self window] makeFirstResponder:_visitButton]; [[self window] makeFirstResponder:_visitButton];
} }
- (void)windowDidLoad - (void)windowDidLoad
{ {
[super windowDidLoad]; [super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
} }

View File

@ -9,7 +9,7 @@
// //
// Based on the Syrup Project and the Formosana Library // Based on the Syrup Project and the Formosana Library
// by Lukhnos Liu (@lukhnos). // by Lukhnos Liu (@lukhnos).
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without // files (the "Software"), to deal in the Software without
@ -41,7 +41,7 @@ IMKCandidates *LTSharedCandidates = nil;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// register and enable the input source (along with all its input modes) // register and enable the input source (along with all its input modes)
if (argc > 1 && !strcmp(argv[1], "install")) { if (argc > 1 && !strcmp(argv[1], "install")) {
NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier]; NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
@ -54,35 +54,35 @@ int main(int argc, char *argv[])
// For Mac OS X 10.5 // For Mac OS X 10.5
bundleURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; bundleURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
} }
TISInputSourceRef inputSource = [OVInputSourceHelper inputSourceForInputSourceID:bundleID]; TISInputSourceRef inputSource = [OVInputSourceHelper inputSourceForInputSourceID:bundleID];
// if this IME name is not found in the list of available IMEs // if this IME name is not found in the list of available IMEs
if (!inputSource) { if (!inputSource) {
NSLog(@"Registering input source %@ at %@.", bundleID, [bundleURL absoluteString]); NSLog(@"Registering input source %@ at %@.", bundleID, [bundleURL absoluteString]);
// then register // then register
BOOL status = [OVInputSourceHelper registerInputSource:bundleURL]; BOOL status = [OVInputSourceHelper registerInputSource:bundleURL];
if (!status) { if (!status) {
NSLog(@"Fatal error: Cannot register input source %@ at %@.", bundleID, [bundleURL absoluteString]); NSLog(@"Fatal error: Cannot register input source %@ at %@.", bundleID, [bundleURL absoluteString]);
[pool drain]; [pool drain];
return -1; return -1;
} }
inputSource = [OVInputSourceHelper inputSourceForInputSourceID:bundleID]; inputSource = [OVInputSourceHelper inputSourceForInputSourceID:bundleID];
// if it still doesn't register successfully, bail. // if it still doesn't register successfully, bail.
if (!inputSource) { if (!inputSource) {
NSLog(@"Fatal error: Cannot find input source %@ after registration.", bundleID); NSLog(@"Fatal error: Cannot find input source %@ after registration.", bundleID);
[pool drain]; [pool drain];
return -1; return -1;
} }
} }
// if it's not enabled, just enabled it // 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]); NSLog(@"Enabling input source %@ at %@.", bundleID, [bundleURL absoluteString]);
BOOL status = [OVInputSourceHelper enableInputSource:inputSource]; BOOL status = [OVInputSourceHelper enableInputSource:inputSource];
if (!status != noErr) { if (!status != noErr) {
NSLog(@"Fatal error: Cannot enable input source %@.", bundleID); NSLog(@"Fatal error: Cannot enable input source %@.", bundleID);
[pool drain]; [pool drain];
@ -94,42 +94,42 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
} }
return 0; return 0;
} }
NSString *mainNibName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"NSMainNibFile"]; NSString *mainNibName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"NSMainNibFile"];
if (!mainNibName) { if (!mainNibName) {
NSLog(@"Fatal error: NSMainNibFile key not defined in Info.plist."); NSLog(@"Fatal error: NSMainNibFile key not defined in Info.plist.");
[pool drain]; [pool drain];
return -1; return -1;
} }
BOOL loadResult = [NSBundle loadNibNamed:mainNibName owner:[NSApplication sharedApplication]]; BOOL loadResult = [NSBundle loadNibNamed:mainNibName owner:[NSApplication sharedApplication]];
if (!loadResult) { if (!loadResult) {
NSLog(@"Fatal error: Cannot load %@.", mainNibName); NSLog(@"Fatal error: Cannot load %@.", mainNibName);
[pool drain]; [pool drain];
return -1; return -1;
} }
IMKServer *server = [[IMKServer alloc] initWithName:kConnectionName bundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]]; IMKServer *server = [[IMKServer alloc] initWithName:kConnectionName bundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
if (!server) { if (!server) {
NSLog(@"Fatal error: Cannot initialize input method server with connection %@.", kConnectionName); NSLog(@"Fatal error: Cannot initialize input method server with connection %@.", kConnectionName);
[pool drain]; [pool drain];
return -1; return -1;
} }
LTSharedCandidates = [[IMKCandidates alloc] initWithServer:server panelType:kIMKSingleColumnScrollingCandidatePanel]; LTSharedCandidates = [[IMKCandidates alloc] initWithServer:server panelType:kIMKSingleColumnScrollingCandidatePanel];
if (!LTSharedCandidates) { if (!LTSharedCandidates) {
NSLog(@"Fatal error: Cannot initialize shared candidate panel with connection %@.", kConnectionName); NSLog(@"Fatal error: Cannot initialize shared candidate panel with connection %@.", kConnectionName);
[server release]; [server release];
[pool drain]; [pool drain];
return -1; return -1;
} }
[[NSApplication sharedApplication] run]; [[NSApplication sharedApplication] run];
[server release]; [server release];
[pool drain]; [pool drain];
return 0; return 0;
} }