Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Problem:    Mac: NSStringPboardType is deprecated.
Solution:   Use NSPasteboardTypeString. (Akshay Hegde, closes #3022)
  • Loading branch information
brammool committed Jun 17, 2018
1 parent 491ac28 commit d595a19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/os_macosx.m
Expand Up @@ -63,8 +63,13 @@
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

NSPasteboard *pb = [NSPasteboard generalPasteboard];
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
NSPasteboardTypeString, nil];
#else
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
NSStringPboardType, nil];
#endif
NSString *bestType = [pb availableTypeFromArray:supportedTypes];
if (!bestType) goto releasepool;

Expand All @@ -76,7 +81,7 @@
/* This type should consist of an array with two objects:
* 1. motion type (NSNumber)
* 2. text (NSString)
* If this is not the case we fall back on using NSStringPboardType.
* If this is not the case we fall back on using NSPasteboardTypeString.
*/
id plist = [pb propertyListForType:VimPboardType];
if ([plist isKindOfClass:[NSArray class]] && [plist count] == 2)
Expand All @@ -92,10 +97,15 @@

if (!string)
{
/* Use NSStringPboardType. The motion type is detected automatically.
/* Use NSPasteboardTypeString. The motion type is detected automatically.
*/
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
NSMutableString *mstring =
[[pb stringForType:NSPasteboardTypeString] mutableCopy];
#else
NSMutableString *mstring =
[[pb stringForType:NSStringPboardType] mutableCopy];
#endif
if (!mstring) goto releasepool;

/* Replace unrecognized end-of-line sequences with \x0a (line feed). */
Expand Down Expand Up @@ -178,15 +188,24 @@

/* See clip_mch_request_selection() for info on pasteboard types. */
NSPasteboard *pb = [NSPasteboard generalPasteboard];
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
NSPasteboardTypeString, nil];
#else
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
NSStringPboardType, nil];
#endif
[pb declareTypes:supportedTypes owner:nil];

NSNumber *motion = [NSNumber numberWithInt:motion_type];
NSArray *plist = [NSArray arrayWithObjects:motion, string, nil];
[pb setPropertyList:plist forType:VimPboardType];

#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
[pb setString:string forType:NSPasteboardTypeString];
#else
[pb setString:string forType:NSStringPboardType];
#endif

[string release];
}
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -761,6 +761,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
63,
/**/
62,
/**/
Expand Down

0 comments on commit d595a19

Please sign in to comment.