mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Added support for dropping text on window.
git-svn-id: http://macvim.googlecode.com/svn/trunk@93 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
+21
-2
@@ -1120,7 +1120,6 @@ static int specialKeyToNSKey(int key);
|
||||
|
||||
do_cmdline_cmd((char_u*)[cmd UTF8String]);
|
||||
|
||||
#if 1
|
||||
// This code was taken from the end of gui_handle_drop().
|
||||
update_screen(NOT_VALID);
|
||||
setcursor();
|
||||
@@ -1128,7 +1127,27 @@ static int specialKeyToNSKey(int key);
|
||||
gui_update_cursor(FALSE, FALSE);
|
||||
gui_mch_flush();
|
||||
#endif
|
||||
#endif
|
||||
#endif // FEAT_DND
|
||||
} else if (DropStringMsgID == msgid) {
|
||||
#ifdef FEAT_DND
|
||||
char_u dropkey[3] = { CSI, KS_EXTRA, (char_u)KE_DROP };
|
||||
const void *bytes = [data bytes];
|
||||
int len = *((int*)bytes); bytes += sizeof(int);
|
||||
NSMutableString *string = [NSMutableString stringWithUTF8String:bytes];
|
||||
|
||||
// Replace unrecognized end-of-line sequences with \x0a (line feed).
|
||||
NSRange range = { 0, [string length] };
|
||||
unsigned n = [string replaceOccurrencesOfString:@"\x0d\x0a"
|
||||
withString:@"\x0a" options:0
|
||||
range:range];
|
||||
if (0 == n) {
|
||||
n = [string replaceOccurrencesOfString:@"\x0d" withString:@"\x0a"
|
||||
options:0 range:range];
|
||||
}
|
||||
|
||||
len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
|
||||
dnd_yank_drag_data((char_u*)[string UTF8String], len);
|
||||
add_to_input_buf(dropkey, sizeof(dropkey));
|
||||
#endif // FEAT_DND
|
||||
} else {
|
||||
NSLog(@"WARNING: Unknown message received (msgid=%d)", msgid);
|
||||
|
||||
+19
-2
@@ -262,14 +262,15 @@
|
||||
#if 1
|
||||
- (NSArray *)acceptableDragTypes
|
||||
{
|
||||
return [NSArray arrayWithObjects:NSFilenamesPboardType, nil];
|
||||
return [NSArray arrayWithObjects:NSFilenamesPboardType,
|
||||
NSStringPboardType, nil];
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
||||
|
||||
if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
|
||||
if ([[pboard types] containsObject:NSFilenamesPboardType]) {
|
||||
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
|
||||
int i, numberOfFiles = [files count];
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
@@ -299,6 +300,16 @@
|
||||
|
||||
[[self vimController] sendMessage:DropFilesMsgID data:data wait:NO];
|
||||
return YES;
|
||||
} else if ([[pboard types] containsObject:NSStringPboardType]) {
|
||||
NSString *string = [pboard stringForType:NSStringPboardType];
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1;
|
||||
|
||||
[data appendBytes:&len length:sizeof(int)];
|
||||
[data appendBytes:[string UTF8String] length:len];
|
||||
|
||||
[[self vimController] sendMessage:DropStringMsgID data:data wait:NO];
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
@@ -312,6 +323,9 @@
|
||||
if ( [[pboard types] containsObject:NSFilenamesPboardType]
|
||||
&& (sourceDragMask & NSDragOperationCopy) )
|
||||
return NSDragOperationCopy;
|
||||
if ( [[pboard types] containsObject:NSStringPboardType]
|
||||
&& (sourceDragMask & NSDragOperationCopy) )
|
||||
return NSDragOperationCopy;
|
||||
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
@@ -324,6 +338,9 @@
|
||||
if ( [[pboard types] containsObject:NSFilenamesPboardType]
|
||||
&& (sourceDragMask & NSDragOperationCopy) )
|
||||
return NSDragOperationCopy;
|
||||
if ( [[pboard types] containsObject:NSStringPboardType]
|
||||
&& (sourceDragMask & NSDragOperationCopy) )
|
||||
return NSDragOperationCopy;
|
||||
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ enum {
|
||||
SetDefaultColorsMsgID,
|
||||
ExecuteActionMsgID,
|
||||
DropFilesMsgID,
|
||||
DropStringMsgID,
|
||||
};
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -485,7 +485,7 @@ clip_mch_request_selection(VimClipboard *cbd)
|
||||
[NSArray arrayWithObject:NSStringPboardType]];
|
||||
if (type) {
|
||||
NSMutableString *string =
|
||||
[[pb stringForType:NSStringPboardType] mutableCopy];
|
||||
[[pb stringForType:NSStringPboardType] mutableCopy];
|
||||
|
||||
// Replace unrecognized end-of-line sequences with \x0a (line feed).
|
||||
NSRange range = { 0, [string length] };
|
||||
|
||||
Reference in New Issue
Block a user