Changeset 7493


Ignore:
Timestamp:
Oct 22, 2007, 5:37:27 PM (14 years ago)
Author:
rme
Message:

Implement "Execute Selection" item on the Lisp menu, with
shortcut command-E.

It's at least semi-standard for command-E to be used for
"Use Selection for Find", but in a nod to MCL muscle memory,
we'll usurp it.

cocoa.lisp: added #/ensureListener: action (and minor update to
#/showListener:).

cocoa-listener.lisp: call #/ensureListener: on the main thread from
ui-object-choose-listener-for-selection so that we always have a
listener to send data to.

cocoa-editor.lisp: add menu item validation for #/evalSelection:.

(As a bonus, changed OpenMCL Help... in the Help menu
to Clozure CL Help...)

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

Legend:

Unmodified
Added
Removed
  • trunk/ccl/cocoa-ide/Clozure CL.app/Contents/Resources/English.lproj/MainMenu.nib/classes.nib

    r7489 r7493  
    2626                                <string>id</string>
    2727                                <key>continue</key>
     28                                <string>id</string>
     29                                <key>evalSelection</key>
    2830                                <string>id</string>
    2931                                <key>exitBreak</key>
  • trunk/ccl/cocoa-ide/Clozure CL.app/Contents/Resources/English.lproj/MainMenu.nib/info.nib

    r7489 r7493  
    99        <key>IBOpenObjects</key>
    1010        <array>
    11                 <integer>24</integer>
     11                <integer>361</integer>
    1212        </array>
    1313        <key>IBSystem Version</key>
  • trunk/ccl/cocoa-ide/cocoa-editor.lisp

    r7480 r7493  
    901901  (:metaclass ns:+ns-object))
    902902
    903 
    904 
    905 
    906 
     903(objc:defmethod (#/evalSelection: :void) ((self hemlock-text-view) sender)
     904  (declare (ignore sender))
     905  (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)))
     912    (dotimes (i (#/count ranges))
     913      (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))))))
    907917
    908918(defloadvar *text-view-context-menu* ())
     
    20992109             (and (> (ns:ns-range-length selection))
    21002110                  (#/shouldChangeTextInRange:replacementString: self selection #@""))))
    2101           (t (call-next-method item)))))
     2111          ((eql action (@selector #/evalSelection:))
     2112           (not (eql 0 (ns:ns-range-length (#/selectedRange self)))))
     2113          (t (call-next-method item)))))
    21022114
    21032115(defmethod user-input-style ((doc hemlock-editor-document))
  • trunk/ccl/cocoa-ide/cocoa-listener.lisp

    r7489 r7493  
    523523(defun hemlock::evaluate-input-selection (selection)
    524524  (application-ui-operation *application* :eval-selection selection))
    525                            
     525 
    526526(defmethod ui-object-choose-listener-for-selection ((app ns:ns-application)
    527527                                                    selection)
    528528  (declare (ignore selection))
     529  (#/performSelectorOnMainThread:withObject:waitUntilDone:
     530   (#/delegate *NSApp*) (@selector #/ensureListener:) +null-ptr+ #$YES)
    529531  (let* ((top-listener-document (#/topListener hemlock-listener-document)))
    530532    (if top-listener-document
  • trunk/ccl/cocoa-ide/cocoa.lisp

    r7489 r7493  
    112112          (#/makeKeyAndOrderFront: w +null-ptr+))))
    113113     (t
    114       (#/makeKeyAndOrderFront: (car listener-windows) +null-ptr+)))))
    115  
     114      (#/makeKeyAndOrderFront: top-listener +null-ptr+)))))
     115
     116(objc:defmethod (#/ensureListener: :void) ((self lisp-application-delegate)
     117                                           sender)
     118  "If no listener exists, create one and bring it to the front without making it the key or main window."
     119  (declare (ignore sender))
     120  (let ((top-listener-document (#/topListener hemlock-listener-document)))
     121    (when (eql top-listener-document +null-ptr+)
     122      (let* ((dc (#/sharedDocumentController ns:ns-document-controller))
     123             (wc nil))
     124        (setq top-listener-document
     125              (#/makeUntitledDocumentOfType:error: dc #@"Listener" +null-ptr+))
     126        (#/addDocument: dc top-listener-document)
     127        (#/makeWindowControllers top-listener-document)
     128        (setq wc (#/lastObject (#/windowControllers top-listener-document)))
     129        (#/orderFront: (#/window wc) +null-ptr+)))))
     130
    116131(defloadvar *processes-window-controller* nil)
    117132
Note: See TracChangeset for help on using the changeset viewer.