From abdcc57d6e20ae5c1e8ede14f7e6aa5df5c8f901 Mon Sep 17 00:00:00 2001 From: Yee Cheng Chin Date: Mon, 18 Feb 2019 22:22:13 -0800 Subject: [PATCH] Remove custom I-beam mouse cursor shape and support "no" cursor The old custom I-beam cursor does not have a HiDPI version, and looks out of place in MacVim compared to the native I-beam cursor. The rationale for its addition (add white border around the cursor for visibility) also seems to not matter anymore as macOS has had its cursors revamped since 10.7.3. Remove the custom cursor for now. Also support the "no" cursor shape, which shows up when "Press Enter" prompt comes up. For the other 'mouseshape' cursors just remove the TODO and explicitly decide not to implement them as they are a little obscure and don't have system native shapes. Could add them later as custom cursors but not worth doing so now. Fix #755 --- src/MacVim/MMTextViewHelper.m | 53 ++++++++++---------- src/MacVim/MacVim.xcodeproj/project.pbxproj | 4 -- src/MacVim/ibeam.png | Bin 193 -> 0 bytes 3 files changed, 26 insertions(+), 31 deletions(-) delete mode 100644 src/MacVim/ibeam.png diff --git a/src/MacVim/MMTextViewHelper.m b/src/MacVim/MMTextViewHelper.m index c9453aed90..16bdfe281a 100644 --- a/src/MacVim/MMTextViewHelper.m +++ b/src/MacVim/MMTextViewHelper.m @@ -1028,36 +1028,35 @@ - (void)dragTimerFired:(NSTimer *)timer - (void)setCursor { - static NSCursor *customIbeamCursor = nil; - - if (!customIbeamCursor) { - // Use a custom Ibeam cursor that has better contrast against dark - // backgrounds. - // TODO: Is the hotspot ok? - NSImage *ibeamImage = [NSImage imageNamed:@"ibeam"]; - if (ibeamImage) { - NSSize size = [ibeamImage size]; - NSPoint hotSpot = { size.width*.5f, size.height*.5f }; - - customIbeamCursor = [[NSCursor alloc] - initWithImage:ibeamImage hotSpot:hotSpot]; - } - if (!customIbeamCursor) { - ASLogWarn(@"Failed to load custom Ibeam cursor"); - customIbeamCursor = [NSCursor IBeamCursor]; - } - } - // This switch should match mshape_names[] in misc2.c. // - // TODO: Add missing cursor shapes. + // We don't fill every shape here. Only the ones that make sense and have + // system native cursors to choose from (unless we ship custom cursors). switch (mouseShape) { - case 2: [customIbeamCursor set]; break; - case 3: case 4: [[NSCursor resizeUpDownCursor] set]; break; - case 5: case 6: [[NSCursor resizeLeftRightCursor] set]; break; - case 9: [[NSCursor crosshairCursor] set]; break; - case 10: [[NSCursor pointingHandCursor] set]; break; - case 11: [[NSCursor openHandCursor] set]; break; + case 0: //arrow + [[NSCursor arrowCursor] set]; break; + //case 1: // blank + case 2: // beam + [[NSCursor IBeamCursor] set]; break; + case 3: // updown + case 4: // udsizing + [[NSCursor resizeUpDownCursor] set]; break; + case 5: // leftright + case 6: // lrsizing + [[NSCursor resizeLeftRightCursor] set]; break; + //case 7: // busy + case 8: // no + [[NSCursor operationNotAllowedCursor] set]; break; + case 9: // crosshair + [[NSCursor crosshairCursor] set]; break; + case 10: // hand1 + [[NSCursor pointingHandCursor] set]; break; + case 11: // hand2 + [[NSCursor openHandCursor] set]; break; + //case 12: // pencil + //case 13: // question + //case 14: // right-arrow + //case 15: // up-arrow default: [[NSCursor arrowCursor] set]; break; } diff --git a/src/MacVim/MacVim.xcodeproj/project.pbxproj b/src/MacVim/MacVim.xcodeproj/project.pbxproj index 0e30fd82d4..cfb8f5ffe3 100644 --- a/src/MacVim/MacVim.xcodeproj/project.pbxproj +++ b/src/MacVim/MacVim.xcodeproj/project.pbxproj @@ -53,7 +53,6 @@ 1DCD00D30E50B2B700460166 /* Undo.png in Resources */ = {isa = PBXBuildFile; fileRef = 1DCD00BE0E50B2B700460166 /* Undo.png */; }; 1DD04DEC0C529C5E006CDC2B /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 1DD04DEB0C529C5E006CDC2B /* Credits.rtf */; }; 1DD0C20C0C60FFB4008CD84A /* gvimrc in Copy Vim Runtime Files */ = {isa = PBXBuildFile; fileRef = 1DD0C20A0C60FF9A008CD84A /* gvimrc */; }; - 1DD3D51E0D82D4C9006E4320 /* ibeam.png in Resources */ = {isa = PBXBuildFile; fileRef = 1DD3D51D0D82D4C9006E4320 /* ibeam.png */; }; 1DD66ECE0C803D3600EBDAB3 /* MMApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DD66ECC0C803D3600EBDAB3 /* MMApplication.m */; }; 1DD9F5E50C85D60500E8D5A5 /* SystemColors.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1DD9F5E40C85D60500E8D5A5 /* SystemColors.plist */; }; 1DE3F8E70D50F80500052B9E /* Preferences.nib in Resources */ = {isa = PBXBuildFile; fileRef = 1DE3F8E50D50F80500052B9E /* Preferences.nib */; }; @@ -229,7 +228,6 @@ 1DCD00BE0E50B2B700460166 /* Undo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Undo.png; path = Toolbar/Undo.png; sourceTree = ""; }; 1DD04DEB0C529C5E006CDC2B /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = ""; }; 1DD0C20A0C60FF9A008CD84A /* gvimrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = gvimrc; sourceTree = ""; }; - 1DD3D51D0D82D4C9006E4320 /* ibeam.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ibeam.png; sourceTree = ""; }; 1DD66ECB0C803D3600EBDAB3 /* MMApplication.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MMApplication.h; sourceTree = ""; }; 1DD66ECC0C803D3600EBDAB3 /* MMApplication.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MMApplication.m; sourceTree = ""; }; 1DD9F5E40C85D60500E8D5A5 /* SystemColors.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = SystemColors.plist; sourceTree = ""; }; @@ -424,7 +422,6 @@ 1D8BEA73104992290069B072 /* FindAndReplace.nib */, 0395A8A90D72D88B00881434 /* General.png */, 1D22374A0E45DF4800E6FFFF /* Advanced.png */, - 1DD3D51D0D82D4C9006E4320 /* ibeam.png */, 1D0F11480D58C77800D5DA09 /* Font */, 1DE9726C0C48050600F96A9F /* Toolbar */, 1DD9F5E40C85D60500E8D5A5 /* SystemColors.plist */, @@ -567,7 +564,6 @@ 1DD9F5E50C85D60500E8D5A5 /* SystemColors.plist in Resources */, 1DE3F8E70D50F80500052B9E /* Preferences.nib in Resources */, 0395A8AA0D72D88B00881434 /* General.png in Resources */, - 1DD3D51E0D82D4C9006E4320 /* ibeam.png in Resources */, 1D22374B0E45DF4800E6FFFF /* Advanced.png in Resources */, 1DCD00BF0E50B2B700460166 /* Attention.png in Resources */, 1DCD00C00E50B2B700460166 /* Copy.png in Resources */, diff --git a/src/MacVim/ibeam.png b/src/MacVim/ibeam.png deleted file mode 100644 index 724aae51b59d86922f402e81a7081361dad000a2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^oIotZ!VDy<*S)L;QjEnx?oJHr&dIz4a`*#$LR>$8 z{`~*{e<1JEr%xY0evGl(&<#>o666=m;PC858j!M5lTo95n|dTDIqG!G0Dl{Da#cH fpXOOSn^+mvwlbSvJLXsm)W+cH>gTe~DWM4f80j|i