Skip to content

Commit 36ebc0b

Browse files
committed
- added back layout manager delegate methods
- added methods for fetching comment and preprocessor colors - removed test file
1 parent f07321b commit 36ebc0b

File tree

3 files changed

+32
-1609
lines changed

3 files changed

+32
-1609
lines changed

SCXcodeMinimap.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
184C11821A740F97002A7C65 /* SCXcodeMinimapSelectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCXcodeMinimapSelectionView.m; sourceTree = "<group>"; };
4040
184C11831A740F97002A7C65 /* SCXcodeMinimapView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCXcodeMinimapView.h; sourceTree = "<group>"; };
4141
184C11841A740F97002A7C65 /* SCXcodeMinimapView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCXcodeMinimapView.m; sourceTree = "<group>"; };
42-
184C11851A740F97002A7C65 /* ShitFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShitFile.h; sourceTree = "<group>"; };
4342
184C118E1A741136002A7C65 /* DVTFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DVTFoundation.framework; path = ../../../../../Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework; sourceTree = "<group>"; };
4443
188308091A7411830005DF40 /* DVTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DVTKit.framework; path = ../../../../../Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework; sourceTree = "<group>"; };
4544
1883080B1A7411930005DF40 /* IDESourceEditor.ideplugin */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = IDESourceEditor.ideplugin; path = ../../../../../Applications/Xcode.app/Contents/PlugIns/IDESourceEditor.ideplugin; sourceTree = "<group>"; };
@@ -145,7 +144,6 @@
145144
184C11821A740F97002A7C65 /* SCXcodeMinimapSelectionView.m */,
146145
184C11831A740F97002A7C65 /* SCXcodeMinimapView.h */,
147146
184C11841A740F97002A7C65 /* SCXcodeMinimapView.m */,
148-
184C11851A740F97002A7C65 /* ShitFile.h */,
149147
18FE09BC1707639E00118FEB /* Supporting Files */,
150148
184C11701A740F8A002A7C65 /* Xcode Headers */,
151149
);

SCXcodeMinimap/SCXcodeMinimapView.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
const CGFloat kDefaultZoomLevel = 0.1f;
2121
const CGFloat kDefaultShadowLevel = 0.1f;
2222

23+
static NSString * const kXcodeSyntaxCommentColor = @"xcode.syntax.comment";
24+
static NSString * const kXcodeSyntaxPreprocessorColor = @"xcode.syntax.preprocessor";
2325
static NSString * const DVTFontAndColorSourceTextSettingsChangedNotification = @"DVTFontAndColorSourceTextSettingsChangedNotification";
2426

2527
@interface SCXcodeMinimapView () <NSLayoutManagerDelegate>
@@ -102,8 +104,28 @@ - (void)setVisible:(BOOL)visible
102104
if(visible) {
103105
[self updateOffset];
104106
}
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};
105119
}
106120

121+
- (void)layoutManager:(NSLayoutManager *)layoutManager didCompleteLayoutForTextContainer:(NSTextContainer *)textContainer atEnd:(BOOL)layoutFinished
122+
{
123+
if(layoutFinished) {
124+
[self updateOffset];
125+
}
126+
}
127+
128+
107129
#pragma mark - Navigation
108130

109131
- (void)updateOffset
@@ -183,6 +205,16 @@ - (NSColor *)backgroundColor
183205
return [[NSColor clearColor] shadowWithLevel:kDefaultShadowLevel];
184206
}
185207

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+
186218
#pragma mark - Autoresizing
187219

188220
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize

0 commit comments

Comments
 (0)