mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
Ctrl-C is intercepted in MacVim and sends SIGINT to Vim process.
git-svn-id: http://macvim.googlecode.com/svn/trunk@149 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
+3
-3
@@ -336,7 +336,7 @@
|
||||
}
|
||||
|
||||
- (byref id <MMFrontendProtocol>)connectBackend:
|
||||
(byref in id <MMBackendProtocol>)backend;
|
||||
(byref in id <MMBackendProtocol>)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
|
||||
|
||||
+3
-9
@@ -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);
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
+3
-1
@@ -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;
|
||||
|
||||
+7
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user