Changeset 11619


Ignore:
Timestamp:
Jan 15, 2009, 11:51:07 AM (11 years ago)
Author:
gb
Message:

Fix (from Shannon Spires, over a year ago) to treat Caps Lock like
shift when mapping key events. (See ticket:219.)

Subclass NSClipView; use an instance of that clip view when embedding
a hemlock text view in a scroll view. Define a scrollToPoint: method
on that NSClipView subclass, so that we can tell when scrolling occurs
and update transient text attributes when it does. (May need to
handle cases when the view is enlarged vertically, as well.)

Try to finally fix ticket:150 (confused by double-click after close
paren at end of file.) There may have been similar problems having
to do with double-clicking before an open paren at the beginning
of the file; this would be caused by Hemlock's VALID-SPOT-P believing
that position 0 (at least) is in the attribute line. (Should probably
change the Hemlock code; files don't necessarily have attribute lines,
and there are probably better ways of telling whether or not we're
in te middle of one.) At EOF, Cocoa claims that a double-click is
trying to select a character (not a word or para); in order to
determine whether we got a single or multi-click, look at the current
event. On Leopard at least, the proposed range is correct in this
case (and it's the granularity that's confused us); should check
Tiger.

Try to clean up some cases where paren highlighting isn't cleared
when it should be. Wouldn't want to claim that no such cases remain,
but it's better.

File:
1 edited

Legend:

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

    r11616 r11619  
    947947            (let* ((char (code-char c)))
    948948              (when (and char (standard-char-p char))
    949                 (setq bits (logandc2 bits +shift-event-mask+))))
     949                (setq bits (logandc2 bits +shift-event-mask+)))
     950              (when (logtest #$NSAlphaShiftKeyMask modifiers)
     951                (setf c (char-code (char-upcase char)))))
    950952            (hi:make-key-event c bits)))))))
    951953
     
    10151017  (let* ((left (text-view-paren-highlight-left-pos self))
    10161018         (right (text-view-paren-highlight-right-pos self)))
    1017     (ns:with-ns-range  (char-range left (1+ (- right left)))
     1019    (ns:with-ns-range  (char-range left 1)
    10181020      (let* ((layout (#/layoutManager self)))
    1019         (#/removeTemporaryAttribute:forCharacterRange: layout #&NSBackgroundColorAttributeName char-range)))))
     1021        (#/removeTemporaryAttribute:forCharacterRange:
     1022         layout #&NSBackgroundColorAttributeName
     1023         char-range)
     1024        (setf (pref char-range #>NSRange.location) right)
     1025        (#/removeTemporaryAttribute:forCharacterRange:
     1026         layout #&NSBackgroundColorAttributeName
     1027         char-range)))))
    10201028
    10211029(defmethod disable-paren-highlight ((self hemlock-textstorage-text-view))
    10221030  (when (eql (text-view-paren-highlight-enabled self) #$YES)
    1023     (setf (text-view-paren-highlight-enabled self) #$NO)))
    1024 
     1031    (setf (text-view-paren-highlight-enabled self) #$NO)
     1032    (remove-paren-highlight self)))
    10251033
    10261034
     
    13461354  (objc:returning-foreign-struct (r)
    13471355     (block HANDLED
    1348        (let* ((index (ns:ns-range-location proposed))             
    1349               (length (ns:ns-range-length proposed)))
     1356       (let* ((index (ns:ns-range-location proposed)) 
     1357              (length (ns:ns-range-length proposed))
     1358              (textstorage (#/textStorage self)))
    13501359         (when (and (eql 0 length)      ; not extending existing selection
    1351                     (not (eql g #$NSSelectByCharacter)))
    1352            (let* ((textstorage (#/textStorage self))
    1353                   (cache (hemlock-buffer-string-cache (#/hemlockString textstorage)))
     1360                    (or (not (eql g #$NSSelectByCharacter))
     1361                        (and (eql index (#/length textstorage))
     1362                             (let* ((event (#/currentEvent (#/window self))))
     1363                               (and (eql (#/type event) #$NSLeftMouseDown)
     1364                                    (> (#/clickCount event) 1))))))
     1365           (let* ((cache (hemlock-buffer-string-cache (#/hemlockString textstorage)))
    13541366                  (buffer (if cache (buffer-cache-buffer cache))))
    13551367             (when (and buffer (string= (hi::buffer-major-mode buffer) "Lisp"))
     
    16261638
    16271639
    1628 
    1629 
    1630 
     1640;;; A clip view subclass, which exists mostlu so that we can track origin changes.
     1641(defclass text-pane-clip-view (ns:ns-clip-view)
     1642  ()
     1643  (:metaclass ns:+ns-object))
     1644
     1645(objc:defmethod (#/scrollToPoint: :void) ((self text-pane-clip-view)
     1646                                           (origin #>NSPoint))
     1647  (call-next-method origin)
     1648  (compute-temporary-attributes (#/documentView self)))
    16311649
    16321650;;; Text-pane
     
    17621780                    (#/setHorizontallyResizable: tv t)
    17631781                    (#/setVerticallyResizable: tv t)))
    1764 
     1782                (#/setContentView: scrollview (make-instance 'text-pane-clip-view))
    17651783                (#/setDocumentView: scrollview tv)           
    17661784                (values tv scrollview)))))))))
Note: See TracChangeset for help on using the changeset viewer.