Skip to content

Commit 82f8cb2

Browse files
committed
Cleaned up notifications, menu items and user defaults, and exposed more configuration options:
- enable/disable comments highlighting - enable/disable preprocessor directives highlighting - enabled/disable main editor vertical scroller (#37)
1 parent 5faa322 commit 82f8cb2

File tree

4 files changed

+175
-55
lines changed

4 files changed

+175
-55
lines changed

SCXcodeMinimap/SCXcodeMinimap.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@
1010

1111
const CGFloat kDefaultZoomLevel;
1212

13-
extern NSString *const SCXodeMinimapShowNotification;
14-
extern NSString *const SCXodeMinimapHideNotification;
13+
extern NSString *const SCXcodeMinimapShouldDisplayChangeNotification;
14+
extern NSString *const SCXcodeMinimapShouldDisplay;
1515

16-
extern NSString *const SCXodeMinimapThemeChangeNotification;
17-
extern NSString *const SCXodeMinimapTheme;
16+
extern NSString *const SCXcodeMinimapThemeChangeNotification;
17+
extern NSString *const SCXcodeMinimapTheme;
18+
19+
extern NSString *const SCXcodeMinimapHighlightCommentsChangeNotification;
20+
extern NSString *const SCXcodeMinimapShouldHighlightComments;
21+
22+
extern NSString *const SCXcodeMinimapHighlightPreprocessorChangeNotification;
23+
extern NSString *const SCXcodeMinimapShouldHighlightPreprocessor;
24+
25+
extern NSString *const SCXcodeMinimapHideEditorScrollerChangeNotification;
26+
extern NSString *const SCXcodeMinimapShouldHideEditorScroller;
1827

1928
@interface SCXcodeMinimap : NSObject
2029

SCXcodeMinimap/SCXcodeMinimap.m

Lines changed: 130 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,33 @@
2020

2121
NSString *const IDESourceCodeEditorDidFinishSetupNotification = @"IDESourceCodeEditorDidFinishSetup";
2222

23-
NSString *const SCXodeMinimapShowNotification = @"SCXodeMinimapShowNotification";
24-
NSString *const SCXodeMinimapHideNotification = @"SCXodeMinimapHideNotification";
23+
NSString *const SCXcodeMinimapShouldDisplayChangeNotification = @"SCXcodeMinimapShouldDisplayChangeNotification";
24+
NSString *const SCXcodeMinimapShouldDisplay = @"SCXcodeMinimapShouldDisplay";
2525

26-
NSString *const SCXodeMinimapThemeChangeNotification = @"SCXodeMinimapThemeChangeNotification";
26+
NSString *const SCXcodeMinimapThemeChangeNotification = @"SCXcodeMinimapThemeChangeNotification";
27+
NSString *const SCXcodeMinimapTheme = @"SCXcodeMinimapTheme";
2728

28-
NSString *const SCXodeMinimapIsInitiallyHidden = @"SCXodeMinimapIsInitiallyHidden";
29-
NSString *const SCXodeMinimapTheme = @"SCXodeMinimapTheme";
29+
NSString *const SCXcodeMinimapHighlightCommentsChangeNotification = @"SCXcodeMinimapHighlightCommentsChangeNotification";
30+
NSString *const SCXcodeMinimapShouldHighlightComments = @"SCXcodeMinimapShouldHighlightComments";
31+
32+
NSString *const SCXcodeMinimapHighlightPreprocessorChangeNotification = @"SCXcodeMinimapHighlightPreprocessorChangeNotification";
33+
NSString *const SCXcodeMinimapShouldHighlightPreprocessor = @"SCXcodeMinimapShouldHighlightPreprocessor";
34+
35+
NSString *const SCXcodeMinimapHideEditorScrollerChangeNotification = @"SCXcodeMinimapHideEditorScrollerChangeNotification";
36+
NSString *const SCXcodeMinimapShouldHideEditorScroller = @"SCXcodeMinimapShouldHideEditorScroller";
37+
38+
NSString *const kViewMenuItemTitle = @"View";
39+
40+
NSString *const kMinimapMenuItemTitle = @"Minimap";
41+
NSString *const kShowMinimapMenuItemTitle = @"Show Minimap";
42+
NSString *const kHideMinimapMenuItemTitle = @"Hide Minimap";
43+
44+
NSString *const kHighlightCommentsMenuItemTitle = @"Highlight comments";
45+
NSString *const kHighlightPreprocessorMenuItemTitle = @"Highlight preprocessor";
46+
NSString *const kHideEditorScrollerMenuItemTitle = @"Hide editor scroller";
47+
48+
NSString *const kThemeMenuItemTitle = @"Theme";
49+
NSString *const kEditorThemeMenuItemTitle = @"Editor Theme";
3050

3151
@implementation SCXcodeMinimap
3252

@@ -43,55 +63,98 @@ - (id)init
4363
{
4464
if (self = [super init]) {
4565

66+
[self registerUserDefaults];
4667
[self createMenuItem];
4768

4869
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onDidFinishSetup:) name:IDESourceCodeEditorDidFinishSetupNotification object:nil];
4970
}
5071
return self;
5172
}
5273

