Skip to content

Commit

Permalink
Punch a hole through the find-cursor stars so you can see the cursor.…
Browse files Browse the repository at this point in the history
… Don't show the arrow find-cursor view reguarly.
  • Loading branch information
gnachman committed Oct 22, 2015
1 parent 8e22de9 commit 19fadf5
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 14 deletions.
8 changes: 8 additions & 0 deletions iTerm2.xcodeproj/project.pbxproj
Expand Up @@ -48,6 +48,8 @@
1D2E802E129DA45A00F3D71E /* PTYTab.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D2E802C129DA45A00F3D71E /* PTYTab.h */; };
1D2E813112A18F7500F3D71E /* SessionView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D2E812F12A18F7500F3D71E /* SessionView.h */; };
1D2F3B3D1516BA470044C337 /* iTermFontPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D2F3B3B1516BA460044C337 /* iTermFontPanel.h */; };
1D300BAA1BD9A8BB002043F7 /* NSDate+iTerm.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D300BA81BD9A8BB002043F7 /* NSDate+iTerm.h */; settings = {ASSET_TAGS = (); }; };
1D300BAB1BD9A8BB002043F7 /* NSDate+iTerm.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D300BA91BD9A8BB002043F7 /* NSDate+iTerm.m */; settings = {ASSET_TAGS = (); }; };
1D31BC65142D33CA001F7ECB /* TriggerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D31BC63142D33CA001F7ECB /* TriggerController.h */; };
1D3452471451475D007B1ECD /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = F6E2DED70AE2F67200D20B3B /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
1D36155512CBF33E00803EA9 /* ScreenChar.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D36155312CBF33E00803EA9 /* ScreenChar.h */; };
Expand Down Expand Up @@ -1765,6 +1767,8 @@
1D2E813012A18F7500F3D71E /* SessionView.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = SessionView.m; sourceTree = "<group>"; tabWidth = 4; };
1D2F3B3B1516BA460044C337 /* iTermFontPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = iTermFontPanel.h; sourceTree = "<group>"; tabWidth = 4; };
1D2F3B3C1516BA460044C337 /* iTermFontPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = iTermFontPanel.m; sourceTree = "<group>"; tabWidth = 4; };
1D300BA81BD9A8BB002043F7 /* NSDate+iTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+iTerm.h"; sourceTree = "<group>"; };
1D300BA91BD9A8BB002043F7 /* NSDate+iTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+iTerm.m"; sourceTree = "<group>"; };
1D31BC63142D33CA001F7ECB /* TriggerController.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = TriggerController.h; sourceTree = "<group>"; tabWidth = 4; };
1D31BC64142D33CA001F7ECB /* TriggerController.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = TriggerController.m; sourceTree = "<group>"; tabWidth = 4; };
1D36155312CBF33E00803EA9 /* ScreenChar.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ScreenChar.h; sourceTree = "<group>"; tabWidth = 4; };
Expand Down Expand Up @@ -3663,6 +3667,8 @@
A67F57AF1B012BD100B4F135 /* NSWorkspace+iTerm.m */,
A667F3891B48AEF200705186 /* NSApplication+iTerm.h */,
A667F38A1B48AEF200705186 /* NSApplication+iTerm.m */,
1D300BA81BD9A8BB002043F7 /* NSDate+iTerm.h */,
1D300BA91BD9A8BB002043F7 /* NSDate+iTerm.m */,
);
name = Categories;
sourceTree = "<group>";
Expand Down Expand Up @@ -4957,6 +4963,7 @@
A6C760471B45C4CF00E3C992 /* SSKeychain.h in Headers */,
A62C3B3E1BD40DC900B5629D /* iTermCapturedOutputMark.h in Headers */,
A62C3B2D1BCC24AB00B5629D /* iTermCommandHistoryCommandUseMO.h in Headers */,
1D300BAA1BD9A8BB002043F7 /* NSDate+iTerm.h in Headers */,
A62C3B421BD40E7C00B5629D /* iTermImageMark.h in Headers */,
A62C3B2B1BCC24AB00B5629D /* iTermCommandHistoryCommandUseMO+CoreDataProperties.h in Headers */,
A62C3B251BCC24AB00B5629D /* iTermCommandHistoryEntryMO.h in Headers */,
Expand Down Expand Up @@ -5965,6 +5972,7 @@
A6C7631A1B45C52B00E3C992 /* iTermProfileSearchToken.m in Sources */,
A6C762FB1B45C52B00E3C992 /* FileTransferManager.m in Sources */,
A6C762B81B45C52B00E3C992 /* NSImage+iTerm.m in Sources */,
1D300BAB1BD9A8BB002043F7 /* NSDate+iTerm.m in Sources */,
A6C762E61B45C52B00E3C992 /* VT100Grid.m in Sources */,
A6C763981B45C52B00E3C992 /* TmuxControllerRegistry.m in Sources */,
A6C763A61B45C52B00E3C992 /* ToolJobs.m in Sources */,
Expand Down
15 changes: 15 additions & 0 deletions sources/NSDate+iTerm.h
@@ -0,0 +1,15 @@
//
// NSDate+NSDate_iTerm.h
// iTerm2
//
// Created by George Nachman on 10/22/15.
//
//

