diff options
| author | Po Lu | 2022-05-28 09:18:09 +0800 |
|---|---|---|
| committer | Po Lu | 2022-05-28 09:18:09 +0800 |
| commit | ffab237cbfda5121fe9d6a1a479dbb5a4c3e5f2f (patch) | |
| tree | c3d1ec02470e8ad603f8d331658e99b61b21e5dc /src | |
| parent | 3c5fbfe4ac52fb951918f0b0e6a10bade7590fa5 (diff) | |
| download | emacs-ffab237cbfda5121fe9d6a1a479dbb5a4c3e5f2f.tar.gz emacs-ffab237cbfda5121fe9d6a1a479dbb5a4c3e5f2f.zip | |
Add file dragging support to NS port
* lisp/dired.el (dired-mouse-drag-files): Document that
`dired-mouse-drag-files' now works on NS.
* lisp/term/ns-win.el (x-begin-drag): Handle FILE_NAME.
* src/nsselect.m (ns_decode_data_to_pasteboard): Handle file URL
type.
(ns_lisp_to_pasteboard, Fns_begin_drag): Handle new type `file'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsselect.m | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/nsselect.m b/src/nsselect.m index a481e80d770..0bd840d92b7 100644 --- a/src/nsselect.m +++ b/src/nsselect.m | |||
| @@ -561,17 +561,34 @@ static void | |||
| 561 | ns_decode_data_to_pasteboard (Lisp_Object type, Lisp_Object data, | 561 | ns_decode_data_to_pasteboard (Lisp_Object type, Lisp_Object data, |
| 562 | NSPasteboard *pasteboard) | 562 | NSPasteboard *pasteboard) |
| 563 | { | 563 | { |
| 564 | NSArray *types, *new; | ||
| 565 | |||
| 566 | types = [pasteboard types]; | ||
| 567 | |||
| 564 | CHECK_SYMBOL (type); | 568 | CHECK_SYMBOL (type); |
| 565 | 569 | ||
| 566 | if (EQ (type, Qstring)) | 570 | if (EQ (type, Qstring)) |
| 567 | { | 571 | { |
| 568 | CHECK_STRING (data); | 572 | CHECK_STRING (data); |
| 569 | 573 | ||
| 570 | [pasteboard declareTypes: [NSArray arrayWithObject: NSPasteboardTypeString] | 574 | new = [types arrayByAddingObject: NSPasteboardTypeString]; |
| 575 | |||
| 576 | [pasteboard declareTypes: new | ||
| 571 | owner: nil]; | 577 | owner: nil]; |
| 572 | [pasteboard setString: [NSString stringWithLispString: data] | 578 | [pasteboard setString: [NSString stringWithLispString: data] |
| 573 | forType: NSPasteboardTypeString]; | 579 | forType: NSPasteboardTypeString]; |
| 574 | } | 580 | } |
| 581 | else if (EQ (type, Qfile)) | ||
| 582 | { | ||
| 583 | CHECK_STRING (data); | ||
| 584 | |||
| 585 | new = [types arrayByAddingObject: NSPasteboardTypeFileURL]; | ||
| 586 | |||
| 587 | [pasteboard declareTypes: new | ||
| 588 | owner: nil]; | ||
| 589 | [pasteboard setString: [NSString stringWithLispString: data] | ||
| 590 | forType: NSPasteboardTypeFileURL]; | ||
| 591 | } | ||
| 575 | else | 592 | else |
| 576 | signal_error ("Unknown pasteboard type", type); | 593 | signal_error ("Unknown pasteboard type", type); |
| 577 | } | 594 | } |
| @@ -582,6 +599,9 @@ ns_lisp_to_pasteboard (Lisp_Object object, | |||
| 582 | { | 599 | { |
| 583 | Lisp_Object tem, type, data; | 600 | Lisp_Object tem, type, data; |
| 584 | 601 | ||
| 602 | [pasteboard declareTypes: [NSArray array] | ||
| 603 | owner: nil]; | ||
| 604 | |||
| 585 | CHECK_LIST (object); | 605 | CHECK_LIST (object); |
| 586 | for (tem = object; CONSP (tem); tem = XCDR (tem)) | 606 | for (tem = object; CONSP (tem); tem = XCDR (tem)) |
| 587 | { | 607 | { |
| @@ -642,6 +662,9 @@ the meaning of DATA: | |||
| 642 | - `string' means DATA should be a string describing text that will | 662 | - `string' means DATA should be a string describing text that will |
| 643 | be dragged to another program. | 663 | be dragged to another program. |
| 644 | 664 | ||
| 665 | - `file' means DATA should be a file URL that will be dragged to | ||
| 666 | another program. | ||
| 667 | |||
| 645 | ACTION is the action that will be taken by the drop target towards the | 668 | ACTION is the action that will be taken by the drop target towards the |
| 646 | data inside PBOARD. | 669 | data inside PBOARD. |
| 647 | 670 | ||