diff options
| author | Jan Djärv | 2013-12-19 11:25:48 +0100 |
|---|---|---|
| committer | Jan Djärv | 2013-12-19 11:25:48 +0100 |
| commit | 1269a680862a9bc6cd65e3d26ef05f68c7521632 (patch) | |
| tree | 1160cb3afcd5b77d2240c276029289ce38feffc1 /lisp | |
| parent | 680e6b8c5a28489733df544edb074fd29d0522a0 (diff) | |
| download | emacs-1269a680862a9bc6cd65e3d26ef05f68c7521632.tar.gz emacs-1269a680862a9bc6cd65e3d26ef05f68c7521632.zip | |
Make NS port use the normal dnd functions.
* lisp/term/ns-win.el: Require dnd.
(global-map): Remove drag items.
(ns-insert-text, ns-set-foreground-at-mouse)
(ns-set-background-at-mouse): Remove
(ns-drag-n-drop, ns-drag-n-drop-other-frame)
(ns-drag-n-drop-as-text, ns-drag-n-drop-as-text-other-frame): New
functions.
* src/nsterm.h (KEY_NS_DRAG_FILE, KEY_NS_DRAG_COLOR, KEY_NS_DRAG_TEXT):
Remove.
* src/nsterm.m (Qfile, Qurl): New.
(EV_MODIFIERS2): New macro.
(EV_MODIFIERS): Use EV_MODIFIERS2.
(ns_term_init): Remove font and color from DND, does not work on
newer OSX, and other ports don't have them.
(performDragOperation:): Handle modifiers used during drag.
Use DRAG_N_DROP_EVENT instead of NS specific events.
Remove global Lisp variables used to communicate with ns-win.el.
Remove font and color handling.
(syms_of_nsterm): Defsym Qfile and Qurl.
Fixes: debbugs:8051
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/term/ns-win.el | 91 |
2 files changed, 55 insertions, 46 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 249f629b5f4..336a7caa8ed 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-12-19 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * term/ns-win.el: Require dnd. | ||
| 4 | (global-map): Remove drag items. | ||
| 5 | (ns-insert-text, ns-set-foreground-at-mouse) | ||
| 6 | (ns-set-background-at-mouse): Remove | ||
| 7 | (ns-drag-n-drop, ns-drag-n-drop-other-frame) | ||
| 8 | (ns-drag-n-drop-as-text, ns-drag-n-drop-as-text-other-frame): New | ||
| 9 | functions. | ||
| 10 | |||
| 1 | 2013-12-19 Glenn Morris <rgm@gnu.org> | 11 | 2013-12-19 Glenn Morris <rgm@gnu.org> |
| 2 | 12 | ||
| 3 | * emacs-lisp/ert.el (ert-select-tests): | 13 | * emacs-lisp/ert.el (ert-select-tests): |
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index 03244aaeb8a..f780fbfc2fe 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el | |||
| @@ -50,6 +50,7 @@ | |||
| 50 | (require 'faces) | 50 | (require 'faces) |
| 51 | (require 'menu-bar) | 51 | (require 'menu-bar) |
| 52 | (require 'fontset) | 52 | (require 'fontset) |
| 53 | (require 'dnd) | ||
| 53 | 54 | ||
| 54 | (defgroup ns nil | 55 | (defgroup ns nil |
| 55 | "GNUstep/Mac OS X specific features." | 56 | "GNUstep/Mac OS X specific features." |
| @@ -160,10 +161,6 @@ The properties returned may include `top', `left', `height', and `width'." | |||
| 160 | (define-key global-map [ns-power-off] 'save-buffers-kill-emacs) | 161 | (define-key global-map [ns-power-off] 'save-buffers-kill-emacs) |
| 161 | (define-key global-map [ns-open-file] 'ns-find-file) | 162 | (define-key global-map [ns-open-file] 'ns-find-file) |
| 162 | (define-key global-map [ns-open-temp-file] [ns-open-file]) | 163 | (define-key global-map [ns-open-temp-file] [ns-open-file]) |
| 163 | (define-key global-map [ns-drag-file] 'ns-find-file) | ||
| 164 | (define-key global-map [ns-drag-color] 'ns-set-foreground-at-mouse) | ||
| 165 | (define-key global-map [S-ns-drag-color] 'ns-set-background-at-mouse) | ||
| 166 | (define-key global-map [ns-drag-text] 'ns-insert-text) | ||
| 167 | (define-key global-map [ns-change-font] 'ns-respond-to-change-font) | 164 | (define-key global-map [ns-change-font] 'ns-respond-to-change-font) |
| 168 | (define-key global-map [ns-open-file-line] 'ns-open-file-select-line) | 165 | (define-key global-map [ns-open-file-line] 'ns-open-file-select-line) |
| 169 | (define-key global-map [ns-spi-service-call] 'ns-spi-service-call) | 166 | (define-key global-map [ns-spi-service-call] 'ns-spi-service-call) |
| @@ -365,14 +362,6 @@ See `ns-insert-working-text'." | |||
| 365 | 362 | ||
| 366 | ;;;; Inter-app communications support. | 363 | ;;;; Inter-app communications support. |
| 367 | 364 | ||
| 368 | (defvar ns-input-text) ; nsterm.m | ||
| 369 | |||
| 370 | (defun ns-insert-text () | ||
| 371 | "Insert contents of `ns-input-text' at point." | ||
| 372 | (interactive) | ||
| 373 | (insert ns-input-text) | ||
| 374 | (setq ns-input-text nil)) | ||
| 375 | |||
| 376 | (defun ns-insert-file () | 365 | (defun ns-insert-file () |
| 377 | "Insert contents of file `ns-input-file' like insert-file but with less | 366 | "Insert contents of file `ns-input-file' like insert-file but with less |
| 378 | prompting. If file is a directory perform a `find-file' on it." | 367 | prompting. If file is a directory perform a `find-file' on it." |
| @@ -518,6 +507,50 @@ unless the current buffer is a scratch buffer." | |||
| 518 | (ns-hide-emacs 'activate) | 507 | (ns-hide-emacs 'activate) |
| 519 | (find-file f))))) | 508 | (find-file f))))) |
| 520 | 509 | ||
| 510 | |||
| 511 | (defun ns-drag-n-drop (event &optional new-frame force-text) | ||
| 512 | "Edit the files listed in the drag-n-drop EVENT. | ||
| 513 | Switch to a buffer editing the last file dropped." | ||
| 514 | (interactive "e") | ||
| 515 | (let* ((window (posn-window (event-start event))) | ||
| 516 | (arg (car (cdr (cdr event)))) | ||
| 517 | (type (car arg)) | ||
| 518 | (data (car (cdr arg))) | ||
| 519 | (url-or-string (cond ((eq type 'file) | ||
| 520 | (concat "file:" data)) | ||
| 521 | (t data)))) | ||
| 522 | (set-frame-selected-window nil window) | ||
| 523 | (when new-frame | ||
| 524 | (select-frame (make-frame))) | ||
| 525 | (raise-frame) | ||
| 526 | (setq window (selected-window)) | ||
| 527 | (if force-text | ||
| 528 | (dnd-insert-text window 'private data) | ||
| 529 | (dnd-handle-one-url window 'private url-or-string)))) | ||
| 530 | |||
| 531 | |||
| 532 | (defun ns-drag-n-drop-other-frame (event) | ||
| 533 | "Edit the files listed in the drag-n-drop EVENT, in other frames. | ||
| 534 | May create new frames, or reuse existing ones. The frame editing | ||
| 535 | the last file dropped is selected." | ||
| 536 | (interactive "e") | ||
| 537 | (ns-drag-n-drop event t)) | ||
| 538 | |||
| 539 | (defun ns-drag-n-drop-as-text (event) | ||
| 540 | "Drop the data in EVENT as text." | ||
| 541 | (interactive "e") | ||
| 542 | (ns-drag-n-drop event nil t)) | ||
| 543 | |||
| 544 | (defun ns-drag-n-drop-as-text-other-frame (event) | ||
| 545 | "Drop the data in EVENT as text in a new frame." | ||
| 546 | (interactive "e") | ||
| 547 | (ns-drag-n-drop event t t)) | ||
| 548 | |||
| 549 | (global-set-key [drag-n-drop] 'ns-drag-n-drop) | ||
| 550 | (global-set-key [C-drag-n-drop] 'ns-drag-n-drop-other-frame) | ||
| 551 | (global-set-key [M-drag-n-drop] 'ns-drag-n-drop-as-text) | ||
| 552 | (global-set-key [C-M-drag-n-drop] 'ns-drag-n-drop-as-text-other-frame) | ||
| 553 | |||
| 521 | ;;;; Frame-related functions. | 554 | ;;;; Frame-related functions. |
| 522 | 555 | ||
| 523 | ;; nsterm.m | 556 | ;; nsterm.m |
| @@ -830,40 +863,6 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") | |||
| 830 | (t | 863 | (t |
| 831 | nil)))) | 864 | nil)))) |
| 832 | 865 | ||
| 833 | (defvar ns-input-color) ; nsterm.m | ||
| 834 | |||
| 835 | (defun ns-set-foreground-at-mouse () | ||
| 836 | "Set the foreground color at the mouse location to `ns-input-color'." | ||
| 837 | (interactive) | ||
| 838 | (let* ((pos (mouse-position)) | ||
| 839 | (frame (car pos)) | ||
| 840 | (face (ns-face-at-pos pos))) | ||
| 841 | (cond | ||
| 842 | ((eq face 'cursor) | ||
| 843 | (modify-frame-parameters frame (list (cons 'cursor-color | ||
| 844 | ns-input-color)))) | ||
| 845 | ((not face) | ||
| 846 | (modify-frame-parameters frame (list (cons 'foreground-color | ||
| 847 | ns-input-color)))) | ||
| 848 | (t | ||
| 849 | (set-face-foreground face ns-input-color frame))))) | ||
| 850 | |||
| 851 | (defun ns-set-background-at-mouse () | ||
| 852 | "Set the background color at the mouse location to `ns-input-color'." | ||
| 853 | (interactive) | ||
| 854 | (let* ((pos (mouse-position)) | ||
| 855 | (frame (car pos)) | ||
| 856 | (face (ns-face-at-pos pos))) | ||
| 857 | (cond | ||
| 858 | ((eq face 'cursor) | ||
| 859 | (modify-frame-parameters frame (list (cons 'cursor-color | ||
| 860 | ns-input-color)))) | ||
| 861 | ((not face) | ||
| 862 | (modify-frame-parameters frame (list (cons 'background-color | ||
| 863 | ns-input-color)))) | ||
| 864 | (t | ||
| 865 | (set-face-background face ns-input-color frame))))) | ||
| 866 | |||
| 867 | ;; Set some options to be as Nextstep-like as possible. | 866 | ;; Set some options to be as Nextstep-like as possible. |
| 868 | (setq frame-title-format t | 867 | (setq frame-title-format t |
| 869 | icon-title-format t) | 868 | icon-title-format t) |