Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use lighter scrollbar scolor when background is dark.
- Loading branch information
Showing
8 changed files
with
193 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// From http://www.cocoadev.com/index.pl?NSImageCategory | ||
// | ||
// NSBitmapImageRep+CoreImage.h | ||
// iTerm2 | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface NSBitmapImageRep (CoreImage) | ||
/* Draws the specified image representation using Core Image. */ | ||
- (void)drawAtPoint:(NSPoint)point | ||
fromRect:(NSRect)fromRect | ||
coreImageFilter:(NSString *)filterName | ||
arguments:(NSDictionary *)arguments; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// From http://www.cocoadev.com/index.pl?NSImageCategory | ||
// NSBitmapImageRep+CoreImage.m | ||
// iTerm2 | ||
|
||
#import <QuartzCore/QuartzCore.h> | ||
#import "NSBitmapImageRep+CoreImage.h" | ||
#import "NSImage+CoreImage.h" | ||
|
||
#define CIIMAGE_PADDING 16.0f | ||
|
||
@implementation NSBitmapImageRep (CoreImage) | ||
|
||
- (void)drawAtPoint: (NSPoint)point fromRect: (NSRect)fromRect coreImageFilter: (NSString *)filterName arguments: (NSDictionary *)arguments { | ||
NSAutoreleasePool *pool; | ||
CIFilter *filter; | ||
CIImage *before; | ||
CIImage *after; | ||
CIContext *ciContext; | ||
CGContextRef cgContext; | ||
|
||
pool = [[NSAutoreleasePool alloc] init]; | ||
before = nil; | ||
|
||
@try { | ||
before = [[CIImage alloc] initWithBitmapImageRep: self]; | ||
if (before) { | ||
filter = [CIFilter filterWithName: filterName]; | ||
[filter setDefaults]; | ||
if (arguments) | ||
[filter setValuesForKeysWithDictionary: arguments]; | ||
[filter setValue: before forKey: @"inputImage"]; | ||
} else { | ||
filter = nil; | ||
} | ||
|
||
after = [filter valueForKey: @"outputImage"]; | ||
if (after) { | ||
if (![[arguments objectForKey: @"gt_noRenderPadding"] boolValue]) { | ||
/* Add a wide berth to the bounds -- the padding can be turned | ||
off by passing an NSNumber with a YES value in the argument | ||
"gt_noRenderPadding" in the argument dictionary. */ | ||
fromRect.origin.x -= CIIMAGE_PADDING; | ||
fromRect.origin.y -= CIIMAGE_PADDING; | ||
fromRect.size.width += CIIMAGE_PADDING * 2.0f; | ||
fromRect.size.height += CIIMAGE_PADDING * 2.0f; | ||
point.x -= CIIMAGE_PADDING; | ||
point.y -= CIIMAGE_PADDING; | ||
} | ||
|
||
cgContext = CGContextRetain((CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]); | ||
if (cgContext) { | ||
ciContext = [CIContext contextWithCGContext: cgContext options: nil]; | ||
[ciContext | ||
drawImage: after | ||
atPoint: *(CGPoint *)(&point) | ||
fromRect: *(CGRect *)(&fromRect)]; | ||
CGContextRelease(cgContext); | ||
} | ||
} | ||
} @catch (NSException *e) { | ||
NSLog("exception encountered during core image filtering: %@", e); | ||
} @finally { | ||
[before release]; | ||
} | ||
|
||
[pool release]; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// From http://www.cocoadev.com/index.pl?NSImageCategory | ||
// | ||
// NSImage+CoreImage.h | ||
// iTerm2 | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface NSImage (CoreImage) | ||
/* Draws the specified image using Core Image. */ | ||
- (void)drawAtPoint: (NSPoint)point fromRect: (NSRect)fromRect coreImageFilter: (NSString *)filterName arguments: (NSDictionary *)arguments; | ||
|
||
/* Gets a bitmap representation of the image, or creates one if the image does not have any. */ | ||
- (NSBitmapImageRep *)bitmapImageRepresentation; | ||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// From http://www.cocoadev.com/index.pl?NSImageCategory | ||
// | ||
// NSImage+CoreImage.m | ||
// iTerm2 | ||
|
||
#import "NSImage+CoreImage.h" | ||
|
||
@implementation NSImage (CoreImage) | ||
- (void)drawAtPoint: (NSPoint)point fromRect: (NSRect)fromRect coreImageFilter: (NSString *)filterName arguments: (NSDictionary *)arguments { | ||
NSAutoreleasePool *pool; | ||
NSBitmapImageRep *rep; | ||
|
||
pool = [[NSAutoreleasePool alloc] init]; | ||
|
||
if (filterName) { | ||
rep = [self bitmapImageRepresentation]; | ||
[rep | ||
drawAtPoint: point | ||
fromRect: fromRect | ||
coreImageFilter: filterName | ||
arguments: arguments]; | ||
} else { | ||
/* bypass core image if no filter is specified */ | ||
[self | ||
drawAtPoint: point | ||
fromRect: fromRect | ||
operation: NSCompositeSourceOver | ||
fraction: 1.0f]; | ||
} | ||
|
||
[pool release]; | ||
} | ||
|
||
- (NSBitmapImageRep *)bitmapImageRepresentation { | ||
NSImageRep *rep; | ||
NSEnumerator *e; | ||
Class bitmapImageRep; | ||
|
||
bitmapImageRep = [NSBitmapImageRep class]; | ||
e = [[self representations] objectEnumerator]; | ||
while ((rep = [e nextObject]) != nil) { | ||
if ([rep isKindOfClass: bitmapImageRep]) | ||
break; | ||
rep = nil; | ||
} | ||
|
||
if (!rep) | ||
rep = [NSBitmapImageRep imageRepWithData: [self TIFFRepresentation]]; | ||
|
||
return (NSBitmapImageRep *)rep; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters