Skip to content

Commit

Permalink
Move tooltips and commenthashtable to WLTerminalView so the counting …
Browse files Browse the repository at this point in the history
…wouldn't be mixed.
  • Loading branch information
clyang committed Jan 6, 2018
1 parent b9fa5fa commit 988c5cb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/Commentator Seeker/WLCommentHotspotHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "WLMouseHotspotHandler.h"

@interface WLCommentHotspotHandler : WLMouseHotspotHandler <WLUpdatable> {
NSMutableArray *_commentTooltipsSet;
NSMutableArray *_commentHashTable;

}
@end
14 changes: 10 additions & 4 deletions src/Commentator Seeker/WLCommentHotspotHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ - (void)addCommentRect:(int)thisFloor
NSRect rect = [_view rectAtRow:r column:c height:1 width:length];
NSString *tooltip = [NSString stringWithFormat:@"%d F", thisFloor];
NSToolTipTag tipTag = [_view addToolTipRect:rect owner:_manager userData:tooltip];
NSMutableArray *_commentTooltipsSet = [_view getCommentTooltipsArray];
[_commentTooltipsSet addObject:tipTag];

NSDictionary *userInfo = [self userInfo];
Expand Down Expand Up @@ -93,6 +94,9 @@ - (void)updateCommentStateForRow:(int)r {

- (int)getCommentFloor:(int)r {
int i=0;

NSMutableArray *_commentHashTable = [_view getCommentHashTableArray];

NSString* row = [[_view frontMostTerminal] stringAtIndex:r * [[WLGlobalConfig sharedInstance] column] length:[[WLGlobalConfig sharedInstance] column]] ?: @"";
if([_commentHashTable count] == 0) {
[_commentHashTable addObject: [row MD5String]];
Expand All @@ -112,6 +116,8 @@ - (int)getCommentFloor:(int)r {
}

- (void)clearTooltipsAndTrackingAreas {
NSMutableArray *_commentTooltipsSet = [_view getCommentTooltipsArray];

for(id tipTag in _commentTooltipsSet){
[_view removeToolTip:(NSToolTipTag)tipTag];
}
Expand All @@ -130,10 +136,10 @@ - (void)update {
return;
}

if(!_commentTooltipsSet) {
_commentTooltipsSet = [[NSMutableArray alloc] init];
_commentHashTable = [[NSMutableArray alloc] init];
}

NSMutableArray *_commentTooltipsSet = [_view getCommentTooltipsArray];
NSMutableArray *_commentHashTable = [_view getCommentHashTableArray];

NSString *lastLine = [[_view frontMostTerminal] stringAtIndex:23 * [[WLGlobalConfig sharedInstance] column] length:[[WLGlobalConfig sharedInstance] column]] ?: @"";

[self clearTooltipsAndTrackingAreas];
Expand Down
5 changes: 5 additions & 0 deletions src/WLTerminalView.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
BOOL _isNotCancelingSelection;
BOOL _isKeying;
BOOL _isMouseActive;
NSMutableArray *_commentTooltipsSet;
NSMutableArray *_commentHashTable;

NSTimer *_activityCheckingTimer;

Expand Down Expand Up @@ -90,6 +92,9 @@
- (int)convertIndexFromPoint:(NSPoint)aPoint;
- (NSPoint)mouseLocationInView;

- (NSMutableArray *)getCommentTooltipsArray;
- (NSMutableArray *)getCommentHashTableArray;

@end

@interface Singleton : NSObject
Expand Down
16 changes: 16 additions & 0 deletions src/WLTerminalView.m
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,22 @@ - (void)confirmPasteColor:(NSWindow *)sheet returnCode:(int)returnCode contextIn
}
}

- (NSMutableArray *)getCommentTooltipsArray {
if(!_commentTooltipsSet) {
_commentTooltipsSet = [[NSMutableArray alloc] init];
}

return _commentTooltipsSet;
}

- (NSMutableArray *)getCommentHashTableArray {
if(!_commentHashTable) {
_commentHashTable = [[NSMutableArray alloc] init];
}

return _commentHashTable;
}

- (void)performPaste {
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSArray *types = [pb types];
Expand Down

0 comments on commit 988c5cb

Please sign in to comment.