From: bodhi <bodhi@5263.org>
To: emacs-pretest-bug@gnu.org
Subject: bug#5248: 23.1.90; Patch for OS X drag-and-drop
Date: Sat, 19 Dec 2009 23:42:13 +1100 [thread overview]
Message-ID: <m2oclvw2xm.fsf@5263.org> (raw)
Hi,
I made a patch on the latest emacs git repository, I guess this is
mirrored regularly from the canonical repository?
The patch modifies emacs to accept all dropped urls, not just
files. The file-url behaviour should be unchanged, but when a
non-file url is dropped it sends a new event with the text of the
url, which by default inserts the text. Maybe a new event isn't
necessary, and it could be treated as dropping text?
The patch is included below, and is also available at
http://gist.github.com/260042
Thanks,
Bodhi
----
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 157b2dd..13bd0ac 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -277,6 +277,7 @@ The properties returned may include `top',
`left', `height', and `width'."
(define-key global-map [ns-new-frame] 'make-frame)
(define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar)
(define-key global-map [ns-show-prefs] 'customize)
+(define-key global-map [ns-drag-url] 'ns-insert-text)
;; Set up a number of aliases and other layers to pretend we're
using
@@ -315,6 +316,7 @@ The properties returned may include `top',
`left', `height', and `width'."
(cons (logior (lsh 0 16) 12) 'ns-new-frame)
(cons (logior (lsh 0 16) 13) 'ns-toggle-toolbar)
(cons (logior (lsh 0 16) 14) 'ns-show-prefs)
+ (cons (logior (lsh 0 16) 15) 'ns-drag-url)
(cons (logior (lsh 1 16) 32) 'f1)
(cons (logior (lsh 1 16) 33) 'f2)
(cons (logior (lsh 1 16) 34) 'f3)
diff --git a/src/nsterm.h b/src/nsterm.h
index 29d312a..8536660 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -365,6 +365,7 @@ typedef unsigned int NSUInteger;
#define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12)
#define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
#define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
+#define KEY_NS_DRAG_URL ((1<<28)|(0<<16)|15)
/* could use list to store these, but rest of emacs has a big
infrastructure
for managing a table of bitmap "records" */
diff --git a/src/nsterm.m b/src/nsterm.m
index 9256c08..73ede9a 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -5456,20 +5456,24 @@ extern void update_window_cursor (struct
window *w, int on);
}
else if ([type isEqualToString: NSURLPboardType])
{
- NSString *file;
- NSURL *fileURL;
-
- if (!(fileURL = [NSURL URLFromPasteboard: pb]) ||
- [fileURL isFileURL] == NO)
- return NO;
-
- file = [fileURL path];
+ NSString *path;
+ NSURL *url;
+
+ if (!(url = [NSURL URLFromPasteboard: pb])) {
+ return NO;
+ } else if ([url isFileURL] == YES) {
+ path = [url path];
+ emacs_event->code = KEY_NS_DRAG_FILE;
+ ns_input_file = append2 (ns_input_file, build_string
([path UTF8String]));
+ } else {
+ path = [url absoluteString];
+ emacs_event->code = KEY_NS_DRAG_URL;
+ ns_input_text = build_string ([path UTF8String]);
+ }
emacs_event->kind = NS_NONKEY_EVENT;
- emacs_event->code = KEY_NS_DRAG_FILE;
+ emacs_event->modifiers = EV_MODIFIERS (theEvent);
XSETINT (emacs_event->x, x);
XSETINT (emacs_event->y, y);
- ns_input_file = append2 (ns_input_file, build_string ([file
UTF8String]));
- emacs_event->modifiers = EV_MODIFIERS (theEvent);
EV_TRAILER (theEvent);
return YES;
}
next reply other threads:[~2009-12-19 12:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-19 12:42 bodhi [this message]
2010-07-13 10:56 ` bug#5248: 23.1.90; Patch for OS X drag-and-drop Adrian Robert
2016-02-17 3:36 ` Andrew Hyatt
2019-04-06 16:20 ` Alan Third
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2oclvw2xm.fsf@5263.org \
--to=bodhi@5263.org \
--cc=5248@debbugs.gnu.org \
--cc=emacs-pretest-bug@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).