Added :browse support for DO.

git-svn-id: http://macvim.googlecode.com/svn/trunk@29 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
Bjorn Winckler
2007-07-29 12:40:25 +00:00
parent 2ddd79ba97
commit a7d20e4dee
4 changed files with 60 additions and 4 deletions
+1
View File
@@ -23,6 +23,7 @@
#if MM_USE_DO
NSConnection *connection;
id frontendProxy;
NSString *browseForFileString;
#else
NSPort *sendPort;
NSPort *receivePort;
+30 -3
View File
@@ -461,15 +461,42 @@ static int eventButtonNumberToVimMouseButton(int buttonNumber);
[self queueMessage:SetVimWindowTitleMsgID data:data];
}
#if MM_USE_DO
- (oneway void)setBrowseForFileString:(in bycopy NSString *)string
{
// NOTE: This is called by [MMVimController panelDidEnd:::] to indicate
// that the save/open panel has finished. If 'string == nil' that means
// the user pressed cancel.
browseForFileString = string ? [string copy] : nil;
}
#endif
- (char *)browseForFileInDirectory:(char *)dir title:(char *)title
saving:(int)saving
{
#if MM_USE_DO
return nil;
#else
//NSLog(@"browseForFileInDirectory:%s title:%s saving:%d", dir, title,
// saving);
#if MM_USE_DO
NSString *ds = dir
? [NSString stringWithCString:dir encoding:NSUTF8StringEncoding]
: nil;
NSString *ts = title
? [NSString stringWithCString:title encoding:NSUTF8StringEncoding]
: nil;
[frontendProxy showSavePanelForDirectory:ds title:ts saving:saving];
// Wait until a reply is sent from MMVimController.
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate distantFuture]];
if (!browseForFileString)
return nil;
char_u *s = vim_strsave((char_u*)[browseForFileString UTF8String]);
[browseForFileString release]; browseForFileString = nil;
return (char *)s;
#else
NSMutableData *data = [NSMutableData data];
[data appendBytes:&saving length:sizeof(int)];
+25 -1
View File
@@ -180,6 +180,27 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag)
}
#if MM_USE_DO
- (oneway void)showSavePanelForDirectory:(in bycopy NSString *)dir
title:(in bycopy NSString *)title
saving:(int)saving
{
if (saving) {
[[NSSavePanel savePanel] beginSheetForDirectory:dir file:nil
modalForWindow:[windowController window]
modalDelegate:self
didEndSelector:@selector(panelDidEnd:code:context:)
contextInfo:NULL];
} else {
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setAllowsMultipleSelection:NO];
[panel beginSheetForDirectory:dir file:nil types:nil
modalForWindow:[windowController window]
modalDelegate:self
didEndSelector:@selector(panelDidEnd:code:context:)
contextInfo:NULL];
}
}
- (oneway void)processCommandQueue:(in NSArray *)queue
{
unsigned i, count = [queue count];
@@ -762,7 +783,10 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag)
- (void)panelDidEnd:(NSSavePanel *)panel code:(int)code context:(void *)context
{
#if !MM_USE_DO
#if MM_USE_DO
NSString *string = (code == NSOKButton) ? [panel filename] : nil;
[backendProxy setBrowseForFileString:string];
#else
NSMutableData *data = [NSMutableData data];
int ok = (code == NSOKButton);
NSString *filename = [panel filename];
+4
View File
@@ -20,10 +20,14 @@
@protocol MMBackendProtocol
- (oneway void)processInput:(int)msgid data:(in NSData *)data;
- (BOOL)checkForModifiedBuffers;
- (oneway void)setBrowseForFileString:(in bycopy NSString *)string;
@end
@protocol MMFrontendProtocol
- (oneway void)processCommandQueue:(in NSArray *)queue;
- (oneway void)showSavePanelForDirectory:(in bycopy NSString *)dir
title:(in bycopy NSString *)title
saving:(int)saving;
@end
@protocol MMAppProtocol