highlight search hits in embedded editors

This commit is contained in:
Robby Findler 2016-07-23 09:18:03 -05:00
parent 28ca7c6d14
commit 52300ff032

View File

@ -1544,10 +1544,13 @@
(lt (get-the-position (car l)) (lt (get-the-position (car l))
(get-the-position (car r)))])]))) (get-the-position (car r)))])])))
(define all-txt-with-regions-to-clear (make-hasheq))
(define/private (clear-all-regions) (define/private (clear-all-regions)
(when to-replace-highlight (when to-replace-highlight
(unhighlight-replace)) (unhighlight-replace))
(unhighlight-ranges/key 'plt:framework:search-bubbles) (for ([(txt _) (in-hash all-txt-with-regions-to-clear)])
(send txt unhighlight-ranges/key 'plt:framework:search-bubbles))
(set! all-txt-with-regions-to-clear (make-hasheq))
(set! search-bubble-table (make-hash))) (set! search-bubble-table (make-hash)))
(define/private (do-search start) (define/private (do-search start)
@ -1603,6 +1606,7 @@
(hash-set! search-bubble-table bubble #t) (hash-set! search-bubble-table bubble #t)
(define-values (txt start end) (get-highlighting-text-and-range bubble)) (define-values (txt start end) (get-highlighting-text-and-range bubble))
(when txt (when txt
(hash-set! all-txt-with-regions-to-clear txt #t)
(send txt highlight-range (send txt highlight-range
start end start end
(if replace-mode? light-search-color normal-search-color) (if replace-mode? light-search-color normal-search-color)
@ -1636,11 +1640,14 @@
'hollow-ellipse))) 'hollow-ellipse)))
(define/private (get-highlighting-text-and-range bubble) (define/private (get-highlighting-text-and-range bubble)
(cond (let loop ([txt this]
[(number? (car bubble)) [txt/pr (car bubble)])
(values this (car bubble) (+ (car bubble) (cdr bubble)))] (cond
[else [(number? txt/pr)
(values #f #f #f)])) (if (is-a? txt text:basic<%>)
(values txt txt/pr (+ txt/pr (cdr bubble)))
(values #f #f #f))]
[else (loop (car txt/pr) (cdr txt/pr))])))
(define/private (unhighlight-anchor) (define/private (unhighlight-anchor)
(unhighlight-range anchor-pos anchor-pos "red" #f 'dot) (unhighlight-range anchor-pos anchor-pos "red" #f 'dot)