| tdevdraw: plumb drag-n-dropped files - plan9port - [fork] Plan 9 from user space |
| git clone git://src.adamsgaard.dk/plan9port |
| Log |
| Files |
| Refs |
| README |
| LICENSE |
| --- |
| commit d52bdd3356137cf67a3458fdee5c94fdec4337e1 |
| parent 25822e8da338df2c15959bd8d347f230dc2b2d89 |
| Author: marius a. eriksen |
| Date: Tue, 23 Dec 2014 20:45:35 -0800
devdraw: plumb drag-n-dropped files
Change-Id: I7585870aee57c7482ebdd19c117be7982123ce79
Reviewed-on: https://plan9port-review.googlesource.com/1130
Reviewed-by: Russ Cox
Diffstat:
A bin/macedit | 17 +++++++++++++++++
M mac/Plumb.app/Contents/MacOS/plumb | 11 +----------
M src/cmd/devdraw/cocoa-screen.m | 39 +++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 10 deletions(-)
--- |
| diff --git a/bin/macedit b/bin/macedit |
| t@@ -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 |
| diff --git a/mac/Plumb.app/Contents/MacOS/plumb b/mac/Plumb.app/Contents/MacOS/plumb |
| t@@ -10,14 +10,5 @@ IFS=$'\n'
for file in $($bin/macargv)
do
- # 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
+ $bin/macedit "$file"
done |
| diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m |
| t@@ -159,6 +159,7 @@ static NSRect dilate(NSRect);
detachDrawingThread:@selector(callservep9p:)
toTarget:[self class] withObject:nil];
}
+
- (void)windowDidBecomeKey:(id)arg
{
getmousepos();
t@@ -298,6 +299,41 @@ attachscreen(char *label, char *winsize)
[win.content setHidden:NO];
[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 |