Permalink
Browse files

Added a new "Copy as Bookmarklet" menu command, which does what it so…

…unds like.
  • Loading branch information...
1 parent d88bcc2 commit ab8a23c2786c18fc18fcb4b7352e270bbb638fc6 August Mueller committed Dec 29, 2009
Showing with 76 additions and 11 deletions.
  1. +1 −1 jstalk.xcodeproj/project.pbxproj
  2. +47 −10 res/English.lproj/MainMenu.xib
  3. +6 −0 src/JSTAppDelegate.m
  4. +22 −0 src/JSTDocument.m
@@ -1250,12 +1250,12 @@
INSTALL_PATH = "@loader_path/../Frameworks";
OTHER_CFLAGS = "-DDEBUG";
OTHER_LDFLAGS = (
+ "-lffi",
"-framework",
Foundation,
"-framework",
AppKit,
"-lexpat",
- "-lffi",
);
PREBINDING = NO;
PRODUCT_NAME = JSTalk;
@@ -2,17 +2,17 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">10B504</string>
- <string key="IBDocument.InterfaceBuilderVersion">732</string>
- <string key="IBDocument.AppKitVersion">1038.2</string>
- <string key="IBDocument.HIToolboxVersion">437.00</string>
+ <string key="IBDocument.SystemVersion">10C540</string>
+ <string key="IBDocument.InterfaceBuilderVersion">740</string>
+ <string key="IBDocument.AppKitVersion">1038.25</string>
+ <string key="IBDocument.HIToolboxVersion">458.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">732</string>
+ <string key="NS.object.0">740</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="106"/>
+ <integer value="205"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -383,6 +383,14 @@
<reference key="NSOnImage" ref="1033313550"/>
<reference key="NSMixedImage" ref="310636482"/>
</object>
+ <object class="NSMenuItem" id="97207725">
+ <reference key="NSMenu" ref="789758025"/>
+ <string key="NSTitle">Copy as Bookmarklet</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="1033313550"/>
+ <reference key="NSMixedImage" ref="310636482"/>
+ </object>
<object class="NSMenuItem" id="29853731">
<reference key="NSMenu" ref="789758025"/>
<string key="NSTitle">Paste</string>
@@ -2092,6 +2100,14 @@
</object>
<int key="connectionID">554</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">copyBookmarkletToPasteboard:</string>
+ <reference key="source" ref="1014"/>
+ <reference key="destination" ref="97207725"/>
+ </object>
+ <int key="connectionID">557</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2305,6 +2321,7 @@
<reference ref="507821607"/>
<reference ref="719306813"/>
<reference ref="404508535"/>
+ <reference ref="97207725"/>
</object>
<reference key="parent" ref="952259628"/>
</object>
@@ -3181,6 +3198,11 @@
<reference key="object" ref="545698899"/>
<reference key="parent" ref="303200189"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">555</int>
+ <reference key="object" ref="97207725"/>
+ <reference key="parent" ref="789758025"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -3407,6 +3429,8 @@
<string>550.IBPluginDependency</string>
<string>551.IBPluginDependency</string>
<string>552.IBPluginDependency</string>
+ <string>555.IBPluginDependency</string>
+ <string>555.ImportedFromIB2</string>
<string>56.IBPluginDependency</string>
<string>56.ImportedFromIB2</string>
<string>57.IBEditorWindowLastContentRect</string>
@@ -3506,7 +3530,7 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
- <string>{{499, 564}, {243, 273}}</string>
+ <string>{{499, 544}, {240, 293}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{197, 734}, {243, 243}}</string>
@@ -3666,6 +3690,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1"/>
<string>{{346, 654}, {221, 183}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
@@ -3716,7 +3742,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">554</int>
+ <int key="maxID">557</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3729,6 +3755,7 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>clearConsole:</string>
+ <string>copyBookmarkletToPasteboard:</string>
<string>executeScript:</string>
<string>executeSelectedScript:</string>
<string>externalEditorAction:</string>
@@ -3749,6 +3776,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -3801,13 +3829,11 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>clearConsole:</string>
<string>executeScript:</string>
- <string>parseCode:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
- <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -3835,6 +3861,10 @@
<object class="IBPartialClassDescription">
<string key="className">JSTTextView</string>
<string key="superclassName">NSTextView</string>
+ <object class="NSMutableDictionary" key="actions">
+ <string key="NS.key.0">parseCode:</string>
+ <string key="NS.object.0">id</string>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">src/JSTTextView.h</string>
@@ -3858,6 +3888,13 @@
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">jscocoa/JSCocoa/JSCocoaLib.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
<string key="minorKey">src/JSTFileWatcher.h</string>
</object>
</object>
@@ -16,6 +16,10 @@ - (void) loadExternalEditorPrefs;
- (void) updatePrefsFontField;
@end
+void JSTUncaughtExceptionHandler(NSException *exception) {
+ NSLog(@"Uncaught exception: %@", exception);
+}
+
@implementation JSTAppDelegate
+ (void) initialize {
@@ -41,6 +45,8 @@ - (void)awakeFromNib {
[JSTalk setShouldLoadJSTPlugins:YES];
[JSTalk listen];
+
+ NSSetUncaughtExceptionHandler(JSTUncaughtExceptionHandler);
}
- (IBAction) showPrefs:(id)sender {
View
@@ -418,6 +418,28 @@ - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar {
}
+- (void) copyBookmarkletToPasteboard:(id)sender {
+
+ NSRange r = [jsTextView selectedRange];
+
+ NSString *selectedText = 0x00;
+
+ if (r.length == 0) {
+ selectedText = [[jsTextView textStorage] string];
+ }
+ else {
+ selectedText = [[[jsTextView textStorage] string] substringWithRange:r];
+ }
+
+ NSString *bookmarklet = [NSString stringWithFormat:@"javascript:%@", [selectedText stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+
+ [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+ [pb setString:bookmarklet forType:NSStringPboardType];
+}
+
+
@end

0 comments on commit ab8a23c

Please sign in to comment.