Ignore:
Timestamp:
Sep 24, 2007, 6:40:52 PM (13 years ago)
Author:
rme
Message:

Merged trunk changes r7244:7286

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ia32/cocoa-ide/cocoa-editor.lisp

    r7244 r7287  
    363363     (hemlock-string :foreign-type :id)
    364364     (edit-count :foreign-type :int)
    365      (cache :foreign-type :id)
     365     (mirror :foreign-type :id)
    366366     (styles :foreign-type :id)
    367367     (selection-set-by-search :foreign-type :<BOOL>))
     
    401401                                                                  (extra :<NSI>nteger))
    402402  (declare (ignorable extra))
    403   (let* ((cache (#/cache self))
     403  (let* ((mirror (#/mirror self))
    404404         (hemlock-string (#/hemlockString self))
    405405         (display (hemlock-buffer-string-cache hemlock-string))
     
    410410    #+debug
    411411    (#_NSLog #@"insert: pos = %ld, n = %ld" :long pos :long n)
    412     ;; We need to update the hemlock string cache here so that #/substringWithRange:
     412    ;; We need to update the hemlock string mirror here so that #/substringWithRange:
    413413    ;; will work on the hemlock buffer string.
    414414    (adjust-buffer-cache-for-insertion display pos n)
     
    417417      (ns:with-ns-range (replacerange pos 0)
    418418        (#/replaceCharactersInRange:withString:
    419          cache replacerange replacestring)))
    420     (#/setAttributes:range: cache font (ns:make-ns-range pos n))   
     419         mirror replacerange replacestring)))
     420    (#/setAttributes:range: mirror font (ns:make-ns-range pos n))   
    421421    (textstorage-note-insertion-at-position self pos n)
    422422    ;; Arguably, changecount stuff should happen via the document's NSUndoManager.
     
    433433  (ns:with-ns-range (range pos n)
    434434    ;; It seems to be necessary to call #/edited:range:changeInLength: before
    435     ;; deleting from the cached attributed string.  It's not clear whether this
     435    ;; deleting from the mirror attributed string.  It's not clear whether this
    436436    ;; is also true of insertions and modifications.
    437437    (#/edited:range:changeInLength: self (logior #$NSTextStorageEditedCharacters
    438438                                                 #$NSTextStorageEditedAttributes)
    439439                                    range (- n))
    440     (#/deleteCharactersInRange: (#/cache self) range))
     440    (#/deleteCharactersInRange: (#/mirror self) range))
    441441  (let* ((display (hemlock-buffer-string-cache (#/hemlockString self))))
    442442    (reset-buffer-cache display)
     
    454454  (declare (ignorable extra))
    455455  (let* ((hemlock-string (#/hemlockString self))
    456          (cache (#/cache self)))
     456         (mirror (#/mirror self)))
    457457    (ns:with-ns-range (range pos n)
    458458      (#/replaceCharactersInRange:withString:
    459        cache range (#/substringWithRange: hemlock-string range))
     459       mirror range (#/substringWithRange: hemlock-string range))
    460460      (#/edited:range:changeInLength: self (logior #$NSTextStorageEditedCharacters
    461461                                                   #$NSTextStorageEditedAttributes) range 0)))
     
    471471                                                                   (fontnum :<NSI>nteger))
    472472  (ns:with-ns-range (range pos n)
    473     (#/setAttributes:range: (#/cache self) (#/objectAtIndex: (#/styles self) fontnum) range)
     473    (#/setAttributes:range: (#/mirror self) (#/objectAtIndex: (#/styles self) fontnum) range)
    474474    (#/edited:range:changeInLength: self #$NSTextStorageEditedAttributes range 0)))
    475475
     
    516516  (slot-value self 'string))
    517517
    518 (objc:defmethod #/cache ((self hemlock-text-storage))
    519   (slot-value self 'cache))
     518(objc:defmethod #/mirror ((self hemlock-text-storage))
     519  (slot-value self 'mirror))
    520520
    521521(objc:defmethod #/hemlockString ((self hemlock-text-storage))
     
    540540  (let* ((newself (#/init self))
    541541         (styles (make-editor-style-map))
    542          (cache (#/retain (make-instance ns:ns-mutable-attributed-string
     542         (mirror (#/retain (make-instance ns:ns-mutable-attributed-string
    543543                                   :with-string s
    544544                                   :attributes (#/objectAtIndex: styles 0)))))
     
    546546    (setf (slot-value newself 'styles) styles)
    547547    (setf (slot-value newself 'hemlock-string) s)
    548     (setf (slot-value newself 'cache) cache)
    549     (setf (slot-value newself 'string) (#/retain (#/string cache)))
     548    (setf (slot-value newself 'mirror) mirror)
     549    (setf (slot-value newself 'string) (#/retain (#/string mirror)))
    550550    newself))
    551551
    552552;;; Should generally only be called after open/revert.
    553 (objc:defmethod (#/updateCache :void) ((self hemlock-text-storage))
    554   (with-slots (hemlock-string cache styles) self
    555     (#/replaceCharactersInRange:withString: cache (ns:make-ns-range 0 (#/length cache)) hemlock-string)
    556     (#/setAttributes:range: cache (#/objectAtIndex: styles 0) (ns:make-ns-range 0 (#/length cache)))))
     553(objc:defmethod (#/updateMirror :void) ((self hemlock-text-storage))
     554  (with-slots (hemlock-string mirror styles) self
     555    (#/replaceCharactersInRange:withString: mirror (ns:make-ns-range 0 (#/length mirror)) hemlock-string)
     556    (#/setAttributes:range: mirror (#/objectAtIndex: styles 0) (ns:make-ns-range 0 (#/length mirror)))))
    557557
    558558;;; This is the only thing that's actually called to create a
     
    573573  #+debug
    574574  (#_NSLog #@"Attributes at index: %lu storage %@" :<NSUI>nteger index :id self)
    575   (with-slots (cache styles) self
    576     (when (>= index (#/length cache))
    577       (#_NSLog #@"Attributes at index: %lu  edit-count: %d cache: %@ layout: %@" :<NSUI>nteger index ::unsigned (slot-value self 'edit-count) :id cache :id (#/objectAtIndex: (#/layoutManagers self) 0))
     575  (with-slots (mirror styles) self
     576    (when (>= index (#/length mirror))
     577      (#_NSLog #@"Attributes at index: %lu  edit-count: %d mirror: %@ layout: %@" :<NSUI>nteger index ::unsigned (slot-value self 'edit-count) :id mirror :id (#/objectAtIndex: (#/layoutManagers self) 0))
    578578      (for-each-textview-using-storage self
    579579                                       (lambda (tv)
     
    582582                                           (process-interrupt proc #'dbg))))
    583583      (dbg))
    584     (let* ((attrs (#/attributesAtIndex:effectiveRange: cache index rangeptr)))
     584    (let* ((attrs (#/attributesAtIndex:effectiveRange: mirror index rangeptr)))
    585585      (when (eql 0 (#/count attrs))
    586586        (#_NSLog #@"No attributes ?")
    587587        (ns:with-ns-range (r)
    588588          (#/attributesAtIndex:longestEffectiveRange:inRange:
    589            cache index r (ns:make-ns-range 0 (#/length cache)))
     589           mirror index r (ns:make-ns-range 0 (#/length mirror)))
    590590          (setq attrs (#/objectAtIndex: styles 0))
    591           (#/setAttributes:range: cache attrs r)))
     591          (#/setAttributes:range: mirror attrs r)))
    592592      attrs)))
    593593
     
    631631  #+debug
    632632  (#_NSLog #@"Set attributes: %@ at %d/%d" :id attributes :int (pref r :<NSR>ange.location) :int (pref r :<NSR>ange.length))
    633   (with-slots (cache) self
    634     (#/setAttributes:range: cache attributes r)
     633  (with-slots (mirror) self
     634    (#/setAttributes:range: mirror attributes r)
    635635      #+debug
    636       (#_NSLog #@"Assigned attributes = %@" :id (#/attributesAtIndex:effectiveRange: cache (pref r :<NSR>ange.location) +null-ptr+))))
     636      (#_NSLog #@"Assigned attributes = %@" :id (#/attributesAtIndex:effectiveRange: mirror (pref r :<NSR>ange.location) +null-ptr+))))
    637637
    638638(defun for-each-textview-using-storage (textstorage f)
     
    21162116                                                display
    21172117                                                (min newlen pointpos))))
    2118     (#/updateCache textstorage)
     2118    (#/updateMirror textstorage)
    21192119    (#/endEditing textstorage)
    21202120    (hi::document-set-point-position self)
     
    21812181               (display (hemlock-buffer-string-cache (#/hemlockString textstorage))))
    21822182          (reset-buffer-cache display)
    2183           (#/updateCache textstorage)
     2183          (#/updateMirror textstorage)
    21842184          (update-line-cache-for-index display 0)
    21852185          (textstorage-note-insertion-at-position
Note: See TracChangeset for help on using the changeset viewer.