Changeset 7531


Ignore:
Timestamp:
Oct 27, 2007, 7:01:36 PM (14 years ago)
Author:
mikel
Message:

implemented the Load Buffer menu item

Location:
trunk/ccl/cocoa-ide
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/cocoa-ide/cocoa-editor.lisp

    r7528 r7531  
    904904  (declare (ignore sender))
    905905  (let* ((dc (#/sharedDocumentController ns:ns-document-controller))
    906         (doc (#/documentForWindow: dc (#/window self)))
    907         (buffer (hemlock-document-buffer doc))
    908         (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
    909         (pathname (hi::buffer-pathname buffer))
    910         (ranges (#/selectedRanges self))
    911         (text (#/string self)))
     906        (doc (#/documentForWindow: dc (#/window self)))
     907        (buffer (hemlock-document-buffer doc))
     908        (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
     909        (pathname (hi::buffer-pathname buffer))
     910        (ranges (#/selectedRanges self))
     911        (text (#/string self)))
    912912    (dotimes (i (#/count ranges))
    913913      (let* ((r (#/rangeValue (#/objectAtIndex: ranges i)))
    914              (s (#/substringWithRange: text r)))
    915         (setq s (lisp-string-from-nsstring s))
    916         (ui-object-eval-selection *NSApp* (list package-name pathname s))))))
     914             (s (#/substringWithRange: text r)))
     915        (setq s (lisp-string-from-nsstring s))
     916        (ui-object-eval-selection *NSApp* (list package-name pathname s))))))
     917
     918(objc:defmethod (#/loadBuffer: :void) ((self hemlock-text-view) sender)
     919  (declare (ignore sender))
     920  (let* ((dc (#/sharedDocumentController ns:ns-document-controller))
     921         (doc (#/documentForWindow: dc (#/window self)))
     922         (buffer (hemlock-document-buffer doc))
     923         (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
     924         (pathname (hi::buffer-pathname buffer)))
     925    (ui-object-load-buffer *NSApp* (list package-name pathname))))
    917926
    918927(defloadvar *text-view-context-menu* ())
     
    21322141                  (#/shouldChangeTextInRange:replacementString: self selection #@""))))
    21332142          ((eql action (@selector #/evalSelection:))
    2134            (not (eql 0 (ns:ns-range-length (#/selectedRange self)))))
     2143           (not (eql 0 (ns:ns-range-length (#/selectedRange self)))))
     2144          ;; if this hemlock-text-view is in an editor windowm and its buffer has
     2145          ;; an associated pathname, then activate the Load Buffer item
     2146          ((eql action (@selector #/loadBuffer:))
     2147           (let* ((d (hemlock-buffer-string-cache (#/hemlockString (#/textStorage self))))
     2148                  (buffer (buffer-cache-buffer d))
     2149                  (pathname (hi::buffer-pathname buffer)))
     2150             (not (null pathname))))
    21352151          (t (call-next-method item)))))
    21362152
  • trunk/ccl/cocoa-ide/cocoa-listener.lisp

    r7502 r7531  
    544544                           app selection)))
    545545    (if (typep target-listener 'cocoa-listener-process)
    546       (destructuring-bind (package path string) selection
     546        (destructuring-bind (package path string) selection
    547547        (hi::send-string-to-listener-process target-listener string :package package :path path)))))
     548
     549(defmethod ui-object-load-buffer ((app ns:ns-application) selection)
     550  (let* ((target-listener (ui-object-choose-listener-for-selection app nil)))
     551    (if (typep target-listener 'cocoa-listener-process)
     552        (destructuring-bind (package path) selection
     553          (let ((string (format nil "(load ~S)" path)))
     554            (hi::send-string-to-listener-process target-listener string :package package :path path))))))
    548555
    549556
Note: See TracChangeset for help on using the changeset viewer.