mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
devdraw: plumb drag-n-dropped files
Change-Id: I7585870aee57c7482ebdd19c117be7982123ce79 Reviewed-on: https://plan9port-review.googlesource.com/1130 Reviewed-by: Russ Cox <rsc@google.com>
This commit is contained in:
parent
25822e8da3
commit
d52bdd3356
3 changed files with 57 additions and 10 deletions
17
bin/macedit
Executable file
17
bin/macedit
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PLAN9=${PLAN9:-/usr/local/plan9}
|
||||||
|
bin=$PLAN9/bin
|
||||||
|
|
||||||
|
file=$1
|
||||||
|
|
||||||
|
# Blanks are problematic in filenames: just plumb
|
||||||
|
# the file's content.
|
||||||
|
if echo "$file" | grep -q " "
|
||||||
|
then
|
||||||
|
base=$(basename "$file" | sed 's/ /_/g')
|
||||||
|
attr="action=showdata filename=/BadName/$base"
|
||||||
|
cat $file | "$bin/plumb" -i -d edit -a "$attr"
|
||||||
|
else
|
||||||
|
"$bin/plumb" -d edit "$file"
|
||||||
|
fi
|
|
@ -10,14 +10,5 @@ IFS=$'\n'
|
||||||
|
|
||||||
for file in $($bin/macargv)
|
for file in $($bin/macargv)
|
||||||
do
|
do
|
||||||
# Blanks are problematic in filenames: just plumb
|
$bin/macedit "$file"
|
||||||
# the file's content.
|
|
||||||
if echo "$file" | grep -q " "
|
|
||||||
then
|
|
||||||
base=$(basename "$file" | sed 's/ /_/g')
|
|
||||||
attr="action=showdata filename=/BadName/$base"
|
|
||||||
cat $file | "$bin/plumb" -i -d edit -a "$attr"
|
|
||||||
else
|
|
||||||
"$bin/plumb" -d edit "$file"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
|
@ -159,6 +159,7 @@ static NSRect dilate(NSRect);
|
||||||
detachDrawingThread:@selector(callservep9p:)
|
detachDrawingThread:@selector(callservep9p:)
|
||||||
toTarget:[self class] withObject:nil];
|
toTarget:[self class] withObject:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidBecomeKey:(id)arg
|
- (void)windowDidBecomeKey:(id)arg
|
||||||
{
|
{
|
||||||
getmousepos();
|
getmousepos();
|
||||||
|
@ -298,6 +299,41 @@ attachscreen(char *label, char *winsize)
|
||||||
[win.content setHidden:NO];
|
[win.content setHidden:NO];
|
||||||
[super deminiaturize:arg];
|
[super deminiaturize:arg];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSDragOperation)draggingEntered:(id)arg
|
||||||
|
{
|
||||||
|
NSPasteboard *b;
|
||||||
|
NSDragOperation op;
|
||||||
|
|
||||||
|
op = [arg draggingSourceOperationMask];
|
||||||
|
b = [arg draggingPasteboard];
|
||||||
|
|
||||||
|
if([[b types] containsObject:NSFilenamesPboardType])
|
||||||
|
if(op&NSDragOperationLink)
|
||||||
|
return NSDragOperationLink;
|
||||||
|
|
||||||
|
return NSDragOperationNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)performDragOperation:(id)arg
|
||||||
|
{
|
||||||
|
NSPasteboard *b;
|
||||||
|
NSArray *files;
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
b = [arg draggingPasteboard];
|
||||||
|
if(![[b types] containsObject:NSFilenamesPboardType])
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
files = [b propertyListForType:NSFilenamesPboardType];
|
||||||
|
n = [files count];
|
||||||
|
for(i=0; i<n; i++)
|
||||||
|
if(fork() == 0)
|
||||||
|
execl("macedit", "macedit", [[files objectAtIndex:i] UTF8String], nil);
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
double
|
double
|
||||||
|
@ -354,6 +390,9 @@ makewin(char *s)
|
||||||
#endif
|
#endif
|
||||||
[w setContentMinSize:NSMakeSize(128,128)];
|
[w setContentMinSize:NSMakeSize(128,128)];
|
||||||
|
|
||||||
|
[w registerForDraggedTypes:[NSArray arrayWithObjects:
|
||||||
|
NSFilenamesPboardType, nil]];
|
||||||
|
|
||||||
win.ofs[0] = w;
|
win.ofs[0] = w;
|
||||||
win.ofs[1] = [[appwin alloc]
|
win.ofs[1] = [[appwin alloc]
|
||||||
initWithContentRect:sr
|
initWithContentRect:sr
|
||||||
|
|
Loading…
Reference in a new issue