74+
- (void)registerUserDefaults
75+
{
76+
NSDictionary *userDefaults = @{SCXcodeMinimapShouldDisplay : @(YES),
77+
SCXcodeMinimapShouldHighlightComments : @(YES),
78+
SCXcodeMinimapShouldHighlightPreprocessor :@(YES)};
79+
80+
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaults];
81+
}
82+
5383
#pragma mark - Menu Items and Actions
5484

5585
- (void)createMenuItem
5686
{
57-
NSMenuItem *editMenuItem = [[NSApp mainMenu] itemWithTitle:@"View"];
87+
NSMenuItem *editMenuItem = [[NSApp mainMenu] itemWithTitle:kViewMenuItemTitle];
5888

5989
if(editMenuItem == nil) {
6090
return;
6191
}
6292

6393
[editMenuItem.submenu addItem:[NSMenuItem separatorItem]];
6494

65-
NSMenuItem *minimapMenuItem = [[NSMenuItem alloc] initWithTitle:@"Minimap" action:nil keyEquivalent:@""];
95+
NSMenuItem *minimapMenuItem = [[NSMenuItem alloc] initWithTitle:kMinimapMenuItemTitle action:nil keyEquivalent:@""];
6696
[editMenuItem.submenu addItem:minimapMenuItem];
6797

6898
NSMenu *minimapMenu = [[NSMenu alloc] init];
6999
{
70-
NSMenuItem *showHideMinimapItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@"M"];
100+
NSMenuItem *showHideMinimapItem = [[NSMenuItem alloc] initWithTitle:@"" action:@selector(toggleMinimap:) keyEquivalent:@"M"];
71101
[showHideMinimapItem setKeyEquivalentModifierMask:NSControlKeyMask | NSShiftKeyMask];
72102
[showHideMinimapItem setTarget:self];
73103
[minimapMenu addItem:showHideMinimapItem];
74104

75-
if ([[NSUserDefaults standardUserDefaults] boolForKey:SCXodeMinimapIsInitiallyHidden]) {
76-
[self hideMiniMap:showHideMinimapItem];
77-
}
78-
else {
79-
[self showMiniMap:showHideMinimapItem];
80-
}
105+
BOOL shouldDisplayMinimap = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldDisplay] boolValue];
106+
[showHideMinimapItem setTitle:(shouldDisplayMinimap ? kHideMinimapMenuItemTitle : kShowMinimapMenuItemTitle)];
81107

82108
[minimapMenu addItem:[NSMenuItem separatorItem]];
83109
}
84110

