From 0ea7546c7c0b86df43cc1ff0c44e07ef90897cc2 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sat, 7 Jun 2008 15:35:25 +0200 Subject: [PATCH] Add 'mousehide' option support --- src/MacVim/MMAtsuiTextView.m | 17 +++++++++++++---- src/MacVim/MMBackend.m | 1 + src/MacVim/MMTextView.m | 17 +++++++++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/MacVim/MMAtsuiTextView.m b/src/MacVim/MMAtsuiTextView.m index e4cc4c5896..470e006094 100644 --- a/src/MacVim/MMAtsuiTextView.m +++ b/src/MacVim/MMAtsuiTextView.m @@ -67,6 +67,7 @@ enum { - (void)updateAtsuStyles; - (void)dispatchKeyEvent:(NSEvent *)event; - (void)sendKeyDown:(const char *)chars length:(int)len modifiers:(int)flags; +- (void)hideMouseCursor; - (MMWindowController *)windowController; - (MMVimController *)vimController; @end @@ -333,8 +334,7 @@ enum { } } - // TODO: Support 'mousehide' (check p_mh) - [NSCursor setHiddenUntilMouseMoves:YES]; + [self hideMouseCursor]; // NOTE: 'string' is either an NSString or an NSAttributedString. Since we // do not support attributes, simply pass the corresponding NSString in the @@ -901,14 +901,23 @@ enum { [data appendBytes:&len length:sizeof(int)]; [data appendBytes:chars length:len]; - // TODO: Support 'mousehide' (check p_mh) - [NSCursor setHiddenUntilMouseMoves:YES]; + [self hideMouseCursor]; //NSLog(@"%s len=%d chars=0x%x", _cmd, len, chars[0]); [[self vimController] sendMessage:KeyDownMsgID data:data]; } } +- (void)hideMouseCursor +{ + // Check 'mousehide' option + id mh = [[[self vimController] vimState] objectForKey:@"p_mh"]; + if (mh && ![mh boolValue]) + [NSCursor setHiddenUntilMouseMoves:NO]; + else + [NSCursor setHiddenUntilMouseMoves:YES]; +} + - (MMWindowController *)windowController { id windowController = [[self window] windowController]; diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 791b29fb66..6ab1769406 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -1486,6 +1486,7 @@ static NSString *MMSymlinkWarningString = NSDictionary *vimState = [NSDictionary dictionaryWithObjectsAndKeys: [[NSFileManager defaultManager] currentDirectoryPath], @"pwd", + [NSNumber numberWithInt:p_mh], @"p_mh", nil]; [self queueMessage:SetVimStateMsgID data:[vimState dictionaryAsData]]; diff --git a/src/MacVim/MMTextView.m b/src/MacVim/MMTextView.m index 7272657db8..22554ced0a 100644 --- a/src/MacVim/MMTextView.m +++ b/src/MacVim/MMTextView.m @@ -57,6 +57,7 @@ enum { - (void)startDragTimerWithInterval:(NSTimeInterval)t; - (void)dragTimerFired:(NSTimer *)timer; - (void)sendKeyDown:(const char *)chars length:(int)len modifiers:(int)flags; +- (void)hideMouseCursor; @end @@ -566,8 +567,7 @@ enum { } } - // TODO: Support 'mousehide' (check p_mh) - [NSCursor setHiddenUntilMouseMoves:YES]; + [self hideMouseCursor]; // NOTE: 'string' is either an NSString or an NSAttributedString. Since we // do not support attributes, simply pass the corresponding NSString in the @@ -1377,12 +1377,21 @@ enum { [data appendBytes:&len length:sizeof(int)]; [data appendBytes:chars length:len]; - // TODO: Support 'mousehide' (check p_mh) - [NSCursor setHiddenUntilMouseMoves:YES]; + [self hideMouseCursor]; //NSLog(@"%s len=%d chars=0x%x", _cmd, len, chars[0]); [[self vimController] sendMessage:KeyDownMsgID data:data]; } } +- (void)hideMouseCursor +{ + // Check 'mousehide' option + id mh = [[[self vimController] vimState] objectForKey:@"p_mh"]; + if (mh && ![mh boolValue]) + [NSCursor setHiddenUntilMouseMoves:NO]; + else + [NSCursor setHiddenUntilMouseMoves:YES]; +} + @end // MMTextView (Private)