Skip to content

Commit f1e735a

Browse files
committed
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 macvim-dev#755
1 parent 21b29de commit f1e735a

File tree

3 files changed

+26
-31
lines changed

3 files changed

+26
-31
lines changed

src/MacVim/MMTextViewHelper.m

+26-27
Original file line numberDiff line numberDiff line change
@@ -1028,36 +1028,35 @@ - (void)dragTimerFired:(NSTimer *)timer
10281028

10291029
- (void)setCursor
10301030
{
1031-
static NSCursor *customIbeamCursor = nil;
1032-
1033-
if (!customIbeamCursor) {
1034-
// Use a custom Ibeam cursor that has better contrast against dark
1035-
// backgrounds.
1036-
// TODO: Is the hotspot ok?
1037-
NSImage *ibeamImage = [NSImage imageNamed:@"ibeam"];
1038-
if (ibeamImage) {
1039-
NSSize size = [ibeamImage size];
1040-
NSPoint hotSpot = { size.width*.5f, size.height*.5f };
1041-
1042-
customIbeamCursor = [[NSCursor alloc]
1043-
initWithImage:ibeamImage hotSpot:hotSpot];
1044-
}
1045-
if (!customIbeamCursor) {
1046-
ASLogWarn(@"Failed to load custom Ibeam cursor");
1047-
customIbeamCursor = [NSCursor IBeamCursor];
1048-
}
1049-
}
1050-
10511031
// This switch should match mshape_names[] in misc2.c.
10521032
//
1053-
// TODO: Add missing cursor shapes.
1033+
// We don't fill every shape here. Only the ones that make sense and have
1034+
// system native cursors to choose from (unless we ship custom cursors).
10541035
switch (mouseShape) {
1055-
case 2: [customIbeamCursor set]; break;
1056-
case 3: case 4: [[NSCursor resizeUpDownCursor] set]; break;
1057-
case 5: case 6: [[NSCursor resizeLeftRightCursor] set]; break;
1058-
case 9: [[NSCursor crosshairCursor] set]; break;
1059-
case 10: [[NSCursor pointingHandCursor] set]; break;
1060-
case 11: [[NSCursor openHandCursor] set]; break;
1036+
case 0: //arrow
1037+
[[NSCursor arrowCursor] set]; break;
1038+
//case 1: // blank
1039+
case 2: // beam
1040+
[[NSCursor IBeamCursor] set]; break;
1041+
case 3: // updown
1042+
case 4: // udsizing
1043+
[[NSCursor resizeUpDownCursor] set]; break;
1044+
case 5: // leftright
1045+
case 6: // lrsizing
1046+
[[NSCursor resizeLeftRightCursor] set]; break;
1047+
//case 7: // busy
1048+
case 8: // no
1049+
[[NSCursor operationNotAllowedCursor] set]; break;
1050+
case 9: // crosshair
1051+
[[NSCursor crosshairCursor] set]; break;
1052+
case 10: // hand1
1053+
[[NSCursor pointingHandCursor] set]; break;
1054+
case 11: // hand2
1055+
[[NSCursor openHandCursor] set]; break;
1056+
//case 12: // pencil
1057+
//case 13: // question
1058+
//case 14: // right-arrow
1059+
//case 15: // up-arrow
10611060
default:
10621061
[[NSCursor arrowCursor] set]; break;
10631062
}

src/MacVim/MacVim.xcodeproj/project.pbxproj

-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
1DCD00D30E50B2B700460166 /* Undo.png in Resources */ = {isa = PBXBuildFile; fileRef = 1DCD00BE0E50B2B700460166 /* Undo.png */; };
5454
1DD04DEC0C529C5E006CDC2B /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 1DD04DEB0C529C5E006CDC2B /* Credits.rtf */; };
5555
1DD0C20C0C60FFB4008CD84A /* gvimrc in Copy Vim Runtime Files */ = {isa = PBXBuildFile; fileRef = 1DD0C20A0C60FF9A008CD84A /* gvimrc */; };
56-
1DD3D51E0D82D4C9006E4320 /* ibeam.png in Resources */ = {isa = PBXBuildFile; fileRef = 1DD3D51D0D82D4C9006E4320 /* ibeam.png */; };
5756
1DD66ECE0C803D3600EBDAB3 /* MMApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DD66ECC0C803D3600EBDAB3 /* MMApplication.m */; };
5857
1DD9F5E50C85D60500E8D5A5 /* SystemColors.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1DD9F5E40C85D60500E8D5A5 /* SystemColors.plist */; };
5958
1DE3F8E70D50F80500052B9E /* Preferences.nib in Resources */ = {isa = PBXBuildFile; fileRef = 1DE3F8E50D50F80500052B9E /* Preferences.nib */; };
@@ -229,7 +228,6 @@
229228
1DCD00BE0E50B2B700460166 /* Undo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Undo.png; path = Toolbar/Undo.png; sourceTree = "<group>"; };
230229
1DD04DEB0C529C5E006CDC2B /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = "<group>"; };
231230
1DD0C20A0C60FF9A008CD84A /* gvimrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = gvimrc; sourceTree = "<group>"; };
232-
1DD3D51D0D82D4C9006E4320 /* ibeam.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ibeam.png; sourceTree = "<group>"; };
233231
1DD66ECB0C803D3600EBDAB3 /* MMApplication.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MMApplication.h; sourceTree = "<group>"; };
234232
1DD66ECC0C803D3600EBDAB3 /* MMApplication.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MMApplication.m; sourceTree = "<group>"; };
235233
1DD9F5E40C85D60500E8D5A5 /* SystemColors.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = SystemColors.plist; sourceTree = "<group>"; };
@@ -424,7 +422,6 @@
424422
1D8BEA73104992290069B072 /* FindAndReplace.nib */,
425423
0395A8A90D72D88B00881434 /* General.png */,
426424
1D22374A0E45DF4800E6FFFF /* Advanced.png */,
427-
1DD3D51D0D82D4C9006E4320 /* ibeam.png */,
428425
1D0F11480D58C77800D5DA09 /* Font */,
429426
1DE9726C0C48050600F96A9F /* Toolbar */,
430427
1DD9F5E40C85D60500E8D5A5 /* SystemColors.plist */,
@@ -567,7 +564,6 @@
567564
1DD9F5E50C85D60500E8D5A5 /* SystemColors.plist in Resources */,
568565
1DE3F8E70D50F80500052B9E /* Preferences.nib in Resources */,
569566
0395A8AA0D72D88B00881434 /* General.png in Resources */,
570-
1DD3D51E0D82D4C9006E4320 /* ibeam.png in Resources */,
571567
1D22374B0E45DF4800E6FFFF /* Advanced.png in Resources */,
572568
1DCD00BF0E50B2B700460166 /* Attention.png in Resources */,
573569
1DCD00C00E50B2B700460166 /* Copy.png in Resources */,

src/MacVim/ibeam.png

-193 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)