Changeset 12110


Ignore:
Timestamp:
May 22, 2009, 10:12:37 AM (10 years ago)
Author:
gb
Message:

#/replaceCharactersAtPosition:length:withString: begin/end editing
around the actual replacement.

#/replaceCharactersInRange:withString: don't go through Hemlock event
processing, just modify the Hemlock buffer, assuming that #/beginEditing
has already been called.

#/keyDown: clear the quote-next-char flag if we have "marked text", e.g.,
are doing dead-key processing or something like it. (If we complete
the dead-key processing, we'll have inserted a character and don't want
to quote the next one; if we cancel out of the dead-key processing ...
might as well exit the quote-next-char state, too.

[Part of the problem in ticket:461 was that (on a US keyboard) the sequence
C-q,Option-E,E,Return did a quoted insert of a #\Return character rather
than executing the listener command bound to #\Newline.]

File:
1 edited

Legend:

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

    r12101 r12110  
    760760         pos (#/length string) replaced-string)))
    761761    (ns:with-ns-range (r pos len)
    762       (#/replaceCharactersInRange:withString: self r string))))
     762      (#/beginEditing self)
     763      (unwind-protect
     764           (#/replaceCharactersInRange:withString: self r string)
     765      (#/endEditing self)))))
    763766
    764767;; In theory (though not yet in practice) we allow for a buffer to be shown in multiple
     
    778781     thereis (and (eq (hemlock-buffer w) buffer) (hemlock-view w))))
    779782
     783
     784;;; Modify the hemlock buffer; don't change attributes.
    780785(objc:defmethod (#/replaceCharactersInRange:withString: :void)
    781786    ((self hemlock-text-storage) (r :<NSR>ange) string)
    782787  (let* ((buffer (hemlock-buffer self))
     788         (hi::*current-buffer* buffer)
    783789         (position (pref r :<NSR>ange.location))
    784790         (length (pref r :<NSR>ange.length))
    785791         (lisp-string (if (> (#/length string) 0) (lisp-string-from-nsstring string)))
    786          (view (front-view-for-buffer buffer)))
     792         (view (front-view-for-buffer buffer)))
     793    (hi::with-mark ((m (hi::buffer-point buffer)))
     794      (hi::move-to-absolute-position m position)
     795      (when (> length 0)
     796        (hi::delete-characters m length))
     797      (when lisp-string
     798        (hi::insert-string m lisp-string)))
    787799    (when view
    788       (let* ((edit-count (slot-value self 'edit-count)))
    789         (dotimes (i edit-count) (#/endEditing self))
    790         (hi::handle-hemlock-event view #'(lambda ()
    791                                            (hi:paste-characters position length
    792                                                                 lisp-string)))
    793         (dotimes (i edit-count)
    794           (#/beginEditing self))))))
     800      (setf (hi::hemlock-view-quote-next-p view) nil))))
    795801
    796802(objc:defmethod (#/setAttributes:range: :void) ((self hemlock-text-storage)
     
    889895  (disable-paren-highlight self))
    890896
     897
     898
     899     
     900
    891901(defmethod eventqueue-abort-pending-p ((self hemlock-textstorage-text-view))
    892902  ;; Return true if cmd-. is in the queue.  Not sure what to do about c-g:
     
    910920         ;; quote-p means handle characters natively
    911921         (quote-p (and view (hi::hemlock-view-quote-next-p view)))
     922         (has-marked-text (#/hasMarkedText self))
    912923         (flags (#/modifierFlags event)))
    913924    #+debug (log-debug "~&quote-p ~s event ~s" quote-p event)
     925    (when (and has-marked-text quote-p)
     926      (setf (hi::hemlock-view-quote-next-p view) nil)
     927      (setq quote-p nil))
    914928    (cond ((and (not *option-is-meta*)
    915929                (logtest #$NSAlternateKeyMask flags))
Note: See TracChangeset for help on using the changeset viewer.