2121NSString *const IDESourceCodeEditorDidFinishSetupNotification = @" IDESourceCodeEditorDidFinishSetup" ;
2222
2323NSString *const SCXcodeMinimapShouldDisplayChangeNotification = @" SCXcodeMinimapShouldDisplayChangeNotification" ;
24- NSString *const SCXcodeMinimapShouldDisplay = @" SCXcodeMinimapShouldDisplay " ;
24+ NSString *const SCXcodeMinimapShouldDisplayKey = @" SCXcodeMinimapShouldDisplayKey " ;
2525
2626NSString *const SCXcodeMinimapHighlightBreakpointsChangeNotification = @" SCXcodeMinimapHighlightBreakpointsChangeNotification" ;
27- NSString *const SCXcodeMinimapShouldHighlightBreakpoints = @" SCXcodeMinimapShouldHighlightBreakpoints " ;
27+ NSString *const SCXcodeMinimapShouldHighlightBreakpointsKey = @" SCXcodeMinimapShouldHighlightBreakpointsKey " ;
2828
2929NSString *const SCXcodeMinimapHighlightCommentsChangeNotification = @" SCXcodeMinimapHighlightCommentsChangeNotification" ;
30- NSString *const SCXcodeMinimapShouldHighlightComments = @" SCXcodeMinimapShouldHighlightComments " ;
30+ NSString *const SCXcodeMinimapShouldHighlightCommentsKey = @" SCXcodeMinimapShouldHighlightCommentsKey " ;
3131
3232NSString *const SCXcodeMinimapHighlightPreprocessorChangeNotification = @" SCXcodeMinimapHighlightPreprocessorChangeNotification" ;
33- NSString *const SCXcodeMinimapShouldHighlightPreprocessor = @" SCXcodeMinimapShouldHighlightPreprocessor" ;
33+ NSString *const SCXcodeMinimapShouldHighlightPreprocessorKey = @" SCXcodeMinimapShouldHighlightPreprocessorKey" ;
34+
35+ NSString *const SCXcodeMinimapHighlightEditorChangeNotification = @" SCXcodeMinimapHighlightEditorChangeNotification" ;
36+ NSString *const SCXcodeMinimapShouldHighlightEditorKey = @" SCXcodeMinimapShouldHighlightEditorKey" ;
3437
3538NSString *const SCXcodeMinimapHideEditorScrollerChangeNotification = @" SCXcodeMinimapHideEditorScrollerChangeNotification" ;
36- NSString *const SCXcodeMinimapShouldHideEditorScroller = @" SCXcodeMinimapShouldHideEditorScroller " ;
39+ NSString *const SCXcodeMinimapShouldHideEditorScrollerKey = @" SCXcodeMinimapShouldHideEditorScrollerKey " ;
3740
3841NSString *const SCXcodeMinimapThemeChangeNotification = @" SCXcodeMinimapThemeChangeNotification" ;
39- NSString *const SCXcodeMinimapTheme = @" SCXcodeMinimapTheme " ;
42+ NSString *const SCXcodeMinimapThemeKey = @" SCXcodeMinimapThemeKey " ;
4043
4144NSString *const kViewMenuItemTitle = @" View" ;
4245
4750NSString *const kHighlightBreakpointsMenuItemTitle = @" Highlight breakpoints" ;
4851NSString *const kHighlightCommentsMenuItemTitle = @" Highlight comments" ;
4952NSString *const kHighlightPreprocessorMenuItemTitle = @" Highlight preprocessor" ;
53+ NSString *const kHighlightEditorMenuItemTitle = @" Highlight main editor" ;
5054NSString *const kHideEditorScrollerMenuItemTitle = @" Hide editor scroller" ;
5155
5256NSString *const kThemeMenuItemTitle = @" Theme" ;
@@ -77,10 +81,10 @@ - (id)init
7781
7882- (void )registerUserDefaults
7983{
80- NSDictionary *userDefaults = @{SCXcodeMinimapShouldDisplay : @(YES ),
81- SCXcodeMinimapShouldHighlightBreakpoints : @(YES ),
82- SCXcodeMinimapShouldHighlightComments : @(YES ),
83- SCXcodeMinimapShouldHighlightPreprocessor : @(YES )};
84+ NSDictionary *userDefaults = @{SCXcodeMinimapShouldDisplayKey : @(YES ),
85+ SCXcodeMinimapShouldHighlightBreakpointsKey : @(YES ),
86+ SCXcodeMinimapShouldHighlightCommentsKey : @(YES ),
87+ SCXcodeMinimapShouldHighlightPreprocessorKey : @(YES )};
8488
8589 [[NSUserDefaults standardUserDefaults ] registerDefaults: userDefaults];
8690}
@@ -107,7 +111,7 @@ - (void)createMenuItem
107111 [showHideMinimapItem setTarget: self ];
108112 [minimapMenu addItem: showHideMinimapItem];
109113
110- BOOL shouldDisplayMinimap = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldDisplay ] boolValue ];
114+ BOOL shouldDisplayMinimap = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldDisplayKey ] boolValue ];
111115 [showHideMinimapItem setTitle: (shouldDisplayMinimap ? kHideMinimapMenuItemTitle : kShowMinimapMenuItemTitle )];
112116
113117 [minimapMenu addItem: [NSMenuItem separatorItem ]];
@@ -119,7 +123,7 @@ - (void)createMenuItem
119123 [highlightBreakpointsMenuItem setTarget: self ];
120124 [minimapMenu addItem: highlightBreakpointsMenuItem];
121125
122- BOOL breakpointHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightBreakpoints ] boolValue ];
126+ BOOL breakpointHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightBreakpointsKey ] boolValue ];
123127 [highlightBreakpointsMenuItem setState: (breakpointHighlightingEnabled ? NSOnState : NSOffState )];
124128
125129
@@ -128,7 +132,7 @@ - (void)createMenuItem
128132 [highlightCommentsMenuItem setTarget: self ];
129133 [minimapMenu addItem: highlightCommentsMenuItem];
130134
131- BOOL commentsHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightComments ] boolValue ];
135+ BOOL commentsHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightCommentsKey ] boolValue ];
132136 [highlightCommentsMenuItem setState: (commentsHighlightingEnabled ? NSOnState : NSOffState )];
133137
134138
@@ -137,16 +141,25 @@ - (void)createMenuItem
137141 [highlightPreprocessorMenuItem setTarget: self ];
138142 [minimapMenu addItem: highlightPreprocessorMenuItem];
139143
140- BOOL preprocessorHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightPreprocessor ] boolValue ];
144+ BOOL preprocessorHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightPreprocessorKey ] boolValue ];
141145 [highlightPreprocessorMenuItem setState: (preprocessorHighlightingEnabled ? NSOnState : NSOffState )];
142146
143147
148+ NSMenuItem *highlightEditorMenuItem = [[NSMenuItem alloc ] initWithTitle: kHighlightEditorMenuItemTitle
149+ action: @selector (toggleEditorHighlighting: ) keyEquivalent: @" " ];
150+ [highlightEditorMenuItem setTarget: self ];
151+ [minimapMenu addItem: highlightEditorMenuItem];
152+
153+ BOOL editorHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightEditorKey] boolValue ];
154+ [highlightEditorMenuItem setState: (editorHighlightingEnabled ? NSOnState : NSOffState )];
155+
156+
144157 NSMenuItem *hideEditorScrollerMenuItem = [[NSMenuItem alloc ] initWithTitle: kHideEditorScrollerMenuItemTitle
145158 action: @selector (toggleEditorScrollerHiding: ) keyEquivalent: @" " ];
146159 [hideEditorScrollerMenuItem setTarget: self ];
147160 [minimapMenu addItem: hideEditorScrollerMenuItem];
148161
149- BOOL shouldHideEditorScroller = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHideEditorScroller ] boolValue ];
162+ BOOL shouldHideEditorScroller = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHideEditorScrollerKey ] boolValue ];
150163 [hideEditorScrollerMenuItem setState: (shouldHideEditorScroller ? NSOnState : NSOffState )];
151164
152165
@@ -159,7 +172,7 @@ - (void)createMenuItem
159172
160173 NSMenu *themesMenu = [[NSMenu alloc ] init ];
161174 {
162- NSString *currentThemeName = [[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapTheme ];
175+ NSString *currentThemeName = [[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapThemeKey ];
163176
164177 NSMenuItem *editorThemeMenuItem = [[NSMenuItem alloc ] initWithTitle: kEditorThemeMenuItemTitle action: @selector (setMinimapTheme: ) keyEquivalent: @" " ];
165178 [editorThemeMenuItem setTarget: self ];
@@ -205,52 +218,61 @@ - (void)createMenuItem
205218
206219- (void )toggleMinimap : (NSMenuItem *)sender
207220{
208- BOOL shouldDisplayMinimap = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldDisplay ] boolValue ];
221+ BOOL shouldDisplayMinimap = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldDisplayKey ] boolValue ];
209222
210223 [sender setTitle: (shouldDisplayMinimap ? kHideMinimapMenuItemTitle : kShowMinimapMenuItemTitle )];
211- [[NSUserDefaults standardUserDefaults ] setObject: @(!shouldDisplayMinimap) forKey: SCXcodeMinimapShouldDisplay ];
224+ [[NSUserDefaults standardUserDefaults ] setObject: @(!shouldDisplayMinimap) forKey: SCXcodeMinimapShouldDisplayKey ];
212225 [[NSNotificationCenter defaultCenter ] postNotificationName: SCXcodeMinimapShouldDisplayChangeNotification object: nil ];
213226}
214227
215228- (void )toggleBreakpointHighlighting : (NSMenuItem *)sender
216229{
217- BOOL breakpointHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightBreakpoints ] boolValue ];
230+ BOOL breakpointHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightBreakpointsKey ] boolValue ];
218231
219232 [sender setState: (breakpointHighlightingEnabled ? NSOffState : NSOnState )];
220- [[NSUserDefaults standardUserDefaults ] setObject: @(!breakpointHighlightingEnabled) forKey: SCXcodeMinimapShouldHighlightBreakpoints ];
233+ [[NSUserDefaults standardUserDefaults ] setObject: @(!breakpointHighlightingEnabled) forKey: SCXcodeMinimapShouldHighlightBreakpointsKey ];
221234 [[NSNotificationCenter defaultCenter ] postNotificationName: SCXcodeMinimapHighlightBreakpointsChangeNotification object: nil ];
222235}
223236
224237- (void )toggleCommentsHighlighting : (NSMenuItem *)sender
225238{
226- BOOL commentsHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightComments ] boolValue ];
239+ BOOL commentsHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightCommentsKey ] boolValue ];
227240
228241 [sender setState: (commentsHighlightingEnabled ? NSOffState : NSOnState )];
229- [[NSUserDefaults standardUserDefaults ] setObject: @(!commentsHighlightingEnabled) forKey: SCXcodeMinimapShouldHighlightComments ];
242+ [[NSUserDefaults standardUserDefaults ] setObject: @(!commentsHighlightingEnabled) forKey: SCXcodeMinimapShouldHighlightCommentsKey ];
230243 [[NSNotificationCenter defaultCenter ] postNotificationName: SCXcodeMinimapHighlightCommentsChangeNotification object: nil ];
231244}
232245
233246- (void )togglePreprocessorHighlighting : (NSMenuItem *)sender
234247{
235- BOOL preprocessorHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightPreprocessor ] boolValue ];
248+ BOOL preprocessorHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightPreprocessorKey ] boolValue ];
236249
237250 [sender setState: (preprocessorHighlightingEnabled ? NSOffState : NSOnState )];
238- [[NSUserDefaults standardUserDefaults ] setObject: @(!preprocessorHighlightingEnabled) forKey: SCXcodeMinimapShouldHighlightPreprocessor ];
251+ [[NSUserDefaults standardUserDefaults ] setObject: @(!preprocessorHighlightingEnabled) forKey: SCXcodeMinimapShouldHighlightPreprocessorKey ];
239252 [[NSNotificationCenter defaultCenter ] postNotificationName: SCXcodeMinimapHighlightPreprocessorChangeNotification object: nil ];
240253}
241254
255+ - (void )toggleEditorHighlighting : (NSMenuItem *)sender
256+ {
257+ BOOL editorHighlightingEnabled = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHighlightEditorKey] boolValue ];
258+
259+ [sender setState: (editorHighlightingEnabled ? NSOffState : NSOnState )];
260+ [[NSUserDefaults standardUserDefaults ] setObject: @(!editorHighlightingEnabled) forKey: SCXcodeMinimapShouldHighlightEditorKey];
261+ [[NSNotificationCenter defaultCenter ] postNotificationName: SCXcodeMinimapHighlightEditorChangeNotification object: nil ];
262+ }
263+
242264- (void )toggleEditorScrollerHiding : (NSMenuItem *)sender
243265{
244- BOOL shouldHideEditorScroller = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHideEditorScroller ] boolValue ];
266+ BOOL shouldHideEditorScroller = [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldHideEditorScrollerKey ] boolValue ];
245267
246268 [sender setState: (shouldHideEditorScroller ? NSOffState : NSOnState )];
247- [[NSUserDefaults standardUserDefaults ] setObject: @(!shouldHideEditorScroller) forKey: SCXcodeMinimapShouldHideEditorScroller ];
269+ [[NSUserDefaults standardUserDefaults ] setObject: @(!shouldHideEditorScroller) forKey: SCXcodeMinimapShouldHideEditorScrollerKey ];
248270 [[NSNotificationCenter defaultCenter ] postNotificationName: SCXcodeMinimapHideEditorScrollerChangeNotification object: nil ];
249271}
250272
251273- (void )setMinimapTheme : (NSMenuItem *)sender
252274{
253- NSString *currentThemeName = [[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapTheme ];
275+ NSString *currentThemeName = [[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapThemeKey ];
254276
255277 if (currentThemeName == sender.title || [currentThemeName isEqualToString: sender.title]) {
256278 return ;
@@ -264,9 +286,9 @@ - (void)setMinimapTheme:(NSMenuItem *)sender
264286 [sender setState: NSOnState ];
265287
266288 if ([sender.menu indexOfItem: sender] == 0 ) {
267- [[NSUserDefaults standardUserDefaults ] removeObjectForKey: SCXcodeMinimapTheme ];
289+ [[NSUserDefaults standardUserDefaults ] removeObjectForKey: SCXcodeMinimapThemeKey ];
268290 } else {
269- [[NSUserDefaults standardUserDefaults ] setObject: sender.title forKey: SCXcodeMinimapTheme ];
291+ [[NSUserDefaults standardUserDefaults ] setObject: sender.title forKey: SCXcodeMinimapThemeKey ];
270292 }
271293
272294 [[NSNotificationCenter defaultCenter ] postNotificationName: SCXcodeMinimapThemeChangeNotification object: nil ];
@@ -290,7 +312,7 @@ - (void)onDidFinishSetup:(NSNotification*)sender
290312 SCXcodeMinimapView *miniMapView = [[SCXcodeMinimapView alloc ] initWithFrame: miniMapScrollViewFrame editor: editor];
291313 [editor.containerView addSubview: miniMapView];
292314
293- [miniMapView setVisible: [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldDisplay ] boolValue ]];
315+ [miniMapView setVisible: [[[NSUserDefaults standardUserDefaults ] objectForKey: SCXcodeMinimapShouldDisplayKey ] boolValue ]];
294316}
295317
296318@end
0 commit comments