diff --git a/Dialog PlugIn.tmproj b/Dialog PlugIn.tmproj new file mode 100644 index 0000000..b7bdaa1 --- /dev/null +++ b/Dialog PlugIn.tmproj @@ -0,0 +1,78 @@ + + + + + currentDocument + Dialog.mm + documents + + + expanded + + name + Dialog PlugIn + regexFolderFilter + !.*/(\.[^/]*|CVS|include|3rd_party|\{arch\}|build|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$ + sourceDirectory + + + + fileHierarchyDrawerWidth + 200 + metaData + + Dialog.h + + caret + + column + 0 + line + 5 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + Dialog.mm + + caret + + column + 0 + line + 53 + + firstVisibleColumn + 0 + firstVisibleLine + 35 + + tm_dialog.mm + + caret + + column + 0 + line + 3 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + + openDocuments + + Dialog.mm + Dialog.h + tm_dialog.mm + + showFileHierarchyDrawer + + windowFrame + {{515, 451}, {766, 578}} + + diff --git a/Dialog.h b/Dialog.h new file mode 100644 index 0000000..f1bd228 --- /dev/null +++ b/Dialog.h @@ -0,0 +1,17 @@ +#import + +@protocol TMPlugInController +- (float)version; +@end + +@protocol TextMateDialogServerProtocol +- (int)textMateDialogServerProtocolVersion; +- (void)showNib:(NSString*)aNib withArguments:(id)someArguments; +@end + +@interface Dialog : NSObject +{ +} +- (id)initWithPlugInController:(id )aController; +- (void)dealloc; +@end diff --git a/Dialog.mm b/Dialog.mm new file mode 100644 index 0000000..434930c --- /dev/null +++ b/Dialog.mm @@ -0,0 +1,87 @@ +#import "Dialog.h" + +#ifndef enumerate +#define enumerate(container,var) for(NSEnumerator* _enumerator = [container objectEnumerator]; var = [_enumerator nextObject]; ) +#endif + +@interface CatchAllNibLoader : NSObject +{ +} +@end + +@implementation CatchAllNibLoader +- (void)setValue:(id)aValue forKey:(NSString*)aKey +{ + NSLog(@"%s %@ = %@", _cmd, aKey, aValue); +} +@end + +@interface DialogServer : NSObject +{ +} +@end + +@implementation DialogServer +- (int)textMateDialogServerProtocolVersion +{ + return 1; +} + +- (void)showNib:(NSString*)aNibPath withArguments:(id)someArguments +{ + NSFileManager* fm = [NSFileManager defaultManager]; + + if(![aNibPath hasPrefix:@"/"]) // relative URL + aNibPath = [[fm currentDirectoryPath] stringByAppendingPathComponent:aNibPath]; + + if(![aNibPath hasSuffix:@".nib"]) + aNibPath = [aNibPath stringByAppendingPathExtension:@"nib"]; + + if(![fm fileExistsAtPath:aNibPath]) + { + NSLog(@"%s nib file not found: %@", _cmd, aNibPath); + return; + } + + NSNib* nib = [[NSNib alloc] initWithContentsOfURL:[NSURL fileURLWithPath:aNibPath]]; + if(!nib) + { + NSLog(@"%s failed loading nib: %@", _cmd, aNibPath); + return; + } + + NSMutableArray* topLevelObjects = nil; + BOOL didInstantiate = [nib instantiateNibWithOwner:[[CatchAllNibLoader new] autorelease] topLevelObjects:&topLevelObjects]; + if(!didInstantiate) + { + NSLog(@"%s failed to instantiate nib", _cmd); + } + + NSLog(@"%s loaded nib with top levle objects %@", _cmd, topLevelObjects); + enumerate(topLevelObjects, id object) + { + if([object isKindOfClass:[NSWindow class]]) + [object makeKeyAndOrderFront:self]; + } +} +@end + +@implementation Dialog +- (id)initWithPlugInController:(id )aController +{ + NSApp = [NSApplication sharedApplication]; + if(self = [super init]) + { + NSConnection* connection = [NSConnection defaultConnection]; + [connection setRootObject:[[DialogServer new] autorelease]]; + if([connection registerName:@"TextMate dialog server"] == NO) + NSLog(@"couldn't setup TextMate dialog server."), NSBeep(); + } + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} +@end diff --git a/Dialog.tmproj b/Dialog.tmproj new file mode 100644 index 0000000..1f39e74 --- /dev/null +++ b/Dialog.tmproj @@ -0,0 +1,50 @@ + + + + + currentDocument + Clock.mm + documents + + + expanded + + name + Clock + regexFileFilter + !(/\.(?!htaccess)[^/]*|\.(tmproj|o|pyc|db)|/Icon\r)$ + regexFolderFilter + !.*/(\.[^/]*|CVS|\{arch\}|build|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$ + sourceDirectory + + + + fileHierarchyDrawerWidth + 200 + metaData + + Clock.mm + + caret + + column + 0 + line + 69 + + firstVisibleColumn + 0 + firstVisibleLine + 42 + + + openDocuments + + Clock.mm + + showFileHierarchyDrawer + + windowFrame + {{417, 275}, {658, 660}} + + diff --git a/Dialog.xcodeproj/project.pbxproj b/Dialog.xcodeproj/project.pbxproj new file mode 100644 index 0000000..6d4ef31 --- /dev/null +++ b/Dialog.xcodeproj/project.pbxproj @@ -0,0 +1,280 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 177E4DA309132A0F0064163D /* Dialog.mm in Sources */ = {isa = PBXBuildFile; fileRef = 177E4DA209132A0F0064163D /* Dialog.mm */; }; + 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; + 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; + 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 177E4DA109132A0F0064163D /* Dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dialog.h; sourceTree = ""; }; + 177E4DA209132A0F0064163D /* Dialog.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Dialog.mm; sourceTree = ""; }; + 32DBCF630370AF2F00C91783 /* Dialog_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dialog_Prefix.pch; sourceTree = ""; }; + 8D5B49B6048680CD000E48DA /* Dialog.tmplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Dialog.tmplugin; sourceTree = BUILT_PRODUCTS_DIR; }; + 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = ""; }; + D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D5B49B3048680CD000E48DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 089C166AFE841209C02AAC07 /* Dialog */ = { + isa = PBXGroup; + children = ( + 08FB77AFFE84173DC02AAC07 /* Classes */, + 32C88E010371C26100C91783 /* Other Sources */, + 089C167CFE841241C02AAC07 /* Resources */, + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, + 19C28FB8FE9D52D311CA2CBB /* Products */, + ); + name = Dialog; + sourceTree = ""; + }; + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, + ); + name = "Frameworks and Libraries"; + sourceTree = ""; + }; + 089C167CFE841241C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + 8D5B49B7048680CD000E48DA /* Info.plist */, + 089C167DFE841241C02AAC07 /* InfoPlist.strings */, + ); + name = Resources; + sourceTree = ""; + }; + 08FB77AFFE84173DC02AAC07 /* Classes */ = { + isa = PBXGroup; + children = ( + 177E4DA209132A0F0064163D /* Dialog.mm */, + 177E4DA109132A0F0064163D /* Dialog.h */, + ); + name = Classes; + sourceTree = ""; + }; + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 089C167FFE841241C02AAC07 /* AppKit.framework */, + D2F7E65807B2D6F200F64583 /* CoreData.framework */, + 089C1672FE841209C02AAC07 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 19C28FB8FE9D52D311CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D5B49B6048680CD000E48DA /* Dialog.tmplugin */, + ); + name = Products; + sourceTree = ""; + }; + 32C88E010371C26100C91783 /* Other Sources */ = { + isa = PBXGroup; + children = ( + 32DBCF630370AF2F00C91783 /* Dialog_Prefix.pch */, + ); + name = "Other Sources"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D5B49AC048680CD000E48DA /* Dialog */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "Dialog" */; + buildPhases = ( + 8D5B49AF048680CD000E48DA /* Resources */, + 8D5B49B1048680CD000E48DA /* Sources */, + 8D5B49B3048680CD000E48DA /* Frameworks */, + 177E4DB50913322B0064163D /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Dialog; + productInstallPath = "$(HOME)/Library/Bundles"; + productName = Dialog; + productReference = 8D5B49B6048680CD000E48DA /* Dialog.tmplugin */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 089C1669FE841209C02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "Dialog" */; + hasScannedForEncodings = 1; + mainGroup = 089C166AFE841209C02AAC07 /* Dialog */; + projectDirPath = ""; + targets = ( + 8D5B49AC048680CD000E48DA /* Dialog */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D5B49AF048680CD000E48DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 177E4DB50913322B0064163D /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "mkdir -p \"$HOME/Library/Application Support/TextMate/PlugIns\"\ncp -pR \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \"$HOME/Library/Application Support/TextMate/PlugIns\""; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D5B49B1048680CD000E48DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 177E4DA309132A0F0064163D /* Dialog.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C167EFE841241C02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 1DEB913B08733D840010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Dialog_Prefix.pch; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Bundles"; + PRODUCT_NAME = Dialog; + WRAPPER_EXTENSION = tmplugin; + ZERO_LINK = YES; + }; + name = Debug; + }; + 1DEB913C08733D840010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Dialog_Prefix.pch; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Bundles"; + PRODUCT_NAME = Dialog; + WRAPPER_EXTENSION = tmplugin; + }; + name = Release; + }; + 1DEB913F08733D840010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Debug; + }; + 1DEB914008733D840010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "Dialog" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB913B08733D840010E9CD /* Debug */, + 1DEB913C08733D840010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "Dialog" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB913F08733D840010E9CD /* Debug */, + 1DEB914008733D840010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 089C1669FE841209C02AAC07 /* Project object */; +} diff --git a/Dialog_Prefix.pch b/Dialog_Prefix.pch new file mode 100644 index 0000000..09ce73d --- /dev/null +++ b/Dialog_Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'Clock' target in the 'Clock' project. +// + +#ifdef __OBJC__ + #import +#endif diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings new file mode 100644 index 0000000..4137b0e Binary files /dev/null and b/English.lproj/InfoPlist.strings differ diff --git a/Example.nib/classes.nib b/Example.nib/classes.nib new file mode 100644 index 0000000..b9b4b09 --- /dev/null +++ b/Example.nib/classes.nib @@ -0,0 +1,4 @@ +{ + IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }); + IBVersion = 1; +} \ No newline at end of file diff --git a/Example.nib/info.nib b/Example.nib/info.nib new file mode 100644 index 0000000..42c6d2f --- /dev/null +++ b/Example.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 69 14 356 240 0 0 1920 1178 + IBFramework Version + 446.1 + IBOpenObjects + + 5 + + IBSystem Version + 8L127 + + diff --git a/Example.nib/keyedobjects.nib b/Example.nib/keyedobjects.nib new file mode 100644 index 0000000..80ec08c Binary files /dev/null and b/Example.nib/keyedobjects.nib differ diff --git a/Info.plist b/Info.plist new file mode 100644 index 0000000..f7e5d91 --- /dev/null +++ b/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleName + ${PRODUCT_NAME} + CFBundleIconFile + + CFBundleIdentifier + com.macromates.dialog_plug-in + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSPrincipalClass + Dialog + + diff --git a/tm_dialog.mm b/tm_dialog.mm new file mode 100644 index 0000000..06e5313 --- /dev/null +++ b/tm_dialog.mm @@ -0,0 +1,162 @@ +/* + g++ -Wmost -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -DDATE=\"`date +%Y-%m-%d`\" -Os "$TM_FILEPATH" -o ~/Library/tm/Support/bin/tm_dialog -framework Cocoa && strip ~/Library/tm/Support/bin/tm_dialog +*/ +#import +#import +#import +#import +#import +#import +#import +#import +#import + +char const* current_version () +{ + char res[32]; + return sscanf("$Revision: 1 $", "$%*[^:]: %s $", res) == 1 ? res : "???"; +} + +char const* AppName; + +@protocol TextMateDialogServerProtocol +- (int)textMateDialogServerProtocolVersion; +- (void)showNib:(NSString*)aNib withArguments:(id)someArguments; +@end + +void contact_server (char const* nibName) +{ + id proxy = [NSConnection rootProxyForConnectionWithRegisteredName:@"TextMate dialog server" host:nil]; + [proxy setProtocolForProxy:@protocol(TextMateDialogServerProtocol)]; + + if(!proxy) + { + fprintf(stderr, "%s: failed to establish connection with TextMate.\n", AppName); + } + else if([proxy textMateDialogServerProtocolVersion] >= 1) + { + [proxy showNib:[NSString stringWithUTF8String:nibName] withArguments:nil]; + } + else + { + fprintf(stderr, "%s: you need to update this helper tool (server at version %d).\n", AppName, [proxy textMateDialogServerProtocolVersion]); + } +} + +void usage () +{ + std::vector pad(10 - std::min(strlen(AppName), size_t(10)), ' '); + pad.push_back('\0'); + + char* buf = NULL; + int len = 0; + asprintf(&buf, + "%1$s r%2$s (" DATE ")\n" + "Usage: %1$s [-awlrdnhv] [file ...]\n" + "Options:\n" + " -a, --async Do not wait for file to be closed by TextMate.\n" + " -w, --wait Wait for file to be closed by TextMate.\n" + " -l, --line Place caret on line after loading file.\n" + " -r, --recent Add file to Open Recent menu.\n" + " -d, --change-dir Change TextMates working directory to that of the file.\n" + " -n, --no-reactivation After edit with -w, do not re-activate the calling app.\n" + " -h, --help Show this information.\n" + " -v, --version Print version information.\n" + "\n" + "If multiple files are given, a project is created consisting of these\n" + "files, -a is then default and -w will be ignored (e.g. \"%1$s *.tex\").\n" + "\n%4$n" + "By default %1$s will not wait for the file to be closed\nexcept when used as filter:\n" + " ls *.tex|%1$s|sh%3$s-w implied\n" + " %1$s -|cat -n %3$s-w implied (read from stdin)\n" + "\n" + "An exception is made if the command is started as something which ends\nwith \"_wait\". " + "So to have a command with --wait as default, you can\ncreate a symbolic link like this:\n" + " ln -s %1$s %1$s_wait\n" + "\n", AppName, current_version(), &pad[0], &len + ); + + if(strstr(AppName, "_wait") == AppName + strlen(AppName) - 5) + buf[len] = '\0'; + fprintf(stderr, "%s", buf); + free(buf); + + exit(-1); +} + +void version () +{ + printf("%s r%s (" DATE ")\n", AppName, current_version()); + exit(-1); +} + +NSString* read_from_stdin () +{ + NSString* res = nil; + char name[] = "/tmp/textmate stdin XXXXXX.txt"; + int fd = mkstemps(name, 4); + if(fd != -1) + { + if(isatty(STDIN_FILENO) == 1) + fprintf(stderr, "%s: Reading from stdin... (press CTRL-D to proceed)\n", AppName); + + char buf[1024]; + while(size_t len = read(STDIN_FILENO, buf, sizeof(buf))) + write(fd, buf, len); + close(fd); + + res = [[NSString stringWithUTF8String:name] stringByStandardizingPath]; + } + return res; +} + +int main (int argc, char* argv[]) +{ +#if 0 + extern char* optarg; + extern int optind; +#endif + if(AppName = strrchr(argv[0], '/')) + AppName++; + else AppName = argv[0]; +#if 0 + static struct option const longopts[] = { + { "async", no_argument, 0, 'a' }, + { "wait", no_argument, 0, 'w' }, + { "line", required_argument, 0, 'l' }, + { "recent", no_argument, 0, 'r' }, + { "change-dir", no_argument, 0, 'd' }, + { "no-reactivation", no_argument, 0, 'n' }, + { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'v' }, + { 0, 0, 0, 0 } + }; + + while((ch = getopt_long(argc, argv, "awrdnhvl:", longopts, NULL)) != -1) + { + switch(ch) + { + case 'a': should_wait = false; break; + case 'w': should_wait = true; break; + case 'l': line = atoi(optarg); break; + case 'r': add_to_recent = true; break; + case 'd': change_dir = true; break; + case 'n': reactivate = false; break; + case 'h': usage(); break; + case 'v': version(); break; + default: usage(); break; + } + } + + argc -= optind; + argv += optind; +#endif + + NSAutoreleasePool* pool = [NSAutoreleasePool new]; + NSApp = [NSApplication sharedApplication]; + + contact_server(argc == 2 ? argv[1] : "foo"); + + [pool release]; + return 0; +}