From: Steven Tamm Date: Thu, 30 Dec 2004 02:04:31 +0000 (+0000) Subject: * macterm.c (SelectionRange): Add Xcode position apple event struct. X-Git-Tag: ttn-vms-21-2-B4~3061 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=456e761becb3d7dc0b7a707079b4f1259e9da598;p=emacs.git * macterm.c (SelectionRange): Add Xcode position apple event struct. (do_ae_open_documents): Handle Xcode-style file position open events. * term/mac-win.el (mac-drag-n-drop): Handle drag-n-drop events that include line numbers. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 25194e149ac..b8bdb1b1ea4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2004-12-29 Sanghyuk Suh + + * term/mac-win.el (mac-drag-n-drop): Handle drag-n-drop events + that include line numbers. + 2004-12-29 Milan Zamazal * files.el (hack-local-variables): If no PREFIX, set it to "^". diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el index 19d25288448..4b3c7531e5a 100644 --- a/lisp/term/mac-win.el +++ b/lisp/term/mac-win.el @@ -1567,21 +1567,29 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman") "Edit the files listed in the drag-n-drop EVENT. Switch to a buffer editing the last file dropped." (interactive "e") - (save-excursion - ;; Make sure the drop target has positive co-ords - ;; before setting the selected frame - otherwise it - ;; won't work. - (let* ((window (posn-window (event-start event))) - (coords (posn-x-y (event-start event))) - (x (car coords)) - (y (cdr coords))) - (if (and (> x 0) (> y 0)) - (set-frame-selected-window nil window)) - (mapcar (lambda (file-name) - (x-dnd-handle-one-url window 'private - (concat "file:" file-name))) - (car (cdr (cdr event))))) - (raise-frame))) + ;; Make sure the drop target has positive co-ords + ;; before setting the selected frame - otherwise it + ;; won't work. + (let* ((window (posn-window (event-start event))) + (coords (posn-x-y (event-start event))) + (x (car coords)) + (y (cdr coords))) + (if (and (> x 0) (> y 0)) + (set-frame-selected-window nil window)) + (mapcar (lambda (file-name) + (if (listp file-name) + (let ((line (car file-name)) + (start (car (cdr file-name))) + (end (car (cdr (cdr file-name))))) + (if (> line 0) + (goto-line line) + (if (and (> start 0) (> end 0)) + (progn (set-mark start) + (goto-char end))))) + (x-dnd-handle-one-url window 'private + (concat "file:" file-name)))) + (car (cdr (cdr event))))) + (raise-frame)) (global-set-key [drag-n-drop] 'mac-drag-n-drop) diff --git a/src/ChangeLog b/src/ChangeLog index 2f974365cdc..4bc9e69ce12 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2004-12-29 Sanghyuk Suh + + * macterm.c (SelectionRange): Add Xcode position apple event struct. + (do_ae_open_documents): Handle Xcode-style file position open + events. + 2004-12-29 Luc Teirlinck * buffer.c (syms_of_buffer) : Correct typo. diff --git a/src/macterm.c b/src/macterm.c index 745457f0ff3..4df30e74386 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -7928,6 +7928,17 @@ path_from_vol_dir_name (char *, int, short, long, char *); /* Called when we receive an AppleEvent with an ID of "kAEOpenDocuments". This routine gets the direct parameter, extracts the FSSpecs in it, and puts their names on a list. */ +#pragma options align=mac68k +typedef struct SelectionRange { + short unused1; // 0 (not used) + short lineNum; // line to select (<0 to specify range) + long startRange; // start of selection range (if line < 0) + long endRange; // end of selection range (if line < 0) + long unused2; // 0 (not used) + long theDate; // modification date/time +} SelectionRange; +#pragma options align=reset + static pascal OSErr do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon) { @@ -7936,11 +7947,19 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon) AEKeyword keyword; DescType actual_type; Size actual_size; + SelectionRange position; err = AEGetParamDesc (message, keyDirectObject, typeAEList, &the_desc); if (err != noErr) goto descriptor_error_exit; + err = AEGetParamPtr (message, keyAEPosition, typeChar, &actual_type, &position, sizeof(SelectionRange), &actual_size); + if (err == noErr) + drag_and_drop_file_list = Fcons (list3 (make_number (position.lineNum + 1), + make_number (position.startRange + 1), + make_number (position.endRange + 1)), + drag_and_drop_file_list); + /* Check to see that we got all of the required parameters from the event descriptor. For an 'odoc' event this should just be the file list. */