Changeset 14238


Ignore:
Timestamp:
Sep 8, 2010, 8:44:06 PM (9 years ago)
Author:
rme
Message:

Add a toolbar and a contextual menu to the backtrace dialog. Update
backtrace.nib to newer format.

Add new file constants.lisp. It only contains tags as used in contextual
menu items at the moment. Add constants.lisp to defsystem file. Move
some constant defintions from xapropos.lisp to constants.lisp.

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

Legend:

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

    r12826 r14238  
    142142    (values val var)))
    143143
     144(defun show-frame-source (frame)
     145  (multiple-value-bind (lfun pc) (frame-descriptor-function frame)
     146    (when lfun
     147      (let ((source (or (and pc (ccl:find-source-note-at-pc lfun pc))
     148                        (ccl:function-source-note lfun))))
     149        (if (source-note-p source)
     150          (hemlock-ext:execute-in-file-view
     151           (ccl:source-note-filename source)
     152           (lambda  ()
     153             (hemlock::move-to-source-note source)))
     154          (hemlock::edit-definition lfun))))))
     155
    144156(defun backtrace-frame-default-action (frame &optional index)
    145157  (if index
    146158    (inspect (frame-descriptor-value frame index))
    147     (multiple-value-bind (lfun pc) (frame-descriptor-function frame)
    148       (when lfun
    149         (let ((source (or (and pc (ccl:find-source-note-at-pc lfun pc))
    150                           (ccl:function-source-note lfun))))
    151           (if (source-note-p source)
    152             (hemlock-ext:execute-in-file-view
    153              (ccl:source-note-filename source)
    154              (lambda  ()
    155                (hemlock::move-to-source-note source)))
    156             (hemlock::edit-definition lfun)))))))
     159    (show-frame-source frame)))
    157160
    158161;; Cocoa layer
     
    215218    ((context :initarg :context :reader backtrace-controller-context)
    216219     (stack-descriptor :initform nil :reader backtrace-controller-stack-descriptor)
    217      (outline-view :foreign-type :id :reader backtrace-controller-outline-view))
     220     (outline-view :foreign-type :id :reader backtrace-controller-outline-view)
     221     (message-field :foreign-type :id :accessor message-field)
     222     (action-menu :foreign-type :id :accessor action-menu)
     223     (action-popup-button :foreign-type :id :accessor action-popup-button)
     224     (contextual-menu :foreign-type :id :accessor contextual-menu))
    218225  (:metaclass ns:+ns-object))
    219226
     
    268275                                (class-name (class-of break-condition))
    269276                                break-condition))))
     277                (ccl::with-autoreleased-nsstring (s break-condition-string)
     278                  (#/setStringValue: (slot-value self 'message-field) s))
    270279                (#/setFont: header-cell (default-font :name "Courier" :size 10 :attributes '(:bold)))
    271280                (#/setStringValue: header-cell (%make-nsstring break-condition-string))))))))
     
    399408
    400409 
    401 
    402 
    403 
    404 
    405 
     410(objc:defmethod (#/validateToolbarItem: #>BOOL) ((self backtrace-window-controller)
     411                                                 toolbar-item)
     412  (let* ((outline-view (backtrace-controller-outline-view self))
     413         (row (#/selectedRow outline-view))
     414         (identifier (#/itemIdentifier toolbar-item)))
     415    (if (or (#/isEqualToString: identifier #@"expand all")
     416            (#/isEqualToString: identifier #@"collapse all"))
     417      #$YES
     418      (when (/= row -1)
     419        (let ((item (#/itemAtRow: outline-view row)))
     420          (cond ((typep item 'frame-label)
     421                 (if (#/isEqualToString: identifier #@"inspect")
     422                   #$NO
     423                   #$YES))
     424              ((typep item 'item-label)
     425               #$YES)
     426              (t
     427               #$NO)))))))
     428
     429(objc:defmethod (#/validateMenuItem: #>BOOL) ((self backtrace-window-controller)
     430                                                 menu-item)
     431  (when (eql (contextual-menu self) (#/menu menu-item))
     432    (let* ((ov (backtrace-controller-outline-view self))
     433           (clicked-row (#/clickedRow ov))
     434           (row (#/selectedRow ov))
     435           (tag (#/tag menu-item)))
     436      (when (/= clicked-row -1)
     437        (setq row clicked-row))
     438      (when (/= row -1)
     439        (let ((item (#/itemAtRow: ov row)))
     440          (cond ((= tag $inspect-item-tag)
     441                 (typep item 'item-label))
     442                ((= tag $source-item-tag)
     443                 t)))))))
     444
     445(defun frame-descriptor-from-item (item)
     446  (etypecase item
     447    (frame-label (frame-label-descriptor item))
     448    (item-label (frame-label-descriptor (item-label-label item)))))
     449
     450(objc:defmethod (#/inspect: :void) ((self backtrace-window-controller) sender)
     451  (declare (ignore sender))
     452  (let* ((ov (backtrace-controller-outline-view self))
     453         (row (#/selectedRow ov)))
     454    (when (/= row -1)
     455      (let ((item (#/itemAtRow: ov row)))
     456        (cond ((typep item 'item-label)
     457               (let* ((frame (frame-label-descriptor (item-label-label item)))
     458                      (index (item-label-index item)))
     459                 (inspect (frame-descriptor-value frame index)))))))))
     460
     461(objc:defmethod (#/source: :void) ((self backtrace-window-controller) sender)
     462  (declare (ignore sender))
     463  (let* ((ov (backtrace-controller-outline-view self))
     464         (row (#/selectedRow ov))
     465         (clicked-row (#/clickedRow ov)))
     466    (when (/= clicked-row -1)
     467      (setq row clicked-row))
     468    (when (/= row -1)
     469      (let* ((item (#/itemAtRow: ov row))
     470             (frame (frame-descriptor-from-item item)))
     471        (show-frame-source frame)))))
     472
     473(objc:defmethod (#/expandAll: :void) ((self backtrace-window-controller) sender)
     474  (declare (ignore sender))
     475  (let ((ov (backtrace-controller-outline-view self)))
     476    (#/expandItem:expandChildren: ov +null-ptr+ #$YES)))
     477
     478(objc:defmethod (#/collapseAll: :void) ((self backtrace-window-controller) sender)
     479  (declare (ignore sender))
     480  (let ((ov (backtrace-controller-outline-view self)))
     481    (#/collapseItem:collapseChildren: ov +null-ptr+ #$YES)))
     482
     483 
  • trunk/source/cocoa-ide/defsystem.lisp

    r14214 r14238  
    6464(defparameter *ide-files*
    6565  '(;"ide-bundle" - loaded by hand above
     66    "constants"
    6667    "cocoa-utils"
    6768    "cocoa-defaults"
  • trunk/source/cocoa-ide/xapropos.lisp

    r13543 r14238  
    4646    (4 . :macro))
    4747  "Associates search menu item tags with keywords.")
    48 
    49 ;;; action menu item tags
    50 (defconstant $inspect-item-tag 0)
    51 (defconstant $source-item-tag 1)
    5248
    5349(objc:defmethod #/init ((wc xapropos-window-controller))
Note: See TracChangeset for help on using the changeset viewer.