Changeset 14248


Ignore:
Timestamp:
Sep 10, 2010, 9:49:47 PM (9 years ago)
Author:
rme
Message:

Add Open Selection menu item to File Menu, with shortcut of cmd-D.
Find Previous is now shift-cmd-G (which is standard).

Add a Source Of contextual menu item. This seems of dubious utility, but
maybe someone out there doesn't know about M-. yet.

Update MainMenu?.nib nib file format.

Location:
trunk/source/cocoa-ide
Files:
2 deleted
2 edited

Legend:

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

    r14247 r14248  
    18071807      pathname)))
    18081808
    1809 ;;; If we get here, we've already checked that the selection represents
    1810 ;;; a valid pathname.
     1809(defun find-symbol-in-packages (string pkgs)
     1810  (setq string (string-upcase string))
     1811  (let (sym)
     1812    (dolist (p pkgs)
     1813      (when (setq sym (find-symbol string p))
     1814        (return)))
     1815    sym))
     1816
    18111817(objc:defmethod (#/openSelection: :void) ((self hemlock-text-view) sender)
    18121818  (declare (ignore sender))
     
    18151821         (pathname (pathname-for-namestring-fragment
    18161822                    (lisp-string-from-nsstring selection))))
    1817     (ed pathname)))
     1823    (when (pathnamep pathname)
     1824      (ed pathname))))
    18181825
    18191826;;; If we get here, we've already checked that the selection represents
     
    18231830  (let* ((text (#/string self))
    18241831         (selection (#/substringWithRange: text (#/selectedRange self)))
    1825          (symbol-name (string-upcase (lisp-string-from-nsstring selection))))
    1826     (inspect (find-symbol symbol-name))))
     1832         (symbol-name (string-upcase (lisp-string-from-nsstring selection)))
     1833         (buffer (hemlock-buffer self))
     1834         (package-name (hi::variable-value 'hemlock::current-package :buffer buffer)))
     1835    (inspect (find-symbol-in-packages symbol-name
     1836                                      (cons package-name
     1837                                            (package-use-list package-name))))))
     1838
     1839(objc:defmethod (#/sourceForSelection: :void) ((self hemlock-text-view) sender)
     1840  (declare (ignore sender))
     1841  (let* ((text (#/string self))
     1842         (selection (#/substringWithRange: text (#/selectedRange self)))
     1843         (sym (find-symbol-in-packages (lisp-string-from-nsstring selection)
     1844                                       (list-all-packages))))
     1845    (ed sym)))
    18271846
    18281847;;; If we don't override this, NSTextView will start adding Google/
     
    18361855         (menu (if (> (length s) 0)
    18371856                 (#/copy (#/menu self))
    1838                  (#/retain (#/menu self)))))
    1839     (when (find-symbol (string-upcase s))
     1857                 (#/retain (#/menu self))))
     1858         (buffer (hemlock-buffer self))
     1859         (package-name (hi::variable-value 'hemlock::current-package :buffer buffer)))
     1860    (when (find-symbol-in-packages (string-upcase s)
     1861                                   (cons package-name
     1862                                         (package-use-list package-name)))
    18401863      (let* ((title (#/stringByAppendingString: #@"Inspect " selection))
    18411864             (item (make-instance 'ns:ns-menu-item :with-title title
    18421865                     :action (@selector #/inspectSelection:)
     1866                     :key-equivalent #@"")))
     1867        (#/setTarget: item self)
     1868        (#/insertItem:atIndex: menu item 0)
     1869        (#/release item)))
     1870    (when (find-symbol-in-packages (string-upcase s) (list-all-packages))
     1871      (let* ((title (#/stringByAppendingString: #@"Source of " selection))
     1872             (item (make-instance 'ns:ns-menu-item :with-title title
     1873                     :action (@selector #/sourceForSelection:)
    18431874                     :key-equivalent #@"")))
    18441875        (#/setTarget: item self)
     
    26092640                  (pathname (hi::buffer-pathname buffer)))
    26102641             (not (null pathname))))
     2642          ((eql action (@selector #/openSelection:))
     2643           (let* ((text (#/string self))
     2644                  (selection (#/substringWithRange: text (#/selectedRange self))))
     2645             (pathname-for-namestring-fragment (lisp-string-from-nsstring selection))))
    26112646          (t (call-next-method item)))))
    26122647
Note: See TracChangeset for help on using the changeset viewer.