From 6a500c45ba234eda04a527dc093ce89cf442ddb3 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Wed, 22 Aug 2007 15:56:31 +0000 Subject: [PATCH] - Ctrl-C is passed on to Vim and handled there (does not send SIGINT) - Cmd-. no longer sends SIGINT git-svn-id: http://macvim.googlecode.com/svn/trunk@175 96c4425d-ca35-0410-94e5-3396d5c13a8f --- MMBackend.m | 6 ++++++ MMTextView.m | 25 +++++-------------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/MMBackend.m b/MMBackend.m index a0a88e6320..64e9a42186 100644 --- a/MMBackend.m +++ b/MMBackend.m @@ -1274,6 +1274,12 @@ static int specialKeyToNSKey(int key); //NSLog(@"non-special: %@ (hex=%x, mods=%d)", key, // [key characterAtIndex:0], mods); + if (length == 1 && ((c == Ctrl_C && ctrl_c_interrupts) + || (c == intr_char && intr_char != Ctrl_C))) { + trash_input_buf(); + got_int = TRUE; + } + // HACK! In most circumstances the Ctrl and Shift modifiers should be // cleared since they are already added to the key by the AppKit. // Unfortunately, the only way to deal with when to clear the modifiers diff --git a/MMTextView.m b/MMTextView.m index 2fda921e38..595fc3754c 100644 --- a/MMTextView.m +++ b/MMTextView.m @@ -121,21 +121,13 @@ NSString *string = [event charactersIgnoringModifiers]; int flags = [event modifierFlags]; int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + NSMutableData *data = [NSMutableData data]; - if (len > 0 && [string characterAtIndex:0] == '.') { - // HACK! Intercept Cmd-. and send SIGINT to Vim. - int pid = [[self vimController] pid]; - if (pid > 0) - kill(pid, SIGINT); - } else { - NSMutableData *data = [NSMutableData data]; + [data appendBytes:&flags length:sizeof(int)]; + [data appendBytes:&len length:sizeof(int)]; + [data appendBytes:[string UTF8String] length:len]; - [data appendBytes:&flags length:sizeof(int)]; - [data appendBytes:&len length:sizeof(int)]; - [data appendBytes:[string UTF8String] length:len]; - - [[self vimController] sendMessage:CmdKeyMsgID data:data wait:NO]; - } + [[self vimController] sendMessage:CmdKeyMsgID data:data wait:NO]; return YES; } @@ -473,13 +465,6 @@ // handle it separately (else Ctrl-C doesn't work). static char enter[2] = { 'K', 'A' }; len = 2; bytes = enter; - } else if (c == 0x3 && imc == 0x63) { - // HACK! Intercept Ctrl-C and send SIGINT to Vim. - int pid = [[self vimController] pid]; - if (pid > 0) { - kill(pid, SIGINT); - return; - } } else { len = [chars lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; bytes = [chars UTF8String];