diff --git a/MMAppController.m b/MMAppController.m index 1d7ef24e67..573b12e057 100644 --- a/MMAppController.m +++ b/MMAppController.m @@ -336,7 +336,7 @@ } - (byref id )connectBackend: - (byref in id )backend; + (byref in id )backend pid:(int)pid { //NSLog(@"Frontend got connection request from backend...adding new " // "MMVimController"); @@ -344,8 +344,8 @@ [(NSDistantObject*)backend setProtocolForProxy:@protocol(MMBackendProtocol)]; - MMVimController *vc = [[[MMVimController alloc] initWithBackend:backend] - autorelease]; + MMVimController *vc = [[[MMVimController alloc] + initWithBackend:backend pid:pid] autorelease]; if (![vimControllers count]) { // The first window autosaves its position. (The autosaving features diff --git a/MMBackend.m b/MMBackend.m index 7499695b0c..3369f5d89b 100644 --- a/MMBackend.m +++ b/MMBackend.m @@ -160,7 +160,9 @@ static int specialKeyToNSKey(int key); selector:@selector(connectionDidDie:) name:NSConnectionDidDieNotification object:connection]; - frontendProxy = [(NSDistantObject*)[proxy connectBackend:self] retain]; + int pid = [[NSProcessInfo processInfo] processIdentifier]; + frontendProxy = [(NSDistantObject*)[proxy connectBackend:self + pid:pid] retain]; if (frontendProxy) { [frontendProxy setProtocolForProxy:@protocol(MMAppProtocol)]; } @@ -1121,14 +1123,6 @@ static int specialKeyToNSKey(int key); length = [key lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; unichar c = [key characterAtIndex:0]; - if ((c == Ctrl_C && ctrl_c_interrupts) - || (c == intr_char && intr_char != Ctrl_C)) { - // TODO: The run loop is not touched while Vim is processing, so - // effectively it is impossible to interrupt Vim. - trash_input_buf(); - got_int = TRUE; - } - //NSLog(@"non-special: %@ (hex=%x, mods=%d)", key, // [key characterAtIndex:0], mods); diff --git a/MMTextView.m b/MMTextView.m index ee227e4f85..b7da8f8100 100644 --- a/MMTextView.m +++ b/MMTextView.m @@ -461,6 +461,13 @@ // 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]; diff --git a/MMVimController.h b/MMVimController.h index 2efdbc3901..1550c6dc25 100644 --- a/MMVimController.h +++ b/MMVimController.h @@ -28,10 +28,12 @@ BOOL shouldUpdateMainMenu; NSToolbar *toolbar; NSMutableDictionary *toolbarItemDict; + int pid; } -- (id)initWithBackend:(id)backend; +- (id)initWithBackend:(id)backend pid:(int)processIdentifier; - (id)backendProxy; +- (int)pid; - (MMWindowController *)windowController; - (void)cleanup; - (void)sendMessage:(int)msgid data:(NSData *)data wait:(BOOL)wait; diff --git a/MMVimController.m b/MMVimController.m index 718b19348c..6eed985e61 100644 --- a/MMVimController.m +++ b/MMVimController.m @@ -78,7 +78,7 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag) @implementation MMVimController -- (id)initWithBackend:(id)backend +- (id)initWithBackend:(id)backend pid:(int)processIdentifier { if ((self = [super init])) { windowController = @@ -88,6 +88,7 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag) mainMenuItems = [[NSMutableArray alloc] init]; popupMenuItems = [[NSMutableArray alloc] init]; toolbarItemDict = [[NSMutableDictionary alloc] init]; + pid = processIdentifier; NSConnection *connection = [backendProxy connectionForProxy]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -137,6 +138,11 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag) return windowController; } +- (int)pid +{ + return pid; +} + - (void)sendMessage:(int)msgid data:(NSData *)data wait:(BOOL)wait { if (!isInitialized) return; diff --git a/MacVim.h b/MacVim.h index 71affc1279..cdab0ff12c 100644 --- a/MacVim.h +++ b/MacVim.h @@ -46,7 +46,7 @@ // @protocol MMAppProtocol - (byref id )connectBackend: - (byref in id )backend; + (byref in id )backend pid:(int)pid; @end