85111
{
86-
NSMenuItem *themesMenuItem = [[NSMenuItem alloc] initWithTitle:@"Theme" action:nil keyEquivalent:@""];
112+
NSMenuItem *highlightCommentsMenuItem = [[NSMenuItem alloc] initWithTitle:kHighlightCommentsMenuItemTitle
113+
action:@selector(toggleCommentsHighlighting:) keyEquivalent:@""];
114+
[highlightCommentsMenuItem setTarget:self];
115+
[minimapMenu addItem:highlightCommentsMenuItem];
116+
117+
BOOL commentsHighlightingEnabled = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHighlightComments] boolValue];
118+
[highlightCommentsMenuItem setState:(commentsHighlightingEnabled ? NSOnState : NSOffState)];
119+
120+
121+
NSMenuItem *highlightPreprocessorMenuItem = [[NSMenuItem alloc] initWithTitle:kHighlightPreprocessorMenuItemTitle
122+
action:@selector(togglePreprocessorHighlighting:) keyEquivalent:@""];
123+
[highlightPreprocessorMenuItem setTarget:self];
124+
[minimapMenu addItem:highlightPreprocessorMenuItem];
125+
126+
BOOL preprocessorHighlightingEnabled = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHighlightPreprocessor] boolValue];
127+
[highlightPreprocessorMenuItem setState:(preprocessorHighlightingEnabled ? NSOnState : NSOffState)];
128+
129+
130+
NSMenuItem *hideEditorScrollerMenuItem = [[NSMenuItem alloc] initWithTitle:kHideEditorScrollerMenuItemTitle
131+
action:@selector(toggleEditorScrollerHiding:) keyEquivalent:@""];
132+
[hideEditorScrollerMenuItem setTarget:self];
133+
[minimapMenu addItem:hideEditorScrollerMenuItem];
134+
135+
BOOL shouldHideEditorScroller = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHideEditorScroller] boolValue];
136+
[hideEditorScrollerMenuItem setState:(shouldHideEditorScroller ? NSOnState : NSOffState)];
137+
138+
139+
[minimapMenu addItem:[NSMenuItem separatorItem]];
140+
}
141+
142+
{
143+
NSMenuItem *themesMenuItem = [[NSMenuItem alloc] initWithTitle:kThemeMenuItemTitle action:nil keyEquivalent:@""];
87144
[minimapMenu addItem:themesMenuItem];
88145

89146
NSMenu *themesMenu = [[NSMenu alloc] init];
90147
{
91-
NSMenuItem *editorThemeMenuItem = [[NSMenuItem alloc] initWithTitle:@"Editor Theme" action:@selector(setMinimapTheme:) keyEquivalent:@""];
148+
NSString *currentThemeName = [[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapTheme];
149+
150+
NSMenuItem *editorThemeMenuItem = [[NSMenuItem alloc] initWithTitle:kEditorThemeMenuItemTitle action:@selector(setMinimapTheme:) keyEquivalent:@""];
92151
[editorThemeMenuItem setTarget:self];
93152
[themesMenu addItem:editorThemeMenuItem];
94153

154+
if(currentThemeName == nil) {
155+
[editorThemeMenuItem setState:NSOnState];
156+
}
157+
95158
[themesMenu addItem:[NSMenuItem separatorItem]];
96159

97160
NSArray *themes = [[DVTFontAndColorTheme preferenceSetsManager] availablePreferenceSets];
@@ -102,6 +165,10 @@ - (void)createMenuItem
102165
NSMenuItem *themeMenuItem = [[NSMenuItem alloc] initWithTitle:theme.localizedName action:@selector(setMinimapTheme:) keyEquivalent:@""];
103166
[themeMenuItem setTarget:self];
104167
[themesMenu addItem:themeMenuItem];
168+
169+
if([theme.localizedName isEqualToString:currentThemeName]) {
170+
[themeMenuItem setState:NSOnState];
171+
}
105172
}
106173

107174
[themesMenu addItem:[NSMenuItem separatorItem]];
@@ -110,6 +177,10 @@ - (void)createMenuItem
110177
NSMenuItem *themeMenuItem = [[NSMenuItem alloc] initWithTitle:theme.localizedName action:@selector(setMinimapTheme:) keyEquivalent:@""];
111178
[themeMenuItem setTarget:self];
112179
[themesMenu addItem:themeMenuItem];
180+
181+
if([theme.localizedName isEqualToString:currentThemeName]) {
182+
[themeMenuItem setState:NSOnState];
183+
}
113184
}
114185
}
115186
[themesMenuItem setSubmenu:themesMenu];
@@ -118,35 +189,64 @@ - (void)createMenuItem
118189
[minimapMenuItem setSubmenu:minimapMenu];
119190
}
120191

