Skip to content

Commit f9a612a

Browse files
committed
Merge pull request #94 from macvim-dev/fix/deprecation-warnings
Fix deprecation warnings (except for NSCopyBits).
2 parents 7e1c6be + c4d75fb commit f9a612a

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/MacVim/MMAppController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,12 +1722,17 @@ - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event
17221722
while ((param = [enumerator nextObject])) {
17231723
NSArray *arr = [param componentsSeparatedByString:@"="];
17241724
if ([arr count] == 2) {
1725+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1726+
[dict setValue:[[arr lastObject] stringByRemovingPercentEncoding]
1727+
forKey:[[arr objectAtIndex:0] stringByRemovingPercentEncoding]];
1728+
#else
17251729
[dict setValue:[[arr lastObject]
17261730
stringByReplacingPercentEscapesUsingEncoding:
17271731
NSUTF8StringEncoding]
17281732
forKey:[[arr objectAtIndex:0]
17291733
stringByReplacingPercentEscapesUsingEncoding:
17301734
NSUTF8StringEncoding]];
1735+
#endif
17311736
}
17321737
}
17331738

src/MacVim/MMTextViewHelper.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,11 @@ - (void)scrollWheel:(NSEvent *)event
340340
// marked text moves outside the view as a result of scrolling.
341341
[self sendMarkedText:nil position:0];
342342
[self unmarkText];
343+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
344+
[[NSTextInputContext currentInputContext] discardMarkedText];
345+
#else
343346
[[NSInputManager currentInputManager] markedTextAbandoned:self];
347+
#endif
344348
}
345349

346350
float dx = [event deltaX];
@@ -773,7 +777,11 @@ - (NSRect)firstRectForCharacterRange:(NSRange)range
773777
rect.origin.y += rect.size.height;
774778

775779
rect.origin = [textView convertPoint:rect.origin toView:nil];
780+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
781+
rect = [[textView window] convertRectToScreen:rect];
782+
#else
776783
rect.origin = [[textView window] convertBaseToScreen:rect.origin];
784+
#endif
777785

778786
return rect;
779787
}
@@ -1117,9 +1125,13 @@ - (BOOL)inputManagerHandleMouseEvent:(NSEvent *)event
11171125
// the Kotoeri manager "commits" the text on left clicks).
11181126

11191127
if (event) {
1128+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
1129+
return [[NSTextInputContext currentInputContext] handleEvent:event];
1130+
#else
11201131
NSInputManager *imgr = [NSInputManager currentInputManager];
11211132
if ([imgr wantsToHandleMouseEvents])
11221133
return [imgr handleMouseEvent:event];
1134+
#endif
11231135
}
11241136

11251137
return NO;
@@ -1152,7 +1164,11 @@ - (void)abandonMarkedText
11521164
// that the marked text should be abandoned. (If pos is set to 0 Vim will
11531165
// send backspace sequences to delete the old marked text.)
11541166
[self sendMarkedText:nil position:-1];
1167+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
1168+
[[NSTextInputContext currentInputContext] discardMarkedText];
1169+
#else
11551170
[[NSInputManager currentInputManager] markedTextAbandoned:self];
1171+
#endif
11561172
}
11571173

11581174
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)

src/MacVim/MMVimView.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,10 @@ - (NSTabViewItem *)addNewTabViewItem
396396
// which tab should be selected at all times. However, the AppKit will
397397
// automatically select the first tab added to a tab view.
398398

399-
NSTabViewItem *tvi = [[NSTabViewItem alloc] initWithIdentifier:nil];
399+
// The documentation claims initWithIdentifier can be given a nil identifier, but the API itself
400+
// is decorated such that doing so produces a warning, so the tab count is used as identifier.
401+
NSInteger identifier = [[self tabView] numberOfTabViewItems];
402+
NSTabViewItem *tvi = [[NSTabViewItem alloc] initWithIdentifier:[NSNumber numberWithInt:identifier]];
400403

401404
// NOTE: If this is the first tab it will be automatically selected.
402405
vimTaskSelectedTab = YES;

0 commit comments

Comments
 (0)