Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Disable code completion popup animation #6

Merged
merged 2 commits into from

2 participants

@jmfd

My change will disable the window zoom and fade-in animations for the code completion popup window when manually triggered. It does so by overriding these two methods:

-[DVTTextCompletionListWindowController showWindowForTextFrame:(NSRect)textFrame explicitAnimation:(BOOL)usesExplicitAnimation]
-[DVTTextCompletionWindow setAlphaValue:(CGFloat)windowAlpha]

This makes the popup behavior like Xcode 3.2.

@jmfd

I've also added a fixin for changing the tab behavior to accept an entire completion. This was earlier Xcode behavior and makes more sense if you're manually popping up the completion list and selecting an entry.

@tom-seddon tom-seddon merged commit 05a38f2 into davekeck:master
@tom-seddon
Collaborator

Thanks! I really like both of these :)

--Tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 28, 2012
  1. @jmfd
Commits on Jul 29, 2012
  1. @jmfd

    Tab key will accept the current completion instead of just accepting …

    jmfd authored
    …the first matching prefix
This page is out of date. Refresh to see the latest.
View
26 XCFixin_DisableAnimations/XCFixin_DisableAnimations.m
@@ -5,6 +5,8 @@
static IMP gOriginalInitWithDuration = nil;
static IMP gOriginalSetDuration = nil;
+static IMP gOriginalSetAlphaValue = nil;
+static IMP gOriginalShowWindowForTextFrameExplicitAnimation = nil;
@interface XCFixin_DisableAnimations : NSObject
@end
@@ -23,6 +25,22 @@ static void overrideSetDuration(id self, SEL _cmd, NSTimeInterval arg1)
((void (*)(id, SEL, NSTimeInterval))gOriginalSetDuration)(self, _cmd, 0.0);
}
+static void overrideShowWindowForTextFrameExplicitAnimation(id self, SEL _cmd, NSRect arg1, BOOL arg2)
+{
+ /* -[DVTTextCompletionListWindowController showWindowForTextFrame:(NSRect)textFrame explicitAnimation:(BOOL)usesExplicitAnimation] */
+ ((void (*)(id, SEL, NSRect, BOOL))gOriginalShowWindowForTextFrameExplicitAnimation)(self, _cmd, arg1, NO);
+}
+
+static void overrideSetAlphaValue(id self, SEL _cmd, CGFloat windowAlpha)
+{
+ /* -[DVTTextCompletionWindow setAlphaValue:(CGFloat)windowAlpha] */
+ if(windowAlpha == 0.0) {
+ ((void (*)(id, SEL, NSTimeInterval))gOriginalSetAlphaValue)(self, _cmd, 0.0);
+ } else {
+ ((void (*)(id, SEL, NSTimeInterval))gOriginalSetAlphaValue)(self, _cmd, 1.0);
+ }
+}
+
+ (void)pluginDidLoad: (NSBundle *)plugin
{
XCFixinPreflight();
@@ -34,6 +52,14 @@ + (void)pluginDidLoad: (NSBundle *)plugin
/* Override -[NSAnimation setDuration:(NSTimeInterval)duration] */
gOriginalSetDuration = XCFixinOverrideMethodString(@"NSAnimation", @selector(setDuration:), (IMP)&overrideSetDuration);
XCFixinAssertOrPerform(gOriginalSetDuration, goto failed);
+
+ /* Override -[DVTTextCompletionWindow setAlphaValue:(CGFloat)windowAlpha] */
+ gOriginalSetAlphaValue = XCFixinOverrideMethodString(@"DVTTextCompletionWindow", @selector(setAlphaValue:), (IMP)&overrideSetAlphaValue);
+ XCFixinAssertOrPerform(gOriginalSetAlphaValue, goto failed);
+
+ /* Override -[DVTTextCompletionListWindowController showWindowForTextFrame:(NSRect)textFrame explicitAnimation:(BOOL)usesExplicitAnimation] */
+ gOriginalShowWindowForTextFrameExplicitAnimation = XCFixinOverrideMethodString(@"DVTTextCompletionListWindowController", @selector(showWindowForTextFrame:explicitAnimation:), (IMP)&overrideShowWindowForTextFrameExplicitAnimation);
+ XCFixinAssertOrPerform(gOriginalShowWindowForTextFrameExplicitAnimation, goto failed);
XCFixinPostflight();
}
View
2  XCFixin_TabAcceptsCompletions/English.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
View
34 XCFixin_TabAcceptsCompletions/Info.plist
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.themha.${PRODUCT_NAME:rfc1034Identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>NSPrincipalClass</key>
+ <string>XCFixin_TabAcceptsCompletions</string>
+ <key>XC4Compatible</key>
+ <true/>
+ <key>XCGCReady</key>
+ <true/>
+ <key>XCPluginHasUI</key>
+ <false/>
+</dict>
+</plist>
View
29 XCFixin_TabAcceptsCompletions/XCFixin_TabAcceptsCompletions.m
@@ -0,0 +1,29 @@
+#import <Cocoa/Cocoa.h>
+#import <objc/runtime.h>
+
+#import "XCFixin.h"
+
+static IMP gOriginalInsertUsefulPrefix = nil;
+
+@interface XCFixin_TabAcceptsCompletions : NSObject
+@end
+
+@implementation XCFixin_TabAcceptsCompletions
+
+static void overrideInsertUsefulPrefix(id self, SEL _cmd)
+{
+ [[[self performSelector:@selector(textView)] performSelector:@selector(completionController)] performSelector:@selector(acceptCurrentCompletion)];
+}
+
++ (void)pluginDidLoad: (NSBundle *)plugin
+{
+ XCFixinPreflight();
+
+ /* Override -[DVTTextCompletionSession insertUsefulPrefix] */
+ gOriginalInsertUsefulPrefix = XCFixinOverrideMethodString(@"DVTTextCompletionSession", @selector(insertUsefulPrefix), (IMP)&overrideInsertUsefulPrefix);
+ XCFixinAssertOrPerform(gOriginalInsertUsefulPrefix, goto failed);
+
+ XCFixinPostflight();
+}
+
+@end
View
259 XCFixin_TabAcceptsCompletions/XCFixin_TabAcceptsCompletions.xcodeproj/project.pbxproj
@@ -0,0 +1,259 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 5514A3FA1506CB8F00A8AD77 /* XCFixin.m in Sources */ = {isa = PBXBuildFile; fileRef = 5514A3F91506CB8F00A8AD77 /* XCFixin.m */; };
+ 55C015D212B7BC2500354E5C /* XCFixin_TabAcceptsCompletions.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C015D112B7BC2500354E5C /* XCFixin_TabAcceptsCompletions.m */; };
+ 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 */
+ 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+ 5514A3F91506CB8F00A8AD77 /* XCFixin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XCFixin.m; path = "../Shared Code/XCFixin.m"; sourceTree = "<group>"; };
+ 5595EEEB150067CB00A30634 /* XCFixin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XCFixin.h; path = "../Shared Code/XCFixin.h"; sourceTree = "<group>"; };
+ 55C015D112B7BC2500354E5C /* XCFixin_TabAcceptsCompletions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCFixin_TabAcceptsCompletions.m; sourceTree = "<group>"; };
+ 8D5B49B6048680CD000E48DA /* XCFixin_TabAcceptsCompletions.xcplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XCFixin_TabAcceptsCompletions.xcplugin; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+/* 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 /* XCFixin_DisableAnimations */ = {
+ isa = PBXGroup;
+ children = (
+ 08FB77AFFE84173DC02AAC07 /* Classes */,
+ 089C167CFE841241C02AAC07 /* Resources */,
+ 089C1671FE841209C02AAC07 /* Frameworks and Libraries */,
+ 19C28FB8FE9D52D311CA2CBB /* Products */,
+ );
+ name = XCFixin_DisableAnimations;
+ sourceTree = "<group>";
+ };
+ 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = {
+ isa = PBXGroup;
+ children = (
+ 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */,
+ );
+ name = "Frameworks and Libraries";
+ sourceTree = "<group>";
+ };
+ 089C167CFE841241C02AAC07 /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ 8D5B49B7048680CD000E48DA /* Info.plist */,
+ 089C167DFE841241C02AAC07 /* InfoPlist.strings */,
+ );
+ name = Resources;
+ sourceTree = "<group>";
+ };
+ 08FB77AFFE84173DC02AAC07 /* Classes */ = {
+ isa = PBXGroup;
+ children = (
+ 5595EEEB150067CB00A30634 /* XCFixin.h */,
+ 5514A3F91506CB8F00A8AD77 /* XCFixin.m */,
+ 55C015D112B7BC2500354E5C /* XCFixin_TabAcceptsCompletions.m */,
+ );
+ name = Classes;
+ sourceTree = "<group>";
+ };
+ 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */,
+ );
+ name = "Linked Frameworks";
+ sourceTree = "<group>";
+ };
+ 19C28FB8FE9D52D311CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 8D5B49B6048680CD000E48DA /* XCFixin_TabAcceptsCompletions.xcplugin */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 8D5B49AC048680CD000E48DA /* XCFixin_TabAcceptsCompletions */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "XCFixin_TabAcceptsCompletions" */;
+ buildPhases = (
+ 8D5B49AF048680CD000E48DA /* Resources */,
+ 8D5B49B1048680CD000E48DA /* Sources */,
+ 8D5B49B3048680CD000E48DA /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = XCFixin_TabAcceptsCompletions;
+ productInstallPath = "$(HOME)/Library/Bundles";
+ productName = XCFixin_DisableAnimations;
+ productReference = 8D5B49B6048680CD000E48DA /* XCFixin_TabAcceptsCompletions.xcplugin */;
+ productType = "com.apple.product-type.bundle";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 089C1669FE841209C02AAC07 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0410;
+ };
+ buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "XCFixin_TabAcceptsCompletions" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 1;
+ knownRegions = (
+ English,
+ Japanese,
+ French,
+ German,
+ );
+ mainGroup = 089C166AFE841209C02AAC07 /* XCFixin_DisableAnimations */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 8D5B49AC048680CD000E48DA /* XCFixin_TabAcceptsCompletions */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 8D5B49AF048680CD000E48DA /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 8D5B49B1048680CD000E48DA /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 55C015D212B7BC2500354E5C /* XCFixin_TabAcceptsCompletions.m in Sources */,
+ 5514A3FA1506CB8F00A8AD77 /* XCFixin.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 089C167EFE841241C02AAC07 /* English */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 1DEB913B08733D840010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ DEPLOYMENT_LOCATION = YES;
+ DEPLOYMENT_POSTPROCESSING = YES;
+ DSTROOT = "$(HOME)";
+ GCC_ENABLE_OBJC_GC = supported;
+ INFOPLIST_FILE = Info.plist;
+ INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins";
+ LD_RUNPATH_SEARCH_PATHS = /Developer;
+ PRODUCT_NAME = XCFixin_TabAcceptsCompletions;
+ STRIP_INSTALLED_PRODUCT = YES;
+ VALID_ARCHS = "i386 x86_64";
+ WRAPPER_EXTENSION = xcplugin;
+ };
+ name = Debug;
+ };
+ 1DEB913C08733D840010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ DEPLOYMENT_LOCATION = YES;
+ DEPLOYMENT_POSTPROCESSING = YES;
+ DSTROOT = "$(HOME)";
+ GCC_ENABLE_OBJC_GC = supported;
+ INFOPLIST_FILE = Info.plist;
+ INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins";
+ LD_RUNPATH_SEARCH_PATHS = /Developer;
+ PRODUCT_NAME = XCFixin_TabAcceptsCompletions;
+ STRIP_INSTALLED_PRODUCT = YES;
+ VALID_ARCHS = "i386 x86_64";
+ WRAPPER_EXTENSION = xcplugin;
+ };
+ name = Release;
+ };
+ 1DEB913F08733D840010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ };
+ name = Debug;
+ };
+ 1DEB914008733D840010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "XCFixin_TabAcceptsCompletions" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB913B08733D840010E9CD /* Debug */,
+ 1DEB913C08733D840010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "XCFixin_TabAcceptsCompletions" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB913F08733D840010E9CD /* Debug */,
+ 1DEB914008733D840010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 089C1669FE841209C02AAC07 /* Project object */;
+}
View
7 ...ions/XCFixin_TabAcceptsCompletions.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:XCFixin_TabAcceptsCompletions.xcodeproj">
+ </FileRef>
+</Workspace>
View
3  XCFixins.xcworkspace/contents.xcworkspacedata
@@ -25,4 +25,7 @@
<FileRef
location = "group:XCFixin_UserScripts/XCFixin_UserScripts.xcodeproj">
</FileRef>
+ <FileRef
+ location = "group:XCFixin_TabAcceptsCompletions/XCFixin_TabAcceptsCompletions.xcodeproj">
+ </FileRef>
</Workspace>
Something went wrong with that request. Please try again.