121-
- (void)hideMiniMap:(NSMenuItem *)sender
192+
- (void)toggleMinimap:(NSMenuItem *)sender
122193
{
123-
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:SCXodeMinimapIsInitiallyHidden];
194+
BOOL shouldDisplayMinimap = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldDisplay] boolValue];
124195

125-
[sender setTitle:@"Show Minimap"];
126-
[sender setAction:@selector(showMiniMap:)];
196+
[sender setTitle:(shouldDisplayMinimap ? kHideMinimapMenuItemTitle : kShowMinimapMenuItemTitle)];
197+
[[NSUserDefaults standardUserDefaults] setObject:@(!shouldDisplayMinimap) forKey:SCXcodeMinimapShouldDisplay];
198+
[[NSNotificationCenter defaultCenter] postNotificationName:SCXcodeMinimapShouldDisplayChangeNotification object:nil];
199+
}
200+
201+
- (void)toggleCommentsHighlighting:(NSMenuItem *)sender
202+
{
203+
BOOL commentsHighlightingEnabled = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHighlightComments] boolValue];
127204

128-
[[NSNotificationCenter defaultCenter] postNotificationName:SCXodeMinimapHideNotification object:nil];
205+
[sender setState:(commentsHighlightingEnabled ? NSOffState : NSOnState)];
206+
[[NSUserDefaults standardUserDefaults] setObject:@(!commentsHighlightingEnabled) forKey:SCXcodeMinimapShouldHighlightComments];
207+
[[NSNotificationCenter defaultCenter] postNotificationName:SCXcodeMinimapHighlightCommentsChangeNotification object:nil];
129208
}
130209

131-
- (void)showMiniMap:(NSMenuItem *)sender
210+
- (void)togglePreprocessorHighlighting:(NSMenuItem *)sender
132211
{
133-
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:SCXodeMinimapIsInitiallyHidden];
212+
BOOL preprocessorHighlightingEnabled = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHighlightPreprocessor] boolValue];
134213

135-
[sender setTitle:@"Hide Minimap"];
136-
[sender setAction:@selector(hideMiniMap:)];
214+
[sender setState:(preprocessorHighlightingEnabled ? NSOffState : NSOnState)];
215+
[[NSUserDefaults standardUserDefaults] setObject:@(!preprocessorHighlightingEnabled) forKey:SCXcodeMinimapShouldHighlightPreprocessor];
216+
[[NSNotificationCenter defaultCenter] postNotificationName:SCXcodeMinimapHighlightPreprocessorChangeNotification object:nil];
217+
}
218+
219+
- (void)toggleEditorScrollerHiding:(NSMenuItem *)sender
220+
{
221+
BOOL shouldHideEditorScroller = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHideEditorScroller] boolValue];
137222

138-
[[NSNotificationCenter defaultCenter] postNotificationName:SCXodeMinimapShowNotification object:nil];
223+
[sender setState:(shouldHideEditorScroller ? NSOffState : NSOnState)];
224+
[[NSUserDefaults standardUserDefaults] setObject:@(!shouldHideEditorScroller) forKey:SCXcodeMinimapShouldHideEditorScroller];
225+
[[NSNotificationCenter defaultCenter] postNotificationName:SCXcodeMinimapHideEditorScrollerChangeNotification object:nil];
139226
}
140227

