Skip to content

Commit 493597c

Browse files
committed
Updating on theme changes.
1 parent 9095051 commit 493597c

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ SCXcodeMiniMap is a plugin that adds a source editor MiniMap to Xcode.
2121

2222
##Known issues
2323
- Line breaks don't match between the normal editor and the minimap
24-
- It doesn't update automatically on theme changes (switching between sources fixes it)
2524

2625
## License
2726
SCXcodeMiniMap is released under the GNU GENERAL PUBLIC LICENSE (see the LICENSE file)

SCXcodeMinimap/SCMiniMapView.m

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#import "SCMiniMapView.h"
1010
#import "SCXcodeMinimap.h"
1111

12+
static NSString * const DVTFontAndColorSourceTextSettingsChangedNotification = @"DVTFontAndColorSourceTextSettingsChangedNotification";
13+
1214
@implementation SCMiniMapView
1315

1416
- (id)initWithFrame:(NSRect)frame
@@ -33,6 +35,11 @@ - (id)initWithFrame:(NSRect)frame
3335
selector:@selector(hide)
3436
name:SCXodeMinimapWantsToBeHiddenNotification
3537
object:nil];
38+
39+
[[NSNotificationCenter defaultCenter] addObserver:self
40+
selector:@selector(updateTheme)
41+
name:DVTFontAndColorSourceTextSettingsChangedNotification
42+
object:nil];
3643
}
3744
return self;
3845
}
@@ -75,18 +82,7 @@ - (NSTextView *)textView
7582

7683
[self setDocumentView:_textView];
7784

78-
NSColor *miniMapBackgroundColor = [NSColor clearColor];
79-
Class DVTFontAndColorThemeClass = NSClassFromString(@"DVTFontAndColorTheme");
80-
81-
if([DVTFontAndColorThemeClass respondsToSelector:@selector(currentTheme)]) {
82-
83-
NSObject *theme = [DVTFontAndColorThemeClass performSelector:@selector(currentTheme)];
84-
if([theme respondsToSelector:@selector(sourceTextBackgroundColor)]) {
85-
miniMapBackgroundColor = [theme performSelector:@selector(sourceTextBackgroundColor)];
86-
}
87-
}
88-
89-
[_textView setBackgroundColor:[miniMapBackgroundColor shadowWithLevel:kDefaultShadowLevel]];
85+
[self updateTheme];
9086
}
9187

9288
return _textView;
@@ -129,6 +125,23 @@ - (void)hide
129125

130126
#pragma mark - Updating
131127

128+
- (void)updateTheme
129+
{
130+
NSColor *miniMapBackgroundColor = [NSColor clearColor];
131+
Class DVTFontAndColorThemeClass = NSClassFromString(@"DVTFontAndColorTheme");
132+
133+
if([DVTFontAndColorThemeClass respondsToSelector:@selector(currentTheme)]) {
134+
135+
NSObject *theme = [DVTFontAndColorThemeClass performSelector:@selector(currentTheme)];
136+
if([theme respondsToSelector:@selector(sourceTextBackgroundColor)]) {
137+
miniMapBackgroundColor = [theme performSelector:@selector(sourceTextBackgroundColor)];
138+
}
139+
}
140+
141+
[self.textView setBackgroundColor:[miniMapBackgroundColor shadowWithLevel:kDefaultShadowLevel]];
142+
[self.selectionView setNeedsDisplay:YES];
143+
}
144+
132145
- (void)updateTextView
133146
{
134147
if ([self isHidden]) {

SCXcodeMinimap/SCSelectionView.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ - (void)drawRect:(NSRect)dirtyRect
2828
NSRectFill(dirtyRect);
2929
}
3030

31+
- (void)setNeedsDisplay:(BOOL)flag
32+
{
33+
if(self.needsDisplay == flag) return;
34+
35+
[self setSelectionColor:nil];
36+
[super setNeedsDisplay:flag];
37+
}
38+
3139
- (NSColor *)selectionColor
3240
{
3341
if(_selectionColor == nil) {

SCXcodeMinimap/SCXcodeMinimap.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
static NSString * const IDESourceCodeEditorDidFinishSetupNotification = @"IDESourceCodeEditorDidFinishSetup";
1616
static NSString * const IDEEditorDocumentDidChangeNotification = @"IDEEditorDocumentDidChangeNotification";
1717
static NSString * const IDESourceCodeEditorTextViewBoundsDidChangeNotification = @"IDESourceCodeEditorTextViewBoundsDidChangeNotification";
18-
static NSString * const DVTFontAndColorSourceTextSettingsChangedNotification = @"DVTFontAndColorSourceTextSettingsChangedNotification";//Unused
1918

20-
NSString *const SCXodeMinimapWantsToBeShownNotification = @"SCXodeMinimapWantsToBeShownNotification";
21-
NSString *const SCXodeMinimapWantsToBeHiddenNotification = @"SCXodeMinimapWantsToBeHiddenNotification";
19+
NSString * const SCXodeMinimapWantsToBeShownNotification = @"SCXodeMinimapWantsToBeShownNotification";
20+
NSString * const SCXodeMinimapWantsToBeHiddenNotification = @"SCXodeMinimapWantsToBeHiddenNotification";
2221

23-
NSString *const SCXodeMinimapIsInitiallyHidden = @"SCXodeMinimapIsInitiallyHidden";
22+
NSString * const SCXodeMinimapIsInitiallyHidden = @"SCXodeMinimapIsInitiallyHidden";
2423

2524
@implementation SCXcodeMinimap
2625

0 commit comments

Comments
 (0)