From cf4e2523230838445d8c32efe670104d60ab38e5 Mon Sep 17 00:00:00 2001 From: Yee Cheng Chin Date: Sun, 5 Nov 2023 12:16:18 -0800 Subject: [PATCH] Fix misc MacVim warnings and treat warnings as errors in CI In CI, turn on warnings as errors, but ignore deprecated warnings as we are still using NSConnection right now and we won't be fixing that for now. Don't turn on warnings as errors for development (similar to Vim itself) / outside of CI, because it could make it annoying to build MacVim locally and across different Xcode versions. Fix the misc warnings. A lot of 64/32-bit warnings due to careless casts of NSInteger/NSUInteger. Also fix up MacVimTests so the waiting for Vim window is more robust when waiting for 2 windows in a row in vim tutor. Otherwise sometimes the tests would randomly fail in CI. --- .github/workflows/ci-macvim.yaml | 2 +- ci/config.mk.xcode.sed | 1 + src/MacVim/MMAppController.m | 64 +++++++++--------- src/MacVim/MMApplication.m | 2 +- src/MacVim/MMBackend.m | 28 ++++---- src/MacVim/MMCoreTextView+ToolTip.m | 6 +- src/MacVim/MMCoreTextView.m | 66 +++++++++---------- src/MacVim/MMFullScreenWindow.m | 2 +- src/MacVim/MMPreferenceController.h | 2 - src/MacVim/MMTextStorage.m | 16 ++--- src/MacVim/MMTextView.m | 18 ++--- src/MacVim/MMTextViewHelper.h | 2 +- src/MacVim/MMTextViewHelper.m | 58 ++++++++-------- src/MacVim/MMTypesetter.m | 4 +- src/MacVim/MMVimController.m | 58 ++++++++-------- src/MacVim/MMVimView.m | 59 ++++++++--------- src/MacVim/MMWindow.m | 2 +- src/MacVim/MMWindowController.m | 2 +- src/MacVim/MacVim.h | 2 +- src/MacVim/MacVim.m | 2 +- src/MacVim/MacVim.xcodeproj/project.pbxproj | 6 +- src/MacVim/MacVimTests/MacVimTests.m | 16 +++-- .../MacVim_xcode8.xcodeproj/project.pbxproj | 6 +- src/MacVim/Miscellaneous.m | 10 +-- .../source/PSMMojaveTabStyle.m | 59 ++++++++++------- .../source/PSMRolloverButton.m | 4 +- .../PSMTabBarControl/source/PSMTabBarCell.m | 8 +-- .../source/PSMTabBarControl.m | 14 ++-- .../source/PSMTabDragAssistant.m | 12 ++-- src/Makefile | 2 +- 30 files changed, 264 insertions(+), 269 deletions(-) create mode 100644 ci/config.mk.xcode.sed diff --git a/.github/workflows/ci-macvim.yaml b/.github/workflows/ci-macvim.yaml index 085ff3f636..efd078b31d 100644 --- a/.github/workflows/ci-macvim.yaml +++ b/.github/workflows/ci-macvim.yaml @@ -188,7 +188,7 @@ jobs: ./configure "${CONFOPT[@]}" --enable-fail-if-missing - sed -i.bak -f ci/config.mk.sed -f ci/config.mk.clang.sed src/auto/config.mk + sed -i.bak -f ci/config.mk.sed -f ci/config.mk.clang.sed -f ci/config.mk.xcode.sed src/auto/config.mk if clang --version | grep -qs '^Apple clang version \(1[3-9]\|[2-9]\d\)\.'; then sed -i.bak -f ci/config.mk.clang-12.sed src/auto/config.mk fi diff --git a/ci/config.mk.xcode.sed b/ci/config.mk.xcode.sed new file mode 100644 index 0000000000..6715017b37 --- /dev/null +++ b/ci/config.mk.xcode.sed @@ -0,0 +1 @@ +/^XCODEFLAGS[[:blank:]]*=/s/$/ GCC_TREAT_WARNINGS_AS_ERRORS="YES" GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS="NO"/ diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index 7473b9d25b..f81128e712 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -567,7 +567,7 @@ - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender // The user default MMUntitledWindow can be set to control whether an // untitled window should open on 'Open' and 'Reopen' events. - int untitledWindowFlag = [ud integerForKey:MMUntitledWindowKey]; + NSInteger untitledWindowFlag = [ud integerForKey:MMUntitledWindowKey]; BOOL isAppOpenEvent = [desc eventID] == kAEOpenApplication; if (isAppOpenEvent && (untitledWindowFlag & MMUntitledWindowOnOpen) == 0) @@ -700,7 +700,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate: boolForKey:MMSuppressTerminationAlertKey]) { // No unmodified buffers, but give a warning if there are multiple // windows and/or tabs open. - int numWindows = [vimControllers count]; + int numWindows = (int)[vimControllers count]; int numTabs = 0; // Count the number of open tabs @@ -1065,7 +1065,7 @@ - (void)refreshMainMenu [fileMenu removeItemAtIndex:dummyIdx]; NSMenu *recentFilesParentMenu = [recentFilesMenuItem menu]; - int idx = [recentFilesParentMenu indexOfItem:recentFilesMenuItem]; + NSInteger idx = [recentFilesParentMenu indexOfItem:recentFilesMenuItem]; if (idx >= 0) { [[recentFilesMenuItem retain] autorelease]; [recentFilesParentMenu removeItemAtIndex:idx]; @@ -1133,7 +1133,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args // The meaning of "layout" is defined by the WIN_* defines in main.c. NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - int layout = [ud integerForKey:MMOpenLayoutKey]; + NSInteger layout = [ud integerForKey:MMOpenLayoutKey]; BOOL splitVert = [ud boolForKey:MMVerticalSplitKey]; BOOL openInCurrentWindow = [ud boolForKey:MMOpenInCurrentWindowKey]; @@ -1166,7 +1166,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args // selection will be lost when selectionRange is set. NSDictionary *args = [NSDictionary dictionaryWithObjectsAndKeys: firstFile, @"filename", - [NSNumber numberWithInt:layout], @"layout", + [NSNumber numberWithInt:(int)layout], @"layout", nil]; [vc sendMessage:SelectAndFocusOpenedFileMsgID data:[args dictionaryAsData]]; } @@ -1188,7 +1188,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args // b) Open any remaining files // - [arguments setObject:[NSNumber numberWithInt:layout] forKey:@"layout"]; + [arguments setObject:[NSNumber numberWithInt:(int)layout] forKey:@"layout"]; [arguments setObject:filenames forKey:@"filenames"]; // (Indicate that files should be opened from now on.) [arguments setObject:[NSNumber numberWithBool:NO] forKey:@"dontOpen"]; @@ -1202,7 +1202,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args } BOOL openOk = YES; - int numFiles = [filenames count]; + int numFiles = (int)[filenames count]; if (MMLayoutWindows == layout && numFiles > 1) { // Open one file at a time in a new window, but don't open too many at // once (at most cap+1 windows will open). If the user has increased @@ -1246,7 +1246,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args - (void)refreshAllAppearances { - unsigned count = [vimControllers count]; + const NSUInteger count = [vimControllers count]; for (unsigned i = 0; i < count; ++i) { MMVimController *vc = [vimControllers objectAtIndex:i]; [vc.windowController refreshApperanceMode]; @@ -1256,7 +1256,7 @@ - (void)refreshAllAppearances /// Refresh all Vim text views' fonts. - (void)refreshAllFonts { - unsigned count = [vimControllers count]; + const NSUInteger count = [vimControllers count]; for (unsigned i = 0; i < count; ++i) { MMVimController *vc = [vimControllers objectAtIndex:i]; [vc.windowController refreshFonts]; @@ -1267,7 +1267,7 @@ - (void)refreshAllFonts /// and resize the windows to match the constraints. - (void)refreshAllResizeConstraints { - const unsigned count = [vimControllers count]; + const NSUInteger count = [vimControllers count]; for (unsigned i = 0; i < count; ++i) { MMVimController *vc = [vimControllers objectAtIndex:i]; [vc.windowController updateResizeConstraints:YES]; @@ -1278,7 +1278,7 @@ - (void)refreshAllResizeConstraints /// cmdline alignment properties to make sure they are pinned properly. - (void)refreshAllTextViews { - unsigned count = [vimControllers count]; + const NSUInteger count = [vimControllers count]; for (unsigned i = 0; i < count; ++i) { MMVimController *vc = [vimControllers objectAtIndex:i]; [vc.windowController.vimView.textView updateCmdlineRow]; @@ -1408,7 +1408,7 @@ - (IBAction)selectNextWindow:(id)sender { ASLogDebug(@"Select next window"); - unsigned i, count = [vimControllers count]; + NSUInteger i, count = [vimControllers count]; if (!count) return; NSWindow *keyWindow = [NSApp keyWindow]; @@ -1430,7 +1430,7 @@ - (IBAction)selectPreviousWindow:(id)sender { ASLogDebug(@"Select previous window"); - unsigned i, count = [vimControllers count]; + NSUInteger i, count = [vimControllers count]; if (!count) return; NSWindow *keyWindow = [NSApp keyWindow]; @@ -1542,7 +1542,7 @@ - (IBAction)coreTextButtonClicked:(id)sender // any new Vim process will pick up on the changed setting. CFPreferencesSetAppValue( (CFStringRef)MMRendererKey, - (CFPropertyListRef)[NSNumber numberWithInt:renderer], + (CFPropertyListRef)[NSNumber numberWithInt:(int)renderer], kCFPreferencesCurrentApplication); CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); @@ -1578,7 +1578,7 @@ - (MMVimController *)keyVimController { NSWindow *keyWindow = [NSApp keyWindow]; if (keyWindow) { - unsigned i, count = [vimControllers count]; + NSUInteger i, count = [vimControllers count]; for (i = 0; i < count; ++i) { MMVimController *vc = [vimControllers objectAtIndex:i]; if ([[[vc windowController] window] isEqual:keyWindow]) @@ -1660,7 +1660,7 @@ - (NSArray *)serverList { NSMutableArray *array = [NSMutableArray array]; - unsigned i, count = [vimControllers count]; + NSUInteger i, count = [vimControllers count]; for (i = 0; i < count; ++i) { MMVimController *controller = [vimControllers objectAtIndex:i]; if ([controller serverName]) @@ -1931,7 +1931,7 @@ - (MMVimController *)topmostVimController NSEnumerator *e = [[NSApp orderedWindows] objectEnumerator]; id window; while ((window = [e nextObject]) && [window isVisible]) { - unsigned i, count = [vimControllers count]; + NSUInteger i, count = [vimControllers count]; for (i = 0; i < count; ++i) { MMVimController *vc = [vimControllers objectAtIndex:i]; if ([[[vc windowController] window] isEqual:window]) @@ -1939,7 +1939,7 @@ - (MMVimController *)topmostVimController } } - unsigned i, count = [vimControllers count]; + NSUInteger i, count = [vimControllers count]; for (i = 0; i < count; ++i) { MMVimController *vc = [vimControllers objectAtIndex:i]; if ([[[vc windowController] window] isVisible]) { @@ -2016,7 +2016,7 @@ - (NSArray *)filterFilesAndNotify:(NSArray *)filenames NSString *firstMissingFile = nil; NSMutableArray *files = [NSMutableArray array]; - unsigned i, count = [filenames count]; + NSUInteger i, count = [filenames count]; for (i = 0; i < count; ++i) { NSString *name = [filenames objectAtIndex:i]; @@ -2076,7 +2076,7 @@ - (NSArray *)filterOpenFiles:(NSArray *)filenames @"map([\"%@\"],\"bufloaded(v:val)\")", [files componentsJoinedByString:@"\",\""]]; - unsigned i, count = [vimControllers count]; + NSUInteger i, count = [vimControllers count]; for (i = 0; i < count && [files count] > 0; ++i) { MMVimController *vc = [vimControllers objectAtIndex:i]; @@ -2428,12 +2428,12 @@ - (int)maxPreloadCacheSize { // The maximum number of Vim processes to keep in the cache can be // controlled via the user default "MMPreloadCacheSize". - int maxCacheSize = [[NSUserDefaults standardUserDefaults] + NSInteger maxCacheSize = [[NSUserDefaults standardUserDefaults] integerForKey:MMPreloadCacheSizeKey]; if (maxCacheSize < 0) maxCacheSize = 0; else if (maxCacheSize > 10) maxCacheSize = 10; - return maxCacheSize; + return (int)maxCacheSize; } - (MMVimController *)takeVimControllerFromCache @@ -2445,7 +2445,7 @@ - (MMVimController *)takeVimControllerFromCache // This method may return nil even though the cache might be non-empty; the // caller should handle this by starting a new Vim process. - int i, count = [cachedVimControllers count]; + NSUInteger i, count = [cachedVimControllers count]; if (0 == count) return nil; // Locate the first Vim controller with up-to-date rc-files sourced. @@ -2461,7 +2461,7 @@ - (MMVimController *)takeVimControllerFromCache // Clear out cache entries whose vimrc/gvimrc files were sourced before // the latest modification date for those files. This ensures that the // latest rc-files are always sourced for new windows. - [self clearPreloadCacheWithCount:i]; + [self clearPreloadCacheWithCount:(int)i]; } if ([cachedVimControllers count] == 0) { @@ -2497,7 +2497,7 @@ - (void)clearPreloadCacheWithCount:(int)count return; if (count < 0) - count = [cachedVimControllers count]; + count = (int)[cachedVimControllers count]; // Make sure the preloaded Vim processes get killed or they'll just hang // around being useless until MacVim is terminated. @@ -2618,9 +2618,7 @@ - (void)startWatchingVimDir (CFArrayRef)pathsToWatch, kFSEventStreamEventIdSinceNow, MMEventStreamLatency, kFSEventStreamCreateFlagNone); - FSEventStreamScheduleWithRunLoop(fsEventStream, - [[NSRunLoop currentRunLoop] getCFRunLoop], - kCFRunLoopDefaultMode); + FSEventStreamSetDispatchQueue(fsEventStream, dispatch_get_main_queue()); FSEventStreamStart(fsEventStream); ASLogDebug(@"Started FS event stream"); @@ -2734,9 +2732,9 @@ - (int)executeInLoginShell:(NSString *)path arguments:(NSArray *)args // Send input to execute to the child process [input appendString:@"\n"]; - int bytes = [input lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + NSUInteger bytes = [input lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - if (write(ds[1], [input UTF8String], bytes) != bytes) return -1; + if (write(ds[1], [input UTF8String], (size_t)bytes) != (ssize_t)bytes) return -1; if (close(ds[1]) == -1) return -1; ++numChildProcesses; @@ -2797,7 +2795,7 @@ - (void)processInputQueues:(id)sender NSNumber *key; while ((key = [e nextObject])) { unsigned long ukey = [key unsignedLongValue]; - int i = 0, count = [vimControllers count]; + NSUInteger i = 0, count = [vimControllers count]; for (i = 0; i < count; ++i) { MMVimController *vc = [vimControllers objectAtIndex:i]; if (ukey == [vc vimControllerId]) { @@ -2882,7 +2880,7 @@ - (NSDictionary *)convertVimControllerArguments:(NSDictionary *)args *cmdline = nil; NSArray *filenames = [args objectForKey:@"filenames"]; - int numFiles = filenames ? [filenames count] : 0; + NSUInteger numFiles = filenames ? [filenames count] : 0; BOOL openFiles = ![[args objectForKey:@"dontOpen"] boolValue]; if (numFiles <= 0 || !openFiles) @@ -3029,7 +3027,7 @@ - (void)removeInputSourceChangedObserver - (void)inputSourceChanged:(NSNotification *)notification { - unsigned i, count = [vimControllers count]; + NSUInteger i, count = [vimControllers count]; for (i = 0; i < count; ++i) { MMVimController *controller = [vimControllers objectAtIndex:i]; MMWindowController *wc = [controller windowController]; diff --git a/src/MacVim/MMApplication.m b/src/MacVim/MMApplication.m index 61b212a996..168275e4c9 100644 --- a/src/MacVim/MMApplication.m +++ b/src/MacVim/MMApplication.m @@ -21,7 +21,7 @@ @implementation MMApplication - (void)sendEvent:(NSEvent *)event { NSEventType type = [event type]; - unsigned flags = [event modifierFlags]; + NSUInteger flags = [event modifierFlags]; // HACK! Intercept 'help' key presses and clear the 'help key flag', else // Cocoa turns the mouse cursor into a question mark and goes into 'context diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index cd127be61e..523cd5d372 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -48,8 +48,8 @@ static unsigned MMServerMax = 1000; // TODO: Move to separate file. -static int eventModifierFlagsToVimModMask(int modifierFlags); -static int eventModifierFlagsToVimMouseModMask(int modifierFlags); +static unsigned eventModifierFlagsToVimModMask(unsigned modifierFlags); +static unsigned eventModifierFlagsToVimMouseModMask(unsigned modifierFlags); static int eventButtonNumberToVimMouseButton(int buttonNumber); // In gui_macvim.m @@ -2081,7 +2081,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data int row = *((int*)bytes); bytes += sizeof(int); int col = *((int*)bytes); bytes += sizeof(int); - int flags = *((int*)bytes); bytes += sizeof(int); + unsigned flags = *((unsigned*)bytes); bytes += sizeof(unsigned); float dy = *((float*)bytes); bytes += sizeof(float); float dx = *((float*)bytes); bytes += sizeof(float); @@ -2122,7 +2122,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data int row = *((int*)bytes); bytes += sizeof(int); int col = *((int*)bytes); bytes += sizeof(int); int button = *((int*)bytes); bytes += sizeof(int); - int flags = *((int*)bytes); bytes += sizeof(int); + unsigned flags = *((unsigned*)bytes); bytes += sizeof(unsigned); int repeat = *((int*)bytes); bytes += sizeof(int); button = eventButtonNumberToVimMouseButton(button); @@ -2136,7 +2136,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data int row = *((int*)bytes); bytes += sizeof(int); int col = *((int*)bytes); bytes += sizeof(int); - int flags = *((int*)bytes); bytes += sizeof(int); + unsigned flags = *((unsigned*)bytes); bytes += sizeof(unsigned); flags = eventModifierFlagsToVimMouseModMask(flags); @@ -2147,7 +2147,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data int row = *((int*)bytes); bytes += sizeof(int); int col = *((int*)bytes); bytes += sizeof(int); - int flags = *((int*)bytes); bytes += sizeof(int); + unsigned flags = *((unsigned*)bytes); bytes += sizeof(unsigned); flags = eventModifierFlagsToVimMouseModMask(flags); @@ -2607,7 +2607,7 @@ - (void)handleScrollbarEvent:(NSData *)data const void *bytes = [data bytes]; int32_t ident = *((int32_t*)bytes); bytes += sizeof(int32_t); - int hitPart = *((int*)bytes); bytes += sizeof(int); + unsigned hitPart = *((unsigned*)bytes); bytes += sizeof(unsigned); float fval = *((float*)bytes); bytes += sizeof(float); scrollbar_T *sb = gui_find_scrollbar(ident); @@ -2765,7 +2765,7 @@ - (void)handleDropString:(NSData *)data #ifdef FEAT_DND char_u dropkey[3] = { CSI, KS_EXTRA, (char_u)KE_DROP }; const void *bytes = [data bytes]; - int len = *((int*)bytes); bytes += sizeof(int); + int len = *((int*)bytes); bytes += sizeof(int); // unused NSMutableString *string = [NSMutableString stringWithUTF8String:bytes]; // Replace unrecognized end-of-line sequences with \x0a (line feed). @@ -2778,7 +2778,7 @@ - (void)handleDropString:(NSData *)data options:0 range:range]; } - len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + len = (int)[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; char_u *s = (char_u*)[string UTF8String]; if (input_conv.vc_type != CONV_NONE) s = string_convert(&input_conv, s, &len); @@ -3517,9 +3517,9 @@ - (void)handleMarkedText:(NSData *)data - (void)handleGesture:(NSData *)data { const void *bytes = [data bytes]; - int flags = *((int*)bytes); bytes += sizeof(int); + unsigned flags = *((int*)bytes); bytes += sizeof(int); int gesture = *((int*)bytes); bytes += sizeof(int); - int modifiers = eventModifierFlagsToVimModMask(flags); + unsigned modifiers = eventModifierFlagsToVimModMask(flags); char_u string[6]; string[3] = CSI; @@ -3761,7 +3761,7 @@ - (NSComparisonResult)serverNameCompare:(NSString *)string -static int eventModifierFlagsToVimModMask(int modifierFlags) +static unsigned eventModifierFlagsToVimModMask(unsigned modifierFlags) { int modMask = 0; @@ -3777,9 +3777,9 @@ static int eventModifierFlagsToVimModMask(int modifierFlags) return modMask; } -static int eventModifierFlagsToVimMouseModMask(int modifierFlags) +static unsigned eventModifierFlagsToVimMouseModMask(unsigned modifierFlags) { - int modMask = 0; + unsigned modMask = 0; if (modifierFlags & NSEventModifierFlagShift) modMask |= MOUSE_SHIFT; diff --git a/src/MacVim/MMCoreTextView+ToolTip.m b/src/MacVim/MMCoreTextView+ToolTip.m index defc5d0d74..ad0e6c0974 100644 --- a/src/MacVim/MMCoreTextView+ToolTip.m +++ b/src/MacVim/MMCoreTextView+ToolTip.m @@ -143,7 +143,7 @@ - (void)_removeTrackingRects:(NSTrackingRectTag *)tags count:(int)count { int i; for (i = 0; i < count; ++i) { - int tag = tags[i]; + const NSInteger tag = tags[i]; if (tag == 0) continue; //DCHECK(tag == kTrackingRectTag); @@ -155,7 +155,7 @@ - (void)_removeTrackingRects:(NSTrackingRectTag *)tags count:(int)count - (void)_sendToolTipMouseExited { // Nothing matters except window, trackingNumber, and userData. - int windowNumber = [[self window] windowNumber]; + NSInteger windowNumber = [[self window] windowNumber]; NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSEventTypeMouseExited location:NSMakePoint(0, 0) modifierFlags:0 @@ -172,7 +172,7 @@ - (void)_sendToolTipMouseExited - (void)_sendToolTipMouseEntered { // Nothing matters except window, trackingNumber, and userData. - int windowNumber = [[self window] windowNumber]; + NSInteger windowNumber = [[self window] windowNumber]; NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSEventTypeMouseEntered location:NSMakePoint(0, 0) modifierFlags:0 diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 83c37dd95c..38b508ee04 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -356,8 +356,8 @@ - (NSRect)rectForRowsInRange:(NSRange)range // Note: This doesn't really take alignCmdLineToBottom into account right now. NSRect rect = { {0, 0}, {0, 0} }; - unsigned start = range.location > maxRows ? maxRows : range.location; - unsigned length = range.length; + NSUInteger start = range.location > maxRows ? maxRows : range.location; + NSUInteger length = range.length; if (start + length > maxRows) length = maxRows - start; @@ -382,8 +382,8 @@ - (NSRect)rectForColumnsInRange:(NSRange)range // only used to place the scrollbars inside MMVimView.) NSRect rect = { {0, 0}, {0, 0} }; - unsigned start = range.location > maxColumns ? maxColumns : range.location; - unsigned length = range.length; + NSUInteger start = range.location > maxColumns ? maxColumns : range.location; + NSUInteger length = range.length; if (start+length > maxColumns) length = maxColumns - start; @@ -918,8 +918,8 @@ - (void)drawRect:(NSRect)rect if (!lineString.length) return; size_t cellOffsetByIndex[lineString.length]; - for (int i = 0, stringIndex = 0; i < lineStringRange.length; i++) { - GridCell cell = *grid_cell(&grid, r, lineStringRange.location + i); + for (int i = 0, stringIndex = 0; i < (int)lineStringRange.length; i++) { + GridCell cell = *grid_cell(&grid, r, (int)lineStringRange.location + i); size_t cell_length = cell.string.length; for (size_t j = 0; j < cell_length; j++) { cellOffsetByIndex[stringIndex++] = i; @@ -1249,8 +1249,8 @@ - (NSSize)constrainRows:(int *)rows columns:(int *)cols toSize:(NSSize)size int desiredRows = maxRows; int desiredCols = maxColumns; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - int right = [ud integerForKey:MMTextInsetRightKey]; - int bot = [ud integerForKey:MMTextInsetBottomKey]; + NSInteger right = [ud integerForKey:MMTextInsetRightKey]; + NSInteger bot = [ud integerForKey:MMTextInsetBottomKey]; if (size.height != desiredSize.height) { float fh = cellSize.height; @@ -1281,8 +1281,8 @@ - (NSSize)desiredSize // Compute the size the text view should be for the entire text area and // inset area to be visible with the present number of rows and columns. NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - int right = [ud integerForKey:MMTextInsetRightKey]; - int bot = [ud integerForKey:MMTextInsetBottomKey]; + NSInteger right = [ud integerForKey:MMTextInsetRightKey]; + NSInteger bot = [ud integerForKey:MMTextInsetBottomKey]; return NSMakeSize(maxColumns * cellSize.width + insetSize.width + right, maxRows * cellSize.height + insetSize.height + bot); @@ -1292,8 +1292,8 @@ - (NSSize)minSize { // Compute the smallest size the text view is allowed to be. NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - int right = [ud integerForKey:MMTextInsetRightKey]; - int bot = [ud integerForKey:MMTextInsetBottomKey]; + NSInteger right = [ud integerForKey:MMTextInsetRightKey]; + NSInteger bot = [ud integerForKey:MMTextInsetBottomKey]; return NSMakeSize(MMMinColumns * cellSize.width + insetSize.width + right, MMMinRows * cellSize.height + insetSize.height + bot); @@ -1308,7 +1308,7 @@ - (void)changeFont:(id)sender if (newFont) { NSString *name = [newFont fontName]; - unsigned len = [name lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + unsigned len = (unsigned)[name lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; if (len > 0) { NSMutableData *data = [NSMutableData data]; float pointSize = [newFont pointSize]; @@ -1393,7 +1393,7 @@ - (BOOL)convertPoint:(NSPoint)point toRow:(int *)row column:(int *)column if (alignCmdLineToBottom) { // Account for the gap we added to pin cmdline to the bottom of the window const NSRect frame = [self bounds]; - const int insetBottom = [[NSUserDefaults standardUserDefaults] integerForKey:MMTextInsetBottomKey]; + const NSInteger insetBottom = [[NSUserDefaults standardUserDefaults] integerForKey:MMTextInsetBottomKey]; const CGFloat gapHeight = frame.size.height - grid.rows*cellSize.height - insetSize.height - insetBottom; const CGFloat cmdlineRowY = insetSize.height + cmdlineRow*cellSize.height + 1; if (point.y > cmdlineRowY) { @@ -1443,7 +1443,7 @@ - (NSRect)rectForRow:(int)row column:(int)col numRows:(int)nr // Note that we don't do this for filling the bottom since it's used only for cmdline which isn't usually // colored anyway. if (col + nc == grid.cols) { - const int insetRight = [[NSUserDefaults standardUserDefaults] integerForKey:MMTextInsetRightKey]; + const NSInteger insetRight = [[NSUserDefaults standardUserDefaults] integerForKey:MMTextInsetRightKey]; CGFloat extraWidth = frame.size.width - insetRight - (rect.size.width + rect.origin.x); rect.size.width += extraWidth; } @@ -1451,7 +1451,7 @@ - (NSRect)rectForRow:(int)row column:(int)col numRows:(int)nr // When configured to align cmdline to bottom, need to adjust the rect with an additional gap to pin // the rect to the bottom. if (alignCmdLineToBottom) { - const int insetBottom = [[NSUserDefaults standardUserDefaults] integerForKey:MMTextInsetBottomKey]; + const NSInteger insetBottom = [[NSUserDefaults standardUserDefaults] integerForKey:MMTextInsetBottomKey]; const CGFloat gapHeight = frame.size.height - grid.rows*cellSize.height - insetSize.height - insetBottom; if (row >= cmdlineRow) { rect.origin.y -= gapHeight; @@ -1613,9 +1613,9 @@ static void rowColFromUtfRange(const Grid* grid, NSRange range, int outFirstLineLen = -1; const int gridSize = grid->cols * grid->rows; - NSUInteger utfIndex = 0; + int utfIndex = 0; for (int i = 0; i < gridSize; i++) { - if (utfIndex >= range.location) { + if (utfIndex >= (int)range.location) { // We are now past the start of the character. const int curRow = i / grid->cols; const int curCol = i % grid->cols; @@ -1627,7 +1627,7 @@ static void rowColFromUtfRange(const Grid* grid, NSRange range, outCol = curCol; } - if (utfIndex >= range.location + range.length) { + if (utfIndex >= (int)range.location + (int)range.length) { // Record the end if we found it. if (outFirstLineNumCols == -1) { outFirstLineLen = utfIndex - startUtfIndex; @@ -1647,7 +1647,7 @@ static void rowColFromUtfRange(const Grid* grid, NSRange range, } NSString *str = grid->cells[i].string; - utfIndex += str == nil ? 1 : str.length; // Note: nil string means empty space. + utfIndex += str == nil ? 1 : (int)str.length; // Note: nil string means empty space. if (grid->cells[i].textFlags & DRAW_WIDE) { i += 1; @@ -2480,7 +2480,7 @@ - (void)setString:(NSString *)string backgroundColor:(int)bg specialColor:(int)sp { const BOOL wide = flags & DRAW_WIDE ? YES : NO; - __block size_t cells_filled = 0; + __block int cells_filled = 0; [string enumerateSubstringsInRange:NSMakeRange(0, string.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) { @@ -2524,14 +2524,14 @@ - (void)deleteLinesFromRow:(int)row lineCount:(int)count scrollBottom:(int)bottom left:(int)left right:(int)right color:(int)color { - for (size_t r = row; r + count <= MIN(grid.rows - 1, bottom); r++) { + for (int r = row; r + count <= MIN(grid.rows - 1, bottom); r++) { memcpy(grid_cell(&grid, r, left), grid_cell(&grid, r + count, left), sizeof(GridCell) * (MIN(grid.cols, right + 1) - MIN(grid.cols, left))); } const GridCell clearCell = { .bg = color }; - for (size_t r = bottom - count + 1; r <= MIN(grid.rows - 1, bottom); r++) { - for (size_t c = left; c <= MIN(grid.cols - 1, right); c++) + for (int r = bottom - count + 1; r <= MIN(grid.rows - 1, bottom); r++) { + for (int c = left; c <= MIN(grid.cols - 1, right); c++) *grid_cell(&grid, r, c) = clearCell; } [self setNeedsDisplayFromRow:row column:left toRow:bottom column:right]; @@ -2541,14 +2541,14 @@ - (void)insertLinesAtRow:(int)row lineCount:(int)count scrollBottom:(int)bottom left:(int)left right:(int)right color:(int)color { - for (size_t r = MIN(grid.rows - 1, bottom); r >= row + count; r--) { + for (int r = MIN(grid.rows - 1, bottom); r >= row + count; r--) { memcpy(grid_cell(&grid, r, left), grid_cell(&grid, r - count, left), sizeof(GridCell) * (MIN(grid.cols, right + 1) - MIN(grid.cols, left))); } const GridCell clearCell = { .bg = color }; - for (size_t r = row; r < MIN(grid.rows, row + count); r++) { - for (size_t c = left; c <= right; c++) + for (int r = row; r < MIN(grid.rows, row + count); r++) { + for (int c = left; c <= right; c++) *grid_cell(&grid, r, c) = clearCell; } [self setNeedsDisplayFromRow:row column:left toRow:bottom column:right]; @@ -2558,8 +2558,8 @@ - (void)clearBlockFromRow:(int)row1 column:(int)col1 toRow:(int)row2 column:(int)col2 color:(int)color { const GridCell clearCell = { .bg = color }; - for (size_t r = row1; r <= row2; r++) { - for (size_t c = col1; c <= col2; c++) + for (int r = row1; r <= row2; r++) { + for (int c = col1; c <= col2; c++) *grid_cell_safe(&grid, r, c) = clearCell; } [self setNeedsDisplayFromRow:row1 column:col1 toRow:row2 column:col2]; @@ -2568,8 +2568,8 @@ - (void)clearBlockFromRow:(int)row1 column:(int)col1 toRow:(int)row2 - (void)clearAll { const GridCell clearCell = { .bg = defaultBackgroundColor.argbInt }; - for (size_t r = 0; r < maxRows; r++) { - for (size_t c = 0; c < maxColumns; c++) + for (int r = 0; r < maxRows; r++) { + for (int c = 0; c < maxColumns; c++) *grid_cell(&grid, r, c) = clearCell; } self.needsDisplay = YES; @@ -2590,8 +2590,8 @@ - (void)setInsertionPointAtRow:(int)row column:(int)col shape:(int)shape - (void)invertBlockFromRow:(int)row column:(int)col numRows:(int)nrows numColumns:(int)ncols { - for (size_t r = row; r < row + nrows; r++) { - for (size_t c = col; c < col + ncols; c++) { + for (int r = row; r < row + nrows; r++) { + for (int c = col; c < col + ncols; c++) { grid_cell_safe(&grid, r, c)->inverted ^= 1; } } diff --git a/src/MacVim/MMFullScreenWindow.m b/src/MacVim/MMFullScreenWindow.m index 03d55ed965..415c1fbd00 100644 --- a/src/MacVim/MMFullScreenWindow.m +++ b/src/MacVim/MMFullScreenWindow.m @@ -387,7 +387,7 @@ - (NSEdgeInsets) viewOffset { #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_12_0) // Account for newer MacBook Pro's which have a notch, which can be queried using the safe area API. if (@available(macos 12.0, *)) { - const int safeAreaBehavior = [ud integerForKey:MMNonNativeFullScreenSafeAreaBehaviorKey]; + const NSInteger safeAreaBehavior = [ud integerForKey:MMNonNativeFullScreenSafeAreaBehaviorKey]; // The safe area utilization is configuration. Right now, we only have two choices: // - 0: avoid the safe area (default) diff --git a/src/MacVim/MMPreferenceController.h b/src/MacVim/MMPreferenceController.h index d06dc47515..3021e1be13 100644 --- a/src/MacVim/MMPreferenceController.h +++ b/src/MacVim/MMPreferenceController.h @@ -35,8 +35,6 @@ - (IBAction)openInCurrentWindowSelectionChanged:(id)sender; - (IBAction)checkForUpdatesChanged:(id)sender; - (IBAction)appearanceChanged:(id)sender; -- (IBAction)lastWindowClosedChanged:(id)sender; -- (IBAction)openUntitledWindowChanged:(id)sender; - (IBAction)smoothResizeChanged:(id)sender; // Appearance pane diff --git a/src/MacVim/MMTextStorage.m b/src/MacVim/MMTextStorage.m index 22b8eb5c37..b7bea86908 100644 --- a/src/MacVim/MMTextStorage.m +++ b/src/MacVim/MMTextStorage.m @@ -808,8 +808,8 @@ - (NSSize)cellSize - (NSRect)rectForRowsInRange:(NSRange)range { NSRect rect = { {0, 0}, {0, 0} }; - unsigned start = range.location > maxRows ? maxRows : range.location; - unsigned length = range.length; + NSUInteger start = range.location > maxRows ? maxRows : range.location; + NSUInteger length = range.length; if (start+length > maxRows) length = maxRows - start; @@ -823,8 +823,8 @@ - (NSRect)rectForRowsInRange:(NSRange)range - (NSRect)rectForColumnsInRange:(NSRange)range { NSRect rect = { {0, 0}, {0, 0} }; - unsigned start = range.location > maxColumns ? maxColumns : range.location; - unsigned length = range.length; + NSUInteger start = range.location > maxColumns ? maxColumns : range.location; + NSUInteger length = range.length; if (start+length > maxColumns) length = maxColumns - start; @@ -1026,7 +1026,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells return NSMakeRange(row*(actualColumns+1) + col, cells); NSString *string = [backingStore string]; - unsigned stringLen = [string length]; + NSUInteger stringLen = [string length]; NSRange r, range = { NSNotFound, 0 }; unsigned idx; int i; @@ -1035,7 +1035,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells || col+cells > actualColumns) { #if MM_TS_PARANOIA_LOG ASLogErr(@"row=%d col=%d cells=%d is out of range (length=%d)", - row, col, cells, stringLen); + row, col, cells, (int)stringLen); #endif return range; } @@ -1149,7 +1149,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells *pcol = i; cache->col = i; - cache->colOffset = idx - range.location; + cache->colOffset = idx - (unsigned)range.location; #endif } #else @@ -1238,7 +1238,7 @@ - (void)fixInvalidCharactersInRange:(NSRange)range [backingStore replaceCharactersInRange:invalidRange withString:@" "]; - end = NSMaxRange(invalidRange); + end = (unsigned)NSMaxRange(invalidRange); range.length -= end - range.location; range.location = end; } diff --git a/src/MacVim/MMTextView.m b/src/MacVim/MMTextView.m index 0702f7cecf..d092cabd74 100644 --- a/src/MacVim/MMTextView.m +++ b/src/MacVim/MMTextView.m @@ -279,9 +279,9 @@ - (void)performBatchDrawWithData:(NSData *)data [textStorage endEditing]; if (cursorRow >= 0) { - unsigned off = [textStorage characterIndexForRow:cursorRow + NSUInteger off = [textStorage characterIndexForRow:cursorRow column:cursorCol]; - unsigned maxoff = [[textStorage string] length]; + NSUInteger maxoff = [[textStorage string] length]; if (off > maxoff) off = maxoff; [self setSelectedRange:NSMakeRange(off, 0)]; @@ -435,8 +435,8 @@ - (NSColor *)defaultForegroundColor - (NSSize)constrainRows:(int *)rows columns:(int *)cols toSize:(NSSize)size { NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - int right = [ud integerForKey:MMTextInsetRightKey]; - int bot = [ud integerForKey:MMTextInsetBottomKey]; + NSInteger right = [ud integerForKey:MMTextInsetRightKey]; + NSInteger bot = [ud integerForKey:MMTextInsetBottomKey]; size.width -= [self textContainerOrigin].x + right; size.height -= [self textContainerOrigin].y + bot; @@ -456,8 +456,8 @@ - (NSSize)desiredSize NSSize size = [(MMTextStorage*)[self textStorage] size]; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - int right = [ud integerForKey:MMTextInsetRightKey]; - int bot = [ud integerForKey:MMTextInsetBottomKey]; + NSInteger right = [ud integerForKey:MMTextInsetRightKey]; + NSInteger bot = [ud integerForKey:MMTextInsetBottomKey]; size.width += [self textContainerOrigin].x + right; size.height += [self textContainerOrigin].y + bot; @@ -471,8 +471,8 @@ - (NSSize)minSize NSSize size = { MMMinColumns*cellSize.width, MMMinRows*cellSize.height }; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - int right = [ud integerForKey:MMTextInsetRightKey]; - int bot = [ud integerForKey:MMTextInsetBottomKey]; + NSInteger right = [ud integerForKey:MMTextInsetRightKey]; + NSInteger bot = [ud integerForKey:MMTextInsetBottomKey]; size.width += [self textContainerOrigin].x + right; size.height += [self textContainerOrigin].y + bot; @@ -589,7 +589,7 @@ - (void)drawRect:(NSRect)rect inset.height -= baseline; - int len = [[helper markedText] length]; + int len = (int)[[helper markedText] length]; // The following implementation should be re-written with // more efficient way... diff --git a/src/MacVim/MMTextViewHelper.h b/src/MacVim/MMTextViewHelper.h index 3ae7f7e424..0aca93ea78 100644 --- a/src/MacVim/MMTextViewHelper.h +++ b/src/MacVim/MMTextViewHelper.h @@ -32,7 +32,7 @@ BOOL isDragging; int dragRow; int dragColumn; - int dragFlags; + unsigned dragFlags; NSPoint dragPoint; BOOL isAutoscrolling; int mouseShape; diff --git a/src/MacVim/MMTextViewHelper.m b/src/MacVim/MMTextViewHelper.m index f2a350ee59..b2834f7bd7 100644 --- a/src/MacVim/MMTextViewHelper.m +++ b/src/MacVim/MMTextViewHelper.m @@ -44,7 +44,7 @@ - (NSRect)trackingRect; - (BOOL)inputManagerHandleMouseEvent:(NSEvent *)event; - (void)sendMarkedText:(NSString *)text position:(int32_t)pos; - (void)abandonMarkedText; -- (void)sendGestureEvent:(int)gesture flags:(int)flags; +- (void)sendGestureEvent:(int)gesture flags:(unsigned)flags; @end @@ -147,7 +147,7 @@ - (void)keyDown:(NSEvent *)event [self hideMouseCursor]; - unsigned flags = [event modifierFlags]; + NSUInteger flags = [event modifierFlags]; id mmta = [[[self vimController] vimState] objectForKey:@"p_mmta"]; NSString *string = [event characters]; NSString *unmod = [event charactersIgnoringModifiers]; @@ -372,12 +372,12 @@ - (void)scrollWheel:(NSEvent *)event int row, col; NSPoint pt = [textView convertPoint:[event locationInWindow] fromView:nil]; if ([textView convertPoint:pt toRow:&row column:&col]) { - int flags = [event modifierFlags]; + unsigned flags = (unsigned)[event modifierFlags]; NSMutableData *data = [NSMutableData data]; [data appendBytes:&row length:sizeof(int)]; [data appendBytes:&col length:sizeof(int)]; - [data appendBytes:&flags length:sizeof(int)]; + [data appendBytes:&flags length:sizeof(unsigned)]; [data appendBytes:&dy length:sizeof(float)]; [data appendBytes:&dx length:sizeof(float)]; @@ -395,8 +395,8 @@ - (void)mouseDown:(NSEvent *)event if (![textView convertPoint:pt toRow:&row column:&col]) return; - int button = [event buttonNumber]; - int flags = [event modifierFlags]; + int button = (int)[event buttonNumber]; + unsigned flags = (unsigned)[event modifierFlags]; int repeat = 0; if (useMouseTime) { @@ -428,7 +428,7 @@ - (void)mouseDown:(NSEvent *)event [data appendBytes:&row length:sizeof(int)]; [data appendBytes:&col length:sizeof(int)]; [data appendBytes:&button length:sizeof(int)]; - [data appendBytes:&flags length:sizeof(int)]; + [data appendBytes:&flags length:sizeof(unsigned)]; [data appendBytes:&repeat length:sizeof(int)]; [[self vimController] sendMessage:MouseDownMsgID data:data]; @@ -444,12 +444,12 @@ - (void)mouseUp:(NSEvent *)event if (![textView convertPoint:pt toRow:&row column:&col]) return; - int flags = [event modifierFlags]; + unsigned flags = (unsigned)[event modifierFlags]; NSMutableData *data = [NSMutableData data]; [data appendBytes:&row length:sizeof(int)]; [data appendBytes:&col length:sizeof(int)]; - [data appendBytes:&flags length:sizeof(int)]; + [data appendBytes:&flags length:sizeof(unsigned)]; [[self vimController] sendMessage:MouseUpMsgID data:data]; @@ -461,7 +461,7 @@ - (void)mouseDragged:(NSEvent *)event if ([self inputManagerHandleMouseEvent:event]) return; - int flags = [event modifierFlags]; + unsigned flags = (unsigned)[event modifierFlags]; int row, col; NSPoint pt = [textView convertPoint:[event locationInWindow] fromView:nil]; if (![textView convertPoint:pt toRow:&row column:&col]) @@ -473,7 +473,7 @@ - (void)mouseDragged:(NSEvent *)event [data appendBytes:&row length:sizeof(int)]; [data appendBytes:&col length:sizeof(int)]; - [data appendBytes:&flags length:sizeof(int)]; + [data appendBytes:&flags length:sizeof(unsigned)]; [[self vimController] sendMessage:MouseDraggedMsgID data:data]; } @@ -523,7 +523,7 @@ - (void)swipeWithEvent:(NSEvent *)event else if (dy < 0) type = MMGestureSwipeDown; else return; - [self sendGestureEvent:type flags:[event modifierFlags]]; + [self sendGestureEvent:type flags:(unsigned)[event modifierFlags]]; } - (void)pressureChangeWithEvent:(NSEvent *)event @@ -553,7 +553,7 @@ - (void)pressureChangeWithEvent:(NSEvent *)event // https://searchfox.org/mozilla-central/source/widget/cocoa/nsChildView.mm [textView quickLookWithEvent:event]; } else { - [self sendGestureEvent:MMGestureForceClick flags:[event modifierFlags]]; + [self sendGestureEvent:MMGestureForceClick flags:(unsigned)[event modifierFlags]]; } } } else { @@ -622,8 +622,8 @@ - (void)changeFont:(id)sender if (newFont) { NSString *name = [newFont displayName]; NSString *wideName = [newFontWide displayName]; - unsigned len = [name lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - unsigned wideLen = [wideName lengthOfBytesUsingEncoding: + unsigned len = (unsigned)[name lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + unsigned wideLen = (unsigned)[wideName lengthOfBytesUsingEncoding: NSUTF8StringEncoding]; if (len > 0) { NSMutableData *data = [NSMutableData data]; @@ -709,7 +709,7 @@ - (void)setMarkedText:(id)text selectedRange:(NSRange)range imRange = range; } - [self sendMarkedText:text position:range.location]; + [self sendMarkedText:text position:(int32_t)range.location]; return; } @@ -842,7 +842,7 @@ - (NSRect)firstRectForCharacterRange:(NSRange)range } } - return [self firstRectForCharacterRange:row column:col length:range.length]; + return [self firstRectForCharacterRange:row column:col length:(int)range.length]; } - (NSRect)firstRectForCharacterRange:(int)row column:(int)col length:(int)numColumns @@ -980,9 +980,9 @@ - (void)doKeyDown:(NSString *)key } const char *chars = [key UTF8String]; - unsigned length = [key lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + unsigned length = (unsigned)[key lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; unsigned keyCode = [currentEvent keyCode]; - unsigned flags = [currentEvent modifierFlags]; + unsigned flags = (unsigned)[currentEvent modifierFlags]; // The low 16 bits are not used for modifier flags by NSEvent. Use // these bits for custom flags. @@ -1002,7 +1002,7 @@ - (void)doKeyDown:(NSString *)key - (void)doInsertText:(NSString *)text { - unsigned length = [text lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + unsigned length = (unsigned)[text lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; if (0 == length) return; @@ -1018,7 +1018,7 @@ - (void)doInsertText:(NSString *)text if (currentEvent) { // HACK! Keys on the numeric key pad are treated as special keys by Vim // so we need to pass on key code and modifier flags in this situation. - unsigned mods = [currentEvent modifierFlags]; + unsigned mods = (unsigned)[currentEvent modifierFlags]; if (mods & NSEventModifierFlagNumericPad) { flags = mods & NSEventModifierFlagDeviceIndependentFlagsMask; keyCode = [currentEvent keyCode]; @@ -1071,7 +1071,7 @@ - (void)dragTimerFired:(NSTimer *)timer [data appendBytes:&dragRow length:sizeof(int)]; [data appendBytes:&col length:sizeof(int)]; - [data appendBytes:&dragFlags length:sizeof(int)]; + [data appendBytes:&dragFlags length:sizeof(unsigned)]; [[self vimController] sendMessage:MouseDraggedMsgID data:data]; @@ -1174,10 +1174,10 @@ - (NSRect)trackingRect { NSRect rect = [textView frame]; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - int left = [ud integerForKey:MMTextInsetLeftKey]; - int top = [ud integerForKey:MMTextInsetTopKey]; - int right = [ud integerForKey:MMTextInsetRightKey]; - int bot = [ud integerForKey:MMTextInsetBottomKey]; + NSUInteger left = [ud integerForKey:MMTextInsetLeftKey]; + NSUInteger top = [ud integerForKey:MMTextInsetTopKey]; + NSUInteger right = [ud integerForKey:MMTextInsetRightKey]; + NSUInteger bot = [ud integerForKey:MMTextInsetBottomKey]; rect.origin.x = left; rect.origin.y = top; @@ -1206,7 +1206,7 @@ - (void)sendMarkedText:(NSString *)text position:(int32_t)pos NSMutableData *data = [NSMutableData data]; unsigned len = text == nil ? 0 - : [text lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + : (unsigned)[text lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; [data appendBytes:&pos length:sizeof(int32_t)]; [data appendBytes:&len length:sizeof(unsigned)]; @@ -1229,11 +1229,11 @@ - (void)abandonMarkedText [[NSTextInputContext currentInputContext] discardMarkedText]; } -- (void)sendGestureEvent:(int)gesture flags:(int)flags +- (void)sendGestureEvent:(int)gesture flags:(unsigned)flags { NSMutableData *data = [NSMutableData data]; - [data appendBytes:&flags length:sizeof(int)]; + [data appendBytes:&flags length:sizeof(unsigned)]; [data appendBytes:&gesture length:sizeof(int)]; [[self vimController] sendMessage:GestureMsgID data:data]; diff --git a/src/MacVim/MMTypesetter.m b/src/MacVim/MMTypesetter.m index 41fa6d448d..1657861b58 100644 --- a/src/MacVim/MMTypesetter.m +++ b/src/MacVim/MMTypesetter.m @@ -119,7 +119,7 @@ - (void)layoutGlyphsInLayoutManager:(NSLayoutManager *)lm // Note that we always start laying out lines from the beginning of a line, // even if 'startCharIdx' may be somewhere in the middle. - unsigned startCharIdx = [lm characterIndexForGlyphAtIndex:startGlyphIdx]; + NSUInteger startCharIdx = [lm characterIndexForGlyphAtIndex:startGlyphIdx]; if (startCharIdx >= [text length]) return; @@ -162,7 +162,7 @@ - (void)layoutGlyphsInLayoutManager:(NSLayoutManager *)lm NSRange glyphRange = { startGlyphIdx, 0 }; NSRect lineRect = { {0, line*cellSize.height}, {[ts actualColumns]*cellSize.width, cellSize.height} }; - int endLine = line + maxNumLines; + int endLine = line + (int)maxNumLines; if (endLine > actualRows) endLine = actualRows; diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index b4b0675c59..cfb236376a 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -333,7 +333,7 @@ - (void)dropFiles:(NSArray *)filenames forceOpen:(BOOL)force NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; // Default to opening in tabs if layout is invalid or set to "windows". - int layout = [ud integerForKey:MMOpenLayoutKey]; + NSInteger layout = [ud integerForKey:MMOpenLayoutKey]; if (layout < 0 || layout > MMLayoutTabs) layout = MMLayoutTabs; @@ -342,7 +342,7 @@ - (void)dropFiles:(NSArray *)filenames forceOpen:(BOOL)force layout = MMLayoutVerticalSplit; NSDictionary *args = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithInt:layout], @"layout", + [NSNumber numberWithInt:(int)layout], @"layout", filenames, @"filenames", [NSNumber numberWithBool:force], @"forceOpen", nil]; @@ -374,7 +374,7 @@ - (void)file:(NSString *)filename draggedToTabAtIndex:(NSUInteger)tabIndex NSDictionary *args = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:layout], @"layout", @[filename], @"filenames", - [NSNumber numberWithInt:tabIndex + 1], @"tabpage", + [NSNumber numberWithInt:(int)tabIndex + 1], @"tabpage", nil]; [self sendMessage:OpenWithArgumentsMsgID data:[args dictionaryAsData]]; @@ -403,12 +403,13 @@ - (void)filesDraggedToTabBar:(NSArray *)filenames - (void)dropString:(NSString *)string { ASLogInfo(@"%@", string); - int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1; - if (len > 0) { + NSUInteger len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1; + if (len > 0 && len < INT_MAX) { NSMutableData *data = [NSMutableData data]; + int len_int = (int)len; - [data appendBytes:&len length:sizeof(int)]; - [data appendBytes:[string UTF8String] length:len]; + [data appendBytes:&len_int length:sizeof(int)]; + [data appendBytes:[string UTF8String] length:len_int]; [self sendMessage:DropStringMsgID data:data]; } @@ -630,9 +631,9 @@ - (void)doProcessInputQueue:(NSArray *)queue { NSMutableArray *delayQueue = nil; - unsigned i, count = [queue count]; + unsigned i, count = (unsigned)[queue count]; if (count % 2) { - ASLogWarn(@"Uneven number of components (%d) in command queue. " + ASLogWarn(@"Uneven number of components (%u) in command queue. " "Skipping...", count); return; } @@ -1333,8 +1334,8 @@ - (NSMenuItem *)menuItemForDescriptor:(NSArray *)desc : [mainMenu itemArray]; NSMenuItem *item = nil; - int i, count = [rootItems count]; - for (i = 0; i < count; ++i) { + NSUInteger i, count; + for (i = 0, count = rootItems.count; i < count; ++i) { item = [rootItems objectAtIndex:i]; if ([[item title] isEqual:rootName]) break; @@ -1342,8 +1343,7 @@ - (NSMenuItem *)menuItemForDescriptor:(NSArray *)desc if (i == count) return nil; - count = [desc count]; - for (i = 1; i < count; ++i) { + for (i = 1, count = desc.count; i < count; ++i) { item = [[item submenu] itemWithTitle:[desc objectAtIndex:i]]; if (!item) return nil; } @@ -1361,8 +1361,7 @@ - (NSMenu *)parentMenuForDescriptor:(NSArray *)desc : [mainMenu itemArray]; NSMenu *menu = nil; - int i, count = [rootItems count]; - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = rootItems.count; i < count; ++i) { NSMenuItem *item = [rootItems objectAtIndex:i]; if ([[item title] isEqual:rootName]) { menu = [item submenu]; @@ -1372,8 +1371,7 @@ - (NSMenu *)parentMenuForDescriptor:(NSArray *)desc if (!menu) return nil; - count = [desc count] - 1; - for (i = 1; i < count; ++i) { + for (NSUInteger i = 1, count = desc.count - 1; i < count; ++i) { NSMenuItem *item = [menu itemWithTitle:[desc objectAtIndex:i]]; menu = [item submenu]; if (!menu) return nil; @@ -1386,15 +1384,13 @@ - (NSMenu *)topLevelMenuForTitle:(NSString *)title { // Search only the top-level menus. - unsigned i, count = [popupMenuItems count]; - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = popupMenuItems.count; i < count; ++i) { NSMenuItem *item = [popupMenuItems objectAtIndex:i]; if ([title isEqual:[item title]]) return [item submenu]; } - count = [mainMenu numberOfItems]; - for (i = 0; i < count; ++i) { + for (NSInteger i = 0, count = mainMenu.numberOfItems; i < count; ++i) { NSMenuItem *item = [mainMenu itemAtIndex:i]; if ([title isEqual:[item title]]) return [item submenu]; @@ -1414,7 +1410,7 @@ - (void)addMenuWithDescriptor:(NSArray *)desc atIndex:(int)idx if (!toolbar) { // NOTE! Each toolbar must have a unique identifier, else each // window will have the same toolbar. - NSString *ident = [NSString stringWithFormat:@"%d", identifier]; + NSString *ident = [NSString stringWithFormat:@"%lu", identifier]; toolbar = [[NSToolbar alloc] initWithIdentifier:ident]; [toolbar setShowsBaselineSeparator:NO]; @@ -1751,7 +1747,7 @@ - (NSImage*)findToolbarIcon:(NSString*)icon NSArray *splitComponents = [sfSymbolName componentsSeparatedByString:@":"]; sfSymbolName = splitComponents[0]; - for (int i = 1, count = splitComponents.count; i < count; i++) { + for (NSUInteger i = 1, count = splitComponents.count; i < count; i++) { NSString *component = splitComponents[i]; if ([component isEqualToString:@"monochrome"]) { monochrome = YES; @@ -1927,7 +1923,7 @@ - (void)addToolbarItemWithLabel:(NSString *)label [self addToolbarItemToDictionaryWithLabel:label toolTip:tip icon:icon]; - int maxIdx = [[toolbar items] count]; + int maxIdx = (int)[[toolbar items] count]; if (maxIdx < idx) idx = maxIdx; [toolbar insertItemWithItemIdentifier:label atIndex:idx]; @@ -1993,7 +1989,7 @@ - (void)addTouchbarItemWithLabel:(NSString *)label } [touchbarInfo.itemDict setObject:touchbarItemInfo forKey:label]; - int maxIdx = [touchbarInfo.itemOrder count]; + int maxIdx = (int)[touchbarInfo.itemOrder count]; if (maxIdx < idx) idx = maxIdx; [touchbarInfo.itemOrder insertObject:label atIndex:idx]; @@ -2160,7 +2156,7 @@ - (void)handleBrowseForFile:(NSDictionary *)attr [panel beginSheetModalForWindow:[windowController window] completionHandler:^(NSInteger result) { - [self savePanelDidEnd:panel code:result context:nil]; + [self savePanelDidEnd:panel code:(int)result context:nil]; }]; } else { NSOpenPanel *panel = [NSOpenPanel openPanel]; @@ -2177,7 +2173,7 @@ - (void)handleBrowseForFile:(NSDictionary *)attr [panel beginSheetModalForWindow:[windowController window] completionHandler:^(NSInteger result) { - [self savePanelDidEnd:panel code:result context:nil]; + [self savePanelDidEnd:panel code:(int)result context:nil]; }]; } } @@ -2216,8 +2212,7 @@ - (void)handleShowDialog:(NSDictionary *)attr [alert setInformativeText:@""]; } - unsigned i, count = [buttonTitles count]; - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = buttonTitles.count; i < count; ++i) { NSString *title = [buttonTitles objectAtIndex:i]; // NOTE: The title of the button may contain the character '&' to // indicate that the following letter should be the key equivalent @@ -2318,7 +2313,7 @@ - (void)beginSheetModalForWindow:(NSWindow *)window #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 [super beginSheetModalForWindow:window completionHandler:^(NSModalResponse code) { - [delegate alertDidEnd:self code:code context:NULL]; + [delegate alertDidEnd:self code:(int)code context:NULL]; }]; #else [super beginSheetModalForWindow:window @@ -2334,8 +2329,7 @@ - (void)beginSheetModalForWindow:(NSWindow *)window rect.origin.y = rect.size.height; NSArray *subviews = [contentView subviews]; - unsigned i, count = [subviews count]; - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = subviews.count; i < count; ++i) { NSView *view = [subviews objectAtIndex:i]; if ([view isKindOfClass:[NSTextField class]] && [view frame].origin.y < rect.origin.y) { diff --git a/src/MacVim/MMVimView.m b/src/MacVim/MMVimView.m index a74845be20..d0a119f174 100644 --- a/src/MacVim/MMVimView.m +++ b/src/MacVim/MMVimView.m @@ -102,9 +102,9 @@ - (MMVimView *)initWithFrame:(NSRect)frame } // Allow control of text view inset via MMTextInset* user defaults. - int left = [ud integerForKey:MMTextInsetLeftKey]; - int top = [ud integerForKey:MMTextInsetTopKey]; - [textView setTextContainerInset:NSMakeSize(left, top)]; + [textView setTextContainerInset:NSMakeSize( + [ud integerForKey:MMTextInsetLeftKey], + [ud integerForKey:MMTextInsetTopKey])]; [textView setAutoresizingMask:NSViewNotSizable]; [self addSubview:textView]; @@ -127,24 +127,24 @@ - (MMVimView *)initWithFrame:(NSRect)frame if (shouldUseYosemiteTabBarStyle() || shouldUseMojaveTabBarStyle()) { CGFloat screenWidth = [[NSScreen mainScreen] frame].size.width; - int tabMaxWidth = [ud integerForKey:MMTabMaxWidthKey]; + int tabMaxWidth = (int)[ud integerForKey:MMTabMaxWidthKey]; if (tabMaxWidth == 0) - tabMaxWidth = screenWidth; - int tabOptimumWidth = [ud integerForKey:MMTabOptimumWidthKey]; + tabMaxWidth = (int)screenWidth; + int tabOptimumWidth = (int)[ud integerForKey:MMTabOptimumWidthKey]; if (tabOptimumWidth == 0) - tabOptimumWidth = screenWidth; + tabOptimumWidth = (int)screenWidth; NSString* tabStyleName = shouldUseMojaveTabBarStyle() ? @"Mojave" : @"Yosemite"; [tabBarControl setStyleNamed:tabStyleName]; - [tabBarControl setCellMinWidth:[ud integerForKey:MMTabMinWidthKey]]; + [tabBarControl setCellMinWidth:(int)[ud integerForKey:MMTabMinWidthKey]]; [tabBarControl setCellMaxWidth:tabMaxWidth]; [tabBarControl setCellOptimumWidth:tabOptimumWidth]; } else { - [tabBarControl setCellMinWidth:[ud integerForKey:MMTabMinWidthKey]]; - [tabBarControl setCellMaxWidth:[ud integerForKey:MMTabMaxWidthKey]]; + [tabBarControl setCellMinWidth:(int)[ud integerForKey:MMTabMinWidthKey]]; + [tabBarControl setCellMaxWidth:(int)[ud integerForKey:MMTabMaxWidthKey]]; [tabBarControl setCellOptimumWidth: - [ud integerForKey:MMTabOptimumWidthKey]]; + (int)[ud integerForKey:MMTabOptimumWidthKey]]; } [tabBarControl setShowAddTabButton:[ud boolForKey:MMShowAddTabButtonKey]]; @@ -275,8 +275,7 @@ - (void)cleanup [tabBarControl removeFromSuperviewWithoutNeedingDisplay]; [textView removeFromSuperviewWithoutNeedingDisplay]; - unsigned i, count = [scrollbars count]; - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = scrollbars.count; i < count; ++i) { MMScroller *sb = [scrollbars objectAtIndex:i]; [sb removeFromSuperviewWithoutNeedingDisplay]; } @@ -367,8 +366,7 @@ - (void)updateTabsWithData:(NSData *)data // take care of which tab to select so set the vimTaskSelectedTab flag to // prevent the tab selection message to be passed on to the VimTask. vimTaskSelectedTab = YES; - int i, count = [[self tabView] numberOfTabViewItems]; - for (i = count-1; i >= tabIdx; --i) { + for (NSInteger i = [self tabView].numberOfTabViewItems-1; i >= tabIdx; --i) { id tvi = [tabViewItems objectAtIndex:i]; [[self tabView] removeTabViewItem:tvi]; } @@ -406,7 +404,7 @@ - (NSTabViewItem *)addNewTabViewItem // The documentation claims initWithIdentifier can be given a nil identifier, but the API itself // is decorated such that doing so produces a warning, so the tab count is used as identifier. NSInteger identifier = [[self tabView] numberOfTabViewItems]; - NSTabViewItem *tvi = [[NSTabViewItem alloc] initWithIdentifier:[NSNumber numberWithInt:identifier]]; + NSTabViewItem *tvi = [[NSTabViewItem alloc] initWithIdentifier:[NSNumber numberWithInt:(int)identifier]]; // NOTE: If this is the first tab it will be automatically selected. vimTaskSelectedTab = YES; @@ -477,11 +475,11 @@ - (void)scroll:(id)sender { NSMutableData *data = [NSMutableData data]; int32_t ident = [(MMScroller*)sender scrollerId]; - int hitPart = [sender hitPart]; + unsigned hitPart = (unsigned)[sender hitPart]; float value = [sender floatValue]; [data appendBytes:&ident length:sizeof(int32_t)]; - [data appendBytes:&hitPart length:sizeof(int)]; + [data appendBytes:&hitPart length:sizeof(unsigned)]; [data appendBytes:&value length:sizeof(float)]; [vimController sendMessage:ScrollbarEventMsgID data:data]; @@ -675,8 +673,7 @@ @implementation MMVimView (Private) - (BOOL)bottomScrollbarVisible { - unsigned i, count = [scrollbars count]; - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = scrollbars.count; i < count; ++i) { MMScroller *scroller = [scrollbars objectAtIndex:i]; if ([scroller type] == MMScrollerTypeBottom && ![scroller isHidden]) return YES; @@ -687,8 +684,7 @@ - (BOOL)bottomScrollbarVisible - (BOOL)leftScrollbarVisible { - unsigned i, count = [scrollbars count]; - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = scrollbars.count; i < count; ++i) { MMScroller *scroller = [scrollbars objectAtIndex:i]; if ([scroller type] == MMScrollerTypeLeft && ![scroller isHidden]) return YES; @@ -699,8 +695,7 @@ - (BOOL)leftScrollbarVisible - (BOOL)rightScrollbarVisible { - unsigned i, count = [scrollbars count]; - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = scrollbars.count; i < count; ++i) { MMScroller *scroller = [scrollbars objectAtIndex:i]; if ([scroller type] == MMScrollerTypeRight && ![scroller isHidden]) return YES; @@ -718,11 +713,10 @@ - (void)placeScrollbars // HACK! Find the lowest left&right vertical scrollbars This hack // continues further down. - unsigned lowestLeftSbIdx = (unsigned)-1; - unsigned lowestRightSbIdx = (unsigned)-1; - unsigned rowMaxLeft = 0, rowMaxRight = 0; - unsigned i, count = [scrollbars count]; - for (i = 0; i < count; ++i) { + NSUInteger lowestLeftSbIdx = (NSUInteger)-1; + NSUInteger lowestRightSbIdx = (NSUInteger)-1; + NSUInteger rowMaxLeft = 0, rowMaxRight = 0; + for (NSUInteger i = 0, count = scrollbars.count; i < count; ++i) { MMScroller *scroller = [scrollbars objectAtIndex:i]; if (![scroller isHidden]) { NSRange range = [scroller range]; @@ -743,7 +737,7 @@ - (void)placeScrollbars } // Place the scrollbars. - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = scrollbars.count; i < count; ++i) { MMScroller *scroller = [scrollbars objectAtIndex:i]; if ([scroller isHidden]) continue; @@ -853,11 +847,10 @@ - (NSUInteger)representedIndexOfTabViewItem:(NSTabViewItem *)tvi - (MMScroller *)scrollbarForIdentifier:(int32_t)ident index:(unsigned *)idx { - unsigned i, count = [scrollbars count]; - for (i = 0; i < count; ++i) { + for (NSUInteger i = 0, count = scrollbars.count; i < count; ++i) { MMScroller *scroller = [scrollbars objectAtIndex:i]; if ([scroller scrollerId] == ident) { - if (idx) *idx = i; + if (idx) *idx = (unsigned)i; return scroller; } } diff --git a/src/MacVim/MMWindow.m b/src/MacVim/MMWindow.m index 7c05880d18..3af65742a0 100644 --- a/src/MacVim/MMWindow.m +++ b/src/MacVim/MMWindow.m @@ -170,7 +170,7 @@ - (void)setBlurRadius:(int)radius } CGSSetWindowBackgroundBlurRadiusFunction* function = GetCGSSetWindowBackgroundBlurRadiusFunction(); if (function) { - function(con, [self windowNumber], radius); + function(con, (int)[self windowNumber], radius); } } } diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 52bedd708d..6da87b00cf 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -1153,7 +1153,7 @@ - (IBAction)fontSizeDown:(id)sender - (IBAction)findAndReplace:(id)sender { - int tag = [sender tag]; + NSInteger tag = [sender tag]; MMFindReplaceController *fr = [MMFindReplaceController sharedInstance]; int flags = 0; diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index 97d662636a..0a9bd33378 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -391,7 +391,7 @@ enum { }; enum { - MMGestureSwipeLeft, + MMGestureSwipeLeft = 0, MMGestureSwipeRight, MMGestureSwipeUp, MMGestureSwipeDown, diff --git a/src/MacVim/MacVim.m b/src/MacVim/MacVim.m index 97d8d7e3b1..7cffc0b89f 100644 --- a/src/MacVim/MacVim.m +++ b/src/MacVim/MacVim.m @@ -51,7 +51,7 @@ debugStringForMessageQueue(NSArray *queue) { NSMutableString *s = [NSMutableString new]; - unsigned i, count = [queue count]; + NSUInteger i, count = [queue count]; int item = 0, menu = 0, enable = 0, remove = 0; int sets = 0, sett = 0, shows = 0, cres = 0, dess = 0; for (i = 0; i < count; i += 2) { diff --git a/src/MacVim/MacVim.xcodeproj/project.pbxproj b/src/MacVim/MacVim.xcodeproj/project.pbxproj index a10e62d398..2d676cbb8d 100644 --- a/src/MacVim/MacVim.xcodeproj/project.pbxproj +++ b/src/MacVim/MacVim.xcodeproj/project.pbxproj @@ -1360,7 +1360,7 @@ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNGUARDED_AVAILABILITY = NO; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; @@ -1421,7 +1421,7 @@ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNGUARDED_AVAILABILITY = NO; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; @@ -1517,7 +1517,6 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; ENABLE_TESTABILITY = YES; - GCC_VERSION = 4.2; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; @@ -1531,7 +1530,6 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - GCC_VERSION = 4.2; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; diff --git a/src/MacVim/MacVimTests/MacVimTests.m b/src/MacVim/MacVimTests/MacVimTests.m index 823839652c..492f354cc9 100644 --- a/src/MacVim/MacVimTests/MacVimTests.m +++ b/src/MacVim/MacVimTests/MacVimTests.m @@ -44,7 +44,7 @@ @interface MacVimTests : XCTestCase @implementation MacVimTests -/// Wait for Vim window to open and is ready to go +/// Wait for Vim window to open - (void)waitForVimOpen { XCTestExpectation *expectation = [self expectationWithDescription:@"VimOpen"]; @@ -61,7 +61,11 @@ - (void)waitForVimOpen { method_setImplementation(method, newIMP); [self waitForExpectations:@[expectation] timeout:10]; method_setImplementation(method, origIMP); +} +/// Wait for Vim window to open and is ready to go +- (void)waitForVimOpenAndWait { + [self waitForVimOpen]; [self waitForEventHandlingAndVimProcess]; } @@ -259,7 +263,7 @@ - (void)testVimTutor { // Adding a new window is necessary for the vimtutor menu to show up as it's // not part of the global menu [app openNewWindow:NewWindowClean activate:YES]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; // Find the vimtutor menu and run it. NSMenu *mainMenu = [NSApp mainMenu]; @@ -278,7 +282,7 @@ - (void)testVimTutor { // Note that `vimtutor` opens Vim twice. Once to copy the file. Another time to // actually open the copied file. [self waitForVimOpen]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; NSString *bufname = [[app keyVimController] evaluateVimExpression:@"bufname()"]; XCTAssertTrue([bufname containsString:@"tutor"]); @@ -302,7 +306,7 @@ - (void)testHelpMenuDocumentationTag { // Test help menu when no window is shown [app performActionForItem:@[@"", @"m'"]]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; MMVimController *vim = [app keyVimController]; XCTAssertEqualObjects(@"help", [vim evaluateVimExpression:@"&buftype"]); @@ -314,7 +318,7 @@ - (void)testHelpMenuDocumentationTag { // Test help menu when there's already a Vim window [app openNewWindow:NewWindowClean activate:YES]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; vim = [app keyVimController]; #define ASSERT_HELP_PATTERN(pattern) \ @@ -358,7 +362,7 @@ - (void) testCmdlineRowCalculation { MMAppController *app = MMAppController.sharedInstance; [app openNewWindow:NewWindowClean activate:YES]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; MMTextView *textView = [[[[app keyVimController] windowController] vimView] textView]; const int numLines = [textView maxRows]; diff --git a/src/MacVim/MacVim_xcode8.xcodeproj/project.pbxproj b/src/MacVim/MacVim_xcode8.xcodeproj/project.pbxproj index 070f45448b..eba27acc12 100644 --- a/src/MacVim/MacVim_xcode8.xcodeproj/project.pbxproj +++ b/src/MacVim/MacVim_xcode8.xcodeproj/project.pbxproj @@ -1361,7 +1361,7 @@ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNGUARDED_AVAILABILITY = NO; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; @@ -1422,7 +1422,7 @@ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNGUARDED_AVAILABILITY = NO; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; @@ -1518,7 +1518,6 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; ENABLE_TESTABILITY = YES; - GCC_VERSION = 4.2; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; @@ -1532,7 +1531,6 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - GCC_VERSION = 4.2; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; diff --git a/src/MacVim/Miscellaneous.m b/src/MacVim/Miscellaneous.m index 50d5fd261d..3ac5fcd9a3 100644 --- a/src/MacVim/Miscellaneous.m +++ b/src/MacVim/Miscellaneous.m @@ -71,7 +71,7 @@ + (id)indexSetWithVimList:(NSString *)list { NSMutableIndexSet *idxSet = [NSMutableIndexSet indexSet]; NSArray *array = [list componentsSeparatedByString:@"\n"]; - unsigned i, count = [array count]; + NSUInteger i, count = [array count]; for (i = 0; i < count; ++i) { NSString *entry = [array objectAtIndex:i]; @@ -125,11 +125,11 @@ @implementation NSMenu (MMExtras) - (int)indexOfItemWithAction:(SEL)action { - int i, count = [self numberOfItems]; + NSUInteger i, count = [self numberOfItems]; for (i = 0; i < count; ++i) { NSMenuItem *item = [self itemAtIndex:i]; if ([item action] == action) - return i; + return (int)i; } return -1; @@ -144,7 +144,7 @@ - (NSMenuItem *)itemWithAction:(SEL)action - (NSMenu *)findMenuContainingItemWithAction:(SEL)action { // NOTE: We only look for the action in the submenus of 'self' - int i, count = [self numberOfItems]; + NSUInteger i, count = [self numberOfItems]; for (i = 0; i < count; ++i) { NSMenu *menu = [[self itemAtIndex:i] submenu]; NSMenuItem *item = [menu itemWithAction:action]; @@ -307,7 +307,7 @@ - (NSInteger)tag if (!filenames) return outnames; - unsigned i, count = [filenames count]; + NSUInteger i, count = [filenames count]; for (i = 0; i < count; ++i) { NSString *nfkc = normalizeFilename([filenames objectAtIndex:i]); [outnames addObject:nfkc]; diff --git a/src/MacVim/PSMTabBarControl/source/PSMMojaveTabStyle.m b/src/MacVim/PSMTabBarControl/source/PSMMojaveTabStyle.m index b6194330e2..3c9e59a3fa 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMMojaveTabStyle.m +++ b/src/MacVim/PSMTabBarControl/source/PSMMojaveTabStyle.m @@ -10,6 +10,8 @@ #import "PSMMojaveTabStyle.h" +#import "PSMRolloverButton.h" + #if HAS_MOJAVE_TAB_STYLE #define kPSMMetalObjectCounterRadius 7.0 @@ -108,21 +110,23 @@ - (NSColor *)backgroundColor:(PSMTabBarCell *)cell isKeyWindow:(BOOL)isKeyWindow BOOL isHighlight = [cell isHighlighted]; - if (isKeyWindow) { - if (isSelected) { - backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundActiveSelected" bundle:[PSMTabBarControl bundle]]; - } else if (isHighlight) { - backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundActiveHighlight" bundle:[PSMTabBarControl bundle]]; - } else { - backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundActive" bundle:[PSMTabBarControl bundle]]; - } - } else { - if (isSelected) { - backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundInactiveSelected" bundle:[PSMTabBarControl bundle]]; - } else if (isHighlight) { - backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundInactiveHighlight" bundle:[PSMTabBarControl bundle]]; + if (@available(macos 10.13, *)) { + if (isKeyWindow) { + if (isSelected) { + backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundActiveSelected" bundle:[PSMTabBarControl bundle]]; + } else if (isHighlight) { + backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundActiveHighlight" bundle:[PSMTabBarControl bundle]]; + } else { + backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundActive" bundle:[PSMTabBarControl bundle]]; + } } else { - backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundInactive" bundle:[PSMTabBarControl bundle]]; + if (isSelected) { + backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundInactiveSelected" bundle:[PSMTabBarControl bundle]]; + } else if (isHighlight) { + backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundInactiveHighlight" bundle:[PSMTabBarControl bundle]]; + } else { + backgroundColor = [NSColor colorNamed:@"MojaveTabBackgroundInactive" bundle:[PSMTabBarControl bundle]]; + } } } @@ -131,10 +135,15 @@ - (NSColor *)backgroundColor:(PSMTabBarCell *)cell isKeyWindow:(BOOL)isKeyWindow - (NSColor *)borderColor:(BOOL)isKeyWindow { - if (isKeyWindow) { - return [NSColor colorNamed:@"MojaveTabBorderActive" bundle:[PSMTabBarControl bundle]]; - } else { - return [NSColor colorNamed:@"MojaveTabBorderInactive" bundle:[PSMTabBarControl bundle]]; + if (@available(macos 10.13, *)) { + if (isKeyWindow) { + return [NSColor colorNamed:@"MojaveTabBorderActive" bundle:[PSMTabBarControl bundle]]; + } else { + return [NSColor colorNamed:@"MojaveTabBorderInactive" bundle:[PSMTabBarControl bundle]]; + } + } + else { + return nil; } } @@ -438,12 +447,14 @@ - (void)drawInteriorWithTabCell:(PSMTabBarCell *)cell inView:(NSView*)controlVie button = closeButton; } if ([cell closeButtonOver]) { - NSAppearanceName appearanceName = [controlView.effectiveAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameAccessibilityHighContrastAqua, NSAppearanceNameDarkAqua, NSAppearanceNameAccessibilityHighContrastDarkAqua]]; - - if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua] || [appearanceName isEqualToString:NSAppearanceNameAccessibilityHighContrastDarkAqua]) { - button = closeButtonOverDark; - } else { - button = closeButtonOver; + if (@available(macos 10.14, *)) { + NSAppearanceName appearanceName = [controlView.effectiveAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameAccessibilityHighContrastAqua, NSAppearanceNameDarkAqua, NSAppearanceNameAccessibilityHighContrastDarkAqua]]; + + if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua] || [appearanceName isEqualToString:NSAppearanceNameAccessibilityHighContrastDarkAqua]) { + button = closeButtonOverDark; + } else { + button = closeButtonOver; + } } } if ([cell closeButtonPressed]) button = closeButtonDown; diff --git a/src/MacVim/PSMTabBarControl/source/PSMRolloverButton.m b/src/MacVim/PSMTabBarControl/source/PSMRolloverButton.m index 619ad077e8..bf390efc0c 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMRolloverButton.m +++ b/src/MacVim/PSMTabBarControl/source/PSMRolloverButton.m @@ -97,7 +97,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { if ([aCoder allowsKeyedCoding]) { [aCoder encodeObject:_rolloverImage forKey:@"rolloverImage"]; [aCoder encodeObject:_usualImage forKey:@"usualImage"]; - [aCoder encodeInt:_myTrackingRectTag forKey:@"myTrackingRectTag"]; + [aCoder encodeInteger:_myTrackingRectTag forKey:@"myTrackingRectTag"]; } } @@ -107,7 +107,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder { if ([aDecoder allowsKeyedCoding]) { _rolloverImage = [[aDecoder decodeObjectForKey:@"rolloverImage"] retain]; _usualImage = [[aDecoder decodeObjectForKey:@"usualImage"] retain]; - _myTrackingRectTag = [aDecoder decodeIntForKey:@"myTrackingRectTag"]; + _myTrackingRectTag = [aDecoder decodeIntegerForKey:@"myTrackingRectTag"]; } } return self; diff --git a/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m b/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m index 9642ba704b..d85d895d7f 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m +++ b/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m @@ -363,8 +363,8 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeInt:_currentStep forKey:@"currentStep"]; [aCoder encodeBool:_isPlaceholder forKey:@"isPlaceholder"]; [aCoder encodeInt:_tabState forKey:@"tabState"]; - [aCoder encodeInt:_closeButtonTrackingTag forKey:@"closeButtonTrackingTag"]; - [aCoder encodeInt:_cellTrackingTag forKey:@"cellTrackingTag"]; + [aCoder encodeInteger:_closeButtonTrackingTag forKey:@"closeButtonTrackingTag"]; + [aCoder encodeInteger:_cellTrackingTag forKey:@"cellTrackingTag"]; [aCoder encodeBool:_closeButtonOver forKey:@"closeButtonOver"]; [aCoder encodeBool:_closeButtonPressed forKey:@"closeButtonPressed"]; [aCoder encodeObject:_indicator forKey:@"indicator"]; @@ -386,8 +386,8 @@ - (id)initWithCoder:(NSCoder *)aDecoder { _currentStep = [aDecoder decodeIntForKey:@"currentStep"]; _isPlaceholder = [aDecoder decodeBoolForKey:@"isPlaceholder"]; _tabState = [aDecoder decodeIntForKey:@"tabState"]; - _closeButtonTrackingTag = [aDecoder decodeIntForKey:@"closeButtonTrackingTag"]; - _cellTrackingTag = [aDecoder decodeIntForKey:@"cellTrackingTag"]; + _closeButtonTrackingTag = [aDecoder decodeIntegerForKey:@"closeButtonTrackingTag"]; + _cellTrackingTag = [aDecoder decodeIntegerForKey:@"cellTrackingTag"]; _closeButtonOver = [aDecoder decodeBoolForKey:@"closeButtonOver"]; _closeButtonPressed = [aDecoder decodeBoolForKey:@"closeButtonPressed"]; _indicator = [[aDecoder decodeObjectForKey:@"indicator"] retain]; diff --git a/src/MacVim/PSMTabBarControl/source/PSMTabBarControl.m b/src/MacVim/PSMTabBarControl/source/PSMTabBarControl.m index 6c8bab1223..0fc60bf491 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMTabBarControl.m +++ b/src/MacVim/PSMTabBarControl/source/PSMTabBarControl.m @@ -396,7 +396,7 @@ - (PSMOverflowPopUpButton *)overflowPopUpButton - (void)setToolTip:(NSString *)value forTabViewItem:(NSTabViewItem *)tvi { - int i, cellCount = [_cells count]; + NSUInteger i, cellCount = [_cells count]; for (i = 0; i < cellCount; i++) { PSMTabBarCell *cell = [_cells objectAtIndex:i]; if ([cell representedObject] == tvi) @@ -665,7 +665,7 @@ - (void)update // size all cells appropriately and create tracking rects // nuke old tracking rects - int i, cellCount = [_cells count]; + unsigned i, cellCount = (unsigned)[_cells count]; for(i = 0; i < cellCount; i++){ id cell = [_cells objectAtIndex:i]; [[NSNotificationCenter defaultCenter] removeObserver:cell]; @@ -1100,7 +1100,7 @@ - (BOOL)performDragOperation:(id )sender if (delegate && [delegate respondsToSelector:@selector(tabView:didDragTabViewItem:toIndex:)]) { NSUInteger idx = [[self representedTabViewItems] indexOfObject:tvi]; if (NSNotFound != idx) { - [delegate tabView:[self tabView] didDragTabViewItem:tvi toIndex:idx]; + [delegate tabView:[self tabView] didDragTabViewItem:tvi toIndex:(int)idx]; } } #endif @@ -1470,7 +1470,7 @@ - (NSUInteger)indexOfCellAtPoint:(NSPoint)point cellFrame:(NSRectPointer)outFram - (PSMTabBarCell *)lastVisibleTab { - int i, cellCount = [_cells count]; + NSUInteger i, cellCount = [_cells count]; for(i = 0; i < cellCount; i++){ if([[_cells objectAtIndex:i] isInOverflowMenu]) return [_cells objectAtIndex:(i-1)]; @@ -1480,12 +1480,12 @@ - (PSMTabBarCell *)lastVisibleTab - (int)numberOfVisibleTabs { - int i, cellCount = [_cells count]; + NSUInteger i, cellCount = [_cells count]; for(i = 0; i < cellCount; i++){ if([[_cells objectAtIndex:i] isInOverflowMenu]) - return i+1; + return (int)i+1; } - return cellCount; + return (int)cellCount; } diff --git a/src/MacVim/PSMTabBarControl/source/PSMTabDragAssistant.m b/src/MacVim/PSMTabBarControl/source/PSMTabDragAssistant.m index 9adee1c281..4e688c6f08 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMTabDragAssistant.m +++ b/src/MacVim/PSMTabBarControl/source/PSMTabDragAssistant.m @@ -146,8 +146,8 @@ - (void)startDraggingCell:(PSMTabBarCell *)cell fromTabBar:(PSMTabBarControl *)c [self setDestinationTabBar:control]; [_participatingTabBars addObject:control]; [self setDraggedCell:cell]; - [self setDraggedCellIndex:[[control cells] indexOfObject:cell]]; - + [self setDraggedCellIndex:(int)[[control cells] indexOfObject:cell]]; + NSRect cellFrame = [cell frame]; // list of widths for animation int i; @@ -175,7 +175,7 @@ - (void)startDraggingCell:(PSMTabBarCell *)cell fromTabBar:(PSMTabBarControl *)c [cell setHighlighted:NO]; NSSize offset = NSZeroSize; [pboard declareTypes:[NSArray arrayWithObjects:@"PSMTabBarControlItemPBType", nil] owner: nil]; - [pboard setString:[[NSNumber numberWithInt:[[control cells] indexOfObject:cell]] stringValue] forType:@"PSMTabBarControlItemPBType"]; + [pboard setString:[[NSNumber numberWithInt:(int)[[control cells] indexOfObject:cell]] stringValue] forType:@"PSMTabBarControlItemPBType"]; _animationTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0/30.0) target:self selector:@selector(animateDrag:) userInfo:nil repeats:YES]; [control dragImage:dragImage at:cellFrame.origin offset:offset event:event pasteboard:pboard source:control slideBack:YES]; } @@ -279,7 +279,7 @@ - (void)calculateDragAnimationForTabBar:(PSMTabBarControl *)control { BOOL removeFlag = YES; NSMutableArray *cells = [control cells]; - int i, cellCount = [cells count]; + int i, cellCount = (unsigned)[cells count]; float xPos = [[control psmTabStyle] leftMarginForTabBarControl]; // identify target cell @@ -359,7 +359,7 @@ - (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control withDraggedCe // called upon first drag - must distribute placeholders [self distributePlaceholdersInTabBar:control]; // replace dragged cell with a placeholder, and clean up surrounding cells - int cellIndex = [[control cells] indexOfObject:cell]; + NSUInteger cellIndex = [[control cells] indexOfObject:cell]; PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:YES inControlView:control] autorelease]; [[control cells] replaceObjectAtIndex:cellIndex withObject:pc]; [[control cells] removeObjectAtIndex:(cellIndex + 1)]; @@ -386,7 +386,7 @@ - (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control - (void)removeAllPlaceholdersFromTabBar:(PSMTabBarControl *)control { - int i, cellCount = [[control cells] count]; + NSUInteger i, cellCount = [[control cells] count]; for(i = (cellCount - 1); i >= 0; i--){ PSMTabBarCell *cell = [[control cells] objectAtIndex:i]; if([cell isPlaceholder]) diff --git a/src/Makefile b/src/Makefile index 5dd5377dd3..c11af47426 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3698,7 +3698,7 @@ macvimclean: rm -rf MacVim/auto MacVim/build MacVim/qlstephen/build xxd/xxd.dSYM; \ fi -# Create a release DMG image that is signed and notaraized +# Create a release DMG image that is signed and notarized macvim-dmg-release: macvim-signed macvim-dmg MacVim/scripts/sign-developer-id $(RELEASEDIR)/MacVim.dmg $(ENTITLEMENTS) MacVim/scripts/notarize-dmg $(RELEASEDIR)/MacVim.dmg