Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Plain text paste new #439

Merged
merged 11 commits into from

2 participants

Patrick Robertson Rob McBroom
Patrick Robertson
Owner

This is an attempt to create a tidied up #419

Hopefully this one will be easier to merge, but that is not definite...

Thanks to @skurfer for suggesting Gitbox, it gave me the idea to git cherry-pick the commits I wanted.
This should be easier to look over - which I think Rob's already done.
If it's all good, this can be merged, #419 can be closed and #430 can be considered separately to this one.

Patrick Robertson
Owner

There is a merge conflict because of what I said in #419:

It is because, with @skurfer's htmlParsing branch merged, git thinks the lines in the xcodeproj for adding BeautifulSoup.py and Clipboard.icns are conflicting. Silly git.

Rob McBroom
Owner

There are two conflicts, but it’s easy enough to deal with. I’ll check this out and make sure it’s still good. I say close #419.

Patrick Robertson
Owner

Merge master now eh? ;-)

Cheers

Rob McBroom
Owner

Sorry. I will look at it as soon as I can. Should have mentioned it before, but my wife is out of town until Wednesday, so it’s me and two little ones. Imagine my free time. Then add to that the Lion upgrade which requires and Xcode upgrade (which may or may not compile QS with the release config, etc.)

Short version: maybe tomorrow. :)

Patrick Robertson
Owner
Rob McBroom
Owner

Xcode 4 Tangent

I think I’m testing this code, but really, I have no idea. Do I have to go to “Edit Scheme” every time I want to switch between Release and Debug?

Rob McBroom
Owner

Any idea why when pasting a URL into Mail.app, it ends up in a different font? (I know it’s opposed to be turned into a link, and it is, but seems like the font should match.) I won’t hold back the merge for this alone. Just curious.

Patrick Robertson
Owner
Rob McBroom skurfer merged commit ade4798 into from
Patrick Robertson
Owner

