diff --git a/src/MacVim/Advanced.png b/src/MacVim/Advanced.png old mode 100755 new mode 100644 diff --git a/src/MacVim/AuthorizedShellCommand.h b/src/MacVim/AuthorizedShellCommand.h deleted file mode 100644 index 2bf139cfc6..0000000000 --- a/src/MacVim/AuthorizedShellCommand.h +++ /dev/null @@ -1,43 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: - * - * VIM - Vi IMproved by Bram Moolenaar - * MacVim GUI port by Bjorn Winckler - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -#import -#import - - -@interface AuthorizedShellCommand : NSObject { - - NSArray *commands; - - AuthorizationRef authorizationRef; - -} - -// Pass an array of dictionaries. Each dictionary has to have the following -// keys: -// -// * MMCommand: The command to execute, an NSString (e.g. @"/usr/bin/rm"). -// * MMArguments: An array of NSStrings, the arguments that are passed to -// the command. -// -- (AuthorizedShellCommand *)initWithCommands:(NSArray *)theCommands; - -// Runs the command passed in the constructor. -- (OSStatus)run; - -// This pops up the permission dialog. Called by run. -- (OSStatus)askUserForPermission; - -@end - - -extern NSString *MMCommand; -extern NSString *MMArguments; - diff --git a/src/MacVim/AuthorizedShellCommand.m b/src/MacVim/AuthorizedShellCommand.m deleted file mode 100644 index 1b90cdb630..0000000000 --- a/src/MacVim/AuthorizedShellCommand.m +++ /dev/null @@ -1,155 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: - * - * VIM - Vi IMproved by Bram Moolenaar - * MacVim GUI port by Bjorn Winckler - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ -/* - * AuthorizedCommand - * - * Runs a set of shell commands which may require authorization. Displays a - * gui dialog to ask the user for authorized access. - */ - -#import "AuthorizedShellCommand.h" -#import - - -@implementation AuthorizedShellCommand - -- (AuthorizedShellCommand *)initWithCommands:(NSArray *)theCommands -{ - if (![super init]) - return nil; - - commands = [theCommands retain]; - return self; -} - -- (void)dealloc -{ - [super dealloc]; - [commands release]; -} - -- (OSStatus)run -{ - OSStatus err; - int i; - const char** arguments = NULL; - AuthorizationFlags flags = kAuthorizationFlagDefaults; - - err = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, - flags, &authorizationRef); - if (err != errAuthorizationSuccess) - return err; - - if ((err = [self askUserForPermission]) != errAuthorizationSuccess) { - goto cleanup; - } - - NSEnumerator* myIterator = [commands objectEnumerator]; - NSDictionary* currCommand; - - while ((currCommand = [myIterator nextObject])) { - /* do something useful with currCommand */ - FILE *ioPipe = NULL; - char junk[256]; - - const char* toolPath = [[currCommand objectForKey:MMCommand] UTF8String]; - NSArray* argumentStrings = [currCommand objectForKey:MMArguments]; - arguments = (const char**)malloc( - ([argumentStrings count] + 1) * sizeof(char*)); - - for (i = 0; i < [argumentStrings count]; ++i) { - arguments[i] = [[argumentStrings objectAtIndex:i] UTF8String]; - } - arguments[i] = NULL; - - err = AuthorizationExecuteWithPrivileges (authorizationRef, toolPath, - kAuthorizationFlagDefaults, (char*const*)arguments, &ioPipe); - if (err != errAuthorizationSuccess) - goto cleanup; - -#if 0 - // We use the pipe to signal us when the command has completed - char *p; - do { - p = fgets(junk, sizeof(junk), ioPipe); - } while (p); -#else - for(;;) - { - int bytesRead = read (fileno (ioPipe), - junk, sizeof (junk)); - if (bytesRead < 1) break; - write (fileno (stdout), junk, bytesRead); - } -#endif - - if (arguments != NULL) { - free(arguments); - arguments = NULL; - } - fclose(ioPipe); - } - - - -cleanup: - AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults); - authorizationRef = 0; - - if (arguments != NULL) - free(arguments); - - return err; -} - -- (OSStatus)askUserForPermission -{ - int i; - - assert(authorizationRef != 0); - - // The documentation for AuthorizationItem says that `value` should be - // the path to the full posix path for kAuthorizationRightExecute. But - // the installer sample "Calling a Privileged Installer" sets it to NULL. - // Gotta love Apple's documentation. - // - // If you don't set `value` correctly, you'll get an - // `errAuthorizationToolEnvironmentError` when you try to execute the - // command. - AuthorizationItem* authItems = - malloc([commands count] * sizeof(AuthorizationItem)); - for (i = 0; i < [commands count]; ++i) { - authItems[i].name = kAuthorizationRightExecute; - authItems[i].value = (void*) - [[[commands objectAtIndex:i] objectForKey:MMCommand] UTF8String]; - authItems[i].valueLength = strlen(authItems[i].value); - authItems[i].flags = 0; - } - - AuthorizationRights rights = { - [commands count], authItems - }; - - OSStatus err = AuthorizationCopyRights(authorizationRef, &rights, NULL, - kAuthorizationFlagInteractionAllowed | - kAuthorizationFlagPreAuthorize | - kAuthorizationFlagExtendRights - , NULL); - - free(authItems); - - return err; -} - -@end - -NSString *MMCommand = @"MMCommand"; -NSString *MMArguments = @"MMArguments"; - diff --git a/src/MacVim/CTGradient.h b/src/MacVim/CTGradient.h deleted file mode 100644 index 68f3a4b106..0000000000 --- a/src/MacVim/CTGradient.h +++ /dev/null @@ -1,73 +0,0 @@ -// -// CTGradient.h -// -// Created by Chad Weider on 2/14/07. -// Writtin by Chad Weider. -// -// Released into public domain on 4/10/08. -// -// Version: 1.8 - -#import - -typedef struct _CTGradientElement - { - float red, green, blue, alpha; - float position; - - struct _CTGradientElement *nextElement; - } CTGradientElement; - -typedef enum _CTBlendingMode - { - CTLinearBlendingMode, - CTChromaticBlendingMode, - CTInverseChromaticBlendingMode - } CTGradientBlendingMode; - - -@interface CTGradient : NSObject - { - CTGradientElement* elementList; - CTGradientBlendingMode blendingMode; - - CGFunctionRef gradientFunction; - } - -+ (id)gradientWithBeginningColor:(NSColor *)begin endingColor:(NSColor *)end; - -+ (id)aquaSelectedGradient; -+ (id)aquaNormalGradient; -+ (id)aquaPressedGradient; - -+ (id)unifiedSelectedGradient; -+ (id)unifiedNormalGradient; -+ (id)unifiedPressedGradient; -+ (id)unifiedDarkGradient; - -+ (id)sourceListSelectedGradient; -+ (id)sourceListUnselectedGradient; - -+ (id)rainbowGradient; -+ (id)hydrogenSpectrumGradient; - -- (CTGradient *)gradientWithAlphaComponent:(float)alpha; - -- (CTGradient *)addColorStop:(NSColor *)color atPosition:(float)position; //positions given relative to [0,1] -- (CTGradient *)removeColorStopAtIndex:(unsigned)index; -- (CTGradient *)removeColorStopAtPosition:(float)position; - -- (CTGradientBlendingMode)blendingMode; -- (NSColor *)colorStopAtIndex:(unsigned)index; -- (NSColor *)colorAtPosition:(float)position; - - -- (void)drawSwatchInRect:(NSRect)rect; -- (void)fillRect:(NSRect)rect angle:(float)angle; //fills rect with axial gradient - // angle in degrees -- (void)radialFillRect:(NSRect)rect; //fills rect with radial gradient - // gradient from center outwards -- (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle; -- (void)radialFillBezierPath:(NSBezierPath *)path; - -@end diff --git a/src/MacVim/CTGradient.m b/src/MacVim/CTGradient.m deleted file mode 100644 index 4056fcf60e..0000000000 --- a/src/MacVim/CTGradient.m +++ /dev/null @@ -1,1271 +0,0 @@ -// -// CTGradient.m -// -// Created by Chad Weider on 2/14/07. -// Writtin by Chad Weider. -// -// Released into public domain on 4/10/08. -// -// Version: 1.8 -#ifdef MM_ENABLE_PLUGINS - -#import "CTGradient.h" - -@interface CTGradient (Private) -- (void)_commonInit; -- (void)setBlendingMode:(CTGradientBlendingMode)mode; -- (void)addElement:(CTGradientElement*)newElement; - -- (CTGradientElement *)elementAtIndex:(unsigned)index; - -- (CTGradientElement)removeElementAtIndex:(unsigned)index; -- (CTGradientElement)removeElementAtPosition:(float)position; -@end - -//C Fuctions for color blending -static void linearEvaluation (void *info, const float *in, float *out); -static void chromaticEvaluation(void *info, const float *in, float *out); -static void inverseChromaticEvaluation(void *info, const float *in, float *out); -static void transformRGB_HSV(float *components); -static void transformHSV_RGB(float *components); -static void resolveHSV(float *color1, float *color2); - - -@implementation CTGradient -/////////////////////////////////////Initialization Type Stuff -- (id)init - { - self = [super init]; - - if (self != nil) - { - [self _commonInit]; - [self setBlendingMode:CTLinearBlendingMode]; - } - return self; - } - -- (void)_commonInit - { - elementList = nil; - } - -- (void)dealloc - { - CGFunctionRelease(gradientFunction); - - CTGradientElement *elementToRemove = elementList; - while(elementList != nil) - { - elementToRemove = elementList; - elementList = elementList->nextElement; - free(elementToRemove); - } - - [super dealloc]; - } - -- (id)copyWithZone:(NSZone *)zone - { - CTGradient *copy = [[[self class] allocWithZone:zone] init]; - - //now just copy my elementlist - CTGradientElement *currentElement = elementList; - while(currentElement != nil) - { - [copy addElement:currentElement]; - currentElement = currentElement->nextElement; - } - - [copy setBlendingMode:blendingMode]; - - return copy; - } - -- (void)encodeWithCoder:(NSCoder *)coder - { - if([coder allowsKeyedCoding]) - { - unsigned count = 0; - CTGradientElement *currentElement = elementList; - while(currentElement != nil) - { - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->red)]; - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->green)]; - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->blue)]; - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->alpha)]; - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->position)]; - - count++; - currentElement = currentElement->nextElement; - } - [coder encodeInt:count forKey:@"CTGradientElementCount"]; - [coder encodeInt:blendingMode forKey:@"CTGradientBlendingMode"]; - } - else - [NSException raise:NSInvalidArchiveOperationException format:@"Only supports NSKeyedArchiver coders"]; - } - -- (id)initWithCoder:(NSCoder *)coder - { - [self _commonInit]; - - [self setBlendingMode:[coder decodeIntForKey:@"CTGradientBlendingMode"]]; - unsigned count = [coder decodeIntForKey:@"CTGradientElementCount"]; - - while(count != 0) - { - CTGradientElement newElement; - - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.red)]; - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.green)]; - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.blue)]; - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.alpha)]; - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.position)]; - - count--; - [self addElement:&newElement]; - } - return self; - } -#pragma mark - - - - -#pragma mark Creation -+ (id)gradientWithBeginningColor:(NSColor *)begin endingColor:(NSColor *)end - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - CTGradientElement color2; - - [[begin colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&color1.red - green:&color1.green - blue:&color1.blue - alpha:&color1.alpha]; - - [[end colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&color2.red - green:&color2.green - blue:&color2.blue - alpha:&color2.alpha]; - color1.position = 0; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)aquaSelectedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = 0.58; - color1.green = 0.86; - color1.blue = 0.98; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = 0.42; - color2.green = 0.68; - color2.blue = 0.90; - color2.alpha = 1.00; - color2.position = 11.5/23; - - CTGradientElement color3; - color3.red = 0.64; - color3.green = 0.80; - color3.blue = 0.94; - color3.alpha = 1.00; - color3.position = 11.5/23; - - CTGradientElement color4; - color4.red = 0.56; - color4.green = 0.70; - color4.blue = 0.90; - color4.alpha = 1.00; - color4.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - [newInstance addElement:&color3]; - [newInstance addElement:&color4]; - - return [newInstance autorelease]; - } - -+ (id)aquaNormalGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.95; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.83; - color2.alpha = 1.00; - color2.position = 11.5/23; - - CTGradientElement color3; - color3.red = color3.green = color3.blue = 0.95; - color3.alpha = 1.00; - color3.position = 11.5/23; - - CTGradientElement color4; - color4.red = color4.green = color4.blue = 0.92; - color4.alpha = 1.00; - color4.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - [newInstance addElement:&color3]; - [newInstance addElement:&color4]; - - return [newInstance autorelease]; - } - -+ (id)aquaPressedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.80; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.64; - color2.alpha = 1.00; - color2.position = 11.5/23; - - CTGradientElement color3; - color3.red = color3.green = color3.blue = 0.80; - color3.alpha = 1.00; - color3.position = 11.5/23; - - CTGradientElement color4; - color4.red = color4.green = color4.blue = 0.77; - color4.alpha = 1.00; - color4.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - [newInstance addElement:&color3]; - [newInstance addElement:&color4]; - - return [newInstance autorelease]; - } - -+ (id)unifiedSelectedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.85; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.95; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)unifiedNormalGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.75; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.90; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)unifiedPressedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.60; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.75; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)unifiedDarkGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.68; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.83; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)sourceListSelectedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = 0.06; - color1.green = 0.37; - color1.blue = 0.85; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = 0.30; - color2.green = 0.60; - color2.blue = 0.92; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)sourceListUnselectedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = 0.43; - color1.green = 0.43; - color1.blue = 0.43; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = 0.60; - color2.green = 0.60; - color2.blue = 0.60; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)rainbowGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = 1.00; - color1.green = 0.00; - color1.blue = 0.00; - color1.alpha = 1.00; - color1.position = 0.0; - - CTGradientElement color2; - color2.red = 0.54; - color2.green = 0.00; - color2.blue = 1.00; - color2.alpha = 1.00; - color2.position = 1.0; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - [newInstance setBlendingMode:CTChromaticBlendingMode]; - - return [newInstance autorelease]; - } - -+ (id)hydrogenSpectrumGradient - { - id newInstance = [[[self class] alloc] init]; - - struct {float hue; float position; float width;} colorBands[4]; - - colorBands[0].hue = 22; - colorBands[0].position = .145; - colorBands[0].width = .01; - - colorBands[1].hue = 200; - colorBands[1].position = .71; - colorBands[1].width = .008; - - colorBands[2].hue = 253; - colorBands[2].position = .885; - colorBands[2].width = .005; - - colorBands[3].hue = 275; - colorBands[3].position = .965; - colorBands[3].width = .003; - - int i; - ///////////////////////////// - for(i = 0; i < 4; i++) - { - float color[4]; - color[0] = colorBands[i].hue - 180*colorBands[i].width; - color[1] = 1; - color[2] = 0.001; - color[3] = 1; - transformHSV_RGB(color); - CTGradientElement fadeIn; - fadeIn.red = color[0]; - fadeIn.green = color[1]; - fadeIn.blue = color[2]; - fadeIn.alpha = color[3]; - fadeIn.position = colorBands[i].position - colorBands[i].width; - - - color[0] = colorBands[i].hue; - color[1] = 1; - color[2] = 1; - color[3] = 1; - transformHSV_RGB(color); - CTGradientElement band; - band.red = color[0]; - band.green = color[1]; - band.blue = color[2]; - band.alpha = color[3]; - band.position = colorBands[i].position; - - color[0] = colorBands[i].hue + 180*colorBands[i].width; - color[1] = 1; - color[2] = 0.001; - color[3] = 1; - transformHSV_RGB(color); - CTGradientElement fadeOut; - fadeOut.red = color[0]; - fadeOut.green = color[1]; - fadeOut.blue = color[2]; - fadeOut.alpha = color[3]; - fadeOut.position = colorBands[i].position + colorBands[i].width; - - - [newInstance addElement:&fadeIn]; - [newInstance addElement:&band]; - [newInstance addElement:&fadeOut]; - } - - [newInstance setBlendingMode:CTChromaticBlendingMode]; - - return [newInstance autorelease]; - } - -#pragma mark - - - - -#pragma mark Modification -- (CTGradient *)gradientWithAlphaComponent:(float)alpha - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement *curElement = elementList; - CTGradientElement tempElement; - - while(curElement != nil) - { - tempElement = *curElement; - tempElement.alpha = alpha; - [newInstance addElement:&tempElement]; - - curElement = curElement->nextElement; - } - - return [newInstance autorelease]; - } - -- (CTGradient *)gradientWithBlendingMode:(CTGradientBlendingMode)mode - { - CTGradient *newGradient = [self copy]; - - [newGradient setBlendingMode:mode]; - - return [newGradient autorelease]; - } - - -//Adds a color stop with at in elementList -//(if two elements are at the same position then added imediatly after the one that was there already) -- (CTGradient *)addColorStop:(NSColor *)color atPosition:(float)position - { - CTGradient *newGradient = [self copy]; - CTGradientElement newGradientElement; - - //put the components of color into the newGradientElement - must make sure it is a RGB color (not Gray or CMYK) - [[color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&newGradientElement.red - green:&newGradientElement.green - blue:&newGradientElement.blue - alpha:&newGradientElement.alpha]; - newGradientElement.position = position; - - //Pass it off to addElement to take care of adding it to the elementList - [newGradient addElement:&newGradientElement]; - - return [newGradient autorelease]; - } - - -//Removes the color stop at from elementList -- (CTGradient *)removeColorStopAtPosition:(float)position - { - CTGradient *newGradient = [self copy]; - CTGradientElement removedElement = [newGradient removeElementAtPosition:position]; - - if(isnan(removedElement.position)) - [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtPosition:]: no such colorStop at position (%f)", [self class], position]; - - return [newGradient autorelease]; - } - -- (CTGradient *)removeColorStopAtIndex:(unsigned)index - { - CTGradient *newGradient = [self copy]; - CTGradientElement removedElement = [newGradient removeElementAtIndex:index]; - - if(isnan(removedElement.position)) - [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtIndex:]: index (%i) beyond bounds", [self class], index]; - - return [newGradient autorelease]; - } -#pragma mark - - - - -#pragma mark Information -- (CTGradientBlendingMode)blendingMode - { - return blendingMode; - } - -//Returns color at in gradient -- (NSColor *)colorStopAtIndex:(unsigned)index - { - CTGradientElement *element = [self elementAtIndex:index]; - - if(element != nil) - return [NSColor colorWithCalibratedRed:element->red - green:element->green - blue:element->blue - alpha:element->alpha]; - - [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtIndex:]: index (%i) beyond bounds", [self class], index]; - - return nil; - } - -- (NSColor *)colorAtPosition:(float)position - { - float components[4]; - - switch(blendingMode) - { - case CTLinearBlendingMode: - linearEvaluation(&elementList, &position, components); break; - case CTChromaticBlendingMode: - chromaticEvaluation(&elementList, &position, components); break; - case CTInverseChromaticBlendingMode: - inverseChromaticEvaluation(&elementList, &position, components); break; - } - - - return [NSColor colorWithCalibratedRed:components[0]/components[3] //undo premultiplication that CG requires - green:components[1]/components[3] - blue:components[2]/components[3] - alpha:components[3]]; - } -#pragma mark - - - - -#pragma mark Drawing -- (void)drawSwatchInRect:(NSRect)rect - { - [self fillRect:rect angle:45]; - } - -- (void)fillRect:(NSRect)rect angle:(float)angle - { - //First Calculate where the beginning and ending points should be - CGPoint startPoint; - CGPoint endPoint; - - if(angle == 0) //screw the calculations - we know the answer - { - startPoint = CGPointMake(NSMinX(rect), NSMinY(rect)); //right of rect - endPoint = CGPointMake(NSMaxX(rect), NSMinY(rect)); //left of rect - } - else if(angle == 90) //same as above - { - startPoint = CGPointMake(NSMinX(rect), NSMinY(rect)); //bottom of rect - endPoint = CGPointMake(NSMinX(rect), NSMaxY(rect)); //top of rect - } - else //ok, we'll do the calculations now - { - float x,y; - float sina, cosa, tana; - - float length; - float deltax, - deltay; - - float rangle = angle * pi/180; //convert the angle to radians - - if(fabsf(tan(rangle))<=1) //for range [-45,45], [135,225] - { - x = NSWidth(rect); - y = NSHeight(rect); - - sina = sin(rangle); - cosa = cos(rangle); - tana = tan(rangle); - - length = x/fabsf(cosa)+(y-x*fabsf(tana))*fabsf(sina); - - deltax = length*cosa/2; - deltay = length*sina/2; - } - else //for range [45,135], [225,315] - { - x = NSHeight(rect); - y = NSWidth(rect); - - sina = sin(rangle - 90*pi/180); - cosa = cos(rangle - 90*pi/180); - tana = tan(rangle - 90*pi/180); - - length = x/fabsf(cosa)+(y-x*fabsf(tana))*fabsf(sina); - - deltax =-length*sina/2; - deltay = length*cosa/2; - } - - startPoint = CGPointMake(NSMidX(rect)-deltax, NSMidY(rect)-deltay); - endPoint = CGPointMake(NSMidX(rect)+deltax, NSMidY(rect)+deltay); - } - - //Calls to CoreGraphics - CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; - CGContextSaveGState(currentContext); - #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 - CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); - #else - CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); - #endif - CGShadingRef myCGShading = CGShadingCreateAxial(colorspace, startPoint, endPoint, gradientFunction, false, false); - - CGContextClipToRect (currentContext, *(CGRect *)&rect); //This is where the action happens - CGContextDrawShading(currentContext, myCGShading); - - CGShadingRelease(myCGShading); - CGColorSpaceRelease(colorspace ); - CGContextRestoreGState(currentContext); - } - -- (void)radialFillRect:(NSRect)rect - { - CGPoint startPoint, endPoint; - float startRadius, endRadius; - float scalex, scaley, transx, transy; - - startPoint = endPoint = CGPointMake(NSMidX(rect), NSMidY(rect)); - - startRadius = -1; - if(NSHeight(rect)>NSWidth(rect)) - { - scalex = NSWidth(rect)/NSHeight(rect); - transx = (NSHeight(rect)-NSWidth(rect))/2; - scaley = 1; - transy = 1; - endRadius = NSHeight(rect)/2; - } - else - { - scalex = 1; - transx = 1; - scaley = NSHeight(rect)/NSWidth(rect); - transy = (NSWidth(rect)-NSHeight(rect))/2; - endRadius = NSWidth(rect)/2; - } - - //Calls to CoreGraphics - CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; - CGContextSaveGState(currentContext); - #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); - #else - CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); - #endif - CGShadingRef myCGShading = CGShadingCreateRadial(colorspace, startPoint, startRadius, endPoint, endRadius, gradientFunction, true, true); - - CGContextClipToRect (currentContext, *(CGRect *)&rect); - CGContextScaleCTM (currentContext, scalex, scaley); - CGContextTranslateCTM(currentContext, transx, transy); - CGContextDrawShading (currentContext, myCGShading); //This is where the action happens - - CGShadingRelease(myCGShading); - CGColorSpaceRelease(colorspace); - CGContextRestoreGState(currentContext); - } - -- (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle - { - NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; - [currentContext saveGraphicsState]; - NSAffineTransform *transform = [[NSAffineTransform alloc] init]; - - [transform rotateByDegrees:-angle]; - [path transformUsingAffineTransform:transform]; - [transform invert]; - [transform concat]; - - [path addClip]; - [self fillRect:[path bounds] angle:0]; - [path transformUsingAffineTransform:transform]; - [transform release]; - [currentContext restoreGraphicsState]; - } -- (void)radialFillBezierPath:(NSBezierPath *)path - { - NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; - [currentContext saveGraphicsState]; - [path addClip]; - [self radialFillRect:[path bounds]]; - [currentContext restoreGraphicsState]; - } -#pragma mark - - - - -#pragma mark Private Methods -- (void)setBlendingMode:(CTGradientBlendingMode)mode; - { - blendingMode = mode; - - //Choose what blending function to use - void *evaluationFunction; - switch(blendingMode) - { - case CTLinearBlendingMode: - evaluationFunction = &linearEvaluation; break; - case CTChromaticBlendingMode: - evaluationFunction = &chromaticEvaluation; break; - case CTInverseChromaticBlendingMode: - evaluationFunction = &inverseChromaticEvaluation; break; - } - - //replace the current CoreGraphics Function with new one - if(gradientFunction != NULL) - CGFunctionRelease(gradientFunction); - - CGFunctionCallbacks evaluationCallbackInfo = {0 , evaluationFunction, NULL}; //Version, evaluator function, cleanup function - - static const float input_value_range [2] = { 0, 1 }; //range for the evaluator input - static const float output_value_ranges [8] = { 0, 1, 0, 1, 0, 1, 0, 1 }; //ranges for the evaluator output (4 returned values) - - gradientFunction = CGFunctionCreate(&elementList, //the two transition colors - 1, input_value_range , //number of inputs (just fraction of progression) - 4, output_value_ranges, //number of outputs (4 - RGBa) - &evaluationCallbackInfo); //info for using the evaluator function - } - -- (void)addElement:(CTGradientElement *)newElement - { - if(elementList == nil || newElement->position < elementList->position) //inserting at beginning of list - { - CTGradientElement *tmpNext = elementList; - elementList = malloc(sizeof(CTGradientElement)); - *elementList = *newElement; - elementList->nextElement = tmpNext; - } - else //inserting somewhere inside list - { - CTGradientElement *curElement = elementList; - - while(curElement->nextElement != nil && !((curElement->position <= newElement->position) && (newElement->position < curElement->nextElement->position))) - { - curElement = curElement->nextElement; - } - - CTGradientElement *tmpNext = curElement->nextElement; - curElement->nextElement = malloc(sizeof(CTGradientElement)); - *(curElement->nextElement) = *newElement; - curElement->nextElement->nextElement = tmpNext; - } - } - -- (CTGradientElement)removeElementAtIndex:(unsigned)index - { - CTGradientElement removedElement; - - if(elementList != nil) - { - if(index == 0) - { - CTGradientElement *tmpNext = elementList; - elementList = elementList->nextElement; - - removedElement = *tmpNext; - free(tmpNext); - - return removedElement; - } - - unsigned count = 1; //we want to start one ahead - CTGradientElement *currentElement = elementList; - while(currentElement->nextElement != nil) - { - if(count == index) - { - CTGradientElement *tmpNext = currentElement->nextElement; - currentElement->nextElement = currentElement->nextElement->nextElement; - - removedElement = *tmpNext; - free(tmpNext); - - return removedElement; - } - - count++; - currentElement = currentElement->nextElement; - } - } - - //element is not found, return empty element - removedElement.red = 0.0; - removedElement.green = 0.0; - removedElement.blue = 0.0; - removedElement.alpha = 0.0; - removedElement.position = NAN; - removedElement.nextElement = nil; - - return removedElement; - } - -- (CTGradientElement)removeElementAtPosition:(float)position - { - CTGradientElement removedElement; - - if(elementList != nil) - { - if(elementList->position == position) - { - CTGradientElement *tmpNext = elementList; - elementList = elementList->nextElement; - - removedElement = *tmpNext; - free(tmpNext); - - return removedElement; - } - else - { - CTGradientElement *curElement = elementList; - while(curElement->nextElement != nil) - { - if(curElement->nextElement->position == position) - { - CTGradientElement *tmpNext = curElement->nextElement; - curElement->nextElement = curElement->nextElement->nextElement; - - removedElement = *tmpNext; - free(tmpNext); - - return removedElement; - } - } - } - } - - //element is not found, return empty element - removedElement.red = 0.0; - removedElement.green = 0.0; - removedElement.blue = 0.0; - removedElement.alpha = 0.0; - removedElement.position = NAN; - removedElement.nextElement = nil; - - return removedElement; - } - - -- (CTGradientElement *)elementAtIndex:(unsigned)index; - { - unsigned count = 0; - CTGradientElement *currentElement = elementList; - - while(currentElement != nil) - { - if(count == index) - return currentElement; - - count++; - currentElement = currentElement->nextElement; - } - - return nil; - } -#pragma mark - - - - -#pragma mark Core Graphics -//////////////////////////////////////Blending Functions///////////////////////////////////// -void linearEvaluation (void *info, const float *in, float *out) - { - float position = *in; - - if(*(CTGradientElement **)info == nil) //if elementList is empty return clear color - { - out[0] = out[1] = out[2] = out[3] = 1; - return; - } - - //This grabs the first two colors in the sequence - CTGradientElement *color1 = *(CTGradientElement **)info; - CTGradientElement *color2 = color1->nextElement; - - //make sure first color and second color are on other sides of position - while(color2 != nil && color2->position < position) - { - color1 = color2; - color2 = color1->nextElement; - } - //if we don't have another color then make next color the same color - if(color2 == nil) - { - color2 = color1; - } - - //----------FailSafe settings---------- - //color1->red = 1; color2->red = 0; - //color1->green = 1; color2->green = 0; - //color1->blue = 1; color2->blue = 0; - //color1->alpha = 1; color2->alpha = 1; - //color1->position = .5; - //color2->position = .5; - //------------------------------------- - - if(position <= color1->position) //Make all below color color1's position equal to color1 - { - out[0] = color1->red; - out[1] = color1->green; - out[2] = color1->blue; - out[3] = color1->alpha; - } - else if (position >= color2->position) //Make all above color color2's position equal to color2 - { - out[0] = color2->red; - out[1] = color2->green; - out[2] = color2->blue; - out[3] = color2->alpha; - } - else //Interpolate color at postions between color1 and color1 - { - //adjust position so that it goes from 0 to 1 in the range from color 1 & 2's position - position = (position-color1->position)/(color2->position - color1->position); - - out[0] = (color2->red - color1->red )*position + color1->red; - out[1] = (color2->green - color1->green)*position + color1->green; - out[2] = (color2->blue - color1->blue )*position + color1->blue; - out[3] = (color2->alpha - color1->alpha)*position + color1->alpha; - } - - //Premultiply the color by the alpha. - out[0] *= out[3]; - out[1] *= out[3]; - out[2] *= out[3]; - } - - - - -//Chromatic Evaluation - -// This blends colors by their Hue, Saturation, and Value(Brightness) right now I just -// transform the RGB values stored in the CTGradientElements to HSB, in the future I may -// streamline it to avoid transforming in and out of HSB colorspace *for later* -// -// For the chromatic blend we shift the hue of color1 to meet the hue of color2. To do -// this we will add to the hue's angle (if we subtract we'll be doing the inverse -// chromatic...scroll down more for that). All we need to do is keep adding to the hue -// until we wrap around the colorwheel and get to color2. -void chromaticEvaluation(void *info, const float *in, float *out) - { - float position = *in; - - if(*(CTGradientElement **)info == nil) //if elementList is empty return clear color - { - out[0] = out[1] = out[2] = out[3] = 1; - return; - } - - //This grabs the first two colors in the sequence - CTGradientElement *color1 = *(CTGradientElement **)info; - CTGradientElement *color2 = color1->nextElement; - - float c1[4]; - float c2[4]; - - //make sure first color and second color are on other sides of position - while(color2 != nil && color2->position < position) - { - color1 = color2; - color2 = color1->nextElement; - } - //if we don't have another color then make next color the same color - if(color2 == nil) - { - color2 = color1; - } - - - c1[0] = color1->red; - c1[1] = color1->green; - c1[2] = color1->blue; - c1[3] = color1->alpha; - - c2[0] = color2->red; - c2[1] = color2->green; - c2[2] = color2->blue; - c2[3] = color2->alpha; - - transformRGB_HSV(c1); - transformRGB_HSV(c2); - resolveHSV(c1,c2); - - if(c1[0] > c2[0]) //if color1's hue is higher than color2's hue then - c2[0] += 360; // we need to move c2 one revolution around the wheel - - - if(position <= color1->position) //Make all below color color1's position equal to color1 - { - out[0] = c1[0]; - out[1] = c1[1]; - out[2] = c1[2]; - out[3] = c1[3]; - } - else if (position >= color2->position) //Make all above color color2's position equal to color2 - { - out[0] = c2[0]; - out[1] = c2[1]; - out[2] = c2[2]; - out[3] = c2[3]; - } - else //Interpolate color at postions between color1 and color1 - { - //adjust position so that it goes from 0 to 1 in the range from color 1 & 2's position - position = (position-color1->position)/(color2->position - color1->position); - - out[0] = (c2[0] - c1[0])*position + c1[0]; - out[1] = (c2[1] - c1[1])*position + c1[1]; - out[2] = (c2[2] - c1[2])*position + c1[2]; - out[3] = (c2[3] - c1[3])*position + c1[3]; - } - - transformHSV_RGB(out); - - //Premultiply the color by the alpha. - out[0] *= out[3]; - out[1] *= out[3]; - out[2] *= out[3]; - } - - - -//Inverse Chromatic Evaluation - -// Inverse Chromatic is about the same story as Chromatic Blend, but here the Hue -// is strictly decreasing, that is we need to get from color1 to color2 by decreasing -// the 'angle' (i.e. 90Ľ -> 180Ľ would be done by subtracting 270Ľ and getting -180Ľ... -// which is equivalent to 180Ľ mod 360Ľ -void inverseChromaticEvaluation(void *info, const float *in, float *out) - { - float position = *in; - - if(*(CTGradientElement **)info == nil) //if elementList is empty return clear color - { - out[0] = out[1] = out[2] = out[3] = 1; - return; - } - - //This grabs the first two colors in the sequence - CTGradientElement *color1 = *(CTGradientElement **)info; - CTGradientElement *color2 = color1->nextElement; - - float c1[4]; - float c2[4]; - - //make sure first color and second color are on other sides of position - while(color2 != nil && color2->position < position) - { - color1 = color2; - color2 = color1->nextElement; - } - //if we don't have another color then make next color the same color - if(color2 == nil) - { - color2 = color1; - } - - c1[0] = color1->red; - c1[1] = color1->green; - c1[2] = color1->blue; - c1[3] = color1->alpha; - - c2[0] = color2->red; - c2[1] = color2->green; - c2[2] = color2->blue; - c2[3] = color2->alpha; - - transformRGB_HSV(c1); - transformRGB_HSV(c2); - resolveHSV(c1,c2); - - if(c1[0] < c2[0]) //if color1's hue is higher than color2's hue then - c1[0] += 360; // we need to move c2 one revolution back on the wheel - - - if(position <= color1->position) //Make all below color color1's position equal to color1 - { - out[0] = c1[0]; - out[1] = c1[1]; - out[2] = c1[2]; - out[3] = c1[3]; - } - else if (position >= color2->position) //Make all above color color2's position equal to color2 - { - out[0] = c2[0]; - out[1] = c2[1]; - out[2] = c2[2]; - out[3] = c2[3]; - } - else //Interpolate color at postions between color1 and color1 - { - //adjust position so that it goes from 0 to 1 in the range from color 1 & 2's position - position = (position-color1->position)/(color2->position - color1->position); - - out[0] = (c2[0] - c1[0])*position + c1[0]; - out[1] = (c2[1] - c1[1])*position + c1[1]; - out[2] = (c2[2] - c1[2])*position + c1[2]; - out[3] = (c2[3] - c1[3])*position + c1[3]; - } - - transformHSV_RGB(out); - - //Premultiply the color by the alpha. - out[0] *= out[3]; - out[1] *= out[3]; - out[2] *= out[3]; - } - - -void transformRGB_HSV(float *components) //H,S,B -> R,G,B - { - float H, S, V; - float R = components[0], - G = components[1], - B = components[2]; - - float MAX = R > G ? (R > B ? R : B) : (G > B ? G : B), - MIN = R < G ? (R < B ? R : B) : (G < B ? G : B); - - if(MAX == MIN) - H = NAN; - else if(MAX == R) - if(G >= B) - H = 60*(G-B)/(MAX-MIN)+0; - else - H = 60*(G-B)/(MAX-MIN)+360; - else if(MAX == G) - H = 60*(B-R)/(MAX-MIN)+120; - else if(MAX == B) - H = 60*(R-G)/(MAX-MIN)+240; - - S = MAX == 0 ? 0 : 1 - MIN/MAX; - V = MAX; - - components[0] = H; - components[1] = S; - components[2] = V; - } - -void transformHSV_RGB(float *components) //H,S,B -> R,G,B - { - float R, G, B; - float H = fmodf(components[0],359), //map to [0,360) - S = components[1], - V = components[2]; - - int Hi = (int)floorf(H/60.) % 6; - float f = H/60-Hi, - p = V*(1-S), - q = V*(1-f*S), - t = V*(1-(1-f)*S); - - switch (Hi) - { - case 0: R=V;G=t;B=p; break; - case 1: R=q;G=V;B=p; break; - case 2: R=p;G=V;B=t; break; - case 3: R=p;G=q;B=V; break; - case 4: R=t;G=p;B=V; break; - case 5: R=V;G=p;B=q; break; - } - - components[0] = R; - components[1] = G; - components[2] = B; - } - -void resolveHSV(float *color1, float *color2) //H value may be undefined (i.e. graycale color) - { // we want to fill it with a sensible value - if(isnan(color1[0]) && isnan(color2[0])) - color1[0] = color2[0] = 0; - else if(isnan(color1[0])) - color1[0] = color2[0]; - else if(isnan(color2[0])) - color2[0] = color1[0]; - } - -@end - -#endif // MM_ENABLE_PLUGINS diff --git a/src/MacVim/Credits.rtf b/src/MacVim/Credits.rtf index d65a7f581e..c099a90209 100644 --- a/src/MacVim/Credits.rtf +++ b/src/MacVim/Credits.rtf @@ -45,8 +45,4 @@ The default font in MacVim, DejaVu Sans Mono, is based on the Bitstream Vera\'99 \ Thanks to Andy Matuschak for {\field{\*\fldinst{HYPERLINK "http://sparkle.andymatuschak.org/"}}{\fldrslt Sparkle}}.\ \ -Thanks to Dave Batton for {\field{\*\fldinst{HYPERLINK "http://www.mere-mortal-software.com/blog/details.php?d=2007-03-11&c=show"}}{\fldrslt DBPrefsWindowController}}.\ -\ -Thanks to Allan Odgaard for making the "Edit in TextMate" input manager source code available, and also to Chris Eidhof and Eelco Lempsink for modifying it so that it could be used with any ODB capable editor.\ -\ Thanks to Damien Guard for {\field{\*\fldinst{HYPERLINK "http://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released"}}{\fldrslt Envy Code R}} (used in MacVim's 16x16 document icons).} \ No newline at end of file diff --git a/src/MacVim/English.lproj/Preferences.nib/designable.nib b/src/MacVim/English.lproj/Preferences.nib/designable.nib index 21bc97d4e2..35a8811db3 100644 --- a/src/MacVim/English.lproj/Preferences.nib/designable.nib +++ b/src/MacVim/English.lproj/Preferences.nib/designable.nib @@ -2,13 +2,13 @@ 1050 - 10C540 - 732 - 1038.25 - 458.00 + 10F569 + 762 + 1038.29 + 461.00 com.apple.InterfaceBuilder.CocoaPlugin - 732 + 762 @@ -28,10 +28,6 @@ NSApplication - - MM - MMRenderer - YES @@ -490,7 +486,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - + 6 System disabledControlTextColor @@ -713,242 +709,55 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {483, 290} NSView - - - 268 - - - - 292 - - - - 256 - - - - 268 - {{12, 115}, {96, 32}} - - YES - - 604110336 - 134217728 - Uninstall - - - -2038284033 - 1 - - - 200 - 25 - - - - - 268 - {{15, 14}, {417, 51}} - - YES - - 67239424 - 4194304 - External Editor is a bit of a hack. It could make other applications unstable, and it could stop working in new versions of OS X. But it usually works well, and uninstallation completely removes it. - - - - - - - - - 268 - {{211, 227}, {152, 26}} - - YES - - -1539178944 - 2048 - - - 109199615 - 1 - - - 400 - 75 - - YES - - OtherViews - - - -1 - 1 - YES - YES - 2 - - - - - 268 - {{12, 221}, {96, 32}} - - YES - - 604110336 - 134217728 - Install - - - -2038284033 - 1 - - - 200 - 25 - - - - - 268 - {{107, 159}, {325, 14}} - - YES - - 67239488 - 272761856 - (version) - - - - - - - - - 268 - {{107, 231}, {102, 17}} - - YES - - 67239488 - 272630784 - External Editor: - - - - - - - - - 268 - {{107, 181}, {325, 42}} - - YES - - 67239424 - 4325376 - Use this to write mails or to fill in web forms with your favorite editor. Save and close the file in your editor to copy the result back to the original application. - - - - - - - - - 268 - {{15, 73}, {417, 34}} - - YES - - 67239424 - 4194304 - You must restart applications that should notice any change you make above. - - - - - - - - - 268 - {{107, 125}, {325, 14}} - - YES - - 67239424 - 1078067200 - This completely removes the External Editor functionality. - - - - - - - - - 268 - {{15, 265}, {417, 34}} - - YES - - 67239424 - 4194304 - Add “Edit in External Editor…” to the Edit menu of other applications like Mail or Safari. - - - - - - - - {{1, 1}, {447, 309}} - - - - {{17, 16}, {449, 325}} - - {0, 0} - - 67239424 - 0 - External Editor - - - 6 - System - textBackgroundColor - - - - 3 - MCAwLjgwMDAwMDAxAA - - - - 1 - 0 - 2 - NO - - - {483, 361} - NSView - 268 + + + 268 + {{18, 92}, {174, 18}} + + YES + + 67239424 + 0 + Draw marked text inline + + + 1211912703 + 2 + + + + + 200 + 25 + + + + + 268 + {{17, 20}, {444, 70}} + + YES + + 67239424 + 272760832 + This option causes marked text to be rendered like normal text which is very convenient when using a complex input method (e.g. Kotoeri). However, it has some known limitations which may be circumvented by disabling this option (e.g. mapping to "dead keys" may not work). Note that without this option the experimental renderer will not draw marked text at all. + + + + + 3 + MC41AA + + + 268 - {{18, 132}, {190, 18}} + {{18, 228}, {190, 18}} YES @@ -970,7 +779,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 102}, {449, 28}} + {{17, 198}, {449, 28}} YES @@ -980,16 +789,13 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - - 3 - MC41AA - + 268 - {{18, 78}, {133, 18}} + {{18, 174}, {133, 18}} YES @@ -1011,7 +817,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 20}, {449, 56}} + {{17, 116}, {449, 56}} YES @@ -1031,7 +837,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - {483, 168} + {483, 264} NSView @@ -1078,62 +884,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 171 - - - integrationPreferences - - - - 192 - - - - editors - - - - 222 - - - - installOdbButton - - - - 245 - - - - uninstallOdbButton - - - - 246 - - - - uninstallOdb: - - - - 266 - - - - installOdb: - - - - 286 - - - - obdBundleVersionLabel - - - - 308 - selectedTag: values.MMOpenLayout @@ -1274,6 +1024,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 1000 + + + value: values.MMUseInlineIm + + + + + + value: values.MMUseInlineIm + value + values.MMUseInlineIm + 2 + + + 1016 + @@ -1435,32 +1201,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - - 191 - - - - - - Integration - - - 213 - - - - - - - - - - - - - - - 620 @@ -1469,6 +1209,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA + + Advanced @@ -1638,148 +1380,41 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 195 - + 1001 + - + - + - 981 - - + 1004 + + - 211 - + 1013 + - + - + - 983 - - - - - 201 - - - - - - - - 982 - - - - - - - - 203 - - - - - 193 - - - - - - - - 980 - - - - - 306 - - - - - - - - 984 - - - - - 334 - - - - - - - - 985 - - - - - 336 - - - - - - - - 986 - - - - - 338 - - - - - - - - 987 - - - - - 340 - - - - - - - - 988 - - - - - 367 - - - - - - - - 989 - - + 1014 + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{329, 705}, {483, 290}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1809,32 +1444,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1849,7 +1458,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin - {{329, 804}, {483, 168}} + {{605, 600}, {483, 264}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1878,16 +1487,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1899,7 +1498,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 1000 + 1016 @@ -1935,20 +1534,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA MMPreferenceController DBPrefsWindowController - - id - id - id - + + openInCurrentWindowSelectionChanged: + id + NSView - NSPopUpButton NSView - NSButton - NSView NSPopUpButton - NSTextField - NSButton IBProjectSource @@ -1984,68 +1577,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA NSObject - - IBProjectSource - PlugInInterface.h - - - - NSObject - - RBSplitView - RBSplitView - - - IBProjectSource - RBSplitView.h - - - - NSObject - - IBUserSource - - - - - RBSplitSubview - NSView - - IBProjectSource - RBSplitSubview.h - - - - RBSplitSubview - - IBProjectSource - RBSplitViewPrivateDefines.h - - - - RBSplitSubview - NSView - - IBUserSource - - - - - RBSplitView - RBSplitSubview - - delegate - id - - - - - RBSplitView - - - - RBSplitView - RBSplitSubview IBUserSource @@ -2104,14 +1635,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA AppKit.framework/Headers/NSUserInterfaceItemSearching.h - - NSBox - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSBox.h - - NSButton NSControl @@ -2551,12 +2074,18 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 0 + IBCocoaFramework com.apple.InterfaceBuilder.CocoaPlugin.macosx YES - ../../MacVim.xcodeproj + ../MacVim.xcodeproj 3 + + {9, 8} + {7, 2} + {15, 15} + diff --git a/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib b/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib index d0b9426f64..6cdc26ee32 100644 Binary files a/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib and b/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib differ diff --git a/src/MacVim/Integration.png b/src/MacVim/Integration.png deleted file mode 100644 index edb2bca56f..0000000000 Binary files a/src/MacVim/Integration.png and /dev/null differ diff --git a/src/MacVim/MMAppController.h b/src/MacVim/MMAppController.h index 1e7870399b..fa507c89d5 100644 --- a/src/MacVim/MMAppController.h +++ b/src/MacVim/MMAppController.h @@ -35,10 +35,6 @@ #if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4) FSEventStreamRef fsEventStream; #endif - -#ifdef MM_ENABLE_PLUGINS - NSMenuItem *plugInMenuItem; -#endif } + (MMAppController *)sharedInstance; @@ -51,12 +47,6 @@ - (NSArray *)filterOpenFiles:(NSArray *)filenames; - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args; - -#ifdef MM_ENABLE_PLUGINS -- (void)addItemToPlugInMenu:(NSMenuItem *)item; -- (void)removeItemFromPlugInMenu:(NSMenuItem *)item; -#endif - - (IBAction)newWindow:(id)sender; - (IBAction)newWindowAndActivate:(id)sender; - (IBAction)fileOpen:(id)sender; diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index 2d93266484..4bb582b0bd 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -42,11 +42,6 @@ #import "MMVimController.h" #import "MMWindowController.h" #import "Miscellaneous.h" - -#ifdef MM_ENABLE_PLUGINS -#import "MMPlugInManager.h" -#endif - #import #import @@ -142,11 +137,6 @@ typedef struct toCommandLine:(NSArray **)cmdline; - (NSString *)workingDirectoryForArguments:(NSDictionary *)args; - (NSScreen *)screenContainingPoint:(NSPoint)pt; - -#ifdef MM_ENABLE_PLUGINS -- (void)removePlugInMenu; -- (void)addPlugInMenuToMenu:(NSMenu *)mainMenu; -#endif @end @@ -216,9 +206,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, @"", MMLoginShellCommandKey, @"", MMLoginShellArgumentKey, [NSNumber numberWithBool:YES], MMDialogsTrackPwdKey, -#ifdef MM_ENABLE_PLUGINS - [NSNumber numberWithBool:YES], MMShowLeftPlugInContainerKey, -#endif [NSNumber numberWithInt:3], MMOpenLayoutKey, [NSNumber numberWithBool:NO], MMVerticalSplitKey, [NSNumber numberWithInt:0], MMPreloadCacheSizeKey, @@ -253,17 +240,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, pidArguments = [NSMutableDictionary new]; inputQueues = [NSMutableDictionary new]; -#ifdef MM_ENABLE_PLUGINS - NSString *plugInTitle = NSLocalizedString(@"Plug-In", - @"Plug-In menu title"); - plugInMenuItem = [[NSMenuItem alloc] initWithTitle:plugInTitle - action:NULL - keyEquivalent:@""]; - NSMenu *submenu = [[NSMenu alloc] initWithTitle:plugInTitle]; - [plugInMenuItem setSubmenu:submenu]; - [submenu release]; -#endif - // NOTE: Do not use the default connection since the Logitech Control // Center (LCC) input manager steals and this would cause MacVim to // never open any windows. (This is a bug in LCC but since they are @@ -298,9 +274,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, [openSelectionString release]; openSelectionString = nil; [recentFilesMenuItem release]; recentFilesMenuItem = nil; [defaultMainMenu release]; defaultMainMenu = nil; -#ifdef MM_ENABLE_PLUGINS - [plugInMenuItem release]; plugInMenuItem = nil; -#endif [appMenuItemTemplate release]; appMenuItemTemplate = nil; [super dealloc]; @@ -399,9 +372,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, - (void)applicationDidFinishLaunching:(NSNotification *)notification { [NSApp setServicesProvider:self]; -#ifdef MM_ENABLE_PLUGINS - [[MMPlugInManager sharedManager] loadAllPlugIns]; -#endif if ([self maxPreloadCacheSize] > 0) { [self scheduleVimControllerPreloadAfterDelay:2]; @@ -633,10 +603,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, [self stopWatchingVimDir]; -#ifdef MM_ENABLE_PLUGINS - [[MMPlugInManager sharedManager] unloadAllPlugIns]; -#endif - #if MM_HANDLE_XCODE_MOD_EVENT [[NSAppleEventManager sharedAppleEventManager] removeEventHandlerForEventClass:'KAHL' @@ -889,12 +855,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, } } [NSApp setWindowsMenu:windowsMenu]; - -#ifdef MM_ENABLE_PLUGINS - // Move plugin menu from old to new main menu. - [self removePlugInMenu]; - [self addPlugInMenuToMenu:mainMenu]; -#endif } - (NSArray *)filterOpenFiles:(NSArray *)filenames @@ -1052,24 +1012,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, return openOk; } -#ifdef MM_ENABLE_PLUGINS -- (void)addItemToPlugInMenu:(NSMenuItem *)item -{ - NSMenu *menu = [plugInMenuItem submenu]; - [menu addItem:item]; - if ([menu numberOfItems] == 1) - [self addPlugInMenuToMenu:[NSApp mainMenu]]; -} - -- (void)removeItemFromPlugInMenu:(NSMenuItem *)item -{ - NSMenu *menu = [plugInMenuItem submenu]; - [menu removeItem:item]; - if ([menu numberOfItems] == 0) - [self removePlugInMenu]; -} -#endif - - (IBAction)newWindow:(id)sender { ASLogDebug(@"Open new window"); @@ -1810,29 +1752,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, return dict; } -#ifdef MM_ENABLE_PLUGINS -- (void)removePlugInMenu -{ - if ([plugInMenuItem menu]) - [[plugInMenuItem menu] removeItem:plugInMenuItem]; -} - -- (void)addPlugInMenuToMenu:(NSMenu *)mainMenu -{ - NSMenu *windowsMenu = [mainMenu findWindowsMenu]; - - if ([[plugInMenuItem submenu] numberOfItems] > 0) { - int idx = windowsMenu ? [mainMenu indexOfItemWithSubmenu:windowsMenu] - : -1; - if (idx > 0) { - [mainMenu insertItem:plugInMenuItem atIndex:idx]; - } else { - [mainMenu addItem:plugInMenuItem]; - } - } -} -#endif - - (void)scheduleVimControllerPreloadAfterDelay:(NSTimeInterval)delay { [self performSelector:@selector(preloadVimController:) diff --git a/src/MacVim/MMAtsuiTextView.h b/src/MacVim/MMAtsuiTextView.h index 7006093c8f..33e9fb41c0 100644 --- a/src/MacVim/MMAtsuiTextView.h +++ b/src/MacVim/MMAtsuiTextView.h @@ -69,6 +69,7 @@ enum { MMMaxCellsPerChar = 2 }; // MMTextView methods // - (void)deleteSign:(NSString *)signName; +- (void)setToolTipAtMousePoint:(NSString *)string; - (void)setPreEditRow:(int)row column:(int)col; - (void)setMouseShape:(int)shape; - (void)setAntialias:(BOOL)state; diff --git a/src/MacVim/MMAtsuiTextView.m b/src/MacVim/MMAtsuiTextView.m index ae7d070bd1..03a836238d 100644 --- a/src/MacVim/MMAtsuiTextView.m +++ b/src/MacVim/MMAtsuiTextView.m @@ -338,6 +338,12 @@ defaultLineHeightForFont(NSFont *font) - (void)deleteSign:(NSString *)signName { + // ONLY in Core Text! +} + +- (void)setToolTipAtMousePoint:(NSString *)string +{ + // ONLY in Core Text! } - (void)setPreEditRow:(int)row column:(int)col @@ -481,32 +487,6 @@ defaultLineHeightForFont(NSFont *font) [helper mouseMoved:event]; } -- (void)mouseEntered:(NSEvent *)event -{ - [helper mouseEntered:event]; -} - -- (void)mouseExited:(NSEvent *)event -{ - [helper mouseExited:event]; -} - -- (void)setFrame:(NSRect)frame -{ - [super setFrame:frame]; - [helper setFrame:frame]; -} - -- (void)viewDidMoveToWindow -{ - [helper viewDidMoveToWindow]; -} - -- (void)viewWillMoveToWindow:(NSWindow *)newWindow -{ - [helper viewWillMoveToWindow:newWindow]; -} - - (NSMenu*)menuForEvent:(NSEvent *)event { // HACK! Return nil to disable default popup menus (Vim provides its own). diff --git a/src/MacVim/MMBackend.h b/src/MacVim/MMBackend.h index 2bf4b070cd..79f6377c86 100644 --- a/src/MacVim/MMBackend.h +++ b/src/MacVim/MMBackend.h @@ -13,6 +13,11 @@ #import "vim.h" +#ifdef FEAT_BEVAL +// Seconds to delay balloon evaluation after mouse event (subtracted from +// p_bdlay). +extern NSTimeInterval MMBalloonEvalInternalDelay; +#endif @interface MMBackend : NSObject x = col; + balloonEval->y = row; + + // Update the balloon eval message after a slight delay (to avoid + // calling it too often). + [NSObject cancelPreviousPerformRequestsWithTarget:self + selector:@selector(bevalCallback:) + object:nil]; + [self performSelector:@selector(bevalCallback:) + withObject:nil + afterDelay:MMBalloonEvalInternalDelay]; + } +#endif } else if (AddInputMsgID == msgid) { NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; @@ -2894,6 +2931,33 @@ static void netbeansReadCallback(CFSocketRef s, } } +#ifdef FEAT_BEVAL +- (void)bevalCallback:(id)sender +{ + if (!(p_beval && balloonEval)) + return; + + if (balloonEval->msgCB != NULL) { + // HACK! We have no way of knowing whether the balloon evaluation + // worked or not, so we keep track of it using a local tool tip + // variable. (The reason we need to know is due to how the Cocoa tool + // tips work: if there is no tool tip we must set it to nil explicitly + // or it might never go away.) + [self setLastToolTip:nil]; + + (*balloonEval->msgCB)(balloonEval, 0); + + [[MMBackend sharedInstance] queueMessage:SetTooltipMsgID properties: + [NSDictionary dictionaryWithObject:(lastToolTip ? lastToolTip : @"") + forKey:@"toolTip"]]; + + // NOTE: We have to explicitly stop the run loop since timer events do + // not cause CFRunLoopRunInMode() to exit. + CFRunLoopStop(CFRunLoopGetCurrent()); + } +} +#endif + @end // MMBackend (Private) diff --git a/src/MacVim/MMCoreTextView+ToolTip.m b/src/MacVim/MMCoreTextView+ToolTip.m new file mode 100644 index 0000000000..83fd12abb1 --- /dev/null +++ b/src/MacVim/MMCoreTextView+ToolTip.m @@ -0,0 +1,230 @@ +/* vi:set ts=8 sts=4 sw=4 ft=objc: + * + * VIM - Vi IMproved by Bram Moolenaar + * MacVim GUI port by Bjorn Winckler + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + * See README.txt for an overview of the Vim source code. + */ +/* + * MMCoreTextView+ToolTip + * + * Cocoa's tool tip interface does not allow changing the tool tip without the + * user moving the mouse outside the view and then back again. This category + * takes care of this problem. + * + * The tool tip code was borrowed from the Chromium project which in turn had + * borrowed it from WebKit (copyright and comments are below). Some minor + * changes were made to adapt the code to MacVim. + */ + +#import "MMCoreTextView.h" + + +// Below is the nasty tooltip stuff -- copied from WebKit's WebHTMLView.mm +// with minor modifications for code style and commenting. +// +// The 'public' interface is -setToolTipAtMousePoint:. This differs from +// -setToolTip: in that the updated tooltip takes effect immediately, +// without the user's having to move the mouse out of and back into the view. +// +// Unfortunately, doing this requires sending fake mouseEnter/Exit events to +// the view, which in turn requires overriding some internal tracking-rect +// methods (to keep track of its owner & userdata, which need to be filled out +// in the fake events.) --snej 7/6/09 + + +/* + * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * (C) 2006, 2007 Graham Dennis (graham.dennis@gmail.com) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Any non-zero value will do, but using something recognizable might help us +// debug some day. +static const NSTrackingRectTag kTrackingRectTag = 0xBADFACE; + + +@implementation MMCoreTextView (ToolTip) + +// Override of a public NSView method, replacing the inherited functionality. +// See above for rationale. +- (NSTrackingRectTag)addTrackingRect:(NSRect)rect + owner:(id)owner + userData:(void *)data + assumeInside:(BOOL)assumeInside +{ + //DCHECK(trackingRectOwner_ == nil); + trackingRectOwner_ = owner; + trackingRectUserData_ = data; + return kTrackingRectTag; +} + +// Override of (apparently) a private NSView method(!) See above for rationale. +- (NSTrackingRectTag)_addTrackingRect:(NSRect)rect + owner:(id)owner + userData:(void *)data + assumeInside:(BOOL)assumeInside + useTrackingNum:(int)tag +{ + //DCHECK(tag == 0 || tag == kTrackingRectTag); + //DCHECK(trackingRectOwner_ == nil); + trackingRectOwner_ = owner; + trackingRectUserData_ = data; + return kTrackingRectTag; +} + +// Override of (apparently) a private NSView method(!) See above for rationale. +- (void)_addTrackingRects:(NSRect *)rects + owner:(id)owner + userDataList:(void **)userDataList + assumeInsideList:(BOOL *)assumeInsideList + trackingNums:(NSTrackingRectTag *)trackingNums + count:(int)count +{ + //DCHECK(count == 1); + //DCHECK(trackingNums[0] == 0 || trackingNums[0] == kTrackingRectTag); + //DCHECK(trackingRectOwner_ == nil); + trackingRectOwner_ = owner; + trackingRectUserData_ = userDataList[0]; + trackingNums[0] = kTrackingRectTag; +} + +// Override of a public NSView method, replacing the inherited functionality. +// See above for rationale. +- (void)removeTrackingRect:(NSTrackingRectTag)tag +{ + if (tag == 0) + return; + + if (tag == kTrackingRectTag) { + trackingRectOwner_ = nil; + return; + } + + if (tag == lastToolTipTag_) { + [super removeTrackingRect:tag]; + lastToolTipTag_ = 0; + return; + } + + // If any other tracking rect is being removed, we don't know how it was + // created and it's possible there's a leak involved (see Radar 3500217). + //NOTREACHED(); +} + +// Override of (apparently) a private NSView method(!) +- (void)_removeTrackingRects:(NSTrackingRectTag *)tags count:(int)count +{ + int i; + for (i = 0; i < count; ++i) { + int tag = tags[i]; + if (tag == 0) + continue; + //DCHECK(tag == kTrackingRectTag); + trackingRectOwner_ = nil; + } +} + +// Sends a fake NSMouseExited event to the view for its current tracking rect. +- (void)_sendToolTipMouseExited +{ + // Nothing matters except window, trackingNumber, and userData. + int windowNumber = [[self window] windowNumber]; + NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseExited + location:NSMakePoint(0, 0) + modifierFlags:0 + timestamp:0 + windowNumber:windowNumber + context:NULL + eventNumber:0 + trackingNumber:kTrackingRectTag + userData:trackingRectUserData_]; + [trackingRectOwner_ mouseExited:fakeEvent]; +} + +// Sends a fake NSMouseEntered event to the view for its current tracking rect. +- (void)_sendToolTipMouseEntered +{ + // Nothing matters except window, trackingNumber, and userData. + int windowNumber = [[self window] windowNumber]; + NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseEntered + location:NSMakePoint(0, 0) + modifierFlags:0 + timestamp:0 + windowNumber:windowNumber + context:NULL + eventNumber:0 + trackingNumber:kTrackingRectTag + userData:trackingRectUserData_]; + [trackingRectOwner_ mouseEntered:fakeEvent]; +} + +// Sets the view's current tooltip, to be displayed at the current mouse +// location. (This does not make the tooltip appear -- as usual, it only +// appears after a delay.) Pass null to remove the tooltip. +- (void)setToolTipAtMousePoint:(NSString *)string +{ + // If the mouse is outside the view, then clear the tooltip (otherwise the + // tooltip may appear outside the view which looks weird!). + NSPoint pt = [[self window] mouseLocationOutsideOfEventStream]; + if (!NSMouseInRect([self convertPoint:pt fromView:nil], [self frame], NO)) + string = nil; + + NSString *toolTip = [string length] == 0 ? nil : string; + NSString *oldToolTip = toolTip_; + if ((toolTip == nil || oldToolTip == nil) ? toolTip == oldToolTip + : [toolTip isEqualToString:oldToolTip]) { + return; + } + if (oldToolTip) { + [self _sendToolTipMouseExited]; + [oldToolTip release]; + } + toolTip_ = [toolTip copy]; + if (toolTip) { + // See radar 3500217 for why we remove all tooltips + // rather than just the single one we created. + [self removeAllToolTips]; + NSRect wideOpenRect = NSMakeRect(-100000, -100000, 200000, 200000); + lastToolTipTag_ = [self addToolTipRect:wideOpenRect + owner:self + userData:NULL]; + [self _sendToolTipMouseEntered]; + } +} + +// NSView calls this to get the text when displaying the tooltip. +- (NSString *)view:(NSView *)view + stringForToolTip:(NSToolTipTag)tag + point:(NSPoint)point + userData:(void *)data +{ + return [[toolTip_ copy] autorelease]; +} + +@end diff --git a/src/MacVim/MMCoreTextView.h b/src/MacVim/MMCoreTextView.h index 1254e86d13..4db048e4f3 100644 --- a/src/MacVim/MMCoreTextView.h +++ b/src/MacVim/MMCoreTextView.h @@ -38,6 +38,12 @@ unsigned maxlen; CGGlyph *glyphs; CGSize *advances; + + // These are used in MMCoreTextView+ToolTip.m + id trackingRectOwner_; // (not retained) + void *trackingRectUserData_; + NSTrackingRectTag lastToolTipTag_; + NSString* toolTip_; } - (id)initWithFrame:(NSRect)frame; @@ -97,7 +103,14 @@ - (NSSize)desiredSize; - (NSSize)minSize; - (NSSize)constrainRows:(int *)rows columns:(int *)cols toSize:(NSSize)size; +@end + +// +// This category is defined in MMCoreTextView+ToolTip.m +// +@interface MMCoreTextView (ToolTip) +- (void)setToolTipAtMousePoint:(NSString *)string; @end #endif // !MM_ENABLE_ATSUI diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 853eb807be..40f7a115fc 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -519,32 +519,6 @@ defaultAdvanceForFont(CTFontRef fontRef) [helper mouseMoved:event]; } -- (void)mouseEntered:(NSEvent *)event -{ - [helper mouseEntered:event]; -} - -- (void)mouseExited:(NSEvent *)event -{ - [helper mouseExited:event]; -} - -- (void)setFrame:(NSRect)frame -{ - [super setFrame:frame]; - [helper setFrame:frame]; -} - -- (void)viewDidMoveToWindow -{ - [helper viewDidMoveToWindow]; -} - -- (void)viewWillMoveToWindow:(NSWindow *)newWindow -{ - [helper viewWillMoveToWindow:newWindow]; -} - - (NSMenu*)menuForEvent:(NSEvent *)event { // HACK! Return nil to disable default popup menus (Vim provides its own). @@ -592,9 +566,6 @@ defaultAdvanceForFont(CTFontRef fontRef) - (void)drawRect:(NSRect)rect { - //ASLogTmp(@"count=%d rect=%@", [drawData count], - // NSStringFromRect(rect)); - NSGraphicsContext *context = [NSGraphicsContext currentContext]; [context setShouldAntialias:antialias]; diff --git a/src/MacVim/MMFullscreenWindow.m b/src/MacVim/MMFullscreenWindow.m index 21f9fb8f66..9480f5f8fe 100644 --- a/src/MacVim/MMFullscreenWindow.m +++ b/src/MacVim/MMFullscreenWindow.m @@ -89,6 +89,9 @@ name:NSWindowDidResignMainNotification object:self]; + // NOTE: Vim needs to process mouse moved events, so enable them here. + [self setAcceptsMouseMovedEvents:YES]; + return self; } diff --git a/src/MacVim/MMPlugInManager.h b/src/MacVim/MMPlugInManager.h deleted file mode 100644 index 03008556cc..0000000000 --- a/src/MacVim/MMPlugInManager.h +++ /dev/null @@ -1,31 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: - * - * VIM - Vi IMproved by Bram Moolenaar - * MacVim GUI port by Bjorn Winckler - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -#import -#import "MMVimController.h" - - -@interface MMPlugInManager : NSObject { - - NSMutableArray *plugInClasses; -} - -- (NSArray *)plugInClasses; - -// Find and load any plugins -- (void)loadAllPlugIns; - -// release instances of loaded plugins -- (void)unloadAllPlugIns; - -// Return singleton instance of MMPluginManager -+ (MMPlugInManager *)sharedManager; - -@end diff --git a/src/MacVim/MMPlugInManager.m b/src/MacVim/MMPlugInManager.m deleted file mode 100644 index 9707d364e4..0000000000 --- a/src/MacVim/MMPlugInManager.m +++ /dev/null @@ -1,151 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: - * - * VIM - Vi IMproved by Bram Moolenaar - * MacVim GUI port by Bjorn Winckler - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -/* - * MMPlugInManager - * - * This class is responsible for finding MacVim plugins at startup, loading - * them, and keeping track of them. - * - * Author: Matt Tolton - */ - -#import "MacVim.h" - -#ifdef MM_ENABLE_PLUGINS - -#import "MMPlugInManager.h" -#import "PlugInInterface.h" -#import "PlugInImpl.h" - -@implementation MMPlugInManager - -static NSString *ext = @"mmplugin"; - -static NSString *appSupportSubpath = @"Application Support/MacVim/PlugIns"; - -static MMPlugInManager *plugInManager = nil; - -+ (MMPlugInManager*)sharedManager -{ - if (!plugInManager) - plugInManager = [[MMPlugInManager alloc] init]; - - return plugInManager; -} - -- (id)init -{ - if ((self = [super init]) == nil) return nil; - plugInClasses = [[NSMutableArray alloc] init]; - return self; -} - -- (void)dealloc -{ - ASLogDebug(@""); - - [plugInClasses release]; plugInClasses = nil; - [super dealloc]; -} - -- (NSArray *)plugInClasses; -{ - return plugInClasses; -} - -- (NSMutableArray *)allBundles -{ - NSArray *librarySearchPaths; - NSEnumerator *searchPathEnum; - NSString *currPath; - NSMutableArray *bundleSearchPaths = [NSMutableArray array]; - NSMutableArray *allBundles = [NSMutableArray array]; - - librarySearchPaths = NSSearchPathForDirectoriesInDomains( - NSLibraryDirectory, NSAllDomainsMask - NSSystemDomainMask, YES); - - searchPathEnum = [librarySearchPaths objectEnumerator]; - while(currPath = [searchPathEnum nextObject]) { - [bundleSearchPaths addObject: - [currPath stringByAppendingPathComponent:appSupportSubpath]]; - } - - [bundleSearchPaths addObject: - [[NSBundle mainBundle] builtInPlugInsPath]]; - - searchPathEnum = [bundleSearchPaths objectEnumerator]; - while(currPath = [searchPathEnum nextObject]) { - NSDirectoryEnumerator *bundleEnum; - NSString *currBundlePath; - bundleEnum = [[NSFileManager defaultManager] - enumeratorAtPath:currPath]; - if(bundleEnum) { - while(currBundlePath = [bundleEnum nextObject]) { - if([[currBundlePath pathExtension] isEqualToString:ext]) { - [allBundles addObject:[currPath - stringByAppendingPathComponent:currBundlePath]]; - } - } - } - } - - return allBundles; -} - -- (BOOL)plugInClassIsValid:(Class)class -{ - return [class conformsToProtocol:@protocol(PlugInProtocol)]; -} - -- (void)loadAllPlugIns -{ - NSMutableArray *bundlePaths; - NSEnumerator *pathEnum; - NSString *currPath; - NSBundle *currBundle; - Class currPrincipalClass; - - bundlePaths = [NSMutableArray array]; - - [bundlePaths addObjectsFromArray:[self allBundles]]; - - pathEnum = [bundlePaths objectEnumerator]; - while(currPath = [pathEnum nextObject]) { - currBundle = [NSBundle bundleWithPath:currPath]; - if(currBundle) { - currPrincipalClass = [currBundle principalClass]; - if(currPrincipalClass && [self plugInClassIsValid:currPrincipalClass]) { - if ([currPrincipalClass initializePlugIn: - [MMPlugInAppMediator sharedAppMediator]]) { - ASLogInfo(@"Plug-in initialized: %@", currPath); - [plugInClasses addObject:currPrincipalClass]; - } else { - ASLogErr(@"Plug-in failed to initialize: %@", currPath); - } - } else { - ASLogErr(@"Plug-in did not conform to protocol: %@", currPath); - } - } - } -} - -- (void)unloadAllPlugIns -{ - int i, count = [plugInClasses count]; - for (i = 0; i < count; i++) - [[plugInClasses objectAtIndex:i] terminatePlugIn]; - - [plugInClasses removeAllObjects]; -} - -@end - -#endif diff --git a/src/MacVim/MMPreferenceController.h b/src/MacVim/MMPreferenceController.h index d9f65dcdc7..c2af1a93c1 100644 --- a/src/MacVim/MMPreferenceController.h +++ b/src/MacVim/MMPreferenceController.h @@ -12,27 +12,14 @@ #import @interface MMPreferenceController : DBPrefsWindowController { - IBOutlet NSView *generalPreferences; - IBOutlet NSView *integrationPreferences; IBOutlet NSView *advancedPreferences; // General pane IBOutlet NSPopUpButton *layoutPopUpButton; - - // Integration pane - NSDictionary *supportedOdbEditors; - IBOutlet NSPopUpButton *editors; - IBOutlet NSButton *installOdbButton; - IBOutlet NSButton *uninstallOdbButton; - IBOutlet NSTextField* obdBundleVersionLabel; } // General pane - (IBAction)openInCurrentWindowSelectionChanged:(id)sender; -// Integration pane -- (IBAction)installOdb:(id)sender; -- (IBAction)uninstallOdb:(id)sender; - @end diff --git a/src/MacVim/MMPreferenceController.m b/src/MacVim/MMPreferenceController.m index a50184bcec..bcf7a6f0a7 100644 --- a/src/MacVim/MMPreferenceController.m +++ b/src/MacVim/MMPreferenceController.m @@ -8,7 +8,6 @@ * See README.txt for an overview of the Vim source code. */ -#import "AuthorizedShellCommand.h" #import "MMPreferenceController.h" #import "Miscellaneous.h" @@ -26,9 +25,11 @@ #import + NSString* nsImageNamePreferencesGeneral = nil; NSString* nsImageNamePreferencesAdvanced = nil; + static void loadSymbols() { // use dlfcn() instead of the deprecated NSModule api. @@ -40,120 +41,8 @@ static void loadSymbols() } -// The compiler on OS X 10.4 balks at using CFSTR() for globals so we get -// around with this some ugly type casting. -static CFStringRef ODBEDITOR = (CFStringRef)@"org.slashpunt.edit_in_odbeditor"; -static CFStringRef ODB_BUNDLE_IDENTIFIER = - (CFStringRef)@"ODBEditorBundleIdentifier"; -static CFStringRef ODB_EDITOR_NAME = (CFStringRef)@"ODBEditorName"; -static NSString *ODBEDITOR_DIR = - @"/Library/InputManagers/Edit in ODBEditor"; -static NSString *ODBEDITOR_PATH = - @"/Library/InputManagers/Edit in ODBEditor/Edit in ODBEditor.bundle"; - - -NSString *kOdbEditorNameNone = @"(None)"; -NSString *kOdbEditorIdentifierNone = @""; - -NSString *kOdbEditorNameBBEdit = @"BBEdit"; -NSString *kOdbEditorIdentifierBBEdit = @"com.barebones.bbedit"; - -NSString *kOdbEditorNameCSSEdit = @"CSSEdit"; -NSString *kOdbEditorIdentifierCSSEdit = @"com.macrabbit.cssedit"; - -NSString *kOdbEditorNameMacVim = @"MacVim"; -NSString *kOdbEditorIdentifierMacVim = @"org.vim.MacVim"; - -NSString *kOdbEditorNameSmultron = @"Smultron"; -NSString *kOdbEditorIdentifierSmultron = @"org.smultron.Smultron"; - -NSString *kOdbEditorNameSubEthaEdit = @"SubEthaEdit"; -NSString *kOdbEditorIdentifierSubEthaEdit = @"de.codingmonkeys.SubEthaEdit"; - -NSString *kOdbEditorNameTextMate = @"TextMate"; -NSString *kOdbEditorIdentifierTextMate = @"com.macromates.textmate"; - -NSString *kOdbEditorNameTextWrangler = @"TextWrangler"; -NSString *kOdbEditorIdentifierTextWrangler = @"com.barebones.textwrangler"; - -NSString *kOdbEditorNameWriteRoom = @"WriteRoom"; -NSString *kOdbEditorIdentifierWriteRoom = @"com.hogbaysoftware.WriteRoom"; - - -@interface MMPreferenceController (Private) -// Integration pane -- (void)updateIntegrationPane; -- (void)setOdbEditorByName:(NSString *)name; -- (NSString *)odbEditorBundleIdentifier; -- (NSString *)odbBundleSourceDir; -- (NSString *)versionOfBundle:(NSString *)bundlePath; -- (NSString *)odbBundleInstalledVersion; -- (NSString *)odbBundleInstallVersion; -@end - @implementation MMPreferenceController -- (id)initWithWindow:(NSWindow *)window -{ - self = [super initWithWindow:window]; - if (self == nil) - return nil; - // taken from Cyberduck. Thanks :-) - supportedOdbEditors = [[NSDictionary alloc] initWithObjectsAndKeys: - kOdbEditorIdentifierNone, kOdbEditorNameNone, - kOdbEditorIdentifierBBEdit, kOdbEditorNameBBEdit, - kOdbEditorIdentifierCSSEdit, kOdbEditorNameCSSEdit, - kOdbEditorIdentifierMacVim, kOdbEditorNameMacVim, - kOdbEditorIdentifierSmultron, kOdbEditorNameSmultron, - kOdbEditorIdentifierSubEthaEdit, kOdbEditorNameSubEthaEdit, - kOdbEditorIdentifierTextMate, kOdbEditorNameTextMate, - kOdbEditorIdentifierTextWrangler, kOdbEditorNameTextWrangler, - kOdbEditorIdentifierWriteRoom, kOdbEditorNameWriteRoom, - nil]; - return self; -} - -- (void)dealloc -{ - ASLogDebug(@""); - - [supportedOdbEditors release]; supportedOdbEditors = nil; - [super dealloc]; -} - -- (void)awakeFromNib -{ - // fill list of editors in integration pane - NSArray *keys = [[supportedOdbEditors allKeys] - sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; - NSMenu *editorsMenu = [editors menu]; - NSEnumerator *enumerator = [keys objectEnumerator]; - NSString *key; - while ((key = [enumerator nextObject]) != nil) { - NSString *identifier = [supportedOdbEditors objectForKey:key]; - - NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:key - action:@selector(odbEditorChanged:) - keyEquivalent:@""]; - [item setTarget:self]; - if (![identifier isEqualToString:kOdbEditorIdentifierNone]) { - NSString *appPath = [[NSWorkspace sharedWorkspace] - absolutePathForAppBundleWithIdentifier:identifier]; - [item setEnabled:appPath != nil]; - if (appPath != nil) { - NSImage *icon = [[NSWorkspace sharedWorkspace] - iconForFile:appPath]; - [icon setSize:NSMakeSize(16, 16)]; // XXX: make res independent - [item setImage:icon]; - } - } - [editorsMenu addItem:item]; - [item release]; - } - - [self updateIntegrationPane]; -} - - (void)setupToolbar { loadSymbols(); @@ -166,8 +55,6 @@ NSString *kOdbEditorIdentifierWriteRoom = @"com.hogbaysoftware.WriteRoom"; [self addView:generalPreferences label:@"General"]; } - [self addView:integrationPreferences label:@"Integration"]; - if (nsImageNamePreferencesAdvanced != NULL) { [self addView:advancedPreferences label:@"Advanced" @@ -194,20 +81,6 @@ NSString *kOdbEditorIdentifierWriteRoom = @"com.hogbaysoftware.WriteRoom"; } -- (BOOL)validateMenuItem:(NSMenuItem *)item -{ - if ([item action] == @selector(odbEditorChanged:)) { - NSString *identifier = [supportedOdbEditors objectForKey:[item title]]; - if (identifier == nil) - return NO; - if ([identifier isEqualToString:kOdbEditorIdentifierNone]) - return YES; - return [[NSWorkspace sharedWorkspace] - absolutePathForAppBundleWithIdentifier:identifier] != nil; - } - return YES; -} - - (IBAction)openInCurrentWindowSelectionChanged:(id)sender { BOOL openInCurrentWindowSelected = ([[sender selectedCell] tag] != 0); @@ -217,197 +90,4 @@ NSString *kOdbEditorIdentifierWriteRoom = @"com.hogbaysoftware.WriteRoom"; [layoutPopUpButton selectItemWithTag:MMLayoutTabs]; } -#pragma mark - -#pragma mark Integration pane - -- (void)updateIntegrationPane -{ - // XXX: check validation api. - // XXX: call this each time the dialog becomes active (so that if the - // user changes settings in terminal, the changes are reflected in the - // dialog) - - NSString *versionString = @""; - - // Check if ODB path exists before calling isFilePackageAtPath: otherwise - // an error is output to stderr on Tiger. - BOOL odbIsInstalled = - [[NSFileManager defaultManager] fileExistsAtPath:ODBEDITOR_PATH] - && [[NSWorkspace sharedWorkspace] isFilePackageAtPath:ODBEDITOR_PATH]; - - // enable/disable buttons - [installOdbButton setTitle:@"Install"]; - if (odbIsInstalled) { - [uninstallOdbButton setEnabled:YES]; - [editors setEnabled:YES]; - - NSString *installVersion = [self odbBundleInstallVersion]; - NSString *installedVersion = [self odbBundleInstalledVersion]; - switch ([installedVersion compare:installVersion - options:NSNumericSearch]) { - case NSOrderedAscending: - versionString = [NSString stringWithFormat: - @"Latest version is %@, you have %@.", - installVersion, installedVersion]; - [installOdbButton setTitle:@"Update"]; - [installOdbButton setEnabled:YES]; - break; - case NSOrderedSame: - versionString = [NSString stringWithFormat: - @"Latest version is %@. You have the latest version.", - installVersion]; - [installOdbButton setEnabled:NO]; - break; - case NSOrderedDescending: - versionString = [NSString stringWithFormat: - @"Latest version is %@, you have %@.", - installVersion, installedVersion]; - [installOdbButton setEnabled:NO]; - break; - } - } else { - [installOdbButton setEnabled:YES]; - [uninstallOdbButton setEnabled:NO]; - [editors setEnabled:NO]; - - versionString = [NSString - stringWithFormat:@"Latest version is %@. It is not installed.", - [self odbBundleInstallVersion]]; - } - - [obdBundleVersionLabel setStringValue:versionString]; - - // make sure the right editor is selected on the popup button - NSString *selectedTitle = kOdbEditorNameNone; - NSArray* keys = [supportedOdbEditors - allKeysForObject:[self odbEditorBundleIdentifier]]; - if ([keys count] > 0) - selectedTitle = [keys objectAtIndex:0]; - [editors selectItemWithTitle:selectedTitle]; -} - -- (void)setOdbEditorByName:(NSString *)name -{ - NSString *identifier = [supportedOdbEditors objectForKey:name]; - if (identifier != kOdbEditorIdentifierNone) { - CFPreferencesSetAppValue(ODB_BUNDLE_IDENTIFIER, identifier, ODBEDITOR); - CFPreferencesSetAppValue(ODB_EDITOR_NAME, name, ODBEDITOR); - } else { - CFPreferencesSetAppValue(ODB_BUNDLE_IDENTIFIER, NULL, ODBEDITOR); - CFPreferencesSetAppValue(ODB_EDITOR_NAME, NULL, ODBEDITOR); - } - CFPreferencesAppSynchronize(ODBEDITOR); -} - -// Note that you can't compare the result of this function with ==, you have -// to use isStringEqual: (since this returns a new copy of the string). -- (NSString *)odbEditorBundleIdentifier -{ - // reading the defaults of a different app is easier with carbon - NSString *bundleIdentifier = (NSString*)CFPreferencesCopyAppValue( - ODB_BUNDLE_IDENTIFIER, ODBEDITOR); - if (bundleIdentifier == nil) - return kOdbEditorIdentifierNone; - return [bundleIdentifier autorelease]; -} - -- (void)odbEditorChanged:(id)sender -{ - [self setOdbEditorByName:[sender title]]; -} - -- (NSString *)odbBundleSourceDir -{ - return [[[NSBundle mainBundle] resourcePath] - stringByAppendingString:@"/Edit in ODBEditor"]; -} - -// Returns the CFBundleVersion of a bundle. This assumes a bundle exists -// at bundlePath. -- (NSString *)versionOfBundle:(NSString *)bundlePath -{ - // -[NSBundle initWithPath:] caches a bundle, so if the bundle is replaced - // with a new bundle on disk, we get the old version. So we can't use it :-( - - NSString *infoPath = [bundlePath - stringByAppendingString:@"/Contents/Info.plist"]; - NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:infoPath]; - return [info objectForKey:@"CFBundleVersion"]; -} - -- (NSString *)odbBundleInstalledVersion -{ - return [self versionOfBundle:ODBEDITOR_PATH]; -} - -- (NSString *)odbBundleInstallVersion -{ - return [self versionOfBundle:[[self odbBundleSourceDir] - stringByAppendingString:@"/Edit in ODBEditor.bundle"]]; -} - -- (IBAction)installOdb:(id)sender -{ - NSString *source = [self odbBundleSourceDir]; - - // It doesn't hurt to rm -rf the InputManager even if it's not there, - // the code is simpler that way. - NSArray *cmd = [NSArray arrayWithObjects: - [NSDictionary dictionaryWithObjectsAndKeys: - @"/bin/rm", MMCommand, - [NSArray arrayWithObjects:@"-rf", ODBEDITOR_DIR, nil], MMArguments, - nil], - [NSDictionary dictionaryWithObjectsAndKeys: - @"/bin/mkdir", MMCommand, - [NSArray arrayWithObjects:@"-p", ODBEDITOR_DIR, nil], MMArguments, - nil], - [NSDictionary dictionaryWithObjectsAndKeys: - @"/bin/cp", MMCommand, - [NSArray arrayWithObjects: @"-R", - source, @"/Library/InputManagers", nil], MMArguments, - nil], - [NSDictionary dictionaryWithObjectsAndKeys: - @"/usr/sbin/chown", MMCommand, - [NSArray arrayWithObjects: @"-R", - @"root:admin", @"/Library/InputManagers", nil], MMArguments, - nil], - nil - ]; - - AuthorizedShellCommand *au = [[AuthorizedShellCommand alloc] - initWithCommands:cmd]; - OSStatus err = [au run]; - if (err == errAuthorizationSuccess) { - // If the user just installed the input manager and no editor was - // selected before, chances are he wants to use MacVim as editor - if ([[self odbEditorBundleIdentifier] - isEqualToString:kOdbEditorIdentifierNone]) { - [self setOdbEditorByName:kOdbEditorNameMacVim]; - } - } else { - ASLogErr(@"Failed to install input manager, error is %d", err); - } - [au release]; - - [self updateIntegrationPane]; -} - -- (IBAction)uninstallOdb:(id)sender -{ - NSArray *cmd = [NSArray arrayWithObject: - [NSDictionary dictionaryWithObjectsAndKeys: - @"/bin/rm", MMCommand, - [NSArray arrayWithObjects: @"-rf", ODBEDITOR_DIR, nil], MMArguments, - nil]]; - - AuthorizedShellCommand *au = [[AuthorizedShellCommand alloc] - initWithCommands:cmd]; - OSStatus err = [au run]; - if (err != errAuthorizationSuccess) - ASLogErr(@"Failed to uninstall input manager, error is %d", err); - [au release]; - - [self updateIntegrationPane]; -} - @end diff --git a/src/MacVim/MMTextView.h b/src/MacVim/MMTextView.h index 65cbfd9397..b931827fa2 100644 --- a/src/MacVim/MMTextView.h +++ b/src/MacVim/MMTextView.h @@ -64,5 +64,7 @@ - (NSRect)rectForRow:(int)row column:(int)col numRows:(int)nr numColumns:(int)nc; +// NOT IMPLEMENTED (only in Core Text renderer) - (void)deleteSign:(NSString *)signName; +- (void)setToolTipAtMousePoint:(NSString *)string; @end diff --git a/src/MacVim/MMTextView.m b/src/MacVim/MMTextView.m index e96c5478de..9ace565495 100644 --- a/src/MacVim/MMTextView.m +++ b/src/MacVim/MMTextView.m @@ -494,6 +494,12 @@ - (void)deleteSign:(NSString *)signName { + // ONLY in Core Text! +} + +- (void)setToolTipAtMousePoint:(NSString *)string +{ + // ONLY in Core Text! } - (BOOL)isOpaque @@ -764,32 +770,6 @@ [helper mouseMoved:event]; } -- (void)mouseEntered:(NSEvent *)event -{ - [helper mouseEntered:event]; -} - -- (void)mouseExited:(NSEvent *)event -{ - [helper mouseExited:event]; -} - -- (void)setFrame:(NSRect)frame -{ - [super setFrame:frame]; - [helper setFrame:frame]; -} - -- (void)viewDidMoveToWindow -{ - [helper viewDidMoveToWindow]; -} - -- (void)viewWillMoveToWindow:(NSWindow *)newWindow -{ - [helper viewWillMoveToWindow:newWindow]; -} - - (NSMenu*)menuForEvent:(NSEvent *)event { // HACK! Return nil to disable NSTextView's popup menus (Vim provides its diff --git a/src/MacVim/MMTextViewHelper.h b/src/MacVim/MMTextViewHelper.h index 61090e5bdc..8f2b1012fa 100644 --- a/src/MacVim/MMTextViewHelper.h +++ b/src/MacVim/MMTextViewHelper.h @@ -40,7 +40,6 @@ enum { NSPoint dragPoint; BOOL isAutoscrolling; int mouseShape; - NSTrackingRectTag trackingRectTag; NSColor *insertionPointColor; BOOL interpretKeyEventsSwallowedKey; NSEvent *currentEvent; @@ -75,11 +74,6 @@ enum { - (void)mouseUp:(NSEvent *)event; - (void)mouseDragged:(NSEvent *)event; - (void)mouseMoved:(NSEvent *)event; -- (void)mouseEntered:(NSEvent *)event; -- (void)mouseExited:(NSEvent *)event; -- (void)setFrame:(NSRect)frame; -- (void)viewDidMoveToWindow; -- (void)viewWillMoveToWindow:(NSWindow *)newWindow; - (BOOL)performDragOperation:(id )sender; - (NSDragOperation)draggingEntered:(id )sender; - (NSDragOperation)draggingUpdated:(id )sender; diff --git a/src/MacVim/MMTextViewHelper.m b/src/MacVim/MMTextViewHelper.m index 630a50f333..87a155ca50 100644 --- a/src/MacVim/MMTextViewHelper.m +++ b/src/MacVim/MMTextViewHelper.m @@ -458,79 +458,12 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) if (![textView convertPoint:pt toRow:&row column:&col]) return; - // HACK! It seems impossible to get the tracking rects set up before the - // view is visible, which means that the first mouseEntered: or - // mouseExited: events are never received. This forces us to check if the - // mouseMoved: event really happened over the text. - int rows, cols; - [textView getMaxRows:&rows columns:&cols]; - if (row >= 0 && row < rows && col >= 0 && col < cols) { - NSMutableData *data = [NSMutableData data]; + NSMutableData *data = [NSMutableData data]; - [data appendBytes:&row length:sizeof(int)]; - [data appendBytes:&col length:sizeof(int)]; + [data appendBytes:&row length:sizeof(int)]; + [data appendBytes:&col length:sizeof(int)]; - [[self vimController] sendMessage:MouseMovedMsgID data:data]; - } -} - -- (void)mouseEntered:(NSEvent *)event -{ - // NOTE: This event is received even when the window is not key; thus we - // have to take care not to enable mouse moved events unless our window is - // key. - if ([[textView window] isKeyWindow]) { - [[textView window] setAcceptsMouseMovedEvents:YES]; - } -} - -- (void)mouseExited:(NSEvent *)event -{ - [[textView window] setAcceptsMouseMovedEvents:NO]; - - // NOTE: This event is received even when the window is not key; if the - // mouse shape is set when our window is not key, the hollow (unfocused) - // cursor will become a block (focused) cursor. - if ([[textView window] isKeyWindow]) { - int shape = 0; - NSMutableData *data = [NSMutableData data]; - [data appendBytes:&shape length:sizeof(int)]; - [[self vimController] sendMessage:SetMouseShapeMsgID data:data]; - } -} - -- (void)setFrame:(NSRect)frame -{ - // When the frame changes we also need to update the tracking rect. - [textView removeTrackingRect:trackingRectTag]; - trackingRectTag = [textView addTrackingRect:[self trackingRect] - owner:textView - userData:NULL - assumeInside:YES]; -} - -- (void)viewDidMoveToWindow -{ - // Set a tracking rect which covers the text. - // NOTE: While the mouse cursor is in this rect the view will receive - // 'mouseMoved:' events so that Vim can take care of updating the mouse - // cursor. - if ([textView window]) { - [[textView window] setAcceptsMouseMovedEvents:YES]; - trackingRectTag = [textView addTrackingRect:[self trackingRect] - owner:textView - userData:NULL - assumeInside:YES]; - } -} - -- (void)viewWillMoveToWindow:(NSWindow *)newWindow -{ - // Remove tracking rect if view moves or is removed. - if ([textView window] && trackingRectTag) { - [textView removeTrackingRect:trackingRectTag]; - trackingRectTag = 0; - } + [[self vimController] sendMessage:MouseMovedMsgID data:data]; } - (BOOL)performDragOperation:(id )sender diff --git a/src/MacVim/MMVimController.h b/src/MacVim/MMVimController.h index 982d2d2ae8..b9fbaac0c5 100644 --- a/src/MacVim/MMVimController.h +++ b/src/MacVim/MMVimController.h @@ -10,10 +10,6 @@ #import "MacVim.h" -#ifdef MM_ENABLE_PLUGINS -#import "PlugInImpl.h" -#endif - @class MMWindowController; @@ -36,9 +32,6 @@ int pid; NSString *serverName; NSDictionary *vimState; -#ifdef MM_ENABLE_PLUGINS - MMPlugInInstanceMediator *instanceMediator; -#endif BOOL isPreloading; NSDate *creationDate; } @@ -70,7 +63,4 @@ - (id)evaluateVimExpressionCocoa:(NSString *)expr errorString:(NSString **)errstr; - (void)processInputQueue:(NSArray *)queue; -#ifdef MM_ENABLE_PLUGINS -- (MMPlugInInstanceMediator *)instanceMediator; -#endif @end diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index d300cd7d90..373fb63eee 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -33,10 +33,8 @@ #import "MMVimView.h" #import "MMWindowController.h" #import "Miscellaneous.h" +#import "MMCoreTextView.h" -#ifdef MM_ENABLE_PLUGINS -#import "MMPlugInManager.h" -#endif static NSString *MMDefaultToolbarImageName = @"Attention"; static int MMAlertTextFieldHeight = 22; @@ -56,6 +54,16 @@ static unsigned identifierCounter = 1; static BOOL isUnsafeMessage(int msgid); +// HACK! AppKit private methods from NSToolTipManager. As an alternative to +// using private methods, it would be possible to set the user default +// NSInitialToolTipDelay (in ms) on app startup, but then it is impossible to +// change the balloon delay without closing/reopening a window. +@interface NSObject (NSToolTipManagerPrivateAPI) ++ (id)sharedToolTipManager; +- (void)setInitialToolTipDelay:(double)arg1; +@end + + @interface MMAlert : NSAlert { NSTextField *textField; } @@ -98,6 +106,7 @@ static BOOL isUnsafeMessage(int msgid); - (void)handleBrowseForFile:(NSDictionary *)attr; - (void)handleShowDialog:(NSDictionary *)attr; - (void)handleDeleteSign:(NSDictionary *)attr; +- (void)setToolTipDelay:(NSTimeInterval)seconds; @end @@ -150,11 +159,6 @@ static BOOL isUnsafeMessage(int msgid); [mainMenu addItem:appMenuItem]; -#ifdef MM_ENABLE_PLUGINS - instanceMediator = [[MMPlugInInstanceMediator alloc] - initWithVimController:self]; -#endif - isInitialized = YES; return self; @@ -166,10 +170,6 @@ static BOOL isUnsafeMessage(int msgid); isInitialized = NO; -#ifdef MM_ENABLE_PLUGINS - [instanceMediator release]; instanceMediator = nil; -#endif - [serverName release]; serverName = nil; [backendProxy release]; backendProxy = nil; @@ -195,13 +195,6 @@ static BOOL isUnsafeMessage(int msgid); return windowController; } -#ifdef MM_ENABLE_PLUGINS -- (MMPlugInInstanceMediator *)instanceMediator -{ - return instanceMediator; -} -#endif - - (NSDictionary *)vimState { return vimState; @@ -839,6 +832,20 @@ static BOOL isUnsafeMessage(int msgid); int y = *((int*)bytes); bytes += sizeof(int); [windowController setTopLeft:NSMakePoint(x,y)]; + } else if (SetTooltipMsgID == msgid) { + id textView = [[windowController vimView] textView]; + NSDictionary *dict = [NSDictionary dictionaryWithData:data]; + NSString *toolTip = dict ? [dict objectForKey:@"toolTip"] : nil; + if (toolTip && [toolTip length] > 0) + [textView setToolTipAtMousePoint:toolTip]; + else + [textView setToolTipAtMousePoint:nil]; + } else if (SetTooltipDelayMsgID == msgid) { + NSDictionary *dict = [NSDictionary dictionaryWithData:data]; + NSNumber *delay = dict ? [dict objectForKey:@"delay"] : nil; + if (delay) + [self setToolTipDelay:[delay floatValue]]; + // IMPORTANT: When adding a new message, make sure to update // isUnsafeMessage() if necessary! } else { @@ -1449,6 +1456,23 @@ static BOOL isUnsafeMessage(int msgid); [view deleteSign:[attr objectForKey:@"imgName"]]; } +- (void)setToolTipDelay:(NSTimeInterval)seconds +{ + // HACK! NSToolTipManager is an AppKit private class. + static Class TTM = nil; + if (!TTM) + TTM = NSClassFromString(@"NSToolTipManager"); + + if (seconds < 0) + seconds = 0; + + if (TTM) { + [[TTM sharedToolTipManager] setInitialToolTipDelay:seconds]; + } else { + ASLogNotice(@"Failed to get NSToolTipManager"); + } +} + @end // MMVimController (Private) diff --git a/src/MacVim/MMVimView.m b/src/MacVim/MMVimView.m index c5a4a9f0b0..7f618c6280 100644 --- a/src/MacVim/MMVimView.m +++ b/src/MacVim/MMVimView.m @@ -662,17 +662,15 @@ enum { - (void)placeScrollbars { NSRect textViewFrame = [textView frame]; - BOOL lsbVisible = [self leftScrollbarVisible]; + BOOL leftSbVisible = NO; + BOOL rightSbVisible = NO; + BOOL botSbVisible = NO; - // HACK! Find the lowest left&right vertical scrollbars, as well as the - // rightmost horizontal scrollbar. This hack continues further down. - // - // TODO! Can there be no more than one horizontal scrollbar? If so, the - // code can be simplified. + // HACK! Find the lowest left&right vertical scrollbars This hack + // continues further down. unsigned lowestLeftSbIdx = (unsigned)-1; unsigned lowestRightSbIdx = (unsigned)-1; - unsigned rightmostSbIdx = (unsigned)-1; - unsigned rowMaxLeft = 0, rowMaxRight = 0, colMax = 0; + unsigned rowMaxLeft = 0, rowMaxRight = 0; unsigned i, count = [scrollbars count]; for (i = 0; i < count; ++i) { MMScroller *scroller = [scrollbars objectAtIndex:i]; @@ -682,14 +680,14 @@ enum { && range.location >= rowMaxLeft) { rowMaxLeft = range.location; lowestLeftSbIdx = i; + leftSbVisible = YES; } else if ([scroller type] == MMScrollerTypeRight && range.location >= rowMaxRight) { rowMaxRight = range.location; lowestRightSbIdx = i; - } else if ([scroller type] == MMScrollerTypeBottom - && range.location >= colMax) { - colMax = range.location; - rightmostSbIdx = i; + rightSbVisible = YES; + } else if ([scroller type] == MMScrollerTypeBottom) { + botSbVisible = YES; } } } @@ -704,25 +702,27 @@ enum { if ([scroller type] == MMScrollerTypeBottom) { rect = [textView rectForColumnsInRange:[scroller range]]; rect.size.height = [NSScroller scrollerWidth]; - if (lsbVisible) + if (leftSbVisible) rect.origin.x += [NSScroller scrollerWidth]; - // HACK! Make sure the rightmost horizontal scrollbar covers the - // text view all the way to the right, otherwise it looks ugly when - // the user drags the window to resize. - if (i == rightmostSbIdx) { - float w = NSMaxX(textViewFrame) - NSMaxX(rect); - if (w > 0) - rect.size.width += w; - } + // HACK! Make sure the horizontal scrollbar covers the text view + // all the way to the right, otherwise it looks ugly when the user + // drags the window to resize. + float w = NSMaxX(textViewFrame) - NSMaxX(rect); + if (w > 0) + rect.size.width += w; // Make sure scrollbar rect is bounded by the text view frame. + // Also leave some room for the resize indicator on the right in + // case there is no right scrollbar. if (rect.origin.x < textViewFrame.origin.x) rect.origin.x = textViewFrame.origin.x; else if (rect.origin.x > NSMaxX(textViewFrame)) rect.origin.x = NSMaxX(textViewFrame); if (NSMaxX(rect) > NSMaxX(textViewFrame)) rect.size.width -= NSMaxX(rect) - NSMaxX(textViewFrame); + if (!rightSbVisible) + rect.size.width -= [NSScroller scrollerWidth]; if (rect.size.width < 0) rect.size.width = 0; } else { @@ -778,6 +778,11 @@ enum { [scroller setNeedsDisplay:YES]; } } + + // HACK: If there is no bottom or right scrollbar the resize indicator will + // cover the bottom-right corner of the text view so tell NSWindow not to + // draw it in this situation. + [[self window] setShowsResizeIndicator:(rightSbVisible||botSbVisible)]; } - (NSUInteger)representedIndexOfTabViewItem:(NSTabViewItem *)tvi diff --git a/src/MacVim/MMWindow.m b/src/MacVim/MMWindow.m index 7f30544c7e..3029dcee34 100644 --- a/src/MacVim/MMWindow.m +++ b/src/MacVim/MMWindow.m @@ -58,6 +58,9 @@ [contentView setAutoresizesSubviews:YES]; [contentView addSubview:tablineSeparator]; + // NOTE: Vim needs to process mouse moved events, so enable them here. + [self setAcceptsMouseMovedEvents:YES]; + return self; } diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index db6bff3147..e457453b2e 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -12,13 +12,6 @@ #import -// -// Uncomment to enable support for MacVim plugins (not to be confused with Vim -// plugins!). -// -//#define MM_ENABLE_PLUGINS - - // Taken from /usr/include/AvailabilityMacros.h #ifndef MAC_OS_X_VERSION_10_4 # define MAC_OS_X_VERSION_10_4 1040 @@ -193,6 +186,8 @@ enum { ZoomMsgID, SetWindowPositionMsgID, DeleteSignMsgID, + SetTooltipMsgID, + SetTooltipDelayMsgID, LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM! }; diff --git a/src/MacVim/MacVim.m b/src/MacVim/MacVim.m index 685685f446..b810529778 100644 --- a/src/MacVim/MacVim.m +++ b/src/MacVim/MacVim.m @@ -96,6 +96,8 @@ char *MessageStrings[] = "ZoomMsgID", "SetWindowPositionMsgID", "DeleteSignMsgID", + "SetTooltipMsgID", + "SetTooltipDelayMsgID", "END OF MESSAGE IDs" // NOTE: Must be last! }; diff --git a/src/MacVim/MacVim.xcodeproj/project.pbxproj b/src/MacVim/MacVim.xcodeproj/project.pbxproj index 26e06c4a23..ec1980a1ab 100644 --- a/src/MacVim/MacVim.xcodeproj/project.pbxproj +++ b/src/MacVim/MacVim.xcodeproj/project.pbxproj @@ -9,11 +9,6 @@ /* Begin PBXBuildFile section */ 0395A8330D71ED7800881434 /* DBPrefsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0395A8320D71ED7800881434 /* DBPrefsWindowController.m */; }; 0395A8AA0D72D88B00881434 /* General.png in Resources */ = {isa = PBXBuildFile; fileRef = 0395A8A90D72D88B00881434 /* General.png */; }; - 0395A95A0D74D47B00881434 /* Integration.png in Resources */ = {isa = PBXBuildFile; fileRef = 0395A9590D74D47B00881434 /* Integration.png */; }; - 0395A9BF0D75D02400881434 /* AuthorizedShellCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 0395A9BE0D75D02400881434 /* AuthorizedShellCommand.m */; }; - 0395A9C30D75D04D00881434 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0395A9C20D75D04D00881434 /* Security.framework */; }; - 0395AA780D76E77800881434 /* Info in Copy ODBEditor */ = {isa = PBXBuildFile; fileRef = 0395AA770D76E77800881434 /* Info */; }; - 0395AAAD0D76E94000881434 /* Edit in ODBEditor.bundle in Copy ODBEditor */ = {isa = PBXBuildFile; fileRef = 0395AA210D76E22700881434 /* Edit in ODBEditor.bundle */; }; 1D09AB420C6A4D520045497E /* MMTypesetter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D09AB400C6A4D520045497E /* MMTypesetter.m */; }; 1D0E051C0BA5F83800B6049E /* Colors.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1D0E051B0BA5F83800B6049E /* Colors.plist */; }; 1D145C7F0E5227CE00691AA0 /* MMTextViewHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D145C7E0E5227CE00691AA0 /* MMTextViewHelper.m */; }; @@ -29,6 +24,7 @@ 1D3D19120CA690FF0004A0A5 /* DejaVuSansMono-BoldOblique.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1D3D190E0CA690FF0004A0A5 /* DejaVuSansMono-BoldOblique.ttf */; }; 1D3D19130CA690FF0004A0A5 /* DejaVuSansMono-Oblique.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1D3D190F0CA690FF0004A0A5 /* DejaVuSansMono-Oblique.ttf */; }; 1D3D19140CA690FF0004A0A5 /* DejaVuSansMono.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1D3D19100CA690FF0004A0A5 /* DejaVuSansMono.ttf */; }; + 1D44972211FCA9B400B0630F /* MMCoreTextView+ToolTip.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D44972111FCA9B400B0630F /* MMCoreTextView+ToolTip.m */; }; 1D493D580C5247BF00AB718C /* Vim in Copy Executables */ = {isa = PBXBuildFile; fileRef = 1D493D570C5247BF00AB718C /* Vim */; }; 1D493DBA0C52534300AB718C /* PSMTabBarControl.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 1D493DB90C52533B00AB718C /* PSMTabBarControl.framework */; }; 1D60088B0E96A0B2003763F0 /* MMFindReplaceController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D60088A0E96A0B2003763F0 /* MMFindReplaceController.m */; }; @@ -78,30 +74,9 @@ 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; B59228A611F7572F00E7F584 /* MacVim.sdef in Resources */ = {isa = PBXBuildFile; fileRef = B59228A511F7572F00E7F584 /* MacVim.sdef */; }; - BD476E300DAAD74400F08A5C /* RBSplitSubview.m in Sources */ = {isa = PBXBuildFile; fileRef = BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */; }; - BD476E310DAAD74400F08A5C /* RBSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD476E2E0DAAD74400F08A5C /* RBSplitView.m */; }; - BD943D530DA3050B00A02D9B /* PlugInImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = BD943D520DA3050B00A02D9B /* PlugInImpl.m */; }; - BD9DF0A00DB2BA020025C97C /* PlugInView.nib in Resources */ = {isa = PBXBuildFile; fileRef = BD9DF09F0DB2BA020025C97C /* PlugInView.nib */; }; - BD9DF0B00DB41E780025C97C /* PlugInGUI.m in Sources */ = {isa = PBXBuildFile; fileRef = BD9DF0AF0DB41E780025C97C /* PlugInGUI.m */; }; - BD9DF0FB0DB48C860025C97C /* CTGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = BD9DF0FA0DB48C860025C97C /* CTGradient.m */; }; - BDA8B1120D9F8A8500B3511A /* MMPlugInManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BDA8B1110D9F8A8500B3511A /* MMPlugInManager.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 0395AA200D76E22700881434 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0395AA190D76E22700881434 /* Edit in ODBEditor.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 8D5B49B6048680CD000E48DA; - remoteInfo = "Edit in ODBEditor"; - }; - 0395AA230D76E2F300881434 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0395AA190D76E22700881434 /* Edit in ODBEditor.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 8D5B49AC048680CD000E48DA; - remoteInfo = "Edit in ODBEditor"; - }; 1D493DB80C52533B00AB718C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1D493DB30C52533B00AB718C /* PSMTabBarControl.xcodeproj */; @@ -119,18 +94,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - 0395AA790D76E77800881434 /* Copy ODBEditor */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "Edit in ODBEditor"; - dstSubfolderSpec = 7; - files = ( - 0395AAAD0D76E94000881434 /* Edit in ODBEditor.bundle in Copy ODBEditor */, - 0395AA780D76E77800881434 /* Info in Copy ODBEditor */, - ); - name = "Copy ODBEditor"; - runOnlyForDeploymentPostprocessing = 0; - }; 1D0DCAD80BA3604D00B6CCFA /* Copy Executables */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -172,12 +135,6 @@ 0395A8310D71ED7800881434 /* DBPrefsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBPrefsWindowController.h; sourceTree = ""; }; 0395A8320D71ED7800881434 /* DBPrefsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBPrefsWindowController.m; sourceTree = ""; }; 0395A8A90D72D88B00881434 /* General.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = General.png; sourceTree = ""; }; - 0395A9590D74D47B00881434 /* Integration.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Integration.png; sourceTree = ""; }; - 0395A9BD0D75D02400881434 /* AuthorizedShellCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthorizedShellCommand.h; sourceTree = ""; }; - 0395A9BE0D75D02400881434 /* AuthorizedShellCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AuthorizedShellCommand.m; sourceTree = ""; }; - 0395A9C20D75D04D00881434 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = ""; }; - 0395AA190D76E22700881434 /* Edit in ODBEditor.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "Edit in ODBEditor.xcodeproj"; path = "edit-in-odb/Edit in ODBEditor.xcodeproj"; sourceTree = ""; }; - 0395AA770D76E77800881434 /* Info */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = Info; path = "edit-in-odb/Info"; sourceTree = ""; }; 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 1D09AB3F0C6A4D520045497E /* MMTypesetter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MMTypesetter.h; sourceTree = ""; }; @@ -203,6 +160,7 @@ 1D3D190E0CA690FF0004A0A5 /* DejaVuSansMono-BoldOblique.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "DejaVuSansMono-BoldOblique.ttf"; path = "dejavu-ttf/DejaVuSansMono-BoldOblique.ttf"; sourceTree = ""; }; 1D3D190F0CA690FF0004A0A5 /* DejaVuSansMono-Oblique.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "DejaVuSansMono-Oblique.ttf"; path = "dejavu-ttf/DejaVuSansMono-Oblique.ttf"; sourceTree = ""; }; 1D3D19100CA690FF0004A0A5 /* DejaVuSansMono.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = DejaVuSansMono.ttf; path = "dejavu-ttf/DejaVuSansMono.ttf"; sourceTree = ""; }; + 1D44972111FCA9B400B0630F /* MMCoreTextView+ToolTip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MMCoreTextView+ToolTip.m"; sourceTree = ""; }; 1D493D570C5247BF00AB718C /* Vim */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = Vim; path = ../Vim; sourceTree = SOURCE_ROOT; }; 1D493DB30C52533B00AB718C /* PSMTabBarControl.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PSMTabBarControl.xcodeproj; path = PSMTabBarControl/PSMTabBarControl.xcodeproj; sourceTree = ""; }; 1D6008820E96886D003763F0 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/FindAndReplace.nib; sourceTree = ""; }; @@ -263,21 +221,6 @@ 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 8D1107320486CEB800E47090 /* MacVim.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MacVim.app; sourceTree = BUILT_PRODUCTS_DIR; }; B59228A511F7572F00E7F584 /* MacVim.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.sdef; path = MacVim.sdef; sourceTree = ""; }; - BD476E2B0DAAD74400F08A5C /* RBSplitSubview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitSubview.h; sourceTree = ""; }; - BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RBSplitSubview.m; sourceTree = ""; }; - BD476E2D0DAAD74400F08A5C /* RBSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitView.h; sourceTree = ""; }; - BD476E2E0DAAD74400F08A5C /* RBSplitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RBSplitView.m; sourceTree = ""; }; - BD476E2F0DAAD74400F08A5C /* RBSplitViewPrivateDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitViewPrivateDefines.h; sourceTree = ""; }; - BD943D310DA2EA2500A02D9B /* PlugInInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInInterface.h; sourceTree = ""; }; - BD943D510DA3050B00A02D9B /* PlugInImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInImpl.h; sourceTree = ""; }; - BD943D520DA3050B00A02D9B /* PlugInImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlugInImpl.m; sourceTree = ""; }; - BD9DF09F0DB2BA020025C97C /* PlugInView.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = PlugInView.nib; sourceTree = ""; }; - BD9DF0AE0DB41E780025C97C /* PlugInGUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInGUI.h; sourceTree = ""; }; - BD9DF0AF0DB41E780025C97C /* PlugInGUI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlugInGUI.m; sourceTree = ""; }; - BD9DF0F90DB48C860025C97C /* CTGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CTGradient.h; sourceTree = ""; }; - BD9DF0FA0DB48C860025C97C /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CTGradient.m; sourceTree = ""; }; - BDA8B1100D9F8A8500B3511A /* MMPlugInManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMPlugInManager.h; sourceTree = ""; }; - BDA8B1110D9F8A8500B3511A /* MMPlugInManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMPlugInManager.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -287,7 +230,6 @@ files = ( 1DFE25A50C527BC4003000F7 /* PSMTabBarControl.framework in Frameworks */, 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, - 0395A9C30D75D04D00881434 /* Security.framework in Frameworks */, 1D8B5A53104AF9FF002E59D5 /* Carbon.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -295,19 +237,9 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 0395AA1A0D76E22700881434 /* Products */ = { - isa = PBXGroup; - children = ( - 0395AA210D76E22700881434 /* Edit in ODBEditor.bundle */, - ); - name = Products; - sourceTree = ""; - }; 0395AA980D76E86200881434 /* Edit in ODBEditor */ = { isa = PBXGroup; children = ( - 0395AA190D76E22700881434 /* Edit in ODBEditor.xcodeproj */, - 0395AA770D76E77800881434 /* Info */, ); name = "Edit in ODBEditor"; sourceTree = ""; @@ -315,6 +247,7 @@ 080E96DDFE201D6D7F000001 /* MacVim Source */ = { isa = PBXGroup; children = ( + 1D44972111FCA9B400B0630F /* MMCoreTextView+ToolTip.m */, 1D6008890E96A0B2003763F0 /* MMFindReplaceController.h */, 1D60088A0E96A0B2003763F0 /* MMFindReplaceController.m */, 1DE63FF90E71820F00959BDB /* MMCoreTextView.h */, @@ -323,15 +256,6 @@ 1D145C7E0E5227CE00691AA0 /* MMTextViewHelper.m */, 1D8059220E118663001699D1 /* Miscellaneous.h */, 1D80591D0E1185EA001699D1 /* Miscellaneous.m */, - BD9DF0F90DB48C860025C97C /* CTGradient.h */, - BD9DF0FA0DB48C860025C97C /* CTGradient.m */, - BD476E2B0DAAD74400F08A5C /* RBSplitSubview.h */, - BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */, - BD476E2D0DAAD74400F08A5C /* RBSplitView.h */, - BD476E2E0DAAD74400F08A5C /* RBSplitView.m */, - BD476E2F0DAAD74400F08A5C /* RBSplitViewPrivateDefines.h */, - 0395A9BD0D75D02400881434 /* AuthorizedShellCommand.h */, - 0395A9BE0D75D02400881434 /* AuthorizedShellCommand.m */, 0395A8310D71ED7800881434 /* DBPrefsWindowController.h */, 0395A8320D71ED7800881434 /* DBPrefsWindowController.m */, 1DE3F8E80D50F84600052B9E /* MMPreferenceController.h */, @@ -362,13 +286,6 @@ 1D1474960C56703C0038FA2B /* MacVim.m */, 32CA4F630368D1EE00C91783 /* MacVim_Prefix.pch */, 29B97316FDCFA39411CA2CEA /* main.m */, - BDA8B1100D9F8A8500B3511A /* MMPlugInManager.h */, - BDA8B1110D9F8A8500B3511A /* MMPlugInManager.m */, - BD943D310DA2EA2500A02D9B /* PlugInInterface.h */, - BD943D510DA3050B00A02D9B /* PlugInImpl.h */, - BD943D520DA3050B00A02D9B /* PlugInImpl.m */, - BD9DF0AE0DB41E780025C97C /* PlugInGUI.h */, - BD9DF0AF0DB41E780025C97C /* PlugInGUI.m */, ); name = "MacVim Source"; sourceTree = ""; @@ -484,9 +401,7 @@ 1D9C602E0EF79C0C0034AD44 /* MacVim.icns */, 1D8BEA73104992290069B072 /* FindAndReplace.nib */, 0395A8A90D72D88B00881434 /* General.png */, - 0395A9590D74D47B00881434 /* Integration.png */, 1D22374A0E45DF4800E6FFFF /* Advanced.png */, - BD9DF09F0DB2BA020025C97C /* PlugInView.nib */, 1DD3D51D0D82D4C9006E4320 /* ibeam.png */, 1D0F11480D58C77800D5DA09 /* Font */, 1DE9726C0C48050600F96A9F /* Toolbar */, @@ -507,7 +422,6 @@ children = ( 1D8B5A52104AF9FF002E59D5 /* Carbon.framework */, 0395AA980D76E86200881434 /* Edit in ODBEditor */, - 0395A9C20D75D04D00881434 /* Security.framework */, 1D493DB30C52533B00AB718C /* PSMTabBarControl.xcodeproj */, 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, @@ -528,14 +442,12 @@ 1D0DCAD80BA3604D00B6CCFA /* Copy Executables */, 1D9EB2840C366D7B0074B739 /* Copy Frameworks */, 1DE608B80C58807F0055263D /* Copy Vim Runtime Files */, - 0395AA790D76E77800881434 /* Copy ODBEditor */, 1D1C31F00EFFBFD6003FE9A5 /* Make Document Icons */, ); buildRules = ( ); dependencies = ( 1D493DCD0C5254A400AB718C /* PBXTargetDependency */, - 0395AA240D76E2F300881434 /* PBXTargetDependency */, ); name = MacVim; productInstallPath = "$(HOME)/Applications"; @@ -561,10 +473,6 @@ mainGroup = 29B97314FDCFA39411CA2CEA /* MacVim */; projectDirPath = ""; projectReferences = ( - { - ProductGroup = 0395AA1A0D76E22700881434 /* Products */; - ProjectRef = 0395AA190D76E22700881434 /* Edit in ODBEditor.xcodeproj */; - }, { ProductGroup = 1D493DB40C52533B00AB718C /* Products */; ProjectRef = 1D493DB30C52533B00AB718C /* PSMTabBarControl.xcodeproj */; @@ -578,13 +486,6 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - 0395AA210D76E22700881434 /* Edit in ODBEditor.bundle */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = "Edit in ODBEditor.bundle"; - remoteRef = 0395AA200D76E22700881434 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 1D493DB90C52533B00AB718C /* PSMTabBarControl.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; @@ -611,9 +512,7 @@ 1D3D19140CA690FF0004A0A5 /* DejaVuSansMono.ttf in Resources */, 1DE3F8E70D50F80500052B9E /* Preferences.nib in Resources */, 0395A8AA0D72D88B00881434 /* General.png in Resources */, - 0395A95A0D74D47B00881434 /* Integration.png in Resources */, 1DD3D51E0D82D4C9006E4320 /* ibeam.png in Resources */, - BD9DF0A00DB2BA020025C97C /* PlugInView.nib in Resources */, 1D22374B0E45DF4800E6FFFF /* Advanced.png in Resources */, 1DCD00BF0E50B2B700460166 /* Attention.png in Resources */, 1DCD00C00E50B2B700460166 /* Copy.png in Resources */, @@ -683,28 +582,17 @@ 1DE9B9500D341AB8008FEDD4 /* MMWindow.m in Sources */, 1DE3F8EB0D50F84600052B9E /* MMPreferenceController.m in Sources */, 0395A8330D71ED7800881434 /* DBPrefsWindowController.m in Sources */, - 0395A9BF0D75D02400881434 /* AuthorizedShellCommand.m in Sources */, 1D80591F0E1185EA001699D1 /* Miscellaneous.m in Sources */, - BDA8B1120D9F8A8500B3511A /* MMPlugInManager.m in Sources */, - BD943D530DA3050B00A02D9B /* PlugInImpl.m in Sources */, - BD476E300DAAD74400F08A5C /* RBSplitSubview.m in Sources */, - BD476E310DAAD74400F08A5C /* RBSplitView.m in Sources */, - BD9DF0B00DB41E780025C97C /* PlugInGUI.m in Sources */, - BD9DF0FB0DB48C860025C97C /* CTGradient.m in Sources */, 1D145C7F0E5227CE00691AA0 /* MMTextViewHelper.m in Sources */, 1D60088B0E96A0B2003763F0 /* MMFindReplaceController.m in Sources */, 1DE63FFB0E71820F00959BDB /* MMCoreTextView.m in Sources */, + 1D44972211FCA9B400B0630F /* MMCoreTextView+ToolTip.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 0395AA240D76E2F300881434 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "Edit in ODBEditor"; - targetProxy = 0395AA230D76E2F300881434 /* PBXContainerItemProxy */; - }; 1D493DCD0C5254A400AB718C /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = PSMTabBarControlFramework; diff --git a/src/MacVim/Miscellaneous.h b/src/MacVim/Miscellaneous.h index 6f0aee5f00..dfe9afb127 100644 --- a/src/MacVim/Miscellaneous.h +++ b/src/MacVim/Miscellaneous.h @@ -45,9 +45,6 @@ extern NSString *MMCurrentPreferencePaneKey; extern NSString *MMLoginShellCommandKey; extern NSString *MMLoginShellArgumentKey; extern NSString *MMDialogsTrackPwdKey; -#ifdef MM_ENABLE_PLUGINS -extern NSString *MMShowLeftPlugInContainerKey; -#endif extern NSString *MMOpenLayoutKey; extern NSString *MMVerticalSplitKey; extern NSString *MMPreloadCacheSizeKey; diff --git a/src/MacVim/Miscellaneous.m b/src/MacVim/Miscellaneous.m index 36d5e8b8d0..7d6e6d1419 100644 --- a/src/MacVim/Miscellaneous.m +++ b/src/MacVim/Miscellaneous.m @@ -37,9 +37,6 @@ NSString *MMCurrentPreferencePaneKey = @"MMCurrentPreferencePane"; NSString *MMLoginShellCommandKey = @"MMLoginShellCommand"; NSString *MMLoginShellArgumentKey = @"MMLoginShellArgument"; NSString *MMDialogsTrackPwdKey = @"MMDialogsTrackPwd"; -#ifdef MM_ENABLE_PLUGINS -NSString *MMShowLeftPlugInContainerKey = @"MMShowLeftPlugInContainer"; -#endif NSString *MMOpenLayoutKey = @"MMOpenLayout"; NSString *MMVerticalSplitKey = @"MMVerticalSplit"; NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize"; diff --git a/src/MacVim/PlugInGUI.h b/src/MacVim/PlugInGUI.h deleted file mode 100644 index 445f8142e2..0000000000 --- a/src/MacVim/PlugInGUI.h +++ /dev/null @@ -1,57 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: - * - * VIM - Vi IMproved by Bram Moolenaar - * MacVim GUI port by Bjorn Winckler - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -#import -#import "RBSplitView.h" - - -@class MMPlugInView; -@class MMPlugInViewContainer; -@class MMPlugInViewController; - -@interface MMPlugInViewHeader : NSView { - IBOutlet MMPlugInViewController *controller; -} -@end - -@interface MMPlugInView : RBSplitSubview { - IBOutlet MMPlugInViewController *controller; -} - -- (MMPlugInViewController *)controller; - -@end - -@interface MMPlugInViewController : NSObject { - IBOutlet RBSplitSubview *plugInSubview; - IBOutlet MMPlugInViewHeader *headerView; - IBOutlet NSView *contentView; - IBOutlet NSTextField *titleField; -} - -- (id)initWithView:(NSView *)view title:(NSString *)title; -- (void)moveToContainer:(MMPlugInViewContainer *)container; -- (RBSplitSubview *)plugInSubview; -- (MMPlugInViewContainer *)container; - -// called when the dropView on the container holding this plugin view was -// changed, and this was the current dropView or it is the new dropView -- (void)dropViewChanged; -@end - -@interface MMPlugInViewContainer : RBSplitView { - RBSplitSubview *fillerView; - - // only used during drag and drop - MMPlugInView *dropView; -} - -- (MMPlugInView *)dropView; -@end diff --git a/src/MacVim/PlugInGUI.m b/src/MacVim/PlugInGUI.m deleted file mode 100644 index b1e272002d..0000000000 --- a/src/MacVim/PlugInGUI.m +++ /dev/null @@ -1,334 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: - * - * VIM - Vi IMproved by Bram Moolenaar - * MacVim GUI port by Bjorn Winckler - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -/* - * MMPlugInViewHeader - * - * Essentially just a title bar for a plugin view. Handles drawing the - * drag-and-drop line where a new plugin view will be inserted. - * - * MMPlugInView - * - * This contains a single view added by a plugin. - * - * MMPlugInViewContainer - * - * This contains multiple MMPlugInViews. It handles the drag and drop aspects - * of the views, as well. - * - * Author: Matt Tolton - */ -#import "MacVim.h" - -#ifdef MM_ENABLE_PLUGINS - -#import "PlugInGUI.h" -#import "CTGradient.h" - -NSString *MMPlugInViewPboardType = @"MMPlugInViewPboardType"; - -@implementation MMPlugInViewHeader - -- (void)mouseDown:(NSEvent *)theEvent -{ - // Make image from view - NSView *view = self; - [view lockFocus]; - NSBitmapImageRep *bitmap = [[[NSBitmapImageRep alloc] - initWithFocusedViewRect: [view bounds]] autorelease]; - [view unlockFocus]; - - NSImage *image = [[[NSImage alloc] initWithSize: [view bounds].size] - autorelease]; - [image addRepresentation:bitmap]; - - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; - - [pboard declareTypes:[NSArray arrayWithObject:MMPlugInViewPboardType] - owner:self]; - - NSPoint pt = [view convertPoint:[view bounds].origin - toView:[controller plugInSubview]]; - [[controller plugInSubview] dragImage:image - at:pt - offset:NSMakeSize(0, 0) - event:theEvent - pasteboard:pboard - source:controller - slideBack:YES]; -} - -- (void)drawRect:(NSRect)rect -{ - NSColor *startColor; - startColor = [NSColor colorWithCalibratedRed:.600 - green:.600 - blue:.600 - alpha:1.0]; - - NSColor *endColor = [NSColor colorWithCalibratedRed:.800 - green:.800 - blue:.800 - alpha:1.0]; - - CTGradient *grad = [CTGradient gradientWithBeginningColor:startColor - endingColor:endColor]; - [grad fillRect:[self bounds] angle:90]; - - MMPlugInView *dropView = [[controller container] dropView]; - - if (dropView == [controller plugInSubview]) { - NSRect insertionRect = NSMakeRect(0,[self bounds].size.height - 2, - [self bounds].size.width, 2); - [[NSColor redColor] set]; - NSRectFill(insertionRect); - } -} - -- (BOOL)isOpaque -{ - return YES; -} - -- (NSRect)dragRect -{ - return NSMakeRect(0, [self bounds].size.height - 6, [self bounds].size.width, 6); -} - -@end - -@implementation MMPlugInView - -- (MMPlugInViewController *)controller -{ - return controller; -} - -@end - -@implementation MMPlugInViewController - -- (id)initWithView:(NSView *)view title:(NSString *)title -{ - if ((self = [super init]) == nil) return nil; - - if (![NSBundle loadNibNamed:@"PlugInView" owner:self]) - ASLogErr(@"Error loading PlugIn nib"); - - [titleField setStringValue:title]; - - [plugInSubview setMinDimension:50 - andMaxDimension:0.0]; - - [view setFrame:[contentView bounds]]; - [contentView addSubview:view]; - - return self; -} - -- (RBSplitSubview *)plugInSubview -{ - return plugInSubview; -} - -- (void)moveToContainer:(MMPlugInViewContainer *)container -{ - if ([plugInSubview splitView]) { - [plugInSubview removeFromSuperview]; - } - [container addSubview:plugInSubview]; -} - -- (void)moveToContainer:(MMPlugInViewContainer *)container before:(MMPlugInView *)lowerView -{ - if ([plugInSubview splitView]) { - [plugInSubview removeFromSuperview]; - } - [container addSubview:plugInSubview positioned:NSWindowBelow relativeTo:lowerView]; -} - -- (MMPlugInViewHeader *)headerView -{ - return headerView; -} - -- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal -{ - if (isLocal) - return NSDragOperationPrivate; - else - return NSDragOperationNone; -} - -- (void)dropViewChanged { - [headerView setNeedsDisplay:YES]; -} - -- (MMPlugInViewContainer *)container { - return (MMPlugInViewContainer *)[plugInSubview splitView]; -} -@end - -@implementation MMPlugInViewContainer - -- (id)initWithFrame:(NSRect)frame -{ - if ((self = [super initWithFrame:frame]) == nil) return nil; - - [self registerForDraggedTypes: - [NSArray arrayWithObjects:MMPlugInViewPboardType, nil]]; - - [self setVertical:NO]; - [self setDelegate:self]; - - fillerView = [[RBSplitSubview alloc] initWithFrame:NSMakeRect(0,0,0,0)]; - [fillerView setHidden:YES]; - - return self; -} - -- (void)dealloc -{ - ASLogDebug(@""); - - [fillerView release]; fillerView = nil; - [super dealloc]; -} - -- (unsigned int)splitView:(RBSplitView*)sender dividerForPoint:(NSPoint)point - inSubview:(RBSplitSubview*)subview -{ - MMPlugInViewController *controller = [(MMPlugInView *)subview controller]; - MMPlugInViewHeader *header = [controller headerView]; - - if ([header mouse:[header convertPoint:point fromView:sender] - inRect:[header dragRect]]) - return [subview position] - 1; - - return NSNotFound; -} - -- (NSRect)splitView:(RBSplitView*)sender cursorRect:(NSRect)rect - forDivider:(unsigned int)theDivider -{ - - if (theDivider != 0) return NSZeroRect; - - int i; - for (i = 1;; i++) { - MMPlugInView *view = (MMPlugInView *)[sender subviewAtPosition:i]; - if (!view) break; - - MMPlugInViewHeader *header = [[view controller] headerView]; - NSRect rect = [header dragRect]; - rect = [sender convertRect:rect fromView:header]; - [sender addCursorRect:rect - cursor:[RBSplitView cursor:RBSVHorizontalCursor]]; - - } - - return NSZeroRect; -} - -- (void)clearDragInfo -{ - if (dropView) { - MMPlugInView *save = dropView; - dropView = nil; - [[save controller] dropViewChanged]; - } -} - -// point should be in the window's coordinate system -- (void)updateDragInfo:(id)info -{ - - [self clearDragInfo]; - - if (!([info draggingSourceOperationMask] & NSDragOperationPrivate)) return; - - if (![[info draggingSource] isKindOfClass:[MMPlugInViewController class]]) return; - - // for now has to be THIS container. in the future, it will be ok for any - // container associated with the same vim instance - if ([[info draggingSource] container] != self) return; - - // XXX for now we just use the view that the mouse is currently over, and - // always insert "above" that view. In the future, we might want to try to - // find the divider that the mouse is closest to and have the dropView be - // the view below that divider. - - NSPoint point = [info draggingLocation]; - - int i; - for (i = 0;; i++) { - MMPlugInView *subview = (MMPlugInView *)[self subviewAtPosition:i]; - if (!subview) break; - - if ([subview mouse:[subview convertPoint:point fromView:nil] - inRect:[subview bounds]]) { - dropView = subview; - break; - } - } - - if ([[info draggingSource] plugInSubview] == dropView) - dropView = nil; - - if (dropView) [[dropView controller] dropViewChanged]; -} - -- (NSDragOperation)draggingEntered:(id)sender -{ - [self updateDragInfo:sender]; - - if (dropView != nil) - return NSDragOperationPrivate; - else - return NSDragOperationNone; -} - -- (NSDragOperation)draggingUpdated:(id)sender -{ - [self updateDragInfo:sender]; - - if (dropView != nil) - return NSDragOperationPrivate; - - return NSDragOperationNone; -} - -- (BOOL)prepareForDragOperation:(id)sender -{ - [self updateDragInfo:sender]; - return dropView != nil; -} - -- (BOOL)performDragOperation:(id)sender -{ - MMPlugInViewController *source = [sender draggingSource]; - [source moveToContainer:self before:dropView]; - [self clearDragInfo]; - return YES; -} - -- (void)draggingExited:(id)sender -{ - [self clearDragInfo]; -} - - -- (MMPlugInView *)dropView { - return dropView; -} - -@end - -#endif diff --git a/src/MacVim/PlugInImpl.h b/src/MacVim/PlugInImpl.h deleted file mode 100644 index 6ab4daee66..0000000000 --- a/src/MacVim/PlugInImpl.h +++ /dev/null @@ -1,37 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: - * - * VIM - Vi IMproved by Bram Moolenaar - * MacVim GUI port by Bjorn Winckler - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -#import -#import "PlugInInterface.h" - -@interface MMPlugInAppMediator : NSObject { - NSMenu *plugInMenu; -} - -+ (MMPlugInAppMediator *)sharedAppMediator; - -@end - - -@class MMVimController; - -// One of these per vim controller object. It manages all of the plugin -// instances for a given controller. -@interface MMPlugInInstanceMediator : NSObject { - // NB: this is a weak reference to the vim controller - MMVimController *vimController; - NSMutableArray *instances; - NSDrawer *drawer; - NSMutableArray *plugInViews ; -} - -- (id)initWithVimController:(MMVimController *)controller; - -@end diff --git a/src/MacVim/PlugInImpl.m b/src/MacVim/PlugInImpl.m deleted file mode 100644 index 8f272b78d6..0000000000 --- a/src/MacVim/PlugInImpl.m +++ /dev/null @@ -1,237 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: - * - * VIM - Vi IMproved by Bram Moolenaar - * MacVim GUI port by Bjorn Winckler - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -/* - * MMPlugInInstanceMediator - * - * Implementation of the PlugInInstanceMediator protocol. One of these is - * created per vim instance. It manages all of the plugin instances for that - * vim instance. - * - * MMPlugInAppMediator - * - * Implementation of the PlugInAppMediator protocol. Singleton class. - * - * Author: Matt Tolton - */ - -#import "Miscellaneous.h" - -#ifdef MM_ENABLE_PLUGINS - -static int MMPlugInArchMajorVersion = 1; -static int MMPlugInArchMinorVersion = 0; - -#import "PlugInImpl.h" -#import "PlugInGUI.h" -#import "MMPlugInManager.h" -#import "RBSplitView.h" -#import "MMAppController.h" -#import "MMVimController.h" - - -@implementation MMPlugInInstanceMediator - -- (void)setupDrawer -{ - // XXX The drawer does not work in full screen mode. Eventually, the - // drawer will go away so I'm ignoring this issue for now. - drawer = [[NSDrawer alloc] initWithContentSize:NSMakeSize(200,100) - preferredEdge:NSMinXEdge]; - - - NSSize contentSize = [drawer contentSize]; - - // XXX memory management for this - MMPlugInViewContainer *containerView = [[MMPlugInViewContainer alloc] - initWithFrame:NSMakeRect(0, 0, contentSize.width, contentSize.height)]; - - [drawer setContentView:containerView]; - - [containerView release]; - - [drawer setParentWindow:[[vimController windowController] window]]; -} - -- (void)toggleDrawer -{ - [drawer toggle:nil]; - [[NSUserDefaults standardUserDefaults] - setBool:[drawer state] == NSDrawerOpenState - || [drawer state] == NSDrawerOpeningState - forKey:MMShowLeftPlugInContainerKey]; -} - -- (void)initializeInstances -{ - NSArray *plugInClasses = [[MMPlugInManager sharedManager] plugInClasses]; - int i, count = [plugInClasses count]; - for (i = 0; i < count; i++) { - Class plugInClass = [plugInClasses objectAtIndex:i]; - if ([plugInClass instancesRespondToSelector: - @selector(initWithMediator:)]) { - id instance = [[[plugInClass alloc] initWithMediator:self] autorelease]; - [instances addObject:instance]; - } - } -} - -- (id)initWithVimController:(MMVimController *)controller -{ - if ((self = [super init]) == nil) return nil; - vimController = controller; - instances = [[NSMutableArray alloc] init]; - plugInViews = [[NSMutableArray alloc] init]; - - [self setupDrawer]; - [self initializeInstances]; - - return self; -} - -- (void)dealloc -{ - ASLogDebug(@""); - - [plugInViews release]; plugInViews = nil; - [instances release]; instances = nil; - [drawer release]; drawer = nil; - vimController = nil; - - [super dealloc]; -} - -- (id)evaluateVimExpression:(NSString *)vimExpression -{ - NSString *errstr = nil; - id res = [vimController evaluateVimExpressionCocoa:vimExpression - errorString:&errstr]; - if (!res) { - // Setting format to %@ instead of just passing errstr avoids warning. - [NSException raise:@"VimEvaluationException" format:@"%@", errstr]; - } - - return res; -} - -- (void)addVimInput:(NSString *)input -{ - [vimController addVimInput:input]; -} - -- (void)addPlugInView:(NSView *)view withTitle:(NSString *)title -{ - // Do this here so that the drawer is never opened automatically when there - // are no plugin views. - if ([[NSUserDefaults standardUserDefaults] - boolForKey:MMShowLeftPlugInContainerKey] && [plugInViews count] == 0) - [drawer open]; - - MMPlugInViewController *newView = - [[MMPlugInViewController alloc] initWithView:view title:title]; - - [plugInViews addObject:newView]; - - [newView moveToContainer:(MMPlugInViewContainer *)[drawer contentView]]; - - [newView release]; -} - -- (void)openFiles:(NSArray *)filenames -{ - [vimController dropFiles:filenames forceOpen:YES]; -} - -- (id)instanceWithClass:(Class)class -{ - int i, count = [instances count]; - for (i = 0; i < count; i++) { - id instance = [instances objectAtIndex:i]; - if ([instance isKindOfClass:class]) - return instance; - } - - return nil; -} - -@end - -@implementation MMPlugInAppMediator - -MMPlugInAppMediator *sharedAppMediator = nil; - -+ (MMPlugInAppMediator *)sharedAppMediator -{ - if (sharedAppMediator == nil) - sharedAppMediator = [[MMPlugInAppMediator alloc] init]; - - return sharedAppMediator; -} - -- (id)init -{ - if ((self = [super init]) == nil) return nil; - - NSString *title = NSLocalizedString(@"Toggle Left Drawer", - @"Toggle Left Drawer menu title"); - NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title - action:@selector(toggleLeftDrawer:) - keyEquivalent:@""] autorelease]; - [item setTarget:self]; - [self addPlugInMenuItem:item]; - [self addPlugInMenuItem:[NSMenuItem separatorItem]]; - - return self; -} - -- (void)toggleLeftDrawer:(id)sender -{ - MMVimController *c = [[MMAppController sharedInstance] keyVimController]; - - [[c instanceMediator] toggleDrawer]; -} - -- (BOOL)validateMenuItem:(NSMenuItem *)item -{ - return [[MMAppController sharedInstance] keyVimController] != nil; -} - -- (void)addPlugInMenuItem:(NSMenuItem *)menuItem -{ - NSAssert(menuItem, @"menuItem cannot be nil"); - [[MMAppController sharedInstance] addItemToPlugInMenu:menuItem]; -} - -// It is a little bit ugly having to pass the class in here. An alternative -// would be to have a 1:1 relationship between app mediators and plugins, so -// that we'd know exactly which plugin class to look for. -- (id)keyPlugInInstanceWithClass:(Class)class -{ - MMVimController *keyVimController = [[NSApp delegate] keyVimController]; - - if (keyVimController) - return [[keyVimController instanceMediator] instanceWithClass:class]; - - return nil; -} - -- (int)majorVersion -{ - return MMPlugInArchMajorVersion; -} - -- (int)minorVersion -{ - return MMPlugInArchMinorVersion; -} - -@end - -#endif diff --git a/src/MacVim/PlugInInterface.h b/src/MacVim/PlugInInterface.h deleted file mode 100644 index dbbf4b64f8..0000000000 --- a/src/MacVim/PlugInInterface.h +++ /dev/null @@ -1,72 +0,0 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: - * - * VIM - Vi IMproved by Bram Moolenaar - * MacVim GUI port by Bjorn Winckler - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - -// This header file should include everything that a plug-in will need so that -// it is all we need to distribute for plug-in developers. - -/* - * PlugInAppMediator - * - * The interface that the plugin may use to interact with the MacVim - * application. - * - * PlugInInstanceMediator - * - * The interface that a plugin may use to interact with a specific vim instance - * within MacVim. - * - * PlugInProtocol - * - * The protocol which the principal class of the plugin must conform to. - * - * Author: Matt Tolton - * - */ - -@protocol PlugInAppMediator - -- (void)addPlugInMenuItem:(NSMenuItem *)menuItem; - -// Returns the plugin instance of the specified class associated with the key vim window. -// If a vim window is not the key window, returns nil. -// If there are no instances with the specified class, returns nil. -- (id)keyPlugInInstanceWithClass:(Class)class; - -// Plugin architecture version. Major versions indicate API incompatibilities. -// Minor versions may include additions, but nothing that should break current -// plugins. -- (int)majorVersion; -- (int)minorVersion; - -@end - -@protocol PlugInInstanceMediator - -// vim values are converted into NSNumber, NSString, NSArray, and NSDictionary -- (id)evaluateVimExpression:(NSString *)vimExpression; -- (void)addVimInput:(NSString *)input; -- (void)openFiles:(NSArray *)fileNames; -- (void)addPlugInView:(NSView *)view withTitle:(NSString *)title; - -@end - -@protocol PlugInProtocol -// The mediator should not be retained. It will exist until terminatePlugIn is -// called. -+ (BOOL)initializePlugIn:(id)mediator; -+ (void)terminatePlugIn; -@end - -@interface NSObject (PlugInProtocol) -// The mediator should not be retained. It will exist until it releases this -// plugin instance, and is not valid after that. -- (id)initWithMediator:(id)mediator; -@end - diff --git a/src/MacVim/PlugInView.nib/classes.nib b/src/MacVim/PlugInView.nib/classes.nib deleted file mode 100644 index ae787f49da..0000000000 --- a/src/MacVim/PlugInView.nib/classes.nib +++ /dev/null @@ -1,98 +0,0 @@ - - - - - IBClasses - - - CLASS - MMPlugInView - LANGUAGE - ObjC - OUTLETS - - controller - MMPlugInViewController - - SUPERCLASS - RBSplitSubview - - - CLASS - MMPlugInViewController - LANGUAGE - ObjC - OUTLETS - - contentView - NSView - headerView - MMPlugInViewHeader - plugInSubview - RBSplitSubview - titleField - NSTextField - - SUPERCLASS - NSObject - - - CLASS - RBSplitView - LANGUAGE - ObjC - OUTLETS - - delegate - id - - SUPERCLASS - RBSplitSubview - - - CLASS - RBSplitSubview - LANGUAGE - ObjC - SUPERCLASS - NSView - - - CLASS - FirstResponder - LANGUAGE - ObjC - SUPERCLASS - NSObject - - - ACTIONS - - didAdjustSubviews - RBSplitView - willAdjustSubviews - RBSplitView - - CLASS - NSObject - LANGUAGE - ObjC - - - CLASS - MMPlugInViewHeader - LANGUAGE - ObjC - OUTLETS - - controller - MMPlugInViewController - - SUPERCLASS - NSView - - - IBVersion - 1 - - diff --git a/src/MacVim/PlugInView.nib/info.nib b/src/MacVim/PlugInView.nib/info.nib deleted file mode 100644 index 668fd0b86d..0000000000 --- a/src/MacVim/PlugInView.nib/info.nib +++ /dev/null @@ -1,20 +0,0 @@ - - - - - IBFramework Version - 629 - IBLastKnownRelativeProjectPath - ../MacVim.xcodeproj - IBOldestOS - 5 - IBOpenObjects - - 6 - - IBSystem Version - 9D34 - targetFramework - IBCocoaFramework - - diff --git a/src/MacVim/PlugInView.nib/keyedobjects.nib b/src/MacVim/PlugInView.nib/keyedobjects.nib deleted file mode 100644 index 28b0310c15..0000000000 Binary files a/src/MacVim/PlugInView.nib/keyedobjects.nib and /dev/null differ diff --git a/src/MacVim/RBSplitSubview.h b/src/MacVim/RBSplitSubview.h deleted file mode 100644 index d058230526..0000000000 --- a/src/MacVim/RBSplitSubview.h +++ /dev/null @@ -1,146 +0,0 @@ -// -// RBSplitSubview.h version 1.1.4 -// RBSplitView -// -// Created by Rainer Brockerhoff on 19/11/2004. -// Copyright 2004-2006 Rainer Brockerhoff. -// Some Rights Reserved under the Creative Commons Attribution License, version 2.5, and/or the MIT License. -// - -#import - -@class RBSplitView; - -// These values are used to inquire about the status of a subview. -typedef enum { - RBSSubviewExpanding=-2, - RBSSubviewCollapsing=-1, - RBSSubviewNormal=0, - RBSSubviewCollapsed=1 -} RBSSubviewStatus; - -@interface RBSplitSubview : NSView { -// Subclasses normally should use setter methods instead of changing instance variables by assignment. -// Most getter methods simply return the corresponding instance variable, so with some care, subclasses -// could reference them directly. - NSString* identifier; // An identifier string for the subview, default is @"". - int tag; // A tag integer for the subview, default is 0. - float minDimension; // The minimum dimension. Must be 1.0 or any larger integer. - float maxDimension; // The maximum dimension. Must be at least equal to the minDimension. - // Set to a large number if there's no maximum. - double fraction; // A fractional part of the dimension, used for proportional resizing. - // Normally varies between -0.999... and 0.999... - // When collapsed, holds the proportion of the RBSplitView's dimension - // the view was occupying before collapsing. - NSRect previous; // Holds the frame rect for the last delegate notification. - NSSize savedSize; // This holds the size the subview had before it was resized beyond - // its minimum or maximum limits. Valid if notInLimits is YES. - unsigned int actDivider; // This is set temporarily while an alternate drag view is being dragged. - BOOL canDragWindow; // This is set temporarily during a mouseDown on a non-opaque subview. - BOOL canCollapse; // YES if the subview can be collapsed. - BOOL notInLimits; // YES if the subview's dimensions are outside the set limits. -} - -// This class method returns YES if some RBSplitSubview is being animated. -+ (BOOL)animating; - -// This is the designated initializer for creating extra subviews programmatically. -- (id)initWithFrame:(NSRect)frame; - -// Returns the immediately containing RBSplitView, or nil if there is none. -// couplingSplitView returns nil if we're a non-coupled RBSplitView. -// outermostSplitView returns the outermost RBSplitView. -- (RBSplitView*)splitView; -- (RBSplitView*)couplingSplitView; -- (RBSplitView*)outermostSplitView; - -// Returns self if we're a RBSplitView, nil otherwise. Convenient for testing or calling methods. -// coupledSplitView returns nil if we're a non-coupled RBSplitView. -- (RBSplitView*)asSplitView; -- (RBSplitView*)coupledSplitView; - -// Sets and gets the coupling between the view and its containing RBSplitView (if any). Coupled -// RBSplitViews take some parameters, such as divider images, from the containing view. The default -// for RBSplitView is YES. However, calling setCoupled: on a RBSplitSubview will have no effect, -// and isCoupled will always return false. -- (void)setCoupled:(BOOL)flag; -- (BOOL)isCoupled; - -// Returns YES if the containing RBSplitView is horizontal. -- (BOOL)splitViewIsHorizontal; - -// Returns the number of subviews. Just a convenience method. -- (unsigned)numberOfSubviews; - -// Sets and gets the tag. -- (void)setTag:(int)theTag; -- (int)tag; - -// Sets and gets the identifier string. Will never be nil. -- (void)setIdentifier:(NSString*)aString; -- (NSString*)identifier; - -// Position means the subview's position within the RBSplitView - counts from zero left to right -// or top to bottom. Setting it will move the subview to another position without changing its size, -// status or attributes. Set position to 0 to move it to the start, or to some large number to move it -// to the end of the RBSplitView. -- (unsigned)position; -- (void)setPosition:(unsigned)newPosition; - -// Returns YES if the subview is collapsed. Collapsed subviews are squashed down to zero but never -// made smaller than the minimum dimension as far as their own subviews are concerned. If the -// subview is being animated this will return NO. -- (BOOL)isCollapsed; - -// This will return the current status of the subview. Negative values mean the subview is -// being animated. -- (RBSSubviewStatus)status; - -// Sets and gets the ability to collapse the subview. However, this can be overridden by the delegate. -- (BOOL)canCollapse; -- (void)setCanCollapse:(BOOL)flag; - -// Tests whether the subview can shrink or expand further. -- (BOOL)canShrink; -- (BOOL)canExpand; - -// Sets and gets the minimum and maximum dimensions. They're set at the same time to make sure values -// are consistent. Despite being floats, they'll always have integer values. The minimum value for the -// minimum is 1.0. Pass 0.0 for the maximum to set it to some huge number. -- (float)minDimension; -- (float)maxDimension; -- (void)setMinDimension:(float)newMinDimension andMaxDimension:(float)newMaxDimension; - -// Call this to expand a subview programmatically. It will return the subview's dimension after -// expansion. -- (float)expand; - -// Call this to collapse a subview programmatically. It will return the negative -// of the subview's dimension _before_ collapsing, or 0.0 if the subview can't be collapsed. -- (float)collapse; - -// These calls collapse and expand subviews with animation. They return YES if animation -// startup was successful. -- (BOOL)collapseWithAnimation; -- (BOOL)expandWithAnimation; - -// These methods collapse and expand subviews with animation, depending on the parameters. -// They return YES if animation startup was successful. If resize is NO, the subview is -// collapsed/expanded without resizing it during animation. -- (BOOL)collapseWithAnimation:(BOOL)animate withResize:(BOOL)resize; -- (BOOL)expandWithAnimation:(BOOL)animate withResize:(BOOL)resize; - -// Returns the current dimension of the subview. -- (float)dimension; - -// Sets the current dimension of the subview, subject to the current maximum and minimum. -// If the subview is collapsed, this has no immediate effect. -- (void)setDimension:(float)value; - -// This method is used internally when a divider is dragged. It tries to change the subview's dimension -// and returns the actual change, collapsing or expanding whenever possible. You usually won't need -// to call this directly. -- (float)changeDimensionBy:(float)increment mayCollapse:(BOOL)mayCollapse move:(BOOL)move; - -@end - diff --git a/src/MacVim/RBSplitSubview.m b/src/MacVim/RBSplitSubview.m deleted file mode 100644 index 60a01ded57..0000000000 --- a/src/MacVim/RBSplitSubview.m +++ /dev/null @@ -1,929 +0,0 @@ -// -// RBSplitSubview.m version 1.1.4 -// RBSplitView -// -// Created by Rainer Brockerhoff on 19/11/2004. -// Copyright 2004-2006 Rainer Brockerhoff. -// Some Rights Reserved under the Creative Commons Attribution License, version 2.5, and/or the MIT License. -// -#ifdef MM_ENABLE_PLUGINS - -#import "RBSplitView.h" -#import "RBSplitViewPrivateDefines.h" - -// This variable points to the animation data structure while an animation is in -// progress; if there's none, it will be NULL. Animating may be very CPU-intensive so -// we allow only one animation to take place at a time. -static animationData* currentAnimation = NULL; - -@implementation RBSplitSubview - -// This class method returns YES if an animation is in progress. -+ (BOOL)animating { - return currentAnimation!=NULL; -} - -// This is the designated initializer for RBSplitSubview. It sets some reasonable defaults. However, you -// can't rely on anything working until you insert it into a RBSplitView. -- (id)initWithFrame:(NSRect)frame { - self = [super initWithFrame:frame]; - if (self) { - fraction = 0.0; - canCollapse = NO; - notInLimits = NO; - minDimension = 1.0; - maxDimension = WAYOUT; - identifier = @""; - previous = NSZeroRect; - savedSize = frame.size; - actDivider = NSNotFound; - canDragWindow = NO; - } - return self; -} - -// Just releases our stuff when going away. -- (void)dealloc { - [identifier release]; - [super dealloc]; -} - -// These return nil since we're not a RBSplitView (they're overridden there). -- (RBSplitView*)asSplitView { - return nil; -} - -- (RBSplitView*)coupledSplitView { - return nil; -} - -// Sets and gets the coupling between a RBSplitView and its containing RBSplitView (if any). -// For convenience, these methods are also implemented here. -- (void)setCoupled:(BOOL)flag { -} - -- (BOOL)isCoupled { - return NO; -} - -// RBSplitSubviews are never flipped, unless they're RBSplitViews. -- (BOOL)isFlipped { - return NO; -} - -// We copy the opacity of the owning split view. -- (BOOL)isOpaque { - return [[self couplingSplitView] isOpaque]; -} - -// A hidden RBSplitSubview is not redrawn and is not considered for drawing dividers. -// This won't work before 10.3, though. -- (void)setHidden:(BOOL)flag { - if ([self isHidden]!=flag) { - RBSplitView* sv = [self splitView]; - [self RB___setHidden:flag]; - if (flag) { - [sv adjustSubviews]; - } else { - [sv adjustSubviewsExcepting:self]; - } - } -} - -// RBSplitSubviews can't be in the responder chain. -- (BOOL)acceptsFirstResponder { - return NO; -} - -// Mousing down should move the window only for a completely transparent background. This might have -// unintended side effects in metal windows, so for those you might want to use a background color -// with a very low alpha (0.01 for instance). -// This is commented out as I'm still experimenting with it. -/*- (BOOL)mouseDownCanMoveWindow { - RBSplitView* sv = [self asSplitView]; - if (!sv) { - sv = [self couplingSplitView]; - } - return [sv background]==nil; - return YES; -}*/ - -// This returns the owning splitview. It's guaranteed to return a RBSplitView or nil. -// You should avoid having "orphan" RBSplitSubviews, or at least manipulating -// them while they're not inserted in a RBSplitView. -- (RBSplitView*)splitView { - id result = [self superview]; - if ([result isKindOfClass:[RBSplitView class]]) { - return (RBSplitView*)result; - } - return nil; -} - -// This also returns the owning splitview. It's overridden for nested RBSplitViews. -- (RBSplitView*)couplingSplitView { - id result = [self superview]; - if ([result isKindOfClass:[RBSplitView class]]) { - return (RBSplitView*)result; - } - return nil; -} - -// This returns the outermost directly containing RBSplitView, or nil. -- (RBSplitView*)outermostSplitView { - id result = nil; - id sv = self; - while ((sv = [sv superview])&&[sv isKindOfClass:[RBSplitView class]]) { - result = sv; - } - return result; -} - -// This convenience method returns YES if the containing RBSplitView is horizontal. -- (BOOL)splitViewIsHorizontal { - return [[self splitView] isHorizontal]; -} - -// You can use either tags (ints) or identifiers (NSStrings) to identify individual subviews. -// We take care not to have nil identifiers. -- (void)setTag:(int)theTag { - tag = theTag; -} - -- (int)tag { - return tag; -} - -- (void)setIdentifier:(NSString*)aString { - [identifier autorelease]; - identifier = aString?[aString retain]:@""; -} - -- (NSString*)identifier { - return identifier; -} - -// If we have an identifier, this will make debugging a little easier by appending it to the -// default description. -- (NSString*)description { - return [identifier length]>0?[NSString stringWithFormat:@"%@(%@)",[super description],identifier]:[super description]; -} - -// This pair of methods allows you to get and change the position of a subview (within the split view); -// this counts from zero from the left or top of the split view. -- (unsigned)position { - RBSplitView* sv = [self splitView]; - return sv?[[sv subviews] indexOfObjectIdenticalTo:self]:0; -} - -- (void)setPosition:(unsigned)newPosition { - RBSplitView* sv = [self splitView]; - if (sv) { - [self retain]; - [self removeFromSuperviewWithoutNeedingDisplay]; - NSArray* subviews = [sv subviews]; - if (newPosition>=[subviews count]) { - [sv addSubview:self positioned:NSWindowAbove relativeTo:nil]; - } else { - [sv addSubview:self positioned:NSWindowBelow relativeTo:[subviews objectAtIndex:newPosition]]; - } - [self release]; - } -} - -// Tests whether the subview is collapsed. -- (BOOL)isCollapsed { - return [self RB___visibleDimension]<=0.0; -} - -// Tests whether the subview can shrink further. -- (BOOL)canShrink { - return [self RB___visibleDimension]>([self canCollapse]?0.0:minDimension); -} - -// Tests whether the subview can expand further. -- (BOOL)canExpand { - return [self RB___visibleDimension]collapsing?RBSSubviewCollapsing:RBSSubviewExpanding; - } - return [self RB___visibleDimension]<=0.0?RBSSubviewCollapsed:RBSSubviewNormal; -} - -// Tests whether the subview can be collapsed. The local instance variable will be overridden by the -// delegate method if it's implemented. -- (BOOL)canCollapse { - BOOL result = canCollapse; - RBSplitView* sv = [self splitView]; - if ([sv RB___numberOfSubviews]<2) { - return NO; - } - id delegate = [sv delegate]; - if ([delegate respondsToSelector:@selector(splitView:canCollapse:)]) { - result = [delegate splitView:sv canCollapse:self]; - } - return result; -} - -// This sets the subview's "canCollapse" flag. Ignored if the delegate's splitView:canCollapse: -// method is implemented. -- (void)setCanCollapse:(BOOL)flag { - canCollapse = flag; -} - -// This expands a collapsed subview and calls the delegate's splitView:didExpand: method, if it exists. -// This is not called internally by other methods; call this to expand a subview programmatically. -// As a convenience to other methods, it returns the subview's dimension after expanding (this may be -// off by 1 pixel due to rounding) or 0.0 if it couldn't be expanded. -// The delegate should not change the subview's frame. -- (float)expand { - return [self RB___expandAndSetToMinimum:NO]; -} - -// This collapses an expanded subview and calls the delegate's splitView:didCollapse: method, if it exists. -// This is not called internally by other methods; call this to expand a subview programmatically. -// As a convenience to other methods, it returns the negative of the subview's dimension before -// collapsing (or 0.0 if it couldn't be collapsed). -// The delegate should not change the subview's frame. -- (float)collapse { - return [self RB___collapse]; -} - -// This tries to collapse the subview with animation, and collapses it instantly if some other -// subview is animating. Returns YES if animation was started successfully. -- (BOOL)collapseWithAnimation { - return [self collapseWithAnimation:YES withResize:YES]; -} - -// This tries to expand the subview with animation, and expands it instantly if some other -// subview is animating. Returns YES if animation was started successfully. -- (BOOL)expandWithAnimation { - return [self expandWithAnimation:YES withResize:YES]; -} - -// These methods collapse and expand subviews with animation, depending on the parameters. -// They return YES if animation startup was successful. If resize is NO, the subview is -// collapsed/expanded without resizing it during animation. -- (BOOL)collapseWithAnimation:(BOOL)animate withResize:(BOOL)resize { - if ([self status]==RBSSubviewNormal) { - if ([self canCollapse]) { - if (animate&&[self RB___animationData:YES resize:resize]) { - [self RB___clearResponder]; - [self RB___stepAnimation]; - return YES; - } else { - [self RB___collapse]; - } - } - } - return NO; -} - -- (BOOL)expandWithAnimation:(BOOL)animate withResize:(BOOL)resize { - if ([self status]==RBSSubviewCollapsed) { - if (animate&&[self RB___animationData:YES resize:resize]) { - [self RB___stepAnimation]; - return YES; - } else { - [self RB___expandAndSetToMinimum:NO]; - } - } - return NO; -} - - -// These 3 methods get and set the view's minimum and maximum dimensions. -// The minimum dimension ought to be an integer at least equal to 1.0 but we make sure. -// The maximum dimension ought to be an integer at least equal to the minimum. As a convenience, -// pass in zero to set it to some huge number. -- (float)minDimension { - return minDimension; -} - -- (float)maxDimension { - return maxDimension; -} - -- (void)setMinDimension:(float)newMinDimension andMaxDimension:(float)newMaxDimension { - minDimension = MAX(1.0,floorf(newMinDimension)); - if (newMaxDimension<1.0) { - newMaxDimension = WAYOUT; - } - maxDimension = MAX(minDimension,floorf(newMaxDimension)); - float dim = [self dimension]; - if ((dimmaxDimension)) { - [[self splitView] setMustAdjust]; - } -} - -// This returns the subview's dimension. If it's collapsed, it returns the dimension it would have -// after expanding. -- (float)dimension { - float dim = [self RB___visibleDimension]; - if (dim<=0.0) { - dim = [[self splitView] RB___dimensionWithoutDividers]*fraction; - if (dimmaxDimension) { - dim = maxDimension; - } - } - return dim; -} - -// Sets the current dimension of the subview, subject to the current maximum and minimum. -// If the subview is collapsed, this will have an effect only after reexpanding. -- (void)setDimension:(float)value { - RBSplitView* sv = [self splitView]; - NSSize size = [self frame].size; - BOOL ishor = [sv isHorizontal]; - if (DIM(size)>0.0) { -// We're not collapsed, set the size and adjust other subviews. - DIM(size) = value; - [self setFrameSize:size]; - [sv adjustSubviewsExcepting:self]; - } else { -// We're collapsed, adjust the fraction so that we'll have the (approximately) correct -// dimension after expanding. - fraction = value/[sv RB___dimensionWithoutDividers]; - } -} - -// This just draws the background of a subview, then tells the delegate, if any. -// The delegate would usually draw a frame inside the subview. -- (void)drawRect:(NSRect)rect { - RBSplitView* sv = [self splitView]; - NSColor* bg = [sv background]; - if (bg) { - [bg set]; - NSRectFillUsingOperation(rect,NSCompositeSourceOver); - } - id del = [sv delegate]; - if ([del respondsToSelector:@selector(splitView:willDrawSubview:inRect:)]) { - [del splitView:sv willDrawSubview:self inRect:rect]; - } -} - -// We check if the RBSplitView must be adjusted before redisplaying programmatically. -// if so, we adjust and display the whole RBSplitView. -- (void)display { - RBSplitView* sv = [self splitView]; - if (sv) { - if ([sv mustAdjust]) { - [sv display]; - } else { - [super display]; - } - } -} - -// RBSplitSubviews will always resize their own subviews. -- (BOOL)autoresizesSubviews { - return YES; -} - -// This is method is called automatically when the subview is resized; don't call it yourself. -- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { - RBSplitView* sv = [self splitView]; - if (sv) { - BOOL ishor = [sv isHorizontal]; - NSRect frame = [self frame]; - float dim = DIM(frame.size); - float other = OTHER(frame.size); -// We resize subviews only when we're inside the subview's limits and the containing splitview's limits. - animationData* anim = [self RB___animationData:NO resize:NO]; - if ((dim>=(anim&&!anim->resizing?anim->dimension:minDimension))&&(dim<=maxDimension)&&(other>=[sv minDimension])&&(other<=[sv maxDimension])) { - if (notInLimits) { -// The subviews can be resized, so we restore the saved size. - oldBoundsSize = savedSize; - } -// We save the size every time the subview's subviews are resized within the limits. - notInLimits = NO; - savedSize = frame.size; - [super resizeSubviewsWithOldSize:oldBoundsSize]; - } else { - notInLimits = YES; - } - } -} - -// This method is used internally when a divider is dragged. It tries to change the subview's dimension -// and returns the actual change, collapsing or expanding whenever possible. You usually won't need -// to call this directly. -- (float)changeDimensionBy:(float)increment mayCollapse:(BOOL)mayCollapse move:(BOOL)move { - RBSplitView* sv = [self splitView]; - if (!sv||(fabsf(increment)<1.0)) { - return 0.0; - } - BOOL ishor = [sv isHorizontal]; - NSRect frame = [self frame]; - float olddim = DIM(frame.size); - float newdim = MAX(0.0,olddim+increment); - if (newdimolddim) { - if (olddim<1.0) { -// Expand if needed. - if (newdim>(minDimension*(0.5+HYSTERESIS))) { - newdim = MAX(newdim,[self RB___expandAndSetToMinimum:YES]); - } else { - return 0.0; - } - } - if (newdim>maxDimension) { - newdim = maxDimension; - } - } - if ((int)newdim!=(int)olddim) { -// The dimension has changed. - increment = newdim-olddim; - DIM(frame.size) = newdim; - if (move) { - DIM(frame.origin) -= increment; - } -// We call super instead of self here to postpone adjusting subviews for nested splitviews. -// [super setFrameSize:frame.size]; - [super setFrame:frame]; - [sv RB___setMustClearFractions]; - [sv setMustAdjust]; - } - return newdim-olddim; -} - -// This convenience method returns the number of subviews (surprise!) -- (unsigned)numberOfSubviews { - return [[self subviews] count]; -} - -// We return the deepest subview that's hit by aPoint. We also check with the delegate if aPoint is -// within an alternate drag view. -- (NSView*)hitTest:(NSPoint)aPoint { - RBSplitView* sv = [self splitView]; - if ([self mouse:aPoint inRect:[self frame]]) { - id delegate = [sv delegate]; - if ([delegate respondsToSelector:@selector(splitView:dividerForPoint:inSubview:)]) { - actDivider = [delegate splitView:sv dividerForPoint:aPoint inSubview:self]; - if ((int)actDivider<(int)([sv RB___numberOfSubviews]-1)) { - return self; - } - } - actDivider = NSNotFound; - NSView* result = [super hitTest:aPoint]; - canDragWindow = ![result isOpaque]; - return result; - } - return nil; -} - -// This method handles clicking and dragging in an empty portion of the subview, or in an alternate -// drag view as designated by the delegate. -- (void)mouseDown:(NSEvent*)theEvent { - NSWindow* window = [self window]; - NSPoint where = [theEvent locationInWindow]; - if (actDivider=WAYOUT) { -// The subview was collapsed when encoded, so we correct the origin and collapse it. - BOOL ishor = [self splitViewIsHorizontal]; - previous.origin.x -= WAYOUT; - DIM(previous.size) = 0.0; - [self setFrameOrigin:previous.origin]; - [self setFrameSize:previous.size]; - } - previous = NSZeroRect; - if ([coder allowsKeyedCoding]) { - [self setIdentifier:[coder decodeObjectForKey:@"identifier"]]; - tag = [coder decodeIntForKey:@"tag"]; - minDimension = [coder decodeFloatForKey:@"minDimension"]; - maxDimension = [coder decodeFloatForKey:@"maxDimension"]; - fraction = [coder decodeDoubleForKey:@"fraction"]; - canCollapse = [coder decodeBoolForKey:@"canCollapse"]; - } else { - [self setIdentifier:[coder decodeObject]]; - [coder decodeValueOfObjCType:@encode(typeof(tag)) at:&tag]; - [coder decodeValueOfObjCType:@encode(typeof(minDimension)) at:&minDimension]; - [coder decodeValueOfObjCType:@encode(typeof(maxDimension)) at:&maxDimension]; - [coder decodeValueOfObjCType:@encode(typeof(fraction)) at:&fraction]; - [coder decodeValueOfObjCType:@encode(typeof(canCollapse)) at:&canCollapse]; - } - } - return self; -} - -@end - -@implementation RBSplitSubview (RB___SubviewAdditions) - -// This hides/shows the subview without calling adjustSubview. -- (void)RB___setHidden:(BOOL)flag { - [super setHidden:flag]; -} - -// This internal method returns the current animationData. It will always return nil if -// the receiver isn't the current owner and some other subview is already being animated. -// Otherwise, if the parameter is YES, a new animation will be started (or the current -// one will be restarted). -- (animationData*)RB___animationData:(BOOL)start resize:(BOOL)resize { - if (currentAnimation&&(currentAnimation->owner!=self)) { -// There already is an animation in progress on some other subview. - return nil; - } - if (start) { -// We want to start (or restart) an animation. - RBSplitView* sv = [self splitView]; - if (sv) { - float dim = [self dimension]; -// First assume the default time, then ask the delegate. - NSTimeInterval total = dim*(0.2/150.0); - id delegate = [sv delegate]; - if ([delegate respondsToSelector:@selector(splitView:willAnimateSubview:withDimension:)]) { - total = [delegate splitView:sv willAnimateSubview:self withDimension:dim]; - } -// No use animating anything shorter than the frametime. - if (total>FRAMETIME) { - if (!currentAnimation) { - currentAnimation = (animationData*)malloc(sizeof(animationData)); - } - if (currentAnimation) { - currentAnimation->owner = self; - currentAnimation->stepsDone = 0; - currentAnimation->elapsedTime = 0.0; - currentAnimation->dimension = dim; - currentAnimation->collapsing = ![self isCollapsed]; - currentAnimation->totalTime = total; - currentAnimation->finishTime = [NSDate timeIntervalSinceReferenceDate]+total; - currentAnimation->resizing = resize; - [sv RB___setDragging:YES]; - } - } else if (currentAnimation) { - free(currentAnimation); - currentAnimation = NULL; - } - } - } - return currentAnimation; -} - -// This internal method steps the animation to the next frame. -- (void)RB___stepAnimation { - NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; - animationData* anim = [self RB___animationData:NO resize:NO]; - if (anim) { - RBSplitView* sv = [self splitView]; - NSTimeInterval remain = anim->finishTime-now; - NSRect frame = [self frame]; - BOOL ishor = [sv isHorizontal]; -// Continuing animation only makes sense if we still have at least FRAMETIME available. - if (remain>=FRAMETIME) { - float dim = DIM(frame.size); - float avg = anim->elapsedTime; -// We try to keep a record of how long it takes, on the average, to resize and adjust -// one animation frame. - if (anim->stepsDone) { - avg /= anim->stepsDone; - } - NSTimeInterval delay = MIN(0.0,FRAMETIME-avg); -// We adjust the new dimension proportionally to how much of the designated time has passed. - dim = floorf(anim->dimension*(remain-avg)/anim->totalTime); - if (dim>4.0) { - if (!anim->collapsing) { - dim = anim->dimension-dim; - } - DIM(frame.size) = dim; - [self RB___setFrame:frame withFraction:0.0 notify:NO]; - [sv adjustSubviews]; - [self display]; - anim->elapsedTime += [NSDate timeIntervalSinceReferenceDate]-now; - ++anim->stepsDone; -// Schedule a timer to do the next animation step. - [self performSelector:@selector(RB___stepAnimation) withObject:nil afterDelay:delay inModes:[NSArray arrayWithObjects:NSDefaultRunLoopMode,NSModalPanelRunLoopMode, - NSEventTrackingRunLoopMode,nil]]; - return; - } - } -// We're finished, either collapse or expand entirely now. - if (anim->collapsing) { - DIM(frame.size) = 0.0; - [self RB___finishCollapse:frame withFraction:anim->dimension/[sv RB___dimensionWithoutDividers]]; - } else { - float savemin,savemax; - float dim = [self RB___setMinAndMaxTo:anim->dimension savingMin:&savemin andMax:&savemax]; - DIM(frame.size) = dim; - [self RB___finishExpand:frame withFraction:0.0]; - minDimension = savemin; - maxDimension = savemax; - } - } -} - -// This internal method stops the animation, if the receiver is being animated. It will -// return YES if the animation was stopped. -- (BOOL)RB___stopAnimation { - if (currentAnimation&&(currentAnimation->owner==self)) { - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(RB___stepAnimation) object:nil]; - free(currentAnimation); - currentAnimation = NULL; - [[self splitView] RB___setDragging:NO]; - return YES; - } - return NO; -} - -// This internal method returns the actual visible dimension of the subview. Differs from -dimension in -// that it returns 0.0 if the subview is collapsed. -- (float)RB___visibleDimension { - BOOL ishor = [self splitViewIsHorizontal]; - NSRect frame = [self frame]; - return MAX(0.0,DIM(frame.size)); -} - -// This pair of internal methods is used only inside -[RBSplitView adjustSubviews] to copy subview data -// from and to that method's internal cache. -- (void)RB___copyIntoCache:(subviewCache*)cache { - cache->sub = self; - cache->rect = [self frame]; - cache->size = [self RB___visibleDimension]; - cache->fraction = fraction; - cache->constrain = NO; -} - -- (void)RB___updateFromCache:(subviewCache*)cache withTotalDimension:(float)value { - float dim = [self RB___visibleDimension]; - if (cache->size>=1.0) { -// New state is not collapsed. - if (dim>=1.0) { -// Old state was not collapsed, so we just change the frame. - [self RB___setFrame:cache->rect withFraction:cache->fraction notify:YES]; - } else { -// Old state was collapsed, so we expand it. - [self RB___finishExpand:cache->rect withFraction:cache->fraction]; - } - } else { -// New state is collapsed. - if (dim>=1.0) { -// Old state was not collapsed, so we clear first responder and change the frame. - [self RB___clearResponder]; - [self RB___finishCollapse:cache->rect withFraction:dim/value]; - } else { -// It was collapsed already, but the frame may have changed, so we set it. - [self RB___setFrame:cache->rect withFraction:cache->fraction notify:YES]; - } - } -} - -// This internal method sets minimum and maximum values to the same value, saves the old values, -// and returns the new value (which will be limited to the old values). -- (float)RB___setMinAndMaxTo:(float)value savingMin:(float*)oldmin andMax:(float*)oldmax { - *oldmin = [self minDimension]; - *oldmax = [self maxDimension]; - if (value<*oldmin) { - value = *oldmin; - } - if (value>*oldmax) { - value = *oldmax; - } - minDimension = maxDimension = value; - return value; -} - -// This internal method tries to clear the first responder, if the current responder is a descendant of -// the receiving subview. If so, it will set first responder to nil, redisplay the former responder and -// return YES. Returns NO otherwise. -- (BOOL)RB___clearResponder { - NSWindow* window = [self window]; - if (window) { - NSView* responder = (NSView*)[window firstResponder]; - if (responder&&[responder respondsToSelector:@selector(isDescendantOf:)]) { - if ([responder isDescendantOf:self]) { - if ([window makeFirstResponder:nil]) { - [responder display]; - return YES; - } - } - } - } - return NO; -} - -// This internal method collapses a subview. -// It returns the negative of the size of the subview before collapsing, or 0.0 if it wasn't collapsed. -- (float)RB___collapse { - float result = 0.0; - if (![self isCollapsed]) { - RBSplitView* sv = [self splitView]; - if (sv&&[self canCollapse]) { - [self RB___clearResponder]; - NSRect frame = [self frame]; - BOOL ishor = [sv isHorizontal]; - result = DIM(frame.size); -// For collapsed views, fraction will contain the fraction of the dimension previously occupied - DIM(frame.size) = 0.0; - [self RB___finishCollapse:frame withFraction:result/[sv RB___dimensionWithoutDividers]]; - } - } - return -result; -} - -// This internal method finishes the collapse of a subview, stopping the animation if -// there is one, and calling the delegate method if there is one. -- (void)RB___finishCollapse:(NSRect)rect withFraction:(double)value { - RBSplitView* sv = [self splitView]; - BOOL finish = [self RB___stopAnimation]; - [self RB___setFrame:rect withFraction:value notify:YES]; - [sv RB___setMustClearFractions]; - if (finish) { - [self display]; - } - id delegate = [sv delegate]; - if ([delegate respondsToSelector:@selector(splitView:didCollapse:)]) { - [delegate splitView:sv didCollapse:self]; - } -} - -// This internal method expands a subview. setToMinimum will usually be YES during a divider drag. -// It returns the size of the subview after expanding, or 0.0 if it wasn't expanded. -- (float)RB___expandAndSetToMinimum:(BOOL)setToMinimum { - float result = 0.0; - RBSplitView* sv = [self splitView]; - if (sv&&[self isCollapsed]) { - NSRect frame = [super frame]; - double frac = fraction; - BOOL ishor = [sv isHorizontal]; - if (setToMinimum) { - result = DIM(frame.size) = minDimension; - } else { - result = [sv RB___dimensionWithoutDividers]*frac; -// We need to apply a compensation factor for proportional resizing in adjustSubviews. - float newdim = floorf((frac>=1.0)?result:result/(1.0-frac)); - DIM(frame.size) = newdim; - result = floorf(result); - } - [self RB___finishExpand:frame withFraction:0.0]; - } - return result; -} - -// This internal method finishes the the expansion of a subview, stopping the animation if -// there is one, and calling the delegate method if there is one. -- (void)RB___finishExpand:(NSRect)rect withFraction:(double)value { - RBSplitView* sv = [self splitView]; - BOOL finish = [self RB___stopAnimation]; - [self RB___setFrame:rect withFraction:value notify:YES]; - [sv RB___setMustClearFractions]; - if (finish) { - [self display]; - } - id delegate = [sv delegate]; - if ([delegate respondsToSelector:@selector(splitView:didExpand:)]) { - [delegate splitView:sv didExpand:self]; - } -} - -// These internal methods set the subview's frame or size, and also store a fraction value -// which is used to ensure repeatability when the whole split view is resized. -- (void)RB___setFrame:(NSRect)rect withFraction:(double)value notify:(BOOL)notify { - RBSplitView* sv = [self splitView]; - id delegate = nil; - if (notify) { - delegate = [sv delegate]; -// If the delegate method isn't implemented, we ignore the delegate altogether. - if ([delegate respondsToSelector:@selector(splitView:changedFrameOfSubview:from:to:)]) { -// If the rects are equal, the delegate isn't called. - if (NSEqualRects(previous,rect)) { - delegate = nil; - } - } else { - delegate = nil; - } - } - [sv setMustAdjust]; - [self setFrame:rect]; - fraction = value; - [delegate splitView:sv changedFrameOfSubview:self from:previous to:rect]; - previous = delegate?rect:NSZeroRect; -} - -- (void)RB___setFrameSize:(NSSize)size withFraction:(double)value { - [[self splitView] setMustAdjust]; - [self setFrameSize:size]; - fraction = value; -} - -// This internal method gets the fraction value. -- (double)RB___fraction { - return fraction; -} - -@end - -#endif // MM_ENABLE_PLUGINS diff --git a/src/MacVim/RBSplitView.h b/src/MacVim/RBSplitView.h deleted file mode 100644 index 0c786c2b09..0000000000 --- a/src/MacVim/RBSplitView.h +++ /dev/null @@ -1,225 +0,0 @@ -// -// RBSplitView.h version 1.1.4 -// RBSplitView -// -// Created by Rainer Brockerhoff on 24/09/2004. -// Copyright 2004-2006 Rainer Brockerhoff. -// Some Rights Reserved under the Creative Commons Attribution License, version 2.5, and/or the MIT License. -// - -#import "RBSplitSubview.h" - -// These values are used to handle the various cursor types. -typedef enum { - RBSVHorizontalCursor=0, // appears over horizontal dividers - RBSVVerticalCursor, // appears over vertical dividers - RBSV2WayCursor, // appears over two-way thumbs - RBSVDragCursor, // appears while dragging - RBSVCursorTypeCount -} RBSVCursorType; - -@interface RBSplitView : RBSplitSubview { -// Subclasses normally should use setter methods instead of changing instance variables by assignment. -// Most getter methods simply return the corresponding instance variable, so with some care, subclasses -// could reference them directly. - IBOutlet id delegate; // The delegate (may be nil). - NSString* autosaveName; // This name is used for storing subview proportions in user defaults. - NSColor* background; // The color used to paint the view's background (may be nil). - NSImage* divider; // The image used for the divider "dimple". - NSRect* dividers; // A C array of NSRects, one for each divider. - float dividerThickness; // Actual divider width; should be an integer and at least 1.0. - BOOL mustAdjust; // Set internally if the subviews need to be adjusted. - BOOL mustClearFractions; // Set internally if fractions should be cleared before adjusting. - BOOL isHorizontal; // The divider's orientation; default is vertical. - BOOL canSaveState; // Set internally to allow saving subview state. - BOOL isCoupled; // If YES, take some parameters from the containing RBSplitView, if any. - BOOL isAdjusting; // Set internally while the subviews are being adjusted. - BOOL isDragging; // Set internally while in a drag loop. - BOOL isInScrollView; // Set internally if directly contained in an NSScrollView. -} - -// These class methods get and set the cursor used for each type. -// Pass in nil to reset to the default cursor for that type. -+ (NSCursor*)cursor:(RBSVCursorType)type; -+ (void)setCursor:(RBSVCursorType)type toCursor:(NSCursor*)cursor; - -// This class method clears the saved state for a given autosave name from the defaults. -+ (void)removeStateUsingName:(NSString*)name; - -// This class method returns the actual key used to store autosave data in the defaults. -+ (NSString*)defaultsKeyForName:(NSString*)name isHorizontal:(BOOL)orientation; - -// Sets and gets the autosaveName; this will be the key used to store the subviews' proportions -// in the user defaults. Default is @"", which doesn't save anything. Set flag to YES to set -// unique names for nested subviews. You are responsible for avoiding duplicates. -- (void)setAutosaveName:(NSString*)aString recursively:(BOOL)flag; -- (NSString*)autosaveName; - -// Saves the current state of the subviews if there's a valid autosave name set. If the argument -// is YES, it's then also called recursively for nested RBSplitViews. Returns YES if successful. -- (BOOL)saveState:(BOOL)recurse; - -// Restores the saved state of the subviews if there's a valid autosave name set. If the argument -// is YES, it's first called recursively for nested RBSplitViews. Returns YES if successful. -// You need to call adjustSubviews after calling this. -- (BOOL)restoreState:(BOOL)recurse; - -// Returns a string encoding the current state of all direct subviews. Does not check for nesting. -- (NSString*)stringWithSavedState; - -// Readjusts all direct subviews according to the encoded string parameter. The number of subviews -// must match. Returns YES if successful. Does not check for nesting. -- (BOOL)setStateFromString:(NSString*)aString; - -// Returns an array with complete state information for the receiver and all subviews, taking -// nesting into account. Don't store this array in a file, as its format might change in the -// future; this is for taking a state snapshot and later restoring it with setStatesFromArray. -- (NSArray*)arrayWithStates; - -// Restores the state of the receiver and all subviews. The array must have been produced by a -// previous call to arrayWithStates. Returns YES if successful. This will fail if you have -// added or removed subviews in the meantime! -// You need to call adjustSubviews after calling this. -- (BOOL)setStatesFromArray:(NSArray*)array; - -// This is the designated initializer for creating RBSplitViews programmatically. -- (id)initWithFrame:(NSRect)frame; - -// This convenience initializer adds any number of subviews and adjusts them proportionally. -- (id)initWithFrame:(NSRect)frame andSubviews:(unsigned)count; - -// Sets and gets the delegate. (Delegates aren't retained.) See further down for delegate methods. -- (void)setDelegate:(id)anObject; -- (id)delegate; - -// Returns a subview which has a certain identifier string, or nil if there's none -- (RBSplitSubview*)subviewWithIdentifier:(NSString*)anIdentifier; - -// Returns the subview at a certain position. Returns nil if the position is invalid. -- (RBSplitSubview*)subviewAtPosition:(unsigned)position; - -// Adds a subview at a certain position. -- (void)addSubview:(NSView*)aView atPosition:(unsigned)position; - -// Sets and gets the divider thickness, which should be a positive integer or zero. -// Setting the divider image also resets this automatically, so you would call this -// only if you want the divider to be larger or smaller than the image. Zero means that -// the image dimensions will be used. -- (void)setDividerThickness:(float)thickness; -- (float)dividerThickness; - -// Sets and gets the divider image. The default image can also be set in Interface Builder, so usually -// there's no need to call this. Passing in nil means that the default divider thickness will be zero, -// and no mouse events will be processed, so that the dividers can be moved only programmatically. -- (void)setDivider:(NSImage*)image; -- (NSImage*)divider; - -// Sets and gets the view background. The default is nil, meaning no background is -// drawn and the view and its subviews are considered transparent. -- (void)setBackground:(NSColor*)color; -- (NSColor*)background; - -// Sets and gets the orientation. This uses the same convention as NSSplitView: vertical means the -// dividers are vertical, but the subviews are in a horizontal row. Sort of counter-intuitive, yes. -- (void)setVertical:(BOOL)flag; -- (BOOL)isVertical; -- (BOOL)isHorizontal; - -// Call this to force adjusting the subviews before display. Called automatically if anything -// relevant is changed. -- (void)setMustAdjust; - -// Returns YES if there's a pending adjustment. -- (BOOL)mustAdjust; - -// Returns YES if we're in a dragging loop. -- (BOOL)isDragging; - -// Returns YES if the view is directly contained in an NSScrollView. -- (BOOL)isInScrollView; - -// Call this to recalculate all subview dimensions. Normally this is done automatically whenever -// something relevant is changed, so you rarely will need to call this explicitly. -- (void)adjustSubviews; - -// This method should be called only from within the splitView:wasResizedFrom:to: delegate method -// to keep some specific subview the same size. -- (void)adjustSubviewsExcepting:(RBSplitSubview*)excepting; - -// This method draws dividers. You should never call it directly but you can override it when -// subclassing, if you need custom dividers. -- (void)drawDivider:(NSImage*)anImage inRect:(NSRect)rect betweenView:(RBSplitSubview*)leading andView:(RBSplitSubview*)trailing; - -@end - -// The following methods are optionally implemented by the delegate. - -@interface NSObject(RBSplitViewDelegate) - -// The delegate can override a subview's ability to collapse by implementing this method. -// Return YES to allow collapsing. If this is implemented, the subviews' built-in -// 'collapsed' flags are ignored. -- (BOOL)splitView:(RBSplitView*)sender canCollapse:(RBSplitSubview*)subview; - -// The delegate can alter the divider's appearance by implementing this method. -// Before calling this, the divider is filled with the background, and afterwards -// the divider image is drawn into the returned rect. If imageRect is empty, no -// divider image will be drawn, because there are nested RBSplitViews. Return -// NSZeroRect to suppress the divider image. Return imageRect to use the default -// location for the image, or change its origin to place the image elsewhere. -// You could also draw the divider yourself at this point and return NSZeroRect. -- (NSRect)splitView:(RBSplitView*)sender willDrawDividerInRect:(NSRect)dividerRect betweenView:(RBSplitSubview*)leading andView:(RBSplitSubview*)trailing withProposedRect:(NSRect)imageRect; - -// These methods are called after a subview is completely collapsed or expanded. adjustSubviews may or may not -// have been called, however. -- (void)splitView:(RBSplitView*)sender didCollapse:(RBSplitSubview*)subview; -- (void)splitView:(RBSplitView*)sender didExpand:(RBSplitSubview*)subview; - -// These methods are called just before and after adjusting subviews. -- (void)willAdjustSubviews:(RBSplitView*)sender; -- (void)didAdjustSubviews:(RBSplitView*)sender; - -// This method will be called after a RBSplitView is resized with setFrameSize: but before -// adjustSubviews is called on it. -- (void)splitView:(RBSplitView*)sender wasResizedFrom:(float)oldDimension to:(float)newDimension; - -// This method will be called when a divider is double-clicked and both leading and trailing -// subviews can be collapsed. Return either of the parameters to collapse that subview, or nil -// to collapse neither. If not implemented, the smaller subview will be collapsed. -- (RBSplitSubview*)splitView:(RBSplitView*)sender collapseLeading:(RBSplitSubview*)leading orTrailing:(RBSplitSubview*)trailing; - -// This method will be called when a cursor rect is being set (inside resetCursorRects). The -// proposed rect is passed in. Return the actual rect, or NSZeroRect to suppress cursor setting -// for this divider. This won't be called for two-axis thumbs, however. The rects are in -// sender's local coordinates. -- (NSRect)splitView:(RBSplitView*)sender cursorRect:(NSRect)rect forDivider:(unsigned int)divider; - -// This method will be called whenever a mouse-down event is received in a divider. Return YES to have -// the event handled by the split view, NO if you wish to ignore it or handle it in the delegate. -- (BOOL)splitView:(RBSplitView*)sender shouldHandleEvent:(NSEvent*)theEvent inDivider:(unsigned int)divider betweenView:(RBSplitSubview*)leading andView:(RBSplitSubview*)trailing; - -// This method will be called just before a subview will be collapsed or expanded with animation. -// Return the approximate time the animation should take, or 0.0 to disallow animation. -// If not implemented, it will use the default of 0.2 seconds per 150 pixels. -- (NSTimeInterval)splitView:(RBSplitView*)sender willAnimateSubview:(RBSplitSubview*)subview withDimension:(float)dimension; - -// This method will be called whenever a subview's frame is changed, usually from inside adjustSubviews' final loop. -// You'd normally use this to move some auxiliary view to keep it aligned with the subview. -- (void)splitView:(RBSplitView*)sender changedFrameOfSubview:(RBSplitSubview*)subview from:(NSRect)fromRect to:(NSRect)toRect; - -// This method is called whenever the event handlers want to check if some point within the RBSplitSubview -// should act as an alternate drag view. Usually, the delegate will check the point (which is in sender's -// local coordinates) against the frame of one or several auxiliary views, and return a valid divider number. -// Returning NSNotFound means the point is not valid. -- (unsigned int)splitView:(RBSplitView*)sender dividerForPoint:(NSPoint)point inSubview:(RBSplitSubview*)subview; - -// This method is called continuously while a divider is dragged, just before the leading subview is resized. -// Return NO to resize the trailing view by the same amount, YES to resize the containing window by the same amount. -- (BOOL)splitView:(RBSplitView*)sender shouldResizeWindowForDivider:(unsigned int)divider betweenView:(RBSplitSubview*)leading andView:(RBSplitSubview*)trailing willGrow:(BOOL)grow; - -// This method is called by each subview's drawRect: method, just after filling it with the background color but -// before the contained subviews are drawn. Usually you would use this to draw a frame inside the subview. -- (void)splitView:(RBSplitView*)sender willDrawSubview:(RBSplitSubview*)subview inRect:(NSRect)rect; - -@end - diff --git a/src/MacVim/RBSplitView.m b/src/MacVim/RBSplitView.m deleted file mode 100644 index 0e11d5bdc3..0000000000 --- a/src/MacVim/RBSplitView.m +++ /dev/null @@ -1,1736 +0,0 @@ -// -// RBSplitView.m version 1.1.4 -// RBSplitView -// -// Created by Rainer Brockerhoff on 24/09/2004. -// Copyright 2004-2006 Rainer Brockerhoff. -// Some Rights Reserved under the Creative Commons Attribution License, version 2.5, and/or the MIT License. -// -#ifdef MM_ENABLE_PLUGINS - -#import "RBSplitView.h" -#import "RBSplitViewPrivateDefines.h" - -// Please don't remove this copyright notice! -static const unsigned char RBSplitView_Copyright[] __attribute__ ((used)) = - "RBSplitView 1.1.4 Copyright(c)2004-2006 by Rainer Brockerhoff ."; - -// This vector keeps currently used cursors. nil means the default cursor. -static NSCursor* cursors[RBSVCursorTypeCount] = {nil}; - -// Our own fMIN and fMAX -static inline float fMIN(float a,float b) { - return ab?a:b; -} - -@implementation RBSplitView - -// These class methods get and set the cursor used for each type. -// Pass in nil to reset to the default cursor for that type. -+ (NSCursor*)cursor:(RBSVCursorType)type { - if ((type>=0)&&(type=0)&&(type1)&&([[parts objectAtIndex:0] intValue]==subcount)&&(k==subcount)) { - int i; - NSRect frame = [self frame]; - BOOL ishor = [self isHorizontal]; - for (i=0;i