Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

とりあえず動くver

  • Loading branch information...
commit b1b10ad64edaff0f772e7f9d36fffda1c9e957dc 1 parent ce1b5fa
@typester authored
View
9 Classes/App.h
@@ -0,0 +1,9 @@
+#import <Cocoa/Cocoa.h>
+
+@interface App : NSObject {
+
+}
+
+-(void)applicationDidFinishLaunching:(NSNotification*)n;
+
+@end
View
36 Classes/App.m
@@ -0,0 +1,36 @@
+#import "App.h"
+
+#import "NSURL+L0URLParsing.h"
+
+@implementation App
+
+-(void)applicationDidFinishLaunching:(NSNotification*)n {
+ NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
+ [appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
+}
+
+-(void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
+ // emacs://open/?url=file://~/.bash_profile&line=11&column=2
+ NSURL *url = [NSURL URLWithString:[[event paramDescriptorForKeyword:keyDirectObject] stringValue]];
+
+ if (url && [[url host] isEqualToString:@"open"]) {
+ NSDictionary *params = [url dictionaryByDecodingQueryString];
+ NSURL *file_url = [NSURL URLWithString:[params objectForKey:@"url"]];
+
+ if (file_url && [[file_url scheme] isEqualToString:@"file"]) {
+ NSString *file = [file_url path];
+ NSString *line = [params objectForKey:@"line"];
+ NSString *column = [params objectForKey:@"column"];
+
+ if (file) {
+ NSTask *task = [[NSTask alloc] init];
+ [task setLaunchPath:@"/Applications/CarbonEmacs.app/Contents/MacOS/bin/emacsclient"];
+ [task setArguments:[NSArray arrayWithObjects:@"-n", [NSString stringWithFormat:@"+%d:%d", [line integerValue], [column integerValue]], file, nil]];
+ [task launch];
+ [task release];
+ }
+ }
+ }
+}
+
+@end
View
22 Classes/NSURL+L0URLParsing.h
@@ -0,0 +1,22 @@
+//
+// NSURL_L0URLParsing.h
+// Diceshaker
+//
+// Created by ∞ on 11/02/09.
+// Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface NSURL (L0URLParsing)
+
+- (NSDictionary*) dictionaryByDecodingQueryString;
+
+@end
+
+@interface NSDictionary (L0URLParsing)
+
+- (NSString*) queryString;
+
+@end
View
81 Classes/NSURL+L0URLParsing.m
@@ -0,0 +1,81 @@
+//
+// NSURL_L0URLParsing.m
+// Diceshaker
+//
+// Created by ∞ on 11/02/09.
+// Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import "NSURL+L0URLParsing.h"
+
+
+@implementation NSURL (L0URLParsing)
+
+- (NSDictionary*) dictionaryByDecodingQueryString;
+{
+ NSString* query = [self query];
+ if (!query) {
+ NSString* resSpecifier = [self resourceSpecifier];
+ NSRange r = [resSpecifier rangeOfString:@"?"];
+
+ if (r.location == NSNotFound || r.location == [resSpecifier length] - 1)
+ return [NSDictionary dictionary];
+ else
+ query = [resSpecifier substringFromIndex:r.location + 1];
+ }
+
+ NSArray* keyValuePairs = [query componentsSeparatedByString:@"&"];
+
+ NSMutableDictionary* dict = [NSMutableDictionary dictionary];
+ for (NSString* pair in keyValuePairs) {
+ NSArray* splitPair = [pair componentsSeparatedByString:@"="];
+ NSAssert([splitPair count] > 0, @"At least one element out of componentsSeparatedByString:");
+ NSString* key = [splitPair objectAtIndex:0];
+
+ NSString* value;
+ if ([splitPair count] > 2) {
+ NSMutableArray* splitPairWithoutKey = [NSMutableArray arrayWithArray:splitPair];
+ [splitPairWithoutKey removeObjectAtIndex:0];
+ value = [splitPairWithoutKey componentsJoinedByString:@"="];
+ } else if ([splitPair count] == 2)
+ value = [splitPair objectAtIndex:1];
+ else
+ value = nil;
+
+ if (value)
+ [dict setObject:[value stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:[key stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+ else
+ [dict setObject:[NSNull null] forKey:[key stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+
+ }
+
+ return dict;
+}
+
+@end
+
+@implementation NSDictionary (L0URLParsing)
+
+- (NSString*) queryString;
+{
+ NSMutableString* queryString = [NSMutableString string];
+
+ BOOL first = YES;
+ for (NSString* key in self) {
+ if (!first)
+ [queryString appendString:@"&"];
+ [queryString appendString:[key stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+
+ id value = [self objectForKey:key];
+ if (![value isEqual:[NSNull null]]) {
+ [queryString appendString:@"="];
+ [queryString appendString:[value stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+ }
+
+ first = NO;
+ }
+
+ return queryString;
+}
+
+@end
View
63 English.lproj/MainMenu.xib
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9D29</string>
- <string key="IBDocument.InterfaceBuilderVersion">664</string>
- <string key="IBDocument.AppKitVersion">949.33</string>
- <string key="IBDocument.HIToolboxVersion">352.00</string>
+ <string key="IBDocument.SystemVersion">9L30</string>
+ <string key="IBDocument.InterfaceBuilderVersion">680</string>
+ <string key="IBDocument.AppKitVersion">949.54</string>
+ <string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="57"/>
@@ -16,6 +16,15 @@
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1021">
@@ -1123,6 +1132,9 @@
<object class="NSCustomObject" id="755631768">
<string key="NSClassName">NSFontManager</string>
</object>
+ <object class="NSCustomObject" id="212841808">
+ <string key="NSClassName">App</string>
+ </object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@@ -1655,6 +1667,14 @@
</object>
<int key="connectionID">449</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="1021"/>
+ <reference key="destination" ref="212841808"/>
+ </object>
+ <int key="connectionID">452</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2551,6 +2571,11 @@
<reference key="object" ref="755631768"/>
<reference key="parent" ref="1049"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">451</int>
+ <reference key="object" ref="212841808"/>
+ <reference key="parent" ref="1049"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -2690,7 +2715,6 @@
<string>354.IBPluginDependency</string>
<string>354.ImportedFromIB2</string>
<string>371.IBEditorWindowLastContentRect</string>
- <string>371.IBPluginDependency</string>
<string>371.IBWindowTemplateEditedContentRect</string>
<string>371.NSWindowTemplate.visibleAtLaunch</string>
<string>371.editorWindowContentRectSynchronizationRect</string>
@@ -2743,6 +2767,8 @@
<string>417.IBPluginDependency</string>
<string>418.IBPluginDependency</string>
<string>419.IBPluginDependency</string>
+ <string>420.IBPluginDependency</string>
+ <string>451.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>5.ImportedFromIB2</string>
<string>56.IBPluginDependency</string>
@@ -2913,9 +2939,8 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{335, 390}, {480, 360}}</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{335, 390}, {480, 360}}</string>
+ <string>{{156, 384}, {480, 360}}</string>
+ <string>{{156, 384}, {480, 360}}</string>
<reference ref="9"/>
<string>{{33, 99}, {480, 360}}</string>
<string>{3.40282e+38, 3.40282e+38}</string>
@@ -2968,6 +2993,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
@@ -3024,11 +3051,23 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">449</int>
+ <int key="maxID">452</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">App</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">App.h</string>
+ </object>
+ </object>
+ </object>
</object>
- <object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
- <nil key="IBDocument.LastKnownRelativeProjectPath"/>
+ <string key="IBDocument.LastKnownRelativeProjectPath">../emacs-handler.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
View
13 Info.plist
@@ -2,6 +2,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>emacs</string>
+ </array>
+ <key>CFBundleURLName</key>
+ <string>org.unknownplace.emacshandler</string>
+ </dict>
+ </array>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
@@ -9,7 +20,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
- <string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
+ <string>org.unknownplace.emacshandler</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
View
18 emacs-handler.xcodeproj/project.pbxproj
@@ -11,6 +11,8 @@
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
+ A07878C2109C002C004947EC /* App.m in Sources */ = {isa = PBXBuildFile; fileRef = A07878BF109C002C004947EC /* App.m */; };
+ A07878C3109C002C004947EC /* NSURL+L0URLParsing.m in Sources */ = {isa = PBXBuildFile; fileRef = A07878C1109C002C004947EC /* NSURL+L0URLParsing.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -24,6 +26,10 @@
32CA4F630368D1EE00C91783 /* emacs-handler_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "emacs-handler_Prefix.pch"; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* emacs-handler.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "emacs-handler.app"; sourceTree = BUILT_PRODUCTS_DIR; };
+ A07878BE109C002C004947EC /* App.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = App.h; path = Classes/App.h; sourceTree = "<group>"; };
+ A07878BF109C002C004947EC /* App.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = App.m; path = Classes/App.m; sourceTree = "<group>"; };
+ A07878C0109C002C004947EC /* NSURL+L0URLParsing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSURL+L0URLParsing.h"; path = "Classes/NSURL+L0URLParsing.h"; sourceTree = "<group>"; };
+ A07878C1109C002C004947EC /* NSURL+L0URLParsing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSURL+L0URLParsing.m"; path = "Classes/NSURL+L0URLParsing.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -41,6 +47,10 @@
080E96DDFE201D6D7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
+ A07878BE109C002C004947EC /* App.h */,
+ A07878BF109C002C004947EC /* App.m */,
+ A07878C0109C002C004947EC /* NSURL+L0URLParsing.h */,
+ A07878C1109C002C004947EC /* NSURL+L0URLParsing.m */,
);
name = Classes;
sourceTree = "<group>";
@@ -167,6 +177,8 @@
buildActionMask = 2147483647;
files = (
8D11072D0486CEB800E47090 /* main.m in Sources */,
+ A07878C2109C002C004947EC /* App.m in Sources */,
+ A07878C3109C002C004947EC /* NSURL+L0URLParsing.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -201,8 +213,7 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "emacs-handler_Prefix.pch";
+ GCC_PRECOMPILE_PREFIX_HEADER = NO;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
PRODUCT_NAME = "emacs-handler";
@@ -215,8 +226,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "emacs-handler_Prefix.pch";
+ GCC_PRECOMPILE_PREFIX_HEADER = NO;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
PRODUCT_NAME = "emacs-handler";
View
7 emacs-handler_Prefix.pch
@@ -1,7 +0,0 @@
-//
-// Prefix header for all source files of the 'emacs-handler' target in the 'emacs-handler' project
-//
-
-#ifdef __OBJC__
- #import <Cocoa/Cocoa.h>
-#endif
View
8 main.m
@@ -1,11 +1,3 @@
-//
-// main.m
-// emacs-handler
-//
-// Created by Daisuke Murase on 09/10/30.
-// Copyright __MyCompanyName__ 2009. All rights reserved.
-//
-
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
Please sign in to comment.
Something went wrong with that request. Please try again.