|
20 | 20 | const CGFloat kDefaultZoomLevel = 0.1f; |
21 | 21 | const CGFloat kDefaultShadowLevel = 0.1f; |
22 | 22 |
|
| 23 | +static NSString * const kXcodeSyntaxCommentColor = @"xcode.syntax.comment"; |
| 24 | +static NSString * const kXcodeSyntaxPreprocessorColor = @"xcode.syntax.preprocessor"; |
23 | 25 | static NSString * const DVTFontAndColorSourceTextSettingsChangedNotification = @"DVTFontAndColorSourceTextSettingsChangedNotification"; |
24 | 26 |
|
25 | 27 | @interface SCXcodeMinimapView () <NSLayoutManagerDelegate> |
@@ -102,8 +104,28 @@ - (void)setVisible:(BOOL)visible |
102 | 104 | if(visible) { |
103 | 105 | [self updateOffset]; |
104 | 106 | } |
| 107 | + |
| 108 | + // Ensure the layout manager's delegate is set to self. The DVTSourceTextView resets it if called to early. |
| 109 | + [self.textView.layoutManager setDelegate:self]; |
| 110 | +} |
| 111 | + |
| 112 | +#pragma mark - NSLayoutManagerDelegate |
| 113 | + |
| 114 | +- (NSDictionary *)layoutManager:(NSLayoutManager *)layoutManager shouldUseTemporaryAttributes:(NSDictionary *)attrs forDrawingToScreen:(BOOL)toScreen atCharacterIndex:(NSUInteger)charIndex effectiveRange:(NSRangePointer)effectiveCharRange |
| 115 | +{ |
| 116 | + DVTTextStorage *storage = [self.editorTextView textStorage]; |
| 117 | + NSColor *color = [storage colorAtCharacterIndex:charIndex effectiveRange:effectiveCharRange context:nil]; |
| 118 | + return @{NSForegroundColorAttributeName : color}; |
105 | 119 | } |
106 | 120 |
|
| 121 | +- (void)layoutManager:(NSLayoutManager *)layoutManager didCompleteLayoutForTextContainer:(NSTextContainer *)textContainer atEnd:(BOOL)layoutFinished |
| 122 | +{ |
| 123 | + if(layoutFinished) { |
| 124 | + [self updateOffset]; |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | + |
107 | 129 | #pragma mark - Navigation |
108 | 130 |
|
109 | 131 | - (void)updateOffset |
@@ -183,6 +205,16 @@ - (NSColor *)backgroundColor |
183 | 205 | return [[NSColor clearColor] shadowWithLevel:kDefaultShadowLevel]; |
184 | 206 | } |
185 | 207 |
|
| 208 | +- (NSColor *)commentColor |
| 209 | +{ |
| 210 | + return [[[DVTFontAndColorTheme currentTheme] syntaxColorsByNodeType] pointerAtIndex:[DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxCommentColor]]; |
| 211 | +} |
| 212 | + |
| 213 | +- (NSColor *)preprocessorColor |
| 214 | +{ |
| 215 | + return [[[DVTFontAndColorTheme currentTheme] syntaxColorsByNodeType] pointerAtIndex:[DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxPreprocessorColor]]; |
| 216 | +} |
| 217 | + |
186 | 218 | #pragma mark - Autoresizing |
187 | 219 |
|
188 | 220 | - (void)resizeWithOldSuperviewSize:(NSSize)oldSize |
|
0 commit comments