141228
- (void)setMinimapTheme:(NSMenuItem *)sender
142229
{
230+
NSString *currentThemeName = [[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapTheme];
231+
232+
if(currentThemeName == sender.title || [currentThemeName isEqualToString:sender.title]) {
233+
return;
234+
}
235+
236+
NSMenu *themesSubmenu = [[[[NSApp mainMenu] itemWithTitle:kViewMenuItemTitle].submenu itemWithTitle:kMinimapMenuItemTitle].submenu itemWithTitle:kThemeMenuItemTitle].submenu;
237+
for(NSMenuItem *item in themesSubmenu.itemArray) {
238+
[item setState:NSOffState];
239+
}
240+
241+
[sender setState:NSOnState];
242+
143243
if([sender.menu indexOfItem:sender] == 0) {
144-
[[NSUserDefaults standardUserDefaults] removeObjectForKey:SCXodeMinimapTheme];
244+
[[NSUserDefaults standardUserDefaults] removeObjectForKey:SCXcodeMinimapTheme];
145245
} else {
146-
[[NSUserDefaults standardUserDefaults] setObject:sender.title forKey:SCXodeMinimapTheme];
246+
[[NSUserDefaults standardUserDefaults] setObject:sender.title forKey:SCXcodeMinimapTheme];
147247
}
148248

149-
[[NSNotificationCenter defaultCenter] postNotificationName:SCXodeMinimapThemeChangeNotification object:nil];
249+
[[NSNotificationCenter defaultCenter] postNotificationName:SCXcodeMinimapThemeChangeNotification object:nil];
150250
}
151251

152252
#pragma mark - Xcode Notification
@@ -167,7 +267,7 @@ - (void)onDidFinishSetup:(NSNotification*)sender
167267
SCXcodeMinimapView *miniMapView = [[SCXcodeMinimapView alloc] initWithFrame:miniMapScrollViewFrame editor:editor];
168268
[editor.containerView addSubview:miniMapView];
169269

170-
[miniMapView setVisible:![[NSUserDefaults standardUserDefaults] boolForKey:SCXodeMinimapIsInitiallyHidden]];
270+
[miniMapView setVisible:[[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldDisplay] boolValue]];
171271
}
172272

173273
@end

SCXcodeMinimap/SCXcodeMinimapView.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
- (instancetype)initWithFrame:(NSRect)frame editor:(IDESourceCodeEditor *)editor;
1616

17-
- (void)updateOffset;
18-
1917
- (void)setVisible:(BOOL)visible;
2018

2119
@end

SCXcodeMinimap/SCXcodeMinimapView.m

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ - (instancetype)initWithFrame:(NSRect)frame editor:(IDESourceCodeEditor *)editor
7070
self.editorScrollView = editor.scrollView;
7171
self.editorTextView = editor.textView;
7272

73-
7473
[self setWantsLayer:YES];
7574
[self setAutoresizingMask:NSViewMinXMargin | NSViewHeightSizable];
7675

77-
7876
self.scrollView = [[NSScrollView alloc] initWithFrame:self.bounds];
7977
[self.scrollView setAutoresizingMask:NSViewMinXMargin | NSViewHeightSizable];
8078
[self.scrollView setDrawsBackground:NO];
@@ -95,28 +93,35 @@ - (instancetype)initWithFrame:(NSRect)frame editor:(IDESourceCodeEditor *)editor
9593
[self.scrollView setMaxMagnification:kDefaultZoomLevel];
9694
[self.scrollView setMagnification:kDefaultZoomLevel];
9795

98-
9996
self.selectionView = [[SCXcodeMinimapSelectionView alloc] init];
10097
[self.textView addSubview:_selectionView];
10198

102-
10399
[self updateTheme];
104100

101+
[self.editorScrollView setHasVerticalScroller:![[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHideEditorScroller] boolValue]];
105102

106103
__weak typeof(self) weakSelf = self;
107-
[[NSNotificationCenter defaultCenter] addObserverForName:SCXodeMinimapShowNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
108-
[weakSelf setVisible:YES];
104+
[[NSNotificationCenter defaultCenter] addObserverForName:SCXcodeMinimapShouldDisplayChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
105+
[weakSelf setVisible:[[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldDisplay] boolValue]];
109106
}];
110107

