mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Fix MacVim warnings: enum renames, graphicsPort, setcmdheight
The list of warnings fixed: - Fix misc AppKit control states enums that got renamed and deprecated. - NSFindPboardType -> NSPasteboardTypeFind deprecation. - Fix usage of deprecated "graphicsPort" API to use CGContext instead. - Use NSFontChanging protocol if it's available. - Move MMCoreTextView's setcmdheight to the correct section in the private implementation category.
This commit is contained in:
@@ -638,7 +638,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
if ([alert runModal] != NSAlertFirstButtonReturn)
|
||||
reply = NSTerminateCancel;
|
||||
|
||||
if ([[alert suppressionButton] state] == NSOnState) {
|
||||
if ([[alert suppressionButton] state] == NSControlStateValueOn) {
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
setBool:YES forKey:MMSuppressTerminationAlertKey];
|
||||
}
|
||||
@@ -1346,7 +1346,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
{
|
||||
ASLogDebug(@"Toggle CoreText renderer");
|
||||
NSInteger renderer = MMRendererDefault;
|
||||
BOOL enable = ([sender state] == NSOnState);
|
||||
BOOL enable = ([sender state] == NSControlStateValueOn);
|
||||
|
||||
if (enable) {
|
||||
renderer = MMRendererCoreText;
|
||||
|
||||
@@ -13,7 +13,13 @@
|
||||
@class MMTextViewHelper;
|
||||
|
||||
|
||||
@interface MMCoreTextView : NSView <NSTextInput> {
|
||||
@interface MMCoreTextView : NSView <
|
||||
NSTextInput
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
|
||||
, NSFontChanging
|
||||
#endif
|
||||
>
|
||||
{
|
||||
// From MMTextStorage
|
||||
int maxRows, maxColumns;
|
||||
NSColor *defaultBackgroundColor;
|
||||
@@ -51,6 +57,11 @@
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame;
|
||||
|
||||
//
|
||||
// NSFontChanging methods
|
||||
//
|
||||
- (void)changeFont:(id)sender;
|
||||
|
||||
//
|
||||
// MMTextStorage methods
|
||||
//
|
||||
|
||||
+45
-45
@@ -565,51 +565,6 @@ static void grid_free(Grid *grid) {
|
||||
[self setCmdlineRow: [[[self vimController] objectForVimStateKey:@"cmdline_row"] intValue]];
|
||||
}
|
||||
|
||||
/// Set Vim's cmdline row number. This will mark the relevant parts to be repainted
|
||||
/// if the row number has changed as we are pinning the cmdline to the bottom,
|
||||
/// because otherwise we will have a gap that doesn't get cleared and leaves artifacts.
|
||||
///
|
||||
/// @param row The row (0-indexed) of the current cmdline in Vim.
|
||||
- (void)setCmdlineRow:(int)row
|
||||
{
|
||||
const BOOL newAlignCmdLineToBottom = [[NSUserDefaults standardUserDefaults] boolForKey:MMCmdLineAlignBottomKey];
|
||||
|
||||
if (newAlignCmdLineToBottom != alignCmdLineToBottom) {
|
||||
// The user settings has changed (usually through the settings panel). Just update everything.
|
||||
alignCmdLineToBottom = newAlignCmdLineToBottom;
|
||||
cmdlineRow = row;
|
||||
[self setNeedsDisplay:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
if (row != cmdlineRow) {
|
||||
// The cmdline row has changed. Need to redraw the necessary parts if we
|
||||
// are configured to pin cmdline to the bottom.
|
||||
if (alignCmdLineToBottom) {
|
||||
// Since we are changing the cmdline row, we need to repaint the
|
||||
// parts where the gap changed. Just for simplicity, we repaint
|
||||
// both the old/new cmdline rows and the row above them. This way
|
||||
// the gap in between the top and bottom aligned rows should be
|
||||
// touched in the repainting and cleared to bg.
|
||||
[self setNeedsDisplayFromRow:cmdlineRow-1
|
||||
column:grid.cols
|
||||
toRow:cmdlineRow
|
||||
column:grid.cols];
|
||||
|
||||
// Have to do this between the two calls as cmdlineRow would affect
|
||||
// the calculation in them.
|
||||
cmdlineRow = row;
|
||||
|
||||
[self setNeedsDisplayFromRow:cmdlineRow-1
|
||||
column:grid.cols
|
||||
toRow:cmdlineRow
|
||||
column:grid.cols];
|
||||
} else {
|
||||
cmdlineRow = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setImControl:(BOOL)enable
|
||||
{
|
||||
[helper setImControl:enable];
|
||||
@@ -1400,6 +1355,51 @@ static void grid_free(Grid *grid) {
|
||||
return (CTLineRef)[(id)line autorelease];
|
||||
}
|
||||
|
||||
/// Set Vim's cmdline row number. This will mark the relevant parts to be repainted
|
||||
/// if the row number has changed as we are pinning the cmdline to the bottom,
|
||||
/// because otherwise we will have a gap that doesn't get cleared and leaves artifacts.
|
||||
///
|
||||
/// @param row The row (0-indexed) of the current cmdline in Vim.
|
||||
- (void)setCmdlineRow:(int)row
|
||||
{
|
||||
const BOOL newAlignCmdLineToBottom = [[NSUserDefaults standardUserDefaults] boolForKey:MMCmdLineAlignBottomKey];
|
||||
|
||||
if (newAlignCmdLineToBottom != alignCmdLineToBottom) {
|
||||
// The user settings has changed (usually through the settings panel). Just update everything.
|
||||
alignCmdLineToBottom = newAlignCmdLineToBottom;
|
||||
cmdlineRow = row;
|
||||
[self setNeedsDisplay:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
if (row != cmdlineRow) {
|
||||
// The cmdline row has changed. Need to redraw the necessary parts if we
|
||||
// are configured to pin cmdline to the bottom.
|
||||
if (alignCmdLineToBottom) {
|
||||
// Since we are changing the cmdline row, we need to repaint the
|
||||
// parts where the gap changed. Just for simplicity, we repaint
|
||||
// both the old/new cmdline rows and the row above them. This way
|
||||
// the gap in between the top and bottom aligned rows should be
|
||||
// touched in the repainting and cleared to bg.
|
||||
[self setNeedsDisplayFromRow:cmdlineRow-1
|
||||
column:grid.cols
|
||||
toRow:cmdlineRow
|
||||
column:grid.cols];
|
||||
|
||||
// Have to do this between the two calls as cmdlineRow would affect
|
||||
// the calculation in them.
|
||||
cmdlineRow = row;
|
||||
|
||||
[self setNeedsDisplayFromRow:cmdlineRow-1
|
||||
column:grid.cols
|
||||
toRow:cmdlineRow
|
||||
column:grid.cols];
|
||||
} else {
|
||||
cmdlineRow = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end // MMCoreTextView (Private)
|
||||
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
[findBox setStringValue:text];
|
||||
|
||||
// NOTE: The 'flags' values must match the FRD_ defines in gui.h.
|
||||
[matchWordButton setState:(flags & 0x08 ? NSOnState : NSOffState)];
|
||||
[ignoreCaseButton setState:(flags & 0x10 ? NSOffState : NSOnState)];
|
||||
[matchWordButton setState:(flags & 0x08 ? NSControlStateValueOn : NSControlStateValueOff)];
|
||||
[ignoreCaseButton setState:(flags & 0x10 ? NSControlStateValueOff : NSControlStateValueOn)];
|
||||
|
||||
[window makeKeyAndOrderFront:self];
|
||||
}
|
||||
@@ -52,12 +52,12 @@
|
||||
|
||||
- (BOOL)ignoreCase
|
||||
{
|
||||
return [ignoreCaseButton state] == NSOnState;
|
||||
return [ignoreCaseButton state] == NSControlStateValueOn;
|
||||
}
|
||||
|
||||
- (BOOL)matchWord
|
||||
{
|
||||
return [matchWordButton state] == NSOnState;
|
||||
return [matchWordButton state] == NSControlStateValueOn;
|
||||
}
|
||||
|
||||
@end // MMFindReplaceController
|
||||
|
||||
@@ -545,7 +545,11 @@
|
||||
[super drawRect:rect];
|
||||
|
||||
if (invertRects) {
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
|
||||
CGContextRef cgctx = context.CGContext;
|
||||
#else
|
||||
CGContextRef cgctx = (CGContextRef)[context graphicsPort];
|
||||
#endif
|
||||
CGContextSaveGState(cgctx);
|
||||
CGContextSetBlendMode(cgctx, kCGBlendModeDifference);
|
||||
CGContextSetRGBFillColor(cgctx, 1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
@@ -1764,7 +1764,7 @@
|
||||
|
||||
if (!query) {
|
||||
// Use find pasteboard for next query.
|
||||
NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSFindPboard];
|
||||
NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSPasteboardNameFind];
|
||||
NSArray *supportedTypes = [NSArray arrayWithObjects:VimFindPboardType,
|
||||
NSPasteboardTypeString, nil];
|
||||
NSString *bestType = [pb availableTypeFromArray:supportedTypes];
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
# define NSAlertStyleCritical NSCriticalAlertStyle
|
||||
# define NSAlertStyleInformational NSInformationalAlertStyle
|
||||
# define NSAlertStyleWarning NSWarningAlertStyle
|
||||
# define NSButtonTypeSwitch NSSwitchButton
|
||||
# define NSCompositingOperationSourceOver NSCompositeSourceOver
|
||||
# define NSCompositingOperationDifference NSCompositeDifference
|
||||
# define NSControlSizeRegular NSRegularControlSize
|
||||
@@ -100,6 +101,12 @@
|
||||
# define NSWindowStyleMaskUnifiedTitleAndToolbar NSUnifiedTitleAndToolbarWindowMask
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
|
||||
// Deprecated constants in 10.13 SDK
|
||||
#define NSControlStateValueOn NSOnState
|
||||
#define NSControlStateValueOff NSOffState
|
||||
#endif
|
||||
|
||||
// Deprecated runtime values. Since these are runtime values, we need to use the
|
||||
// minimum required OS as determining factor. Otherwise it would crash.
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ showHiddenFilesView()
|
||||
initWithFrame:NSMakeRect(0, 0, 140, 18)] autorelease];
|
||||
[button setTitle:
|
||||
NSLocalizedString(@"Show Hidden Files", @"Show Hidden Files Checkbox")];
|
||||
[button setButtonType:NSSwitchButton];
|
||||
[button setButtonType:NSButtonTypeSwitch];
|
||||
|
||||
[button setTarget:nil];
|
||||
[button setAction:@selector(hiddenFilesButtonToggled:)];
|
||||
|
||||
Reference in New Issue
Block a user