[Openmcl-devel] The smoking cursor

Ron Garret ron at awun.net
Sun Jan 27 20:42:29 UTC 2008


This is again in reference to the matching-paren highlighting bug  
(ticket 64).

The following code causes matching parens to blink red-green instead  
of black-white.  They blink red when the cursor is visible and green  
when the cursor is not visible.  If you try it you will see the  
following:

1.  When you type a close paren there is a VERY brief flash of green  
on the matching open paren.  (Uncomment the call to sleep to make this  
more apparent.  But this breaks double-clicking for some reason so you  
won't want to leave it uncommented.)

2.  Despite the fact that this code ONLY paints close parens with  
either a red or a green background, the screen nonetheless does not  
get filled with red and green squares.  Some other code somewhere is  
helpfully making the background of the matching parens white again.  I  
believe it is THAT code that is the source of the bug.  But I have no  
idea how to even begin trying to figure out where that code is.

BTW, note that the call to flushGraphics is missing in the original  
code, but it is necessary to make the brief green flash on keypresses  
manifest themselves.  I suspect this is a clue.

rg

---

(in-package "GUI")

;;; Maybe cause 1 character in the textview to blink (by drawing an  
empty
;;; character rectangle) in synch with the insertion point.

(objc:defmethod (#/drawInsertionPointInRect:color:turnedOn: :void)
     ((self hemlock-textstorage-text-view)
      (r :<NSR>ect)
      color
      (flag :<BOOL>))
   (unless (#/editingInProgress (#/textStorage self))
     (unless (eql #$NO (text-view-blink-enabled self))
       (let* ((layout (#/layoutManager self))
              (container (#/textContainer self))
              (blink-color (text-view-blink-color self)))
         (ns:with-ns-range  (char-range (text-view-blink-location  
self) 1)
           (let* ((glyph-range (#/ 
glyphRangeForCharacterRange:actualCharacterRange:
                                layout
                                char-range
                                +null-ptr+))
                  (rect (#/boundingRectForGlyphRange:inTextContainer:
                         layout
                         glyph-range
                         container)))
             (#/set blink-color)
             (#/set (if flag (#/redColor ns:ns-color) (#/greenColor  
ns:ns-color)))
             (#_NSRectFill rect)
             (unless flag
               (#/drawGlyphsForGlyphRange:atPoint:
                layout glyph-range (#/textContainerOrigin self)))
             (#/flushGraphics (#/currentContext ns:ns-graphics-context))
            ; (sleep 0.1)
             )))))
   (call-next-method r color flag))



More information about the Openmcl-devel mailing list