#import <Foundation/Foundation.h>

@interface NSDate (iTerm)

+ (BOOL)isAprilFools;

@end
30 changes: 30 additions & 0 deletions sources/NSDate+iTerm.m
@@ -0,0 +1,30 @@
//
// NSDate+NSDate_iTerm.m
// iTerm2
//
// Created by George Nachman on 10/22/15.
//
//

#import "NSDate+iTerm.h"

@implementation NSDate (iTerm)

+ (BOOL)isAprilFools {
static NSTimeInterval lastComputation;
static BOOL result;
NSTimeInterval now = [self timeIntervalSinceReferenceDate];
if (now - lastComputation > 3600) {
// Check no more than once an hour. This could be much more efficient, but doing anything with
// time is fraught with bugs and peril, so we'll just keep it simple.
NSCalendar *calendar =
[[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDateComponents *components =
[calendar components:(NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:[self date]];
result = (components.month == 4 && components.day == 1);
lastComputation = now;
}
return result;
}

@end
11 changes: 2 additions & 9 deletions sources/ToolCommandHistoryView.m
Expand Up @@ -12,6 +12,7 @@
#import "iTermCommandHistoryEntryMO+Additions.h"
#import "iTermSearchField.h"
#import "NSDateFormatterExtras.h"
#import "NSDate+iTerm.h"
#import "NSTableColumn+iTerm.h"
#import "PTYSession.h"

Expand Down Expand Up @@ -191,15 +192,7 @@ - (id)tableView:(NSTableView *)aTableView
withString:@" "];

if (commandUse.code.integerValue) {
static dispatch_once_t onceToken;
static BOOL egg;
dispatch_once(&onceToken, ^{
NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDateComponents *components = [calendar components:(NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:[NSDate date]];
egg = (components.month == 4 && components.day == 1);
});

if (egg) {
if ([NSDate isAprilFools]) {
value = [@"💩 " stringByAppendingString:value];
} else {
value = [@"🚫 " stringByAppendingString:value];
Expand Down
26 changes: 21 additions & 5 deletions sources/iTermFindCursorView.m
Expand Up @@ -7,6 +7,8 @@
//

#import "iTermFindCursorView.h"
#import "NSBezierPath+iTerm.h"
#import "NSDate+iTerm.h"
#import <QuartzCore/QuartzCore.h>

// Delay before teardown.
Expand Down Expand Up @@ -119,6 +121,22 @@ - (instancetype)initWithFrame:(NSRect)frameRect {
- (void)setCursorPosition:(NSPoint)cursorPosition {
[super setCursorPosition:cursorPosition];
_emitterLayer.emitterPosition = cursorPosition;

CAShapeLayer *mask = [[CAShapeLayer alloc] init];

NSBezierPath *outerPath = [NSBezierPath bezierPathWithRect:self.bounds];
outerPath.windingRule = NSEvenOddWindingRule;

NSBezierPath *path = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(cursorPosition.x - 20,
cursorPosition.y - 20,
40,
40)];
[outerPath appendBezierPath:path];

mask.fillRule = kCAFillRuleEvenOdd;
mask.path = [outerPath iterm_CGPath];
mask.fillColor = [[NSColor blackColor] CGColor];
self.layer.mask = mask;
}

#pragma mark - Private methods
Expand Down Expand Up @@ -193,12 +211,10 @@ @implementation iTermFindCursorView {
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
static int count;
++count;
if (count % 2) {
return [iTermFindCursorViewStarsImpl alloc];
} else {
if ([NSDate isAprilFools]) {
return [iTermFindCursorViewArrowImpl alloc];
} else {
return [iTermFindCursorViewStarsImpl alloc];
}
}

Expand Down

0 comments on commit 19fadf5

Please sign in to comment.