Changeset 6622


Ignore:
Timestamp:
May 28, 2007, 12:51:56 AM (18 years ago)
Author:
Gary Byers
Message:

Insertion uses active font; should unscramble this some more, but
it looks like the cached attributed string is working, as far as it
goes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ide-1.0/ccl/examples/cocoa-editor.lisp

    r6614 r6622  
    536536  #+debug
    537537  (#_NSLog #@"Attributes at index: %d" :unsigned index)
    538   #-no
     538  #+no
    539539  (let* ((buffer-cache (hemlock-buffer-string-cache (slot-value self 'string)))
    540540         (buffer (buffer-cache-buffer buffer-cache))
     
    562562              (pref rangeptr :<NSR>ange.length) len))
    563563      (svref *styles* style)))
    564   #+no
     564  #-no
    565565  (with-slots (cache) self
    566566    (let* ((attrs (#/attributesAtIndex:effectiveRange: cache index rangeptr)))
     
    16821682                                        n))))
    16831683
     1684(defun buffer-active-font (buffer)
     1685  (let* ((style 0)
     1686         (region (hi::buffer-active-font-region buffer)))
     1687    (when region
     1688      (let* ((start (hi::region-end region)))
     1689        (setq style (hi::font-mark-font start))))
     1690    (svref *styles* style)))
     1691     
    16841692(defun hi::buffer-note-insertion (buffer mark n)
    16851693  (when (hi::bufferp buffer)
     
    16891697        (let* ((pos (mark-absolute-position mark))
    16901698               (cache (#/cache textstorage))
    1691                (hemlock-string (#/string textstorage)))
     1699               (hemlock-string (#/string textstorage))
     1700               (display (hemlock-buffer-string-cache hemlock-string))
     1701               (buffer (buffer-cache-buffer display))
     1702               (font (buffer-active-font buffer)))
    16921703          (unless (eq (hi::mark-%kind mark) :right-inserting)
    16931704            (decf pos n))
    16941705          #+debug
    1695           (format t "~&insert: pos = ~d, n = ~d" pos n)
    1696           (let* ((display (hemlock-buffer-string-cache hemlock-string)))
    1697             ;(reset-buffer-cache display)
    1698             (adjust-buffer-cache-for-insertion display pos n)
    1699             (update-line-cache-for-index display pos))
     1706          (#_NSLog #@"insert: pos = %d, n = %d" :int pos :int n)
     1707          ;;(reset-buffer-cache display)
     1708          (adjust-buffer-cache-for-insertion display pos n)
     1709          (update-line-cache-for-index display pos)
    17001710          (#/replaceCharactersInRange:withString:
    17011711           cache (ns:make-ns-range pos 0)
    1702            (#/substringWithRange: hemlock-string (ns:make-ns-range pos n)))
     1712           (#/substringWithRange: hemlock-string (ns:make-ns-range pos n)))
     1713          (#/setAttributes:range: cache font (ns:make-ns-range pos n))
    17031714          #-all-in-cocoa-thread
    17041715          (textstorage-note-insertion-at-position textstorage pos n)
     
    19361947        (let* ((textstorage (slot-value self 'textstorage))
    19371948               (display (hemlock-buffer-string-cache (#/string textstorage))))
     1949          (reset-buffer-cache display)
    19381950          (#/updateCache textstorage)
    1939           (reset-buffer-cache display)
    19401951          (update-line-cache-for-index display 0)
    19411952          (textstorage-note-insertion-at-position
     
    21002111      (setq *hemlock-document-controller* (call-next-method))
    21012112      (setf (slot-value *hemlock-document-controller* 'last-encoding) 0))))
     2113
     2114(defun iana-charset-name-of-nsstringencoding (ns)
     2115  (#_CFStringConvertEncodingToIANACharSetName
     2116   (#_CFStringConvertNSStringEncodingToEncoding ns)))
     2117   
    21022118
    21032119;;; Return a list of :<NSS>tring<E>ncodings, sorted by the
Note: See TracChangeset for help on using the changeset viewer.