This repository was archived by the owner on Dec 12, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDVTTextSidebarView+XSourceNote.m
More file actions
64 lines (52 loc) · 2.54 KB
/
Copy pathDVTTextSidebarView+XSourceNote.m
File metadata and controls
64 lines (52 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// DVTTextSidebarView+XSourceNote.m
// XSourceNote
//
// Created by everettjf on 10/31/15.
// Copyright © 2015 everettjf. All rights reserved.
//
#import "DVTTextSidebarView+XSourceNote.h"
#import "JRSwizzle.h"
#import "IDEKit.h"
#import "XSourceNoteModel.h"
#import "XSourceNoteStorage.h"
@implementation DVTTextSidebarView (XSourceNote)
+(void)load{
NSError *error = nil;
[DVTTextSidebarView jr_swizzleMethod:@selector(_drawLineNumbersInSidebarRect:foldedIndexes:count:linesToInvert:linesToReplace:getParaRectBlock:)
withMethod:@selector(XSourceNote_drawLineNumbersInSidebarRect:foldedIndexes:count:linesToInvert:linesToReplace:getParaRectBlock:)
error:& error];
}
- (void)XSourceNote_drawLineNumbersInSidebarRect:(CGRect)rect
foldedIndexes:(NSUInteger *)indexes
count:(NSUInteger)indexCount
linesToInvert:(id)invert
linesToReplace:(id)replace
getParaRectBlock:(id)rectBlock{
NSString *rootPath = [XSourceNoteStorage sharedStorage].rootPath;
if(rootPath && ![rootPath isEqualToString:@""]){
NSString *fileName = self.window.representedFilename;
NSString *relativePath = [fileName stringByReplacingOccurrencesOfString:rootPath withString:@""];
for(NSUInteger idx = 0; idx < indexCount; ++idx){
NSUInteger line = indexes[idx];
if([[XSourceNoteModel sharedModel]hasLineMark:relativePath line:line]){
[self XSourceNote_drawNoteAtLine:line];
}
}
}
[self XSourceNote_drawLineNumbersInSidebarRect:rect foldedIndexes:indexes count:indexCount linesToInvert:invert linesToReplace:replace getParaRectBlock:rectBlock];
}
static inline NSRect NSRectRelativeTo(NSRect rect,NSPoint origin){
return NSMakeRect(origin.x + rect.origin.x, origin.y + rect.origin.y,rect.size.width,rect.size.height);
}
-(void)XSourceNote_drawNoteAtLine:(NSUInteger)lineNumber{
CGRect paragRect,lineRect;
[self getParagraphRect:¶gRect firstLineRect:&lineRect forLineNumber:lineNumber];
//// Color Declarations
NSColor* color = [NSColor colorWithCalibratedRed: 0.389 green: 0.994 blue: 0.356 alpha: 1];
//// Rectangle Drawing
NSBezierPath* rectanglePath = [NSBezierPath bezierPathWithRect: NSRectRelativeTo(NSMakeRect(0, 0, 4, lineRect.size.height), lineRect.origin)];
[color setFill];
[rectanglePath fill];
}
@end