Skip to content

Commit 4776cbb

Browse files
committed
Moved the MiniMap show/hide menu item to the View menu and added a Ctrl+Shift+M shortcut
1 parent 3ae360d commit 4776cbb

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

SCXcodeMinimap/SCMiniMapView.m

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#import "SCMiniMapView.h"
1010
#import "SCXcodeMinimap.h"
11-
#import <QuartzCore/QuartzCore.h>
1211

1312
@implementation SCMiniMapView
1413

@@ -91,7 +90,7 @@ - (SCSelectionView *)selectionView
9190

9291
#pragma mark - Show/Hide
9392

94-
- (void) show
93+
- (void)show
9594
{
9695
self.hidden = NO;
9796

@@ -103,7 +102,7 @@ - (void) show
103102
[self updateSelectionView];
104103
}
105104

106-
- (void) hide
105+
- (void)hide
107106
{
108107
self.hidden = YES;
109108

@@ -204,19 +203,18 @@ - (void)mouseDragged:(NSEvent *)theEvent
204203

205204
- (void) handleMouseEvent:(NSEvent *)theEvent
206205
{
207-
NSPoint locationInSelf = [self convertPoint:theEvent.locationInWindow fromView:nil];
208-
209-
NSSize textSize = [self.textView.layoutManager usedRectForTextContainer:self.textView.textContainer].size;
210-
NSSize frameSize = self.frame.size;
206+
NSPoint locationInSelf = [self convertPoint:theEvent.locationInWindow fromView:nil];
211207

212-
NSLog(@"text Height : %f ; frame Height : %f",textSize.height, frameSize.height);
213-
NSPoint point;
214-
if (textSize.height < frameSize.height) {
215-
point = NSMakePoint(locationInSelf.x / textSize.width, locationInSelf.y / textSize.height);
216-
}
217-
else {
218-
point = NSMakePoint(locationInSelf.x / textSize.width, locationInSelf.y / frameSize.height);
219-
}
208+
NSSize textSize = [self.textView.layoutManager usedRectForTextContainer:self.textView.textContainer].size;
209+
NSSize frameSize = self.frame.size;
210+
211+
NSPoint point;
212+
if (textSize.height < frameSize.height) {
213+
point = NSMakePoint(locationInSelf.x / textSize.width, locationInSelf.y / textSize.height);
214+
}
215+
else {
216+
point = NSMakePoint(locationInSelf.x / textSize.width, locationInSelf.y / frameSize.height);
217+
}
220218

221219
[self goAtRelativePosition:point];
222220
}

SCXcodeMinimap/SCXcodeMinimap.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#import "SCMiniMapView.h"
1010
#import "SCXcodeMinimap.h"
11-
#import "SCSelectionView.h"
1211
#import <objc/runtime.h>
1312

1413
static char kKeyMiniMapView;
@@ -45,10 +44,11 @@ - (id)init {
4544

4645
- (void)createMenuItem
4746
{
48-
NSMenuItem *editMenuItem = [[NSApp mainMenu] itemWithTitle:@"Edit"];
49-
NSMenuItem *miniMapItem = [[NSMenuItem alloc] initWithTitle:@"Show Mini Map"
47+
NSMenuItem *editMenuItem = [[NSApp mainMenu] itemWithTitle:@"View"];
48+
NSMenuItem *miniMapItem = [[NSMenuItem alloc] initWithTitle:@""
5049
action:NULL
51-
keyEquivalent:@""];
50+
keyEquivalent:@"M"];
51+
[miniMapItem setKeyEquivalentModifierMask:NSControlKeyMask | NSShiftKeyMask];
5252

5353
miniMapItem.target = self;
5454

@@ -67,21 +67,21 @@ - (void)createMenuItem
6767
}
6868
}
6969

70-
- (void) hideMiniMap:(NSMenuItem *)sender
70+
- (void)hideMiniMap:(NSMenuItem *)sender
7171
{
7272
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:SCXodeMinimapIsInitiallyHidden];
7373

74-
[sender setState:NSOffState];
74+
[sender setTitle:@"Show MiniMap"];
7575
[sender setAction:@selector(showMiniMap:)];
7676

7777
[[NSNotificationCenter defaultCenter] postNotificationName:SCXodeMinimapWantsToBeHiddenNotification object:nil];
7878
}
7979

80-
- (void) showMiniMap:(NSMenuItem *)sender
80+
- (void)showMiniMap:(NSMenuItem *)sender
8181
{
8282
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:SCXodeMinimapIsInitiallyHidden];
8383

84-
[sender setState:NSOnState];
84+
[sender setTitle:@"Hide MiniMap"];
8585
[sender setAction:@selector(hideMiniMap:)];
8686

8787
[[NSNotificationCenter defaultCenter] postNotificationName:SCXodeMinimapWantsToBeShownNotification object:nil];

0 commit comments

Comments
 (0)