Changeset 12229


Ignore:
Timestamp:
Jun 8, 2009, 8:07:59 AM (10 years ago)
Author:
gb
Message:

Make menu commands which operate on the buffer (or its file) use the
buffer's "default package", not its "current package".

Don't compute temporary attributes or highlight matching parens in the
echo area.

Convenience function to access "edit level" of a buffer.

HEMLOCK-EXT::INVOKE-ALLOWING-BUFFER-DISPLAY: new function, close
any pending edits on the buffer's textstorage, call thunk, restore
edit level.

Free hemlock textstorage when an editor document is dealloc'ed, not
just when it's closed. (#/close method is probably unnecessary.)

File:
1 edited

Legend:

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

    r12182 r12229  
    999999  ;; If no modifier keys are pressed, send hemlock a no-op.
    10001000  ;; (Or almost a no-op - this does an update-hemlock-selection as a side-effect)
    1001 
    10021001  (unless (logtest #$NSDeviceIndependentModifierFlagsMask (#/modifierFlags event))
    10031002    (let* ((view (hemlock-view self)))
     
    12531252    (when pane (hemlock-view pane))))
    12541253
     1254
     1255
    12551256(objc:defmethod (#/evalSelection: :void) ((self hemlock-text-view) sender)
    12561257  (declare (ignore sender))
     
    12691270  (declare (ignore sender))
    12701271  (let* ((buffer (hemlock-buffer self))
    1271          (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
     1272         (package-name (hi::variable-value 'hemlock::default-package :buffer buffer))
    12721273         (pathname (hi::buffer-pathname buffer))
    12731274         (s (lisp-string-from-nsstring (#/string self))))
     
    12771278  (declare (ignore sender))
    12781279  (let* ((buffer (hemlock-buffer self))
    1279          (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
     1280         (package-name (hi::variable-value 'hemlock::default-package :buffer buffer))
    12801281         (pathname (hi::buffer-pathname buffer)))
    12811282    (ui-object-load-buffer *NSApp* (list package-name pathname))))
     
    12841285  (declare (ignore sender))
    12851286  (let* ((buffer (hemlock-buffer self))
    1286          (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
     1287         (package-name (hi::variable-value 'hemlock::default-package :buffer buffer))
    12871288         (pathname (hi::buffer-pathname buffer)))
    12881289    (ui-object-compile-buffer *NSApp* (list package-name pathname))))
     
    12911292  (declare (ignore sender))
    12921293  (let* ((buffer (hemlock-buffer self))
    1293          (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
     1294         (package-name (hi::variable-value 'hemlock::default-package :buffer buffer))
    12941295         (pathname (hi::buffer-pathname buffer)))
    12951296    (ui-object-compile-and-load-buffer *NSApp* (list package-name pathname))))
     
    15021503             ;; selection: mark at n1, point at n1+m.
    15031504             ;; In all cases, activate Hemlock selection.
     1505             (disable-paren-highlight self)
    15041506             (unless still-selecting
    15051507                (let* ((pointpos (hi:mark-absolute-position point))
     
    17841786  (:metaclass ns:+ns-object))
    17851787(declaim (special echo-area-view))
     1788
     1789(defmethod compute-temporary-attributes ((self echo-area-view))
     1790)
     1791
     1792(defmethod update-paren-highlight ((self echo-area-view))
     1793)
    17861794
    17871795(defmethod hemlock-view ((self echo-area-view))
     
    20732081        (buffer-document-begin-editing old)))))
    20742082
     2083
    20752084(defun buffer-document-end-editing (buffer)
    20762085  (when buffer
     
    20922101  (assume-cocoa-thread) ;; see comment in #/editingInProgress
    20932102  (slot-value (slot-value document 'textstorage) 'edit-count))
     2103
     2104(defun hi::buffer-edit-level (buffer)
     2105  (if buffer
     2106    (let* ((document (hi::buffer-document buffer)))
     2107      (if document
     2108        (document-edit-level document)
     2109        0))
     2110    0))
     2111
     2112(defun hemlock-ext::invoke-allowing-buffer-display (buffer thunk)
     2113  ;; Call THUNK with the buffer's edit-level at 0, then restore the buffer's edit level.
     2114  (let* ((level (hi::buffer-edit-level buffer)))
     2115    (dotimes (i level) (buffer-document-end-editing buffer))
     2116    (unwind-protect
     2117        (funcall thunk)
     2118      (dotimes (i level) (buffer-document-begin-editing buffer)))))
     2119
     2120
    20942121
    20952122(defun perform-edit-change-notification (textstorage selector pos n &optional (extra 0))
     
    27112738    (unless (%null-ptr-p textstorage)
    27122739      (setf (slot-value self 'textstorage) (%null-ptr))
     2740      #+huh?
    27132741      (for-each-textview-using-storage
    27142742       textstorage
     
    27182746      (close-hemlock-textstorage textstorage)))
    27192747  (call-next-method))
     2748
     2749(objc:defmethod (#/dealloc :void) ((self hemlock-editor-document))
     2750  (let* ((textstorage (slot-value self 'textstorage)))
     2751    (unless (%null-ptr-p textstorage)
     2752      (setf (slot-value self 'textstorage) (%null-ptr))
     2753      (close-hemlock-textstorage textstorage)))
     2754  (call-next-method))
     2755
     2756
    27202757
    27212758(defmethod view-screen-lines ((view hi:hemlock-view))
Note: See TracChangeset for help on using the changeset viewer.