changed serching text notification from pull-style to push-style, ie the text now notifies the frame when it wants to be actived for searching instead of waiting for the frame to ask
svn: r10858
This commit is contained in:
parent
a690f715c5
commit
bd6ed2dfc2
|
@ -356,11 +356,6 @@
|
|||
(frame:searchable-mixin
|
||||
frame:standard-menus%))
|
||||
(init-field name)
|
||||
|
||||
(field [text-to-search #f])
|
||||
(define/public (set-text-to-search text) (set! text-to-search text))
|
||||
(define/override (get-text-to-search) text-to-search)
|
||||
|
||||
(define/override (on-size w h)
|
||||
(preferences:set 'drscheme:multi-file-search:frame-size (cons w h))
|
||||
(super on-size w h))
|
||||
|
|
|
@ -1577,10 +1577,6 @@ module browser threading seems wrong.
|
|||
(define/public (make-searchable canvas)
|
||||
(update-info)
|
||||
(set! search-canvas canvas))
|
||||
(define/override (get-text-to-search)
|
||||
(if search-canvas
|
||||
(send search-canvas get-editor)
|
||||
(get-editor)))
|
||||
|
||||
(define was-locked? #f)
|
||||
|
||||
|
@ -2497,6 +2493,7 @@ module browser threading seems wrong.
|
|||
(list x y w h)))
|
||||
(send txt get-canvases)))
|
||||
|
||||
(inherit set-text-to-search)
|
||||
(define/private (restore-visible-tab-regions)
|
||||
(define (set-visible-regions txt regions ints?)
|
||||
(when regions
|
||||
|
@ -2543,8 +2540,12 @@ module browser threading seems wrong.
|
|||
(set-visible-regions definitions-text vd #f)
|
||||
(set-visible-regions interactions-text vi #t))
|
||||
(case (send current-tab get-focus-d/i)
|
||||
[(defs) (send (car definitions-canvases) focus)]
|
||||
[(ints) (send (car interactions-canvases) focus)]))
|
||||
[(defs)
|
||||
(send (car definitions-canvases) focus)
|
||||
(set-text-to-search (send (car definitions-canvases) get-editor))]
|
||||
[(ints)
|
||||
(send (car interactions-canvases) focus)
|
||||
(set-text-to-search (send (car interactions-canvases) get-editor))]))
|
||||
|
||||
(define/private (pathname-equal? p1 p2)
|
||||
(with-handlers ([exn:fail:filesystem? (λ (x) #f)])
|
||||
|
|
|
@ -1670,8 +1670,9 @@
|
|||
(init-find/replace-edits)
|
||||
(keymap:call/text-keymap-initializer
|
||||
(λ ()
|
||||
(let* ([to-be-searched-text (send frame get-text-to-search)]
|
||||
[to-be-searched-canvas (send to-be-searched-text get-canvas)]
|
||||
(let ([to-be-searched-text (send frame get-text-to-search)])
|
||||
(when to-be-searched-text
|
||||
(let* ([to-be-searched-canvas (send to-be-searched-text get-canvas)]
|
||||
|
||||
[allow-replace? (not (send to-be-searched-text is-locked?))]
|
||||
|
||||
|
@ -1811,10 +1812,11 @@
|
|||
(when to-be-searched-canvas
|
||||
(send to-be-searched-canvas force-display-focus #t))
|
||||
(send dialog show #t)
|
||||
(remove-pref-callback)))))
|
||||
(remove-pref-callback)))))))
|
||||
|
||||
(define searchable<%> (interface (basic<%>)
|
||||
get-text-to-search
|
||||
set-text-to-search
|
||||
hide-search
|
||||
unhide-search
|
||||
set-search-direction
|
||||
|
@ -1951,9 +1953,9 @@
|
|||
(lambda ([reset-search-anchor? #t] [beep? #t] [wrap? #t])
|
||||
(when searching-frame
|
||||
(let* ([string (get-text)]
|
||||
[top-searching-edit (get-searching-edit)]
|
||||
|
||||
[searching-edit (let ([focus-snip (send top-searching-edit get-focus-snip)])
|
||||
[top-searching-edit (get-searching-edit)])
|
||||
(when top-searching-edit
|
||||
(let ([searching-edit (let ([focus-snip (send top-searching-edit get-focus-snip)])
|
||||
(if focus-snip
|
||||
(send focus-snip get-editor)
|
||||
top-searching-edit))]
|
||||
|
@ -2039,7 +2041,7 @@
|
|||
(found found-edit pos))))
|
||||
(not-found found-edit #f))]
|
||||
[else
|
||||
(found found-edit first-pos)]))))))))
|
||||
(found found-edit first-pos)]))))))))))
|
||||
(field [dont-search #f]
|
||||
[case-sensitive? (preferences:get 'framework:case-sensitive-search?)])
|
||||
(define/public (toggle-case-sensitive)
|
||||
|
@ -2055,7 +2057,7 @@
|
|||
(when on?
|
||||
(let ([edit (get-searching-edit)])
|
||||
(when edit
|
||||
(reset-search-anchor (get-searching-edit)))))
|
||||
(reset-search-anchor edit))))
|
||||
(super on-focus on?))
|
||||
(define/augment (after-insert x y)
|
||||
(unless dont-search
|
||||
|
@ -2142,12 +2144,15 @@
|
|||
(define/override (on-activate on?)
|
||||
(unless hidden?
|
||||
(if on?
|
||||
(reset-search-anchor (get-text-to-search))
|
||||
(let ([txt (get-text-to-search)])
|
||||
(when txt
|
||||
(reset-search-anchor txt)))
|
||||
(clear-search-highlight)))
|
||||
(super on-activate on?))
|
||||
|
||||
(define/public (get-text-to-search)
|
||||
(error 'get-text-to-search "abstract method in searchable-mixin"))
|
||||
(define text-to-search #f)
|
||||
(define/public (set-text-to-search txt) (set! text-to-search txt))
|
||||
(define/public-final (get-text-to-search) text-to-search)
|
||||
|
||||
(define/public hide-search
|
||||
(lambda ([startup? #f])
|
||||
|
@ -2156,13 +2161,14 @@
|
|||
(λ (l)
|
||||
(remove search-panel l))))
|
||||
(clear-search-highlight)
|
||||
#;
|
||||
(send (get-text-to-search) set-searching-str #f #f)
|
||||
(let ([txt (get-text-to-search)])
|
||||
(when txt
|
||||
#;(send txt set-searching-str #f #f)
|
||||
(unless startup?
|
||||
(let ([canvas (send (get-text-to-search) get-canvas)])
|
||||
(let ([canvas (send txt get-canvas)])
|
||||
(when canvas
|
||||
(send canvas force-display-focus #f)
|
||||
(send canvas focus))))
|
||||
(send canvas focus))))))
|
||||
(set! hidden? #t)))
|
||||
|
||||
(define/public (unhide-search)
|
||||
|
@ -2172,21 +2178,24 @@
|
|||
|
||||
(build-search-gui-in-frame)
|
||||
|
||||
(let ([canvas (send (get-text-to-search) get-canvas)])
|
||||
(let ([txt (get-text-to-search)])
|
||||
(when txt
|
||||
(let ([canvas (send txt get-canvas)])
|
||||
(when canvas
|
||||
(send canvas force-display-focus #t)))
|
||||
(show/hide-replace (send (get-text-to-search) is-locked?))
|
||||
(send canvas force-display-focus #t))))
|
||||
(show/hide-replace (and txt (send txt is-locked?)))
|
||||
(send search-panel focus)
|
||||
(send find-edit set-position 0 (send find-edit last-position))
|
||||
|
||||
#;
|
||||
(send (get-text-to-search) set-searching-str
|
||||
(send txt set-searching-str
|
||||
(send find-edit get-text)
|
||||
(send find-edit get-case-sensitive?))
|
||||
|
||||
(unless (memq search-panel (send super-root get-children))
|
||||
(send super-root add-child search-panel))
|
||||
(reset-search-anchor (get-text-to-search))))
|
||||
(when txt
|
||||
(reset-search-anchor txt)))))
|
||||
|
||||
(define/private (undock)
|
||||
(preferences:set 'framework:search-using-dialog? #t)
|
||||
|
@ -2252,13 +2261,15 @@
|
|||
(send find-edit get-text 0 (send find-edit last-position)))))))
|
||||
(define (replace&search)
|
||||
(let ([text (get-text-to-search)])
|
||||
(when text
|
||||
(send text begin-edit-sequence)
|
||||
(when (replace)
|
||||
(search-again))
|
||||
(send text end-edit-sequence)))
|
||||
(send text end-edit-sequence))))
|
||||
(define (replace-all)
|
||||
(let* ([replacee-edit (get-text-to-search)]
|
||||
[embeded-replacee-edit (find-embedded-focus-editor replacee-edit)]
|
||||
(let ([replacee-edit (get-text-to-search)])
|
||||
(when replacee-edit
|
||||
(let* ([embeded-replacee-edit (find-embedded-focus-editor replacee-edit)]
|
||||
[pos (if (eq? searching-direction 'forward)
|
||||
(send embeded-replacee-edit get-start-position)
|
||||
(send embeded-replacee-edit get-end-position))]
|
||||
|
@ -2272,11 +2283,14 @@
|
|||
(when (send find-edit search #t #f #f)
|
||||
(replace)
|
||||
(loop))))
|
||||
(send replacee-edit end-edit-sequence)))
|
||||
(send replacee-edit end-edit-sequence)))))
|
||||
(define (replace)
|
||||
(let* ([search-text (send find-edit get-text)]
|
||||
[replacee-edit (find-embedded-focus-editor (get-text-to-search))]
|
||||
[replacee-start (send replacee-edit get-start-position)]
|
||||
(let ([search-text (send find-edit get-text)]
|
||||
[replacee-edit (let ([txt (get-text-to-search)])
|
||||
(and txt
|
||||
(find-embedded-focus-editor txt)))])
|
||||
(and replacee-edit
|
||||
(let* ([replacee-start (send replacee-edit get-start-position)]
|
||||
[new-text (send replace-edit get-text)]
|
||||
[replacee (send replacee-edit get-text
|
||||
replacee-start
|
||||
|
@ -2291,7 +2305,7 @@
|
|||
replacee-start
|
||||
(+ replacee-start (string-length new-text)))
|
||||
#t)
|
||||
#f)))
|
||||
#f)))))
|
||||
|
||||
(define/private (find-embedded-focus-editor editor)
|
||||
(let loop ([editor editor])
|
||||
|
@ -2308,14 +2322,15 @@
|
|||
(when find-canvas
|
||||
(set-searching-frame this)
|
||||
(unhide-search)
|
||||
(send (cond
|
||||
(cond
|
||||
[(send find-canvas has-focus?)
|
||||
replace-canvas]
|
||||
(send replace-canvas focus)]
|
||||
[(send replace-canvas has-focus?)
|
||||
(send (get-text-to-search) get-canvas)]
|
||||
(let ([txt (get-text-to-search)])
|
||||
(when txt
|
||||
(send (send txt get-canvas) focus)))]
|
||||
[else
|
||||
find-canvas])
|
||||
focus)))
|
||||
(send find-canvas focus)])))
|
||||
(define (move-to-search-or-search)
|
||||
(set-searching-frame this)
|
||||
(unhide-search)
|
||||
|
@ -2422,7 +2437,9 @@
|
|||
'forward
|
||||
'backward)])
|
||||
(set-search-direction forward)
|
||||
(reset-search-anchor (get-text-to-search)))))))
|
||||
(let ([txt (get-text-to-search)])
|
||||
(when txt
|
||||
(reset-search-anchor txt))))))))
|
||||
|
||||
(define _10
|
||||
(begin
|
||||
|
@ -2472,8 +2489,6 @@
|
|||
(define searchable-text-mixin
|
||||
(mixin (text<%> searchable<%>) (searchable-text<%>)
|
||||
(inherit get-editor)
|
||||
(define/override (get-text-to-search)
|
||||
(get-editor))
|
||||
(define/override (get-editor<%>) text:searching<%>)
|
||||
(define/override (get-editor%) text:searching%)
|
||||
(super-new)))
|
||||
|
|
|
@ -578,6 +578,14 @@ WARNING: printf is rebound in the body of the unit to always
|
|||
(redo-search)
|
||||
(inner (void) after-delete start len))
|
||||
|
||||
(inherit get-top-level-window)
|
||||
(define/override (on-focus on?)
|
||||
(let ([f (get-top-level-window)])
|
||||
(when (is-a? f frame:searchable<%>)
|
||||
(when on?
|
||||
(send f set-text-to-search this))))
|
||||
(super on-focus on?))
|
||||
|
||||
(inherit highlight-range begin-edit-sequence end-edit-sequence find-string)
|
||||
|
||||
(define clear-regions void)
|
||||
|
|
|
@ -886,12 +886,12 @@
|
|||
}
|
||||
@definterface[frame:searchable<%> (frame:basic<%>)]{
|
||||
Frames that implement this interface support searching.
|
||||
@defmethod*[(((get-text-to-search) (instance (subclass?/c text%))))]{
|
||||
Override this method to specify which text to search.
|
||||
|
||||
|
||||
Returns the result of
|
||||
@method[frame:editor<%> get-editor].
|
||||
@defmethod*[(((get-text-to-search) (is-a?/c (subclass?/c text%))))]{
|
||||
Returns the last value passed to
|
||||
@method[frame:searchable<%> set-text-to-search].
|
||||
}
|
||||
@defmethod[(set-text-to-search [txt (or/c false/c (is-a?/c (subclass?/c text%)))]) void?]{
|
||||
Sets the current text to be searched.
|
||||
}
|
||||
@defmethod*[(((hide-search) void))]{
|
||||
This method hides the searching information on the bottom of the
|
||||
|
|
Loading…
Reference in New Issue
Block a user