diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 6224822dbc..8e1b6f2953 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -1138,7 +1138,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font); NSColor *col = [NSColor performSelector:NSSelectorFromString(obj)]; if (col) { CGFloat r, g, b, a; - col = [col colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + col = [col colorUsingColorSpace:NSColorSpace.sRGBColorSpace]; [col getRed:&r green:&g blue:&b alpha:&a]; return (((int)(r*255+.5f) & 0xff) << 16) + (((int)(g*255+.5f) & 0xff) << 8) @@ -1473,9 +1473,9 @@ static char_u *extractSelectedText() NSString *string = [[NSString alloc] initWithUTF8String:(char*)str]; - NSArray *types = [NSArray arrayWithObject:NSStringPboardType]; + NSArray *types = [NSArray arrayWithObject:NSPasteboardTypeString]; [pboard declareTypes:types owner:nil]; - BOOL ok = [pboard setString:string forType:NSStringPboardType]; + BOOL ok = [pboard setString:string forType:NSPasteboardTypeString]; [string release]; vim_free(str); @@ -2502,12 +2502,14 @@ static char_u *extractSelectedText() case NSScrollerIncrementPage: value += (size > 2 ? size - 2 : 1); break; +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 case NSScrollerDecrementLine: --value; break; case NSScrollerIncrementLine: ++value; break; +#endif case NSScrollerKnob: isStillDragging = YES; // fall through ... diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index dbc37577cf..0a88ad3c79 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -1,4 +1,4 @@ -/* vi:set ts=8 sts=4 sw=4 ft=objc: +/* vi:set ts=8 sts=4 sw=4 ft=objc fdm=syntax: * * VIM - Vi IMproved by Bram Moolenaar * MacVim GUI port by Bjorn Winckler @@ -8,8 +8,13 @@ * See README.txt for an overview of the Vim source code. */ +// This file contains root-level commonly used definitions that both Vim and +// MacVim processes need access to. + #import +#pragma region Backward compatibility defines + // Taken from /usr/include/AvailabilityMacros.h #ifndef MAC_OS_X_VERSION_10_7 # define MAC_OS_X_VERSION_10_7 1070 @@ -58,6 +63,10 @@ # define NSAppKitVersionNumber10_14 1671 #endif +// Deprecated constants. Since these are constants, we just need the compiler, +// not the runtime to know about them. As such, we can use MAX_ALLOWED to +// determine if we need to map or not. + #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 // Deprecated constants in 10.12 SDK # define NSAlertStyleCritical NSCriticalAlertStyle @@ -91,6 +100,16 @@ # define NSWindowStyleMaskUnifiedTitleAndToolbar NSUnifiedTitleAndToolbarWindowMask #endif +// Deprecated runtime values. Since these are runtime values, we need to use the +// minimum required OS as determining factor. Otherwise it would crash. + +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13 +// Deprecated runtime values in 10.13 SDK. +# define NSPasteboardNameFind NSFindPboard +#endif + +#pragma endregion + #import #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 # define MM_USE_ASL @@ -98,6 +117,7 @@ # import #endif +#pragma region Shared protocols // // This is the protocol MMBackend implements. @@ -171,7 +191,9 @@ client:(in byref id )client; @end +#pragma endregion +#pragma region IPC messages // // The following enum lists all messages that are passed between MacVim and @@ -330,6 +352,8 @@ enum { MMGestureForceClick, }; +#pragma endregion + // Create a string holding the labels of all messages in message queue for // debugging purposes (condense some messages since there may typically be LOTS @@ -405,6 +429,7 @@ extern NSString *VimFindPboardType; // MacVim Apple Event Constants #define keyMMUntitledWindow 'MMuw' +#pragma region Logging // Logging related functions and macros. // @@ -496,3 +521,5 @@ void ASLInit(); # define ASLogTmp(fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__) #endif + +#pragma endregion diff --git a/src/MacVim/MacVim.m b/src/MacVim/MacVim.m index 31cbe47d14..c005048d5a 100644 --- a/src/MacVim/MacVim.m +++ b/src/MacVim/MacVim.m @@ -159,7 +159,7 @@ debugStringForMessageQueue(NSArray *queue) - (unsigned)argbInt { CGFloat rf, gf, bf, af; - [[self colorUsingColorSpace:NSColorSpace.deviceRGBColorSpace] + [[self colorUsingColorSpace:NSColorSpace.sRGBColorSpace] getRed:&rf green:&gf blue:&bf alpha:&af]; unsigned r = rf * 255, g = gf * 255, b = bf * 255, a = af*255; return a<<24 | r<<16 | g<<8 | b; @@ -171,7 +171,7 @@ debugStringForMessageQueue(NSArray *queue) float g = ((rgb>>8) & 0xff)/255.0f; float b = (rgb & 0xff)/255.0f; - return [NSColor colorWithDeviceRed:r green:g blue:b alpha:1.0f]; + return [NSColor colorWithSRGBRed:r green:g blue:b alpha:1.0f]; } + (NSColor *)colorWithArgbInt:(unsigned)argb @@ -181,7 +181,7 @@ debugStringForMessageQueue(NSArray *queue) float g = ((argb>>8) & 0xff)/255.0f; float b = (argb & 0xff)/255.0f; - return [NSColor colorWithDeviceRed:r green:g blue:b alpha:a]; + return [NSColor colorWithSRGBRed:r green:g blue:b alpha:a]; } @end // NSColor (MMExtras) diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index b9b23632ce..24bfae2086 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -1916,9 +1916,9 @@ gui_macvim_add_to_find_pboard(char_u *pat) if (!s) return; - NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSFindPboard]; + NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSPasteboardNameFind]; NSArray *supportedTypes = [NSArray arrayWithObjects:VimFindPboardType, - NSStringPboardType, nil]; + NSPasteboardTypeString, nil]; [pb declareTypes:supportedTypes owner:nil]; // Put two entries on the Find pasteboard: @@ -1927,7 +1927,7 @@ gui_macvim_add_to_find_pboard(char_u *pat) // The second entry will be used by other applications when taking entries // off the Find pasteboard, whereas MacVim will use the first if present. [pb setString:s forType:VimFindPboardType]; - [pb setString:[s stringByRemovingFindPatterns] forType:NSStringPboardType]; + [pb setString:[s stringByRemovingFindPatterns] forType:NSPasteboardTypeString]; } void