Skip to content

Commit

Permalink
Add new clipboard preference option, "Paste on Right Click" to help w…
Browse files Browse the repository at this point in the history
…ith two-button mice (e.g. Magic Mouse)
  • Loading branch information
khirbat committed Jan 19, 2010
1 parent ca5ac42 commit 214cbff
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 59 deletions.
6 changes: 6 additions & 0 deletions src/PasteOnRightclick.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Created by Anmol Khirbat on 1/18/10.

@interface TerminalCopyOnSelect : NSObject {
}
+ (void)load;
@end
25 changes: 25 additions & 0 deletions src/PasteOnRightclick.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Created by Anmol Khirbat on 1/18/10.

#import "PasteOnRightclick.h"
#import "JRSwizzle.h"
#import "Macros.h"

@implementation NSView (PasteOnRightclick)
- (void) Visor_rightMouseDown:(NSEvent *)theEvent
{
bool pasteOnRightclick = [[NSUserDefaults standardUserDefaults] boolForKey:@"VisorPasteOnRightclick"];

if (pasteOnRightclick)
[(id)self performSelector:@selector(paste:) withObject:nil];
else
[self Visor_rightMouseDown:theEvent];
}
@end

@implementation PasteOnRightclick
+ (void) load {
[NSClassFromString(@"TTView") jr_swizzleMethod:@selector(rightMouseDown:)
withMethod:@selector(Visor_rightMouseDown:) error:NULL];
LOG(@"PasteOnRightclick installed");
}
@end
6 changes: 6 additions & 0 deletions src/Visor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
26C7384F11045EBF00E5058E /* PasteOnRightclick.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C7384E11045EBF00E5058E /* PasteOnRightclick.m */; };
7F849AAC0A457E2200963040 /* Defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7F849AA60A457DE100963040 /* Defaults.plist */; };
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
Expand Down Expand Up @@ -37,6 +38,8 @@
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
26C7384D11045EBF00E5058E /* PasteOnRightclick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteOnRightclick.h; sourceTree = "<group>"; };
26C7384E11045EBF00E5058E /* PasteOnRightclick.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PasteOnRightclick.m; sourceTree = "<group>"; };
7F01469F0A3E6571006AF239 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
7F849AA60A457DE100963040 /* Defaults.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; path = Defaults.plist; sourceTree = "<group>"; };
8D5B49B6048680CD000E48DA /* Visor.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Visor.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -144,6 +147,8 @@
D6FCDC681002BA42000FDA45 /* CopyOnSelect.m */,
D68AA7000F371C810094AA92 /* Visor.h */,
D68AA7010F371C810094AA92 /* Visor.m */,
26C7384D11045EBF00E5058E /* PasteOnRightclick.h */,
26C7384E11045EBF00E5058E /* PasteOnRightclick.m */,
);
name = Classes;
sourceTree = "<group>";
Expand Down Expand Up @@ -315,6 +320,7 @@
D65FF88B105D853000B54560 /* GTMObjC2Runtime.m in Sources */,
D65FF894105D875D00B54560 /* GTMCarbonEvent.m in Sources */,
D65FF91B105D9B6200B54560 /* QSBKeyMap.m in Sources */,
26C7384F11045EBF00E5058E /* PasteOnRightclick.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
143 changes: 84 additions & 59 deletions src/Visor.xib
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<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">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
Expand All @@ -15,13 +15,13 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>732</string>
<string>732</string>
<string>740</string>
<string>740</string>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="385"/>
<integer value="391"/>
<integer value="15"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
Expand Down Expand Up @@ -50,6 +50,11 @@
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSUserDefaultsController" id="367619262">
<object class="NSMutableArray" key="NSDeclaredKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>visorPasteOnRightClick</string>
<string>VisorPasteOnRightclick</string>
</object>
<bool key="NSSharedInstance">YES</bool>
</object>
<object class="NSMenu" id="935150787">
Expand Down Expand Up @@ -577,7 +582,7 @@
<object class="NSTextField" id="768424552">
<reference key="NSNextResponder" ref="164090357"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{-38, 90}, {179, 17}}</string>
<string key="NSFrame">{{-38, 71}, {179, 17}}</string>
<reference key="NSSuperview" ref="164090357"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="760681356">
Expand All @@ -593,7 +598,7 @@
<object class="NSButton" id="195226599">
<reference key="NSNextResponder" ref="164090357"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{152, 88}, {248, 18}}</string>
<string key="NSFrame">{{152, 69}, {248, 18}}</string>
<reference key="NSSuperview" ref="164090357"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="822742941">
Expand Down Expand Up @@ -955,7 +960,7 @@
</object>
<object class="NSButton" id="773473875">
<reference key="NSNextResponder" ref="164090357"/>
<int key="NSvFlags">268</int>
<int key="NSvFlags">12</int>
<string key="NSFrame">{{152, 108}, {149, 18}}</string>
<reference key="NSSuperview" ref="164090357"/>
<bool key="NSEnabled">YES</bool>
Expand All @@ -975,6 +980,28 @@
<int key="NSPeriodicInterval">25</int>
</object>
</object>
<object class="NSButton" id="273687589">
<reference key="NSNextResponder" ref="164090357"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{152, 89}, {149, 18}}</string>
<reference key="NSSuperview" ref="164090357"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="913193565">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">0</int>
<string key="NSContents">Paste on Right Click</string>
<reference key="NSSupport" ref="245419672"/>
<reference key="NSControlView" ref="273687589"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">130</int>
<reference key="NSNormalImage" ref="898817514"/>
<reference key="NSAlternateImage" ref="267369008"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
</object>
<object class="NSButton" id="885853248">
<reference key="NSNextResponder" ref="164090357"/>
<int key="NSvFlags">268</int>
Expand Down Expand Up @@ -1149,7 +1176,7 @@
<string>NeXT TIFF v4.0 pasteboard type</string>
</object>
</object>
<string key="NSFrame">{{360, 74}, {48, 48}}</string>
<string key="NSFrame">{{360, 55}, {48, 48}}</string>
<reference key="NSSuperview" ref="164090357"/>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="367373299">
Expand Down Expand Up @@ -1416,22 +1443,6 @@
</object>
<int key="connectionID">525</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: values.VisorCopyOnSelect</string>
<reference key="source" ref="742149434"/>
<reference key="destination" ref="367619262"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="742149434"/>
<reference key="NSDestination" ref="367619262"/>
<string key="NSLabel">value: values.VisorCopyOnSelect</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">values.VisorCopyOnSelect</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">526</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: values.VisorUseSlide</string>
Expand Down Expand Up @@ -1560,6 +1571,22 @@
</object>
<int key="connectionID">573</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: values.VisorPasteOnRightclick</string>
<reference key="source" ref="273687589"/>
<reference key="destination" ref="367619262"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="273687589"/>
<reference key="NSDestination" ref="367619262"/>
<string key="NSLabel">value: values.VisorPasteOnRightclick</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">values.VisorPasteOnRightclick</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">582</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -1702,14 +1729,15 @@
<reference ref="894054412"/>
<reference ref="486444524"/>
<reference ref="773473875"/>
<reference ref="195226599"/>
<reference ref="1008250074"/>
<reference ref="373575250"/>
<reference ref="768424552"/>
<reference ref="818235845"/>
<reference ref="173689463"/>
<reference ref="302318399"/>
<reference ref="797332666"/>
<reference ref="768424552"/>
<reference ref="195226599"/>
<reference ref="818235845"/>
<reference ref="273687589"/>
</object>
<reference key="parent" ref="463743529"/>
</object>
Expand Down Expand Up @@ -2116,6 +2144,20 @@
<reference key="object" ref="797332666"/>
<reference key="parent" ref="164090357"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">574</int>
<reference key="object" ref="273687589"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="913193565"/>
</object>
<reference key="parent" ref="164090357"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">575</int>
<reference key="object" ref="913193565"/>
<reference key="parent" ref="273687589"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
Expand Down Expand Up @@ -2230,14 +2272,17 @@
<string>565.IBPluginDependency</string>
<string>567.IBPluginDependency</string>
<string>571.IBPluginDependency</string>
<string>574.IBPluginDependency</string>
<string>574.ImportedFromIB2</string>
<string>575.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
<string>9.ImportedFromIB2</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{0, 1031}, {197, 103}}</string>
<string>{{54, 877}, {197, 103}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand All @@ -2252,9 +2297,9 @@
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{982, 178}, {591, 455}}</string>
<string>{{78, 92}, {591, 455}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{982, 178}, {591, 455}}</string>
<string>{{78, 92}, {591, 455}}</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -2345,6 +2390,9 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
Expand All @@ -2363,7 +2411,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">573</int>
<int key="maxID">582</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -2445,12 +2493,14 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>infoLine</string>
<string>runningApplicationClass_</string>
<string>settingsWindow</string>
<string>statusMenu</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>WebView</string>
<string>id</string>
<string>NSWindow</string>
<string>NSMenu</string>
</object>
Expand Down Expand Up @@ -2893,27 +2943,6 @@
<string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">QuartzCore.framework/Headers/CAAnimation.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">QuartzCore.framework/Headers/CALayer.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">QuartzCore.framework/Headers/CIImageProvider.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
Expand Down Expand Up @@ -3159,10 +3188,6 @@
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
Expand Down

0 comments on commit 214cbff

Please sign in to comment.