mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Add MMUseMouseTime, Revise #77
`MMUseMouseTime` allows to override the time threshold for detecting multiple
mouse down events using Vim `mousetime` option.
$ defaults write org.vim.MacVim MMUseMouseTime -bool TRUE
This commit is contained in:
@@ -1844,6 +1844,7 @@ static void netbeansReadCallback(CFSocketRef s,
|
||||
[NSNumber numberWithBool:mmta], @"p_mmta",
|
||||
[NSNumber numberWithInt:numTabs], @"numTabs",
|
||||
[NSNumber numberWithInt:fuoptions_flags], @"fullScreenOptions",
|
||||
[NSNumber numberWithLong:p_mouset], @"p_mouset",
|
||||
nil];
|
||||
|
||||
// Put the state before all other messages.
|
||||
@@ -1932,12 +1933,12 @@ static void netbeansReadCallback(CFSocketRef s,
|
||||
int col = *((int*)bytes); bytes += sizeof(int);
|
||||
int button = *((int*)bytes); bytes += sizeof(int);
|
||||
int flags = *((int*)bytes); bytes += sizeof(int);
|
||||
int count = *((int*)bytes); bytes += sizeof(int);
|
||||
int repeat = *((int*)bytes); bytes += sizeof(int);
|
||||
|
||||
button = eventButtonNumberToVimMouseButton(button);
|
||||
if (button >= 0) {
|
||||
flags = eventModifierFlagsToVimMouseModMask(flags);
|
||||
gui_send_mouse_event(button, col, row, count>1, flags);
|
||||
gui_send_mouse_event(button, col, row, repeat, flags);
|
||||
}
|
||||
} else if (MouseUpMsgID == msgid) {
|
||||
if (!data) return;
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
BOOL interpretKeyEventsSwallowedKey;
|
||||
NSEvent *currentEvent;
|
||||
NSMutableDictionary *signImages;
|
||||
BOOL useMouseTime;
|
||||
NSDate *mouseDownTime;
|
||||
|
||||
// Input Manager
|
||||
NSRange imRange;
|
||||
|
||||
@@ -80,6 +80,11 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
|
||||
|
||||
signImages = [[NSMutableDictionary alloc] init];
|
||||
|
||||
useMouseTime =
|
||||
[[NSUserDefaults standardUserDefaults] boolForKey:MMUseMouseTimeKey];
|
||||
if (useMouseTime)
|
||||
mouseDownTime = [[NSDate date] retain];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -91,6 +96,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
|
||||
[markedText release]; markedText = nil;
|
||||
[markedTextAttributes release]; markedTextAttributes = nil;
|
||||
[signImages release]; signImages = nil;
|
||||
[mouseDownTime release]; mouseDownTime = nil;
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
if (asciiImSource) {
|
||||
@@ -380,7 +386,21 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
|
||||
|
||||
int button = [event buttonNumber];
|
||||
int flags = [event modifierFlags];
|
||||
int count = [event clickCount];
|
||||
int repeat = 0;
|
||||
|
||||
if (useMouseTime) {
|
||||
// Use Vim mouseTime option to handle multiple mouse down events
|
||||
NSDate *now = [[NSDate date] retain];
|
||||
id mouset = [[[self vimController] vimState] objectForKey:@"p_mouset"];
|
||||
NSTimeInterval interval =
|
||||
[now timeIntervalSinceDate:mouseDownTime] * 1000.0;
|
||||
if (interval < (NSTimeInterval)[mouset longValue])
|
||||
repeat = 1;
|
||||
mouseDownTime = now;
|
||||
} else {
|
||||
repeat = [event clickCount] > 1;
|
||||
}
|
||||
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
|
||||
// If desired, intepret Ctrl-Click as a right mouse click.
|
||||
@@ -398,7 +418,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
|
||||
[data appendBytes:&col length:sizeof(int)];
|
||||
[data appendBytes:&button length:sizeof(int)];
|
||||
[data appendBytes:&flags length:sizeof(int)];
|
||||
[data appendBytes:&count length:sizeof(int)];
|
||||
[data appendBytes:&repeat length:sizeof(int)];
|
||||
|
||||
[[self vimController] sendMessage:MouseDownMsgID data:data];
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ extern NSString *MMUseInlineImKey;
|
||||
#endif // INCLUDE_OLD_IM_CODE
|
||||
extern NSString *MMSuppressTerminationAlertKey;
|
||||
extern NSString *MMNativeFullScreenKey;
|
||||
extern NSString *MMUseMouseTimeKey;
|
||||
|
||||
|
||||
// Enum for MMUntitledWindowKey
|
||||
|
||||
@@ -47,6 +47,7 @@ NSString *MMUseInlineImKey = @"MMUseInlineIm";
|
||||
#endif // INCLUDE_OLD_IM_CODE
|
||||
NSString *MMSuppressTerminationAlertKey = @"MMSuppressTerminationAlert";
|
||||
NSString *MMNativeFullScreenKey = @"MMNativeFullScreen";
|
||||
NSString *MMUseMouseTimeKey = @"MMUseMouseTime";
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user