111-
[[NSNotificationCenter defaultCenter] addObserverForName:SCXodeMinimapHideNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
112-
[weakSelf setVisible:NO];
108+
[[NSNotificationCenter defaultCenter] addObserverForName:SCXcodeMinimapHighlightCommentsChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
109+
[weakSelf invalidateVisibleMinimapRange];
113110
}];
114111

115-
[[NSNotificationCenter defaultCenter] addObserverForName:DVTFontAndColorSourceTextSettingsChangedNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
116-
[weakSelf updateTheme];
112+
[[NSNotificationCenter defaultCenter] addObserverForName:SCXcodeMinimapHighlightPreprocessorChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
113+
[weakSelf invalidateVisibleMinimapRange];
114+
}];
115+
116+
[[NSNotificationCenter defaultCenter] addObserverForName:SCXcodeMinimapHideEditorScrollerChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
117+
[weakSelf.editorScrollView setHasVerticalScroller:![[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHideEditorScroller] boolValue]];
117118
}];
118119

119-
[[NSNotificationCenter defaultCenter] addObserverForName:SCXodeMinimapThemeChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
120+
[[NSNotificationCenter defaultCenter] addObserverForName:SCXcodeMinimapThemeChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
121+
[weakSelf updateTheme];
122+
}];
123+
124+
[[NSNotificationCenter defaultCenter] addObserverForName:DVTFontAndColorSourceTextSettingsChangedNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
120125
[weakSelf updateTheme];
121126
}];
122127

@@ -171,13 +176,21 @@ - (NSDictionary *)layoutManager:(NSLayoutManager *)layoutManager
171176
effectiveRange:effectiveCharRange
172177
context:self.editorTextView.syntaxColoringContext];
173178

174-
if(nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxCommentNodeName] ||
175-
nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxCommentDocNodeName] ||
176-
nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxCommentDocKeywordNodeName])
177-
{
178-
return @{NSForegroundColorAttributeName : self.theme.sourceTextBackgroundColor, NSBackgroundColorAttributeName : self.commentColor};
179-
} else if(nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxPreprocessorNodeName]) {
180-
return @{NSForegroundColorAttributeName : self.theme.sourceTextBackgroundColor, NSBackgroundColorAttributeName : self.preprocessorColor};
179+
BOOL shouldHighlightComments = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHighlightComments] boolValue];
180+
if(shouldHighlightComments) {
181+
if(nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxCommentNodeName] ||
182+
nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxCommentDocNodeName] ||
183+
nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxCommentDocKeywordNodeName])
184+
{
185+
return @{NSForegroundColorAttributeName : self.theme.sourceTextBackgroundColor, NSBackgroundColorAttributeName : self.commentColor};
186+
}
187+
}
188+
189+
BOOL shouldHighlightPreprocessor = [[[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapShouldHighlightPreprocessor] boolValue];
190+
if(shouldHighlightPreprocessor) {
191+
if(nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:kXcodeSyntaxPreprocessorNodeName]) {
192+
return @{NSForegroundColorAttributeName : self.theme.sourceTextBackgroundColor, NSBackgroundColorAttributeName : self.preprocessorColor};
193+
}
181194
}
182195

183196
NSColor *color = [self.theme.syntaxColorsByNodeType pointerAtIndex:nodeType];
@@ -265,7 +278,7 @@ - (void)updateTheme
265278
DVTPreferenceSetManager *preferenceSetManager = [DVTFontAndColorTheme preferenceSetsManager];
266279
NSArray *preferenceSet = [preferenceSetManager availablePreferenceSets];
267280

268-
NSString *themeName = [[NSUserDefaults standardUserDefaults] objectForKey:SCXodeMinimapTheme];
281+
NSString *themeName = [[NSUserDefaults standardUserDefaults] objectForKey:SCXcodeMinimapTheme];
269282
NSUInteger themeIndex = [preferenceSet indexesOfObjectsPassingTest:^BOOL(DVTFontAndColorTheme *theme, NSUInteger idx, BOOL *stop) {
270283
return [theme.localizedName isEqualTo:themeName];
271284
}].lastIndex;

0 commit comments

Comments
 (0)