fixed some bugs in the yellow highlighting

svn: r11750
This commit is contained in:
Robby Findler 2008-09-14 23:19:42 +00:00
parent c870eadf03
commit bd954710f6

View File

@ -986,7 +986,6 @@ WARNING: printf is rebound in the body of the unit to always
(define/augment (on-insert start len) (define/augment (on-insert start len)
(begin-edit-sequence) (begin-edit-sequence)
(clear-all-regions) (clear-all-regions)
(update-yellow)
(inner (void) on-insert start len)) (inner (void) on-insert start len))
(define/augment (after-insert start len) (define/augment (after-insert start len)
(unless updating-search? (unless updating-search?
@ -1001,7 +1000,6 @@ WARNING: printf is rebound in the body of the unit to always
(define/augment (after-delete start len) (define/augment (after-delete start len)
(unless updating-search? (unless updating-search?
(content-changed)) (content-changed))
(update-yellow)
(inner (void) after-delete start len) (inner (void) after-delete start len)
(end-edit-sequence)) (end-edit-sequence))
@ -1033,17 +1031,16 @@ WARNING: printf is rebound in the body of the unit to always
(define/override (on-focus on?) (define/override (on-focus on?)
(let ([f (get-top-level-window)]) (let ([f (get-top-level-window)])
(when (is-a? f frame:searchable<%>) (when (is-a? f frame:searchable<%>)
(when on? (set! has-focus? on?)
(send f set-text-to-search this) (cond
(clear-yellow) [on?
(set! clear-yellow void)) ;; this triggers a call to update-yellow
(set! do-yellow? (send f set-text-to-search this)]
(and (not on?) [else
(eq? (send f get-text-to-search) this))) (update-yellow)])))
(update-yellow)))
(super on-focus on?)) (super on-focus on?))
(define do-yellow? #f) (define has-focus? #f)
(define clear-yellow void) (define clear-yellow void)
(define/augment (after-set-position) (define/augment (after-set-position)
(update-yellow) (update-yellow)
@ -1077,17 +1074,29 @@ WARNING: printf is rebound in the body of the unit to always
(send tlw search-hits-changed))))) (send tlw search-hits-changed)))))
(define/private (update-yellow) (define/private (update-yellow)
(when do-yellow? (cond
(let ([start (get-start-position)] [has-focus?
[end (get-end-position)]) (unless (eq? clear-yellow void)
(unless (= start end) (clear-yellow)
(begin-edit-sequence) (set! clear-yellow void))]
(clear-yellow) [searching-str
(set! clear-yellow void) (let ([start (get-start-position)]
(when searching-str [end (get-end-position)])
(when (do-search searching-str start end) (cond
(set! clear-yellow (highlight-range start end "khaki" #f 'low 'ellipse)))) [(= start end)
(end-edit-sequence))))) (clear-yellow)
(set! clear-yellow void)]
[else
(begin-edit-sequence)
(clear-yellow)
(set! clear-yellow void)
(when (and searching-str (= (string-length searching-str) (- end start)))
(when (do-search searching-str start end)
(set! clear-yellow (highlight-range start end "khaki" #f 'low 'ellipse))))
(end-edit-sequence)]))]
[else
(clear-yellow)
(set! clear-yellow void)]))
(define/public (get-search-bubbles) (define/public (get-search-bubbles)
(sort (hash-map search-bubble-table (sort (hash-map search-bubble-table
@ -1161,6 +1170,8 @@ WARNING: printf is rebound in the body of the unit to always
'hollow-ellipse)))))] 'hollow-ellipse)))))]
[else [else
(invalidate-bitmap-cache)]) (invalidate-bitmap-cache)])
(update-yellow)
(end-edit-sequence) (end-edit-sequence)
;; stopping the timer ensures that when there is both an edit to the buffer *and* ;; stopping the timer ensures that when there is both an edit to the buffer *and*