mirror of
https://github.com/textmate/textmate.git
synced 2026-01-22 21:27:56 -05:00
Add workaround for 10.8 API
This should cause TextMate to once again run on 10.7 (issue #643).
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
@interface NSColor (Creation)
|
||||
@interface NSColor (TMColorAdditions)
|
||||
+ (NSColor*)colorWithString:(NSString*)aString;
|
||||
+ (NSColor*)tmColorWithCGColor:(CGColorRef)aColor;
|
||||
@end
|
||||
|
||||
@interface NSColor (OakColor)
|
||||
- (CGColorRef)tmCGColor;
|
||||
- (BOOL)isDark;
|
||||
@end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#import "NSColor Additions.h"
|
||||
#import <OakFoundation/OakFoundation.h>
|
||||
|
||||
@implementation NSColor (Creation)
|
||||
@implementation NSColor (TMColorAdditions)
|
||||
+ (NSColor*)colorWithString:(NSString*)aString
|
||||
{
|
||||
if(NSIsEmptyString(aString))
|
||||
@@ -23,9 +23,21 @@
|
||||
return [self colorWithCGColor:aColor];
|
||||
return [NSColor colorWithColorSpace:[[[NSColorSpace alloc] initWithCGColorSpace:CGColorGetColorSpace(aColor)] autorelease] components:CGColorGetComponents(aColor) count:CGColorGetNumberOfComponents(aColor)];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSColor (OakColor)
|
||||
- (CGColorRef)tmCGColor
|
||||
{
|
||||
if([self respondsToSelector:@selector(CGColor)])
|
||||
return [self CGColor];
|
||||
|
||||
NSColor* rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
||||
CGFloat rgba[4];
|
||||
[rgbColor getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]];
|
||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
|
||||
CGColorRef res = CGColorCreate(colorSpace, rgba);
|
||||
CGColorSpaceRelease(colorSpace);
|
||||
return (CGColorRef)[(id)res autorelease];
|
||||
}
|
||||
|
||||
- (BOOL)isDark
|
||||
{
|
||||
uint32_t r(lroundf(255 * [self redComponent]));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#import "GutterView.h"
|
||||
#import <OakAppKit/OakAppKit.h>
|
||||
#import <OakAppKit/NSImage Additions.h>
|
||||
#import <OakAppKit/NSColor Additions.h>
|
||||
#import <OakFoundation/NSString Additions.h>
|
||||
#import <text/types.h>
|
||||
#import <cf/cf.h>
|
||||
@@ -276,9 +277,9 @@ static CTLineRef CTCreateLineFromText (std::string const& text, NSFont* font, NS
|
||||
CTLineRef res = NULL;
|
||||
if(CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks))
|
||||
{
|
||||
if(CGColorRef cgColor = [color CGColor])
|
||||
if(CGColorRef cgColor = [color tmCGColor])
|
||||
CFDictionaryAddValue(dict, kCTForegroundColorAttributeName, cgColor);
|
||||
|
||||
|
||||
if(CTFontRef ctFont = CTFontCreateWithName((CFStringRef)[font fontName], [font pointSize], NULL))
|
||||
{
|
||||
CFDictionaryAddValue(dict, kCTFontAttributeName, ctFont);
|
||||
|
||||
Reference in New Issue
Block a user