Thanks for closing the issue Rob. I keep forgetting to put fixes #... in my commits :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
1  Quicksilver/Code-QuickStepCore/QSObject_Pasteboard.h
View
@@ -12,6 +12,7 @@
+ (id)objectWithClipping:(NSString *)clippingFile;
- (id)initWithClipping:(NSString *)clippingFile;
- (void)guessName;
+- (BOOL)putOnPasteboardAsPlainTextOnly:(NSPasteboard *)pboard;
- (BOOL)putOnPasteboard:(NSPasteboard *)pboard declareTypes:(NSArray *)types includeDataForTypes:(NSArray *)includeTypes;
- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type;
- (void)pasteboardChangedOwner:(NSPasteboard *)sender;
53 Quicksilver/Code-QuickStepCore/QSObject_Pasteboard.m
View
@@ -18,8 +18,8 @@ id objectForPasteboardType(NSPasteboard *pasteboard, NSString *type) {
return nil;
}
+// writes the selected data to the general pasteboard
bool writeObjectToPasteboard(NSPasteboard *pasteboard, NSString *type, id data) {
- //NSArray *plistTypes = [NSArray arrayWithObjects:NSFilenamesPboardType, @"ABPeopleUIDsPboardType", @"WebURLsWithTitlesPboardType", nil];
if ([NSURLPboardType isEqualToString:type]) {
[[NSURL URLWithString:data] writeToPasteboard:pasteboard];
[pasteboard addTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
@@ -217,27 +217,49 @@ Rich Text Format (RTF)
}
}
+- (BOOL)putOnPasteboardAsPlainTextOnly:(NSPasteboard *)pboard {
+ NSArray *types = [NSArray arrayWithObject:NSStringPboardType];
+ [pboard declareTypes:types owner:nil];
+ NSString *string = [self stringValue];
+ [pboard setString:string forType:NSStringPboardType];
+ return YES;
+}
+
+// Declares the types that should be put on the pasteboard
- (BOOL)putOnPasteboard:(NSPasteboard *)pboard declareTypes:(NSArray *)types includeDataForTypes:(NSArray *)includeTypes {
if (!types) {
- types = [[[[self dataDictionary] allKeys] mutableCopy] autorelease];
- if ([types containsObject:QSProxyType])
- [(NSMutableArray *)types addObjectsFromArray:[[[self resolvedObject] dataDictionary] allKeys]];
+ // get the different pboard types from the object's data dictionary -- they're all stored here
+ types = [[[[self dataDictionary] allKeys] mutableCopy] autorelease];
+ if ([types containsObject:QSProxyType])
+ [(NSMutableArray *)types addObjectsFromArray:[[[self resolvedObject] dataDictionary] allKeys]];
}
else {
NSMutableSet *typeSet = [NSMutableSet setWithArray:types];
[typeSet intersectSet:[NSSet setWithArray:[[self dataDictionary] allKeys]]];
types = [[[typeSet allObjects] mutableCopy] autorelease];
}
-
+ // If there's no string type for the object, we need to set one
+ if (![types containsObject:NSStringPboardType]) {
+ [(NSMutableArray *)types addObject:NSStringPboardType];
+ [[self dataDictionary] setObject:[self stringValue] forKey:NSStringPboardType];
+ }
+
+ // define the types to be included on the pasteboard
if (!includeTypes) {
if ([types containsObject:NSFilenamesPboardType])
includeTypes = [NSArray arrayWithObject:NSFilenamesPboardType];
-// [pboard declareTypes:includeTypes owner:self];
+ // [pboard declareTypes:includeTypes owner:self];
else if ([types containsObject:NSURLPboardType])
- includeTypes = [NSArray arrayWithObject:NSURLPboardType];
+ // for urls, define plain text, rtf and html
+ includeTypes = [NSArray arrayWithObjects:NSURLPboardType,NSHTMLPboardType,NSRTFPboardType,nil];
else if ([types containsObject:NSColorPboardType])
includeTypes = [NSArray arrayWithObject:NSColorPboardType];
}
+ // last case: no other useful types: return a basic string
+ if (!includeTypes) {
+ includeTypes = [NSArray arrayWithObject:NSStringPboardType];
+ }
+
[pboard declareTypes:types owner:self];
/*
// ***warning ** Should add additional information for file items if ([paths count] == 1) {
@@ -246,6 +268,19 @@ - (BOOL)putOnPasteboard:(NSPasteboard *)pboard declareTypes:(NSArray *)types inc
}
*/
// NSLog(@"declareTypes: %@", [types componentsJoinedByString:@", "]);
+
+ // For URLs, create the RTF and HTML data to be stored in the clipboard
+ if ([types containsObject:NSURLPboardType]) {
+ // add the RTF and HTML types to the list of types
+ types = [types arrayByAddingObjectsFromArray:[NSArray arrayWithObjects:NSHTMLPboardType,NSRTFPboardType,nil]];
+ // Create the HTML and RTF data
+ NSData *htmlData = [NSString dataForObject:self forType:NSHTMLPboardType];
+ NSData *rtfData = [NSString dataForObject:self forType:NSRTFPboardType];
+ // Add the HTML and RTF data to the object's data dictionary
+ [[self dataDictionary] setObject:htmlData forKey:NSHTMLPboardType];
+ [[self dataDictionary] setObject:rtfData forKey:NSRTFPboardType];
+ }
+
for (NSString *thisType in includeTypes) {
if ([types containsObject:thisType]) {
// NSLog(@"includedata, %@", thisType);
@@ -254,9 +289,9 @@ - (BOOL)putOnPasteboard:(NSPasteboard *)pboard declareTypes:(NSArray *)types inc
}
if ([self identifier]) {
[pboard addTypes:[NSArray arrayWithObject:@"QSObjectID"] owner:self];
- writeObjectToPasteboard(pboard, @"QSObjectID", [self identifier]);
+ writeObjectToPasteboard(pboard, @"QSObjectID", [self stringValue]);
}
-
+
[pboard addTypes:[NSArray arrayWithObject:@"QSObjectAddress"] owner:self];
// NSLog(@"types %@", [pboard types]);
return YES;
1  Quicksilver/Code-QuickStepFoundation/NSString_BLTRExtensions.h
View
@@ -73,4 +73,5 @@ NSComparisonResult prefixCompare(NSString *aString, NSString *bString);
- (NSString *)stringByResolvingWildcardsInPath;
- (NSString *)firstUnusedFilePath;
- (NSArray *)componentsSeparatedByStrings:(NSArray *)strings;
++ (NSData *)dataForObject:(id)object forType:(NSString *)type;
@end
29 Quicksilver/Code-QuickStepFoundation/NSString_BLTRExtensions.m
View
@@ -368,5 +368,34 @@ - (NSString *)firstUnusedFilePath {
alternatePath = [NSString stringWithFormat:@"%@ %d.%@", basePath, i, extension];
return alternatePath;
}
++ (NSData *)dataForObject:(id)object forType:(NSString *)type {
+ // the string's link (only different from the title if it contains the mailto: prefix)
+ NSString *linkString = [object objectForType:NSURLPboardType];
+ // the string's title
+ NSString *titleString = [object stringValue];
+
+ // Dict containing the attributed string's attributes (most notably, a link)
+ NSDictionary *attStringAttributes = [NSDictionary dictionaryWithObject:[NSURL URLWithString:[linkString URLEncoding]]
+ forKey:NSLinkAttributeName];
+
+ // create the attributed string
+ NSAttributedString *attString = [[NSAttributedString alloc] initWithString:titleString attributes:attStringAttributes];
+
+ // For HTML pasteboard types, create a HTML data object
+ if([type isEqualToString:NSHTMLPboardType]) {
+ NSArray * exclude = [NSArray arrayWithObjects:@"doctype",@"html",@"head",@"body",@"xml",nil];
+ NSDictionary * htmlAtt = [NSDictionary dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType, NSDocumentTypeDocumentAttribute,
+ exclude,NSExcludedElementsDocumentAttribute,nil];
+
+ return [attString dataFromRange:NSMakeRange(0, [attString length]) documentAttributes:htmlAtt error:nil];
+ }
+ // For RTF pasteboard types, create an RTF data object
+ else if([type isEqualToString:NSRTFPboardType]) {
+ return [attString RTFFromRange:NSMakeRange(0, [attString length])
+ documentAttributes:nil];
+ }
+
+ return nil;
+}
@end
3  Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSActionProvider_EmbeddedProviders.h
View
@@ -47,6 +47,9 @@
@end
@interface ClipboardActions : QSActionProvider
+-(QSObject *)pasteObject:(QSObject *)dObject;
+-(QSObject *)pasteObjectAsPlainText:(QSObject *)dObject;
+-(QSObject *)pasteObject:(QSObject *)dObject asPlainText:(BOOL)plainText;
@end
23 Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSActionProvider_EmbeddedProviders.m
View
@@ -743,7 +743,6 @@ - (NSArray *)validActionsForDirectObject:(QSObject *)dObject indirectObject:(QSO
@end
# define kPasteboardPasteAction @"PasteboardPasteAction"
-# define kPasteboardExpandAction @"PasteboardExpandAction"
@implementation ClipboardActions
- (QSObject *)copyObject:(QSObject *)dObject {
@@ -751,11 +750,29 @@ - (QSObject *)copyObject:(QSObject *)dObject {
return nil;
}
- (QSObject *)pasteObject:(QSObject *)dObject {
- if ([dObject putOnPasteboard:[NSPasteboard generalPasteboard]]) {
+
+ [self pasteObject:dObject asPlainText:NO];
+ return nil;
+}
+- (QSObject *)pasteObjectAsPlainText:(QSObject *)dObject {
+
+ [self pasteObject:dObject asPlainText:YES];
+ return nil;
+}
+- (QSObject *)pasteObject:(QSObject *)dObject asPlainText:(BOOL)plainText {
+
+ BOOL success;
+ if(plainText) {
+ success = [dObject putOnPasteboardAsPlainTextOnly:[NSPasteboard generalPasteboard]];
+ }
+ else {
+ success = [dObject putOnPasteboard:[NSPasteboard generalPasteboard]];
+ }
+ if(success) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"WindowsShouldHide" object:self];
[[NSApp keyWindow] orderOut:self];
QSForcePaste();
} else NSBeep();
return nil;
}
-@end
+@end
19 Quicksilver/PlugIns-Main/QSCorePlugIn/QSCorePlugIn-Info.plist
View
@@ -563,6 +563,23 @@
<key>precedence</key>
<real>-0.5</real>
</dict>
+ <key>PasteboardPasteActionAsPlainText</key>
+ <dict>
+ <key>actionClass</key>
+ <string>ClipboardActions</string>
+ <key>actionSelector</key>
+ <string>pasteObjectAsPlainText:</string>
+ <key>directTypes</key>
+ <array>
+ <string>*</string>
+ </array>
+ <key>enabled</key>
+ <true/>
+ <key>icon</key>
+ <string>Clipboard</string>
+ <key>precedence</key>
+ <real>-0.5</real>
+ </dict>
<key>PasteboardPasteAction</key>
<dict>
<key>actionClass</key>
@@ -579,6 +596,8 @@
<string>Clipboard</string>
<key>precedence</key>
<real>-0.5</real>
+ <key>alternateAction</key>
+ <string>PasteboardPasteActionAsPlainText</string>
</dict>
<key>QSCatalogEntryRescanAction</key>
<dict>
BIN  Quicksilver/PlugIns-Main/QSCorePlugIn/Resources/Clipboard.icns
View
Binary file not shown
2  Quicksilver/PlugIns-Main/QSCorePlugIn/Resources/en.lproj/QSAction.description.strings
View
@@ -62,6 +62,8 @@
<string>IM item to a contact</string>
<key>PasteboardPasteAction</key>
<string>Paste this object to the current application</string>
+ <key>PasteboardPasteActionAsPlainText</key>
+ <string>Paste this object as plain text to the current application</string>
<key>ProcessKillAction</key>
<string>Force an application to quit</string>
<key>ProcessResumeAction</key>
4 Quicksilver/PlugIns-Main/QSCorePlugIn/Resources/en.lproj/QSAction.name.strings
View
@@ -89,7 +89,9 @@
<key>PasteboardCopyAction</key>
<string>Copy to Clipboard</string>
<key>PasteboardPasteAction</key>
- <string>Paste with Clipboard</string>
+ <string>Paste</string>
+ <key>PasteboardPasteActionAsPlainText</key>
+ <string>Paste as Plain Text</string>
<key>ProcessKillAction</key>
<string>Force Quit (Kill)</string>
<key>ProcessLowerPriorityAction</key>
4 Quicksilver/Quicksilver.xcodeproj/project.pbxproj
View
@@ -301,6 +301,7 @@
CD3F9ECC13619CE00013FCB7 /* UKMainThreadProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 7FA4ED4609132402007DB407 /* UKMainThreadProxy.h */; settings = {ATTRIBUTES = (Public, ); }; };
CD3F9ECD13619CE00013FCB7 /* UKKQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7FA4ED4409132402007DB407 /* UKKQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
CD3F9ECE13619CE00013FCB7 /* UKFileWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 7FA4ED4009132402007DB407 /* UKFileWatcher.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ CDC9C6C513DA2B6D0053B09C /* Clipboard.icns in Resources */ = {isa = PBXBuildFile; fileRef = CDC9C6C413DA2B6D0053B09C /* Clipboard.icns */; };
CDCC201010A4C14B009C4EED /* QSMDPredicate.h in Headers */ = {isa = PBXBuildFile; fileRef = CDCC200E10A4C14B009C4EED /* QSMDPredicate.h */; settings = {ATTRIBUTES = (Public, ); }; };
CDCC201110A4C14B009C4EED /* QSMDPredicate.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCC200F10A4C14B009C4EED /* QSMDPredicate.m */; };
D493990D1350078E00B908C6 /* QSDownloads.h in Headers */ = {isa = PBXBuildFile; fileRef = D49399091350078E00B908C6 /* QSDownloads.h */; };
@@ -1206,6 +1207,7 @@
92DC402B0E25A0C40091BD92 /* Action.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Action.png; sourceTree = "<group>"; };
92E946170D04CCEF0013377F /* QSModifierKeyEvents.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = QSModifierKeyEvents.h; sourceTree = "<group>"; };
92E946180D04CCEF0013377F /* QSModifierKeyEvents.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = QSModifierKeyEvents.m; sourceTree = "<group>"; };
+ CDC9C6C413DA2B6D0053B09C /* Clipboard.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Clipboard.icns; sourceTree = "<group>"; };
CDCC200E10A4C14B009C4EED /* QSMDPredicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSMDPredicate.h; sourceTree = "<group>"; };
CDCC200F10A4C14B009C4EED /* QSMDPredicate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QSMDPredicate.m; sourceTree = "<group>"; };
D49399091350078E00B908C6 /* QSDownloads.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSDownloads.h; sourceTree = "<group>"; };
@@ -1871,6 +1873,7 @@
7F840FC7096C3356006E6F0E /* Resources */ = {
isa = PBXGroup;
children = (
+ CDC9C6C413DA2B6D0053B09C /* Clipboard.icns */,
7F841BB5096CCCBF006E6F0E /* Rocket.png */,
7F840FC8096C3356006E6F0E /* QSAction.description.strings */,
7F840FCA096C3356006E6F0E /* QSAction.name.strings */,
@@ -3305,6 +3308,7 @@
7F840FF3096C3356006E6F0E /* Preferences.strings in Resources */,
7F841BB6096CCCBF006E6F0E /* Rocket.png in Resources */,
D4A43887137CCF0300F15F7F /* QSURLExtractor.py in Resources */,
+ CDC9C6C513DA2B6D0053B09C /* Clipboard.icns in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
10 Quicksilver/Resources/ActionsPrecedence.plist
View
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppLaunchAction</key>
@@ -23,11 +23,13 @@
<key>FileOpenAction</key>
<integer>1</integer>
<key>FileOpenWithAction</key>
- <real>0.10000000000000001</real>
+ <real>0.1</real>
<key>FileRevealAction</key>
- <real>0.10000000000000001</real>
+ <real>0.1</real>
<key>PasteboardPasteAction</key>
<real>-0.5</real>
+ <key>PasteboardPasteActionAsPlainText</key>
+ <string>-0.6</string>
<key>QSCLExecuteAction</key>
<integer>2</integer>
<key>QSCLExecuteWithArgsAction</key>
@@ -35,7 +37,7 @@
<key>QSEmailItemAction</key>
<integer>0</integer>
<key>QSEmailItemReverseAction</key>
- <real>-0.20000000000000001</real>
+ <real>-0.2</real>
<key>QSLargeTypeAction</key>
<integer>1</integer>
<key>QSPutOnShelfAction</key>
Something went wrong with that request. Please try again.