diff --git a/MacDown.xcodeproj/project.pbxproj b/MacDown.xcodeproj/project.pbxproj index 81f315a6e..2c2a36f81 100644 --- a/MacDown.xcodeproj/project.pbxproj +++ b/MacDown.xcodeproj/project.pbxproj @@ -1191,12 +1191,10 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-MacDown/Pods-MacDown-frameworks.sh", "${PODS_ROOT}/Sparkle/Sparkle.framework", - "${PODS_ROOT}/Sparkle/Sparkle.framework.dSYM", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sparkle.framework", - "${DWARF_DSYM_FOLDER_PATH}/Sparkle.framework.dSYM", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -1699,7 +1697,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; }; @@ -1744,7 +1742,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; SDKROOT = macosx; }; name = Release; @@ -1759,7 +1757,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "MacDown/Code/MacDown-Prefix.pch"; INFOPLIST_FILE = "MacDown/MacDown-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.uranusjr.${PRODUCT_NAME:rfc1034identifier:lower}-debug"; PRODUCT_NAME = MacDown; SDKROOT = macosx; @@ -1777,7 +1775,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "MacDown/Code/MacDown-Prefix.pch"; INFOPLIST_FILE = "MacDown/MacDown-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.uranusjr.${PRODUCT_NAME:rfc1034identifier:lower}"; PRODUCT_NAME = MacDown; SDKROOT = macosx; @@ -1807,7 +1805,7 @@ "$(inherited)", "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/MacDown-ggdtxvuybojeqbhjydkhilziizrv/Build/Products/Debug", ); - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.uranusjr.${PRODUCT_NAME:rfc1034identifier:lower}"; PRODUCT_NAME = MacDownTests; TEST_HOST = "$(BUNDLE_LOADER)"; @@ -1833,7 +1831,7 @@ "$(inherited)", "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/MacDown-ggdtxvuybojeqbhjydkhilziizrv/Build/Products/Debug", ); - MACOSX_DEPLOYMENT_TARGET = 10.8; + MACOSX_DEPLOYMENT_TARGET = 11.0; PRODUCT_BUNDLE_IDENTIFIER = "com.uranusjr.${PRODUCT_NAME:rfc1034identifier:lower}"; PRODUCT_NAME = MacDownTests; TEST_HOST = "$(BUNDLE_LOADER)"; diff --git a/MacDown/Code/Application/MPToolbarController.m b/MacDown/Code/Application/MPToolbarController.m index a6caddd97..0b157494c 100644 --- a/MacDown/Code/Application/MPToolbarController.m +++ b/MacDown/Code/Application/MPToolbarController.m @@ -134,10 +134,12 @@ - (void)selectedToolbarItemGroupItem:(NSSegmentedControl *)sender // Add space after the specified toolbar item indices int spaceAfterIndices[] = {}; // No space in the default set + NSUInteger spaceAfterIndicesCount = 0; int flexibleSpaceAfterIndices[] = {2, 3, 5, 7, 11}; - int i = 0; - int j = 0; - int k = 0; + NSUInteger flexibleSpaceAfterIndicesCount = sizeof(flexibleSpaceAfterIndices) / sizeof(flexibleSpaceAfterIndices[0]); + NSUInteger i = 0; + NSUInteger j = 0; + NSUInteger k = 0; for (NSString *itemIdentifier in orderedToolbarItemIdentifiers) { @@ -150,13 +152,13 @@ - (void)selectedToolbarItemGroupItem:(NSSegmentedControl *)sender [defaultItemIdentifiers addObject:itemIdentifier]; } - if (i == spaceAfterIndices[j]) + if (j < spaceAfterIndicesCount && i == spaceAfterIndices[j]) { [defaultItemIdentifiers addObject:NSToolbarSpaceItemIdentifier]; j++; } - if (i == flexibleSpaceAfterIndices[k]) + if (k < flexibleSpaceAfterIndicesCount && i == flexibleSpaceAfterIndices[k]) { [defaultItemIdentifiers addObject:NSToolbarFlexibleSpaceItemIdentifier]; k++; diff --git a/MacDown/Code/Document/MPDocument.m b/MacDown/Code/Document/MPDocument.m index acbc77ffe..dc1f52fc1 100644 --- a/MacDown/Code/Document/MPDocument.m +++ b/MacDown/Code/Document/MPDocument.m @@ -609,8 +609,8 @@ - (NSPrintInfo *)printInfo NSPrintInfo *info = [super printInfo]; if (!info) info = [[NSPrintInfo sharedPrintInfo] copy]; - info.horizontalPagination = NSAutoPagination; - info.verticalPagination = NSAutoPagination; + info.horizontalPagination = NSPrintingPaginationModeAutomatic; + info.verticalPagination = NSPrintingPaginationModeAutomatic; info.verticallyCentered = NO; info.topMargin = 50.0; info.leftMargin = 0.0; @@ -1260,7 +1260,7 @@ - (IBAction)exportHtml:(id)sender NSWindow *w = self.windowForSheet; [panel beginSheetModalForWindow:w completionHandler:^(NSInteger result) { - if (result != NSFileHandlingPanelOKButton) + if (result != NSModalResponseOK) return; BOOL styles = controller.stylesIncluded; BOOL highlighting = controller.highlightingIncluded; @@ -1284,7 +1284,7 @@ - (IBAction)exportPdf:(id)sender w = [windowControllers[0] window]; [panel beginSheetModalForWindow:w completionHandler:^(NSInteger result) { - if (result != NSFileHandlingPanelOKButton) + if (result != NSModalResponseOK) return; NSDictionary *settings = @{ @@ -1450,7 +1450,7 @@ - (IBAction)insertNewParagraph:(id)sender if (location == newlineBefore + 1 && location == newlineAfter) [self.editor insertNewline:self]; else - [self.editor insertText:@"\n\n"]; + [self.editor insertText:@"\n\n" replacementRange:self.editor.selectedRange]; } - (IBAction)setEditorOneQuarter:(id)sender diff --git a/MacDown/Code/Extension/NSTextView+Autocomplete.m b/MacDown/Code/Extension/NSTextView+Autocomplete.m index b27df5add..74d15222e 100644 --- a/MacDown/Code/Extension/NSTextView+Autocomplete.m +++ b/MacDown/Code/Extension/NSTextView+Autocomplete.m @@ -93,7 +93,7 @@ - (void)insertSpacesForTab NSUInteger offset = (currentLocation - p - 1) % 4; if (offset) spaces = [spaces substringFromIndex:offset]; - [self insertText:spaces]; + [self insertText:spaces replacementRange:self.selectedRange]; } - (BOOL)completeMatchingCharactersForTextInRange:(NSRange)range @@ -583,7 +583,7 @@ - (BOOL)completeNextListItem:(BOOL)autoIncrement if (contentLength > location + t.length && [[content substringWithRange:r] isEqualToString:t]) { - [self insertText:indent]; + [self insertText:indent replacementRange:self.selectedRange]; return YES; } @@ -598,7 +598,7 @@ - (BOOL)completeNextListItem:(BOOL)autoIncrement // Insert completion for normal cases. if (t.length) it = [NSString stringWithFormat:@"%@ ", it]; - [self insertText:it]; + [self insertText:it replacementRange:self.selectedRange]; return YES; } @@ -639,7 +639,7 @@ - (BOOL)completeNextBlockquoteLine } // Insert completion. - [self insertText:markers]; + [self insertText:markers replacementRange:self.selectedRange]; return YES; } @@ -658,7 +658,8 @@ - (BOOL)completeNextIndentedLine [self insertNewline:self]; NSRange indentRange = NSMakeRange(start, end - start); - [self insertText:[content substringWithRange:indentRange]]; + [self insertText:[content substringWithRange:indentRange] + replacementRange:self.selectedRange]; return YES; } diff --git a/MacDown/Code/Preferences/MPGeneralPreferencesViewController.m b/MacDown/Code/Preferences/MPGeneralPreferencesViewController.m index bd1ff757b..d36b6b8f1 100644 --- a/MacDown/Code/Preferences/MPGeneralPreferencesViewController.m +++ b/MacDown/Code/Preferences/MPGeneralPreferencesViewController.m @@ -41,7 +41,7 @@ - (IBAction)updateWordCounterVisibility:(id)sender { if (sender == self.autoRenderingToggle) { - if (self.autoRenderingToggle.state != NSOnState) + if (self.autoRenderingToggle.state != NSControlStateValueOn) self.preferences.editorShowWordCount = NO; } } diff --git a/MacDown/Code/Utility/MPUtilities.m b/MacDown/Code/Utility/MPUtilities.m index c6a546fab..effac49cf 100644 --- a/MacDown/Code/Utility/MPUtilities.m +++ b/MacDown/Code/Utility/MPUtilities.m @@ -160,7 +160,16 @@ BOOL MPStringIsNewline(NSString *str) NSBundle *bundle = [NSBundle mainBundle]; NSString *filePath = [bundle pathForResource:name ofType:@"map" inDirectory:@"Data"]; - return [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; + NSData *data = [NSData dataWithContentsOfFile:filePath]; + if (!data) + return nil; + + NSSet *classes = [NSSet setWithObjects: + [NSDictionary class], [NSMutableDictionary class], + [NSString class], [NSMutableString class], + [NSData class], [NSMutableData class], nil]; + return [NSKeyedUnarchiver unarchivedObjectOfClasses:classes + fromData:data error:NULL]; } id MPGetObjectFromJavaScript(NSString *code, NSString *variableName) @@ -211,4 +220,3 @@ id MPGetObjectFromJavaScript(NSString *code, NSString *variableName) JSStringRelease(js); return object; } - diff --git a/MacDown/Code/View/MPDocumentSplitView.m b/MacDown/Code/View/MPDocumentSplitView.m index ff0ec8d24..8191e1638 100644 --- a/MacDown/Code/View/MPDocumentSplitView.m +++ b/MacDown/Code/View/MPDocumentSplitView.m @@ -13,8 +13,9 @@ @implementation NSColor (Equality) - (BOOL)isEqualToColor:(NSColor *)color { - NSColor *rgb1 = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; - NSColor *rgb2 = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + NSColorSpace *colorSpace = [NSColorSpace genericRGBColorSpace]; + NSColor *rgb1 = [self colorUsingColorSpace:colorSpace]; + NSColor *rgb2 = [color colorUsingColorSpace:colorSpace]; return rgb1 && rgb2 && [rgb1 isEqual:rgb2]; } diff --git a/MacDown/Code/View/MPEditorView.m b/MacDown/Code/View/MPEditorView.m index 6c7804acd..e8961e530 100644 --- a/MacDown/Code/View/MPEditorView.m +++ b/MacDown/Code/View/MPEditorView.m @@ -40,7 +40,7 @@ - (BOOL)scrollsPastEnd } - (void)awakeFromNib { - [self registerForDraggedTypes:[NSArray arrayWithObjects: NSDragPboard, nil]]; + [self registerForDraggedTypes:@[NSPasteboardTypeFileURL]]; [super awakeFromNib]; } @@ -65,21 +65,26 @@ - (NSDragOperation)draggingEntered:(id )sender { - (BOOL)performDragOperation:(id )sender { NSPasteboard *pboard; NSDragOperation sourceDragMask; - + sourceDragMask = [sender draggingSourceOperationMask]; pboard = [sender draggingPasteboard]; - - if ( [[pboard types] containsObject:NSFilenamesPboardType] ) { - NSArray *files = [pboard propertyListForType:NSFilenamesPboardType]; - + + NSDictionary *options = @{ + NSPasteboardURLReadingFileURLsOnlyKey: @YES, + NSPasteboardURLReadingContentsConformToTypesKey: @[@"public.jpeg"], + }; + NSArray *urls = [pboard readObjectsForClasses:@[[NSURL class]] + options:options]; + NSURL *fileURL = urls.firstObject; + if (fileURL) { /* Load data of file. */ NSError *error; - NSData *fileData = [NSData dataWithContentsOfFile: files[0] - options: NSMappedRead - error: &error]; + NSData *fileData = [NSData dataWithContentsOfURL:fileURL + options:NSDataReadingMappedIfSafe + error:&error]; if (!error) { // convert to base64 representation - NSString *dataString = [fileData base64Encoding]; + NSString *dataString = [fileData base64EncodedStringWithOptions:0]; // insert into text. NSInteger insertionPoint = [[[self selectedRanges] objectAtIndex:0] rangeValue].location; diff --git a/MacDown/MacDown.entitlements b/MacDown/MacDown.entitlements new file mode 100644 index 000000000..97fe58853 --- /dev/null +++ b/MacDown/MacDown.entitlements @@ -0,0 +1,7 @@ + + + + com.apple.security.cs.allow-jit + com.apple.security.cs.allow-unsigned-executable-memory + com.apple.security.cs.disable-library-validation + diff --git a/Podfile b/Podfile index 6c5288f69..b926e9d74 100644 --- a/Podfile +++ b/Podfile @@ -1,4 +1,4 @@ -platform :osx, "10.8" +platform :osx, "11.0" source 'https://github.com/MacDownApp/cocoapods-specs.git' # Patched libraries. source 'https://cdn.cocoapods.org/' @@ -27,3 +27,11 @@ end target "macdown-cmd" do pod 'GBCli', '~> 1.1' end + +post_install do |installer| + installer.pods_project.targets.each do |t| + t.build_configurations.each do |config| + config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '11.0' + end + end +end diff --git a/Podfile.lock b/Podfile.lock index b90fe24af..82f22792b 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -46,6 +46,6 @@ SPEC CHECKSUMS: PAPreferences: 9f0ffb1e67174a0df001af9d3320166ceb9ee6f5 Sparkle: 06ea33170007c5937ee54da481b4481af98fac79 -PODFILE CHECKSUM: e9356b9a2ceafda7889ba385de6e9f2d8b06cba0 +PODFILE CHECKSUM: 11d06d0c907d0d1cff079d96568b1ab059b50878 -COCOAPODS: 1.8.4 +COCOAPODS: 1.16.2