more adjustments to searching and related things

svn: r10939
This commit is contained in:
Robby Findler 2008-07-28 03:48:23 +00:00
parent a71b13eacd
commit b088ac9c74
10 changed files with 332 additions and 273 deletions

View File

@ -306,7 +306,19 @@ TODO
(λ (obj evt)
(with-drs-frame
obj
(λ (frame) (send frame prev-tab))))))
(λ (frame) (send frame prev-tab)))))
(send drs-bindings-keymap add-function
"collapse"
(λ (obj evt)
(with-drs-frame
obj
(λ (frame) (send frame collapse)))))
(send drs-bindings-keymap add-function
"split"
(λ (obj evt)
(with-drs-frame
obj
(λ (frame) (send frame split))))))
(send drs-bindings-keymap map-function "f5" "execute")
(send drs-bindings-keymap map-function "f1" "search-help-desk")
@ -317,6 +329,9 @@ TODO
(send drs-bindings-keymap map-function "c:pagedown" "next-tab")
(send drs-bindings-keymap map-function "c:pageup" "prev-tab")
(send drs-bindings-keymap map-function "c:x;0" "collapse")
(send drs-bindings-keymap map-function "c:x;2" "split")
(define (get-drs-bindings-keymap) drs-bindings-keymap)
;; drs-bindings-keymap-mixin :

View File

@ -1863,7 +1863,7 @@ module browser threading seems wrong.
(inherit get-edit-target-window)
(define/private (split)
(define/public (split)
(let ([canvas-to-be-split (get-edit-target-window)])
(cond
[(memq canvas-to-be-split definitions-canvases)
@ -2017,7 +2017,7 @@ module browser threading seems wrong.
(unbox bw)
(unbox bh))))
(define/private (collapse)
(define/public (collapse)
(let* ([target (get-edit-target-window)])
(cond
[(memq target definitions-canvases)
@ -3373,16 +3373,16 @@ module browser threading seems wrong.
(make-object separator-menu-item% (get-show-menu))
(new menu:can-restore-menu-item%
(shortcut (if (eq? (system-type) 'macosx) #\r #\m))
(shortcut (if (eq? (system-type) 'macosx) #f #\m))
(label (string-constant split-menu-item-label))
(parent (get-show-menu))
(shortcut-prefix (if (eq? (system-type) 'macosx)
(cons 'shift (get-default-shortcut-prefix))
(get-default-shortcut-prefix)))
(callback (λ (x y) (split)))
(demand-callback (λ (item) (split-demand item))))
(new menu:can-restore-menu-item%
(shortcut #\r)
(shortcut (if (eq? (system-type) 'macosx) #f #\m))
(shortcut-prefix (if (eq? (system-type) 'macosx)
(get-default-shortcut-prefix)
(cons 'shift (get-default-shortcut-prefix))))
(label (string-constant collapse-menu-item-label))
(parent (get-show-menu))
(callback (λ (x y) (collapse)))

View File

@ -1829,12 +1829,14 @@
[else
(found found-edit first-pos)]))))))))
(define callback-queued? #f)
(define/private (update-searching-str)
(let ([tlw (get-top-level-window)])
(when tlw
(let ([txt (send tlw get-text-to-search)])
(when txt
(update-searching-str/cs txt (get-case-sensitive-search?)))))))
(define/public (text-to-search-changed old new)
(when old
@ -1895,6 +1897,17 @@
(set-styles-fixed #t)))
(define search/replace-keymap (new keymap%))
(send search/replace-keymap map-function "tab" "switch-between-search-and-replace")
(send search/replace-keymap add-function "switch-between-search-and-replace"
(λ (text evt)
(let ([find-txt (send (send text get-top-level-window) get-find-edit)]
[replace-txt (send (send text get-top-level-window) get-replace-edit)])
(cond
[(eq? find-txt text)
(send (send replace-txt get-canvas) focus)]
[(eq? replace-txt text)
(send (send find-txt get-canvas) focus)]))))
(send search/replace-keymap map-function "return" "find")
(send search/replace-keymap add-function "find"
(λ (text evt)
@ -1928,7 +1941,10 @@
(super on-paint))
(super-new)))
(define-local-member-name update-matches)
(define-local-member-name
update-matches
get-find-edit
get-replace-edit)
(define searchable-mixin
(mixin (standard-menus<%>) (searchable<%>)
@ -1937,20 +1953,35 @@
(define case-sensitive-search? (preferences:get 'framework:case-sensitive-search?))
(define/public (get-case-sensitive-search?) case-sensitive-search?)
(define/override (edit-menu:find-callback menu evt) (search 'forward) #t)
(define/override (edit-menu:find-callback menu evt)
(cond
[hidden?
(unhide-search #t)]
[(or (not text-to-search)
(send (send text-to-search get-canvas) has-focus?))
(send find-edit set-position 0 (send find-edit last-position))
(send find-canvas focus)]
[else
(let ([canvas (send text-to-search get-canvas)])
(when canvas
(send canvas focus)))])
#t)
(define/override (edit-menu:create-find?) #t)
(define/override (edit-menu:find-backwards-callback menu evt) (search 'backward) #t)
(define/override (edit-menu:create-find-backwards?) #t)
(define/override (edit-menu:find-again-callback menu evt) (search 'forward) #t)
(define/override (edit-menu:create-find-again?) #t)
(define/override (edit-menu:replace-and-find-callback menu evt) (replace&search 'forward) #t)
(define/override (edit-menu:replace-and-find-on-demand item) (send item enable (can-replace?)))
(define/override (edit-menu:create-replace-and-find?) #t)
(define/override (edit-menu:find-again-backwards-callback menu evt) (search 'backward) #t)
(define/override (edit-menu:create-find-again-backwards?) #t)
(define/override (edit-menu:replace-and-find-backwards-callback menu evt) (replace&search 'backward) #t)
(define/override (edit-menu:replace-and-find-backwards-on-demand item)
(define/override (edit-menu:replace-and-find-again-callback menu evt) (replace&search 'forward) #t)
(define/override (edit-menu:replace-and-find-again-on-demand item) (send item enable (can-replace?)))
(define/override (edit-menu:create-replace-and-find-again?) #t)
(define/override (edit-menu:replace-and-find-again-backwards-callback menu evt) (replace&search 'backward) #t)
(define/override (edit-menu:replace-and-find-again-backwards-on-demand item)
(send item enable (can-replace?)))
(define/override edit-menu:create-replace-and-find-backwards? (λ () #t))
(define/override edit-menu:create-replace-and-find-again-backwards? (λ () #t))
(define/override (edit-menu:find-case-sensitive-callback menu evt)
(set! case-sensitive-search? (not case-sensitive-search?))
@ -1965,19 +1996,6 @@
(define/override (edit-menu:replace-all-on-demand item) (send item enable (can-replace?)))
(define/override (edit-menu:create-replace-all?) #t)
(define/override (edit-menu:create-toggle-find-focus?) #t)
(define/override (edit-menu:toggle-find-focus-callback menu evt)
(cond
[hidden?
(unhide-search #t)]
[(or (not text-to-search)
(send (send text-to-search get-canvas) has-focus?))
(send find-canvas focus)]
[else
(let ([canvas (send text-to-search get-canvas)])
(when canvas
(send canvas focus)))]))
(define/override make-root-area-container
(λ (% parent)
(let* ([s-root (super make-root-area-container
@ -2026,11 +2044,11 @@
(when hidden?
(set! hidden? #f)
(build-search-gui-in-frame)
(send find-edit set-position 0 (send find-edit last-position))
(send find-edit text-to-search-changed #f text-to-search)
(unless (memq search/replace-panel (send super-root get-children))
(send super-root add-child search/replace-panel))
(when focus?
(send find-edit set-position 0 (send find-edit last-position))
(send (send find-edit get-canvas) focus))))
(define/public (can-replace?)
@ -2143,6 +2161,9 @@
(define find-edit #f)
(define replace-edit #f)
(define/public (get-find-edit) find-edit)
(define/public (get-replace-edit) replace-edit)
(inherit begin-container-sequence end-container-sequence)
(define/private (build-search-gui-in-frame)
@ -2155,14 +2176,17 @@
(define _0 (set! search/replace-panel (new horizontal-panel%
[parent super-root]
[stretchable-height #f])))
(define search-panel (new horizontal-panel%
[parent search/replace-panel]
[stretchable-height #f]))
(define replace-panel (new horizontal-panel%
[parent search/replace-panel]
[stretchable-height #f]))
(define search-panel
(new horizontal-panel%
[parent search/replace-panel]
[stretchable-height #f]))
(define replace-panel
(new horizontal-panel%
[parent search/replace-panel]
[stretchable-height #f]))
(define _1 (set! find-canvas (new searchable-canvas%
[style '(hide-hscroll hide-vscroll)]
[vertical-inset 2]
[parent search-panel]
[editor find-edit]
[line-count 1]
@ -2170,16 +2194,19 @@
[stretchable-width #t])))
(define _3 (set! replace-canvas (new searchable-canvas%
[style '(hide-hscroll hide-vscroll)]
[vertical-inset 2]
[parent replace-panel]
[editor replace-edit]
[line-count 1]
[stretchable-height #f]
[stretchable-width #t])))
(define search-button (make-object button%
(string-constant find)
search-panel
(λ (x y) (search 'forward))))
(define search-button (new button%
[label (string-constant find)]
[vert-margin 0]
[parent search-panel]
[callback (λ (x y) (search 'forward))]
[font small-control-font]))
(define hits-panel (new vertical-panel%
[parent search-panel]
@ -2189,37 +2216,47 @@
(define num-msg (new message%
[label "0"]
[vert-margin 0]
[auto-resize #t]
[font small-control-font]
[parent hits-panel]))
(define mth-msg (new message%
[label "Matches"]
[font small-control-font]
[font tiny-control-font]
[parent hits-panel]))
(define matches-msg (new message%
[label "Matches"]
[vert-margin 0]
[font tiny-control-font]
[parent hits-panel]))
(define _6 (set! update-matches
(λ (m)
(send mth-msg set-label (if (= m 1) "Match" "Matches"))
(send num-msg set-label
(list->string
(reverse
(let loop ([chars (reverse (string->list (format "~a" m)))])
(cond
[(<= (length chars) 3)
chars]
[else (list* (list-ref chars 0)
(list-ref chars 1)
(list-ref chars 2)
#\,
(loop (cdddr chars)))]))))))))
(let ([number
(list->string
(reverse
(let loop ([chars (reverse (string->list (format "~a" m)))])
(cond
[(<= (length chars) 3)
chars]
[else (list* (list-ref chars 0)
(list-ref chars 1)
(list-ref chars 2)
#\,
(loop (cdddr chars)))]))))])
(send num-msg set-label number)
(send matches-msg set-label (if (= m 1) "Match" "Matches"))))))
(define replace-all-button (make-object button%
(string-constant replace-all-menu-item)
replace-panel
(λ x (replace-all))))
(define replace&search-button
(new button%
[label (string-constant replace&find)]
[vert-margin 0]
[parent replace-panel]
[font small-control-font]
[callback (λ (x y) (replace&search 'forward))]))
(define hide-button (make-object button% (string-constant hide)
search/replace-panel
(λ args (hide-search))))
(define hide-button (new button%
[label (string-constant hide)]
[vert-margin 0]
[parent search/replace-panel]
[font small-control-font]
[callback (λ (x y) (hide-search))]))
(void))
(end-container-sequence)))

View File

@ -967,7 +967,9 @@
(λ ()
(let loop ([obj frame])
(cond
[(and found-one? (is-a? obj editor-canvas%))
[(and found-one?
(is-a? obj editor-canvas%)
(is-a? (send obj get-editor) editor:keymap<%>))
(send obj focus)
(k (void))]
[(and (is-a? obj window<%>) (send obj has-focus?))

View File

@ -359,28 +359,37 @@
'(string-constant find-menu-item)
edit-menu:edit-target-on-demand
#f)
(make-an-item 'edit-menu 'find-backwards
'(string-constant find-backwards-info)
'(λ (item control) (void))
#\f
'(cons 'shift (get-default-shortcut-prefix))
'(string-constant find-backwards-menu-item)
edit-menu:edit-target-on-demand
#f)
(make-an-item 'edit-menu 'replace-and-find
'(string-constant replace-and-find-info)
(make-an-item 'edit-menu 'find-again
'(string-constant find-again-info)
'(λ (item control) (void))
#\g
'(get-default-shortcut-prefix)
'(string-constant replace-and-find-menu-item)
'(string-constant find-again-menu-item)
edit-menu:edit-target-on-demand
#f)
(make-an-item 'edit-menu 'replace-and-find-backwards
'(string-constant replace-and-find-backwards-info)
(make-an-item 'edit-menu 'find-again-backwards
'(string-constant find-again-backwards-info)
'(λ (item control) (void))
#\g
'(cons 'shift (get-default-shortcut-prefix))
'(string-constant replace-and-find-backwards-menu-item)
'(string-constant find-again-backwards-menu-item)
edit-menu:edit-target-on-demand
#f)
(make-an-item 'edit-menu 'replace-and-find-again
'(string-constant replace-and-find-again-info)
'(λ (item control) (void))
#\r
'(get-default-shortcut-prefix)
'(string-constant replace-and-find-again-menu-item)
edit-menu:edit-target-on-demand
#f)
(make-an-item 'edit-menu 'replace-and-find-again-backwards
'(string-constant replace-and-find-again-backwards-info)
'(λ (item control) (void))
#\r
'(cons 'shift (get-default-shortcut-prefix))
'(string-constant replace-and-find-again-backwards-menu-item)
edit-menu:edit-target-on-demand
#f)
(make-an-item 'edit-menu 'replace-all
@ -391,17 +400,6 @@
'(string-constant replace-all-menu-item)
edit-menu:edit-target-on-demand
#f)
(make-an-item 'edit-menu 'toggle-find-focus
'(string-constant toggle-find-focus-info)
'(λ (item control) (void))
#\f
'(cons (case (system-type)
[(macosx) 'option]
[else 'alt])
(get-default-shortcut-prefix))
'(string-constant toggle-find-focus)
'(λ (item) (void))
#f)
(make-a-checkable-item 'edit-menu 'find-case-sensitive
'(string-constant find-case-sensitive-info)

View File

@ -122,36 +122,36 @@
edit-menu:find-help-string
edit-menu:find-on-demand
edit-menu:create-find?
edit-menu:find-backwards-callback
edit-menu:get-find-backwards-item
edit-menu:find-backwards-string
edit-menu:find-backwards-help-string
edit-menu:find-backwards-on-demand
edit-menu:create-find-backwards?
edit-menu:replace-and-find-callback
edit-menu:get-replace-and-find-item
edit-menu:replace-and-find-string
edit-menu:replace-and-find-help-string
edit-menu:replace-and-find-on-demand
edit-menu:create-replace-and-find?
edit-menu:replace-and-find-backwards-callback
edit-menu:get-replace-and-find-backwards-item
edit-menu:replace-and-find-backwards-string
edit-menu:replace-and-find-backwards-help-string
edit-menu:replace-and-find-backwards-on-demand
edit-menu:create-replace-and-find-backwards?
edit-menu:find-again-callback
edit-menu:get-find-again-item
edit-menu:find-again-string
edit-menu:find-again-help-string
edit-menu:find-again-on-demand
edit-menu:create-find-again?
edit-menu:find-again-backwards-callback
edit-menu:get-find-again-backwards-item
edit-menu:find-again-backwards-string
edit-menu:find-again-backwards-help-string
edit-menu:find-again-backwards-on-demand
edit-menu:create-find-again-backwards?
edit-menu:replace-and-find-again-callback
edit-menu:get-replace-and-find-again-item
edit-menu:replace-and-find-again-string
edit-menu:replace-and-find-again-help-string
edit-menu:replace-and-find-again-on-demand
edit-menu:create-replace-and-find-again?
edit-menu:replace-and-find-again-backwards-callback
edit-menu:get-replace-and-find-again-backwards-item
edit-menu:replace-and-find-again-backwards-string
edit-menu:replace-and-find-again-backwards-help-string
edit-menu:replace-and-find-again-backwards-on-demand
edit-menu:create-replace-and-find-again-backwards?
edit-menu:replace-all-callback
edit-menu:get-replace-all-item
edit-menu:replace-all-string
edit-menu:replace-all-help-string
edit-menu:replace-all-on-demand
edit-menu:create-replace-all?
edit-menu:toggle-find-focus-callback
edit-menu:get-toggle-find-focus-item
edit-menu:toggle-find-focus-string
edit-menu:toggle-find-focus-help-string
edit-menu:toggle-find-focus-on-demand
edit-menu:create-toggle-find-focus?
edit-menu:find-case-sensitive-callback
edit-menu:get-find-case-sensitive-item
edit-menu:find-case-sensitive-string
@ -393,34 +393,44 @@
edit-menu:find-on-demand
(λ (item) (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
(define/public (edit-menu:create-find?) #f)
(define/public edit-menu:find-backwards-callback (λ (item control) (void)))
(define/public (edit-menu:get-find-backwards-item) edit-menu:find-backwards-item)
(define/public (edit-menu:find-backwards-string) (string-constant find-backwards-menu-item))
(define/public (edit-menu:find-backwards-help-string) (string-constant find-backwards-info))
(define/public edit-menu:find-again-callback (λ (item control) (void)))
(define/public (edit-menu:get-find-again-item) edit-menu:find-again-item)
(define/public (edit-menu:find-again-string) (string-constant find-again-menu-item))
(define/public (edit-menu:find-again-help-string) (string-constant find-again-info))
(define/public
edit-menu:find-backwards-on-demand
edit-menu:find-again-on-demand
(λ (item) (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
(define/public (edit-menu:create-find-backwards?) #f)
(define/public edit-menu:replace-and-find-callback (λ (item control) (void)))
(define/public (edit-menu:get-replace-and-find-item) edit-menu:replace-and-find-item)
(define/public (edit-menu:replace-and-find-string) (string-constant replace-and-find-menu-item))
(define/public (edit-menu:replace-and-find-help-string) (string-constant replace-and-find-info))
(define/public (edit-menu:create-find-again?) #f)
(define/public edit-menu:find-again-backwards-callback (λ (item control) (void)))
(define/public (edit-menu:get-find-again-backwards-item) edit-menu:find-again-backwards-item)
(define/public (edit-menu:find-again-backwards-string) (string-constant find-again-backwards-menu-item))
(define/public (edit-menu:find-again-backwards-help-string) (string-constant find-again-backwards-info))
(define/public
edit-menu:replace-and-find-on-demand
edit-menu:find-again-backwards-on-demand
(λ (item) (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
(define/public (edit-menu:create-replace-and-find?) #f)
(define/public edit-menu:replace-and-find-backwards-callback (λ (item control) (void)))
(define/public (edit-menu:get-replace-and-find-backwards-item) edit-menu:replace-and-find-backwards-item)
(define/public (edit-menu:create-find-again-backwards?) #f)
(define/public edit-menu:replace-and-find-again-callback (λ (item control) (void)))
(define/public (edit-menu:get-replace-and-find-again-item) edit-menu:replace-and-find-again-item)
(define/public (edit-menu:replace-and-find-again-string) (string-constant replace-and-find-again-menu-item))
(define/public (edit-menu:replace-and-find-again-help-string) (string-constant replace-and-find-again-info))
(define/public
(edit-menu:replace-and-find-backwards-string)
(string-constant replace-and-find-backwards-menu-item))
(define/public
(edit-menu:replace-and-find-backwards-help-string)
(string-constant replace-and-find-backwards-info))
(define/public
edit-menu:replace-and-find-backwards-on-demand
edit-menu:replace-and-find-again-on-demand
(λ (item) (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
(define/public (edit-menu:create-replace-and-find-backwards?) #f)
(define/public (edit-menu:create-replace-and-find-again?) #f)
(define/public edit-menu:replace-and-find-again-backwards-callback (λ (item control) (void)))
(define/public
(edit-menu:get-replace-and-find-again-backwards-item)
edit-menu:replace-and-find-again-backwards-item)
(define/public
(edit-menu:replace-and-find-again-backwards-string)
(string-constant replace-and-find-again-backwards-menu-item))
(define/public
(edit-menu:replace-and-find-again-backwards-help-string)
(string-constant replace-and-find-again-backwards-info))
(define/public
edit-menu:replace-and-find-again-backwards-on-demand
(λ (item) (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
(define/public (edit-menu:create-replace-and-find-again-backwards?) #f)
(define/public edit-menu:replace-all-callback (λ (item control) (void)))
(define/public (edit-menu:get-replace-all-item) edit-menu:replace-all-item)
(define/public (edit-menu:replace-all-string) (string-constant replace-all-menu-item))
@ -429,12 +439,6 @@
edit-menu:replace-all-on-demand
(λ (item) (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
(define/public (edit-menu:create-replace-all?) #f)
(define/public edit-menu:toggle-find-focus-callback (λ (item control) (void)))
(define/public (edit-menu:get-toggle-find-focus-item) edit-menu:toggle-find-focus-item)
(define/public (edit-menu:toggle-find-focus-string) (string-constant toggle-find-focus))
(define/public (edit-menu:toggle-find-focus-help-string) (string-constant toggle-find-focus-info))
(define/public edit-menu:toggle-find-focus-on-demand (λ (item) (void)))
(define/public (edit-menu:create-toggle-find-focus?) #f)
(define/public edit-menu:find-case-sensitive-callback (λ (item control) (void)))
(define/public (edit-menu:get-find-case-sensitive-item) edit-menu:find-case-sensitive-item)
(define/public (edit-menu:find-case-sensitive-string) (string-constant find-case-sensitive-menu-item))
@ -697,47 +701,61 @@
(shortcut-prefix (get-default-shortcut-prefix))
(help-string (edit-menu:find-help-string))
(demand-callback (λ (menu-item) (edit-menu:find-on-demand menu-item))))))
(define edit-menu:find-backwards-item
(and (edit-menu:create-find-backwards?)
(define edit-menu:find-again-item
(and (edit-menu:create-find-again?)
(new
(get-menu-item%)
(label (edit-menu:find-backwards-string))
(label (edit-menu:find-again-string))
(parent edit-menu)
(callback
(let ((edit-menu:find-backwards-callback (λ (item evt) (edit-menu:find-backwards-callback item evt))))
edit-menu:find-backwards-callback))
(shortcut #\f)
(shortcut-prefix (cons 'shift (get-default-shortcut-prefix)))
(help-string (edit-menu:find-backwards-help-string))
(demand-callback (λ (menu-item) (edit-menu:find-backwards-on-demand menu-item))))))
(define edit-menu:replace-and-find-item
(and (edit-menu:create-replace-and-find?)
(new
(get-menu-item%)
(label (edit-menu:replace-and-find-string))
(parent edit-menu)
(callback
(let ((edit-menu:replace-and-find-callback
(λ (item evt) (edit-menu:replace-and-find-callback item evt))))
edit-menu:replace-and-find-callback))
(let ((edit-menu:find-again-callback (λ (item evt) (edit-menu:find-again-callback item evt))))
edit-menu:find-again-callback))
(shortcut #\g)
(shortcut-prefix (get-default-shortcut-prefix))
(help-string (edit-menu:replace-and-find-help-string))
(demand-callback (λ (menu-item) (edit-menu:replace-and-find-on-demand menu-item))))))
(define edit-menu:replace-and-find-backwards-item
(and (edit-menu:create-replace-and-find-backwards?)
(help-string (edit-menu:find-again-help-string))
(demand-callback (λ (menu-item) (edit-menu:find-again-on-demand menu-item))))))
(define edit-menu:find-again-backwards-item
(and (edit-menu:create-find-again-backwards?)
(new
(get-menu-item%)
(label (edit-menu:replace-and-find-backwards-string))
(label (edit-menu:find-again-backwards-string))
(parent edit-menu)
(callback
(let ((edit-menu:replace-and-find-backwards-callback
(λ (item evt) (edit-menu:replace-and-find-backwards-callback item evt))))
edit-menu:replace-and-find-backwards-callback))
(let ((edit-menu:find-again-backwards-callback
(λ (item evt) (edit-menu:find-again-backwards-callback item evt))))
edit-menu:find-again-backwards-callback))
(shortcut #\g)
(shortcut-prefix (cons 'shift (get-default-shortcut-prefix)))
(help-string (edit-menu:replace-and-find-backwards-help-string))
(demand-callback (λ (menu-item) (edit-menu:replace-and-find-backwards-on-demand menu-item))))))
(help-string (edit-menu:find-again-backwards-help-string))
(demand-callback (λ (menu-item) (edit-menu:find-again-backwards-on-demand menu-item))))))
(define edit-menu:replace-and-find-again-item
(and (edit-menu:create-replace-and-find-again?)
(new
(get-menu-item%)
(label (edit-menu:replace-and-find-again-string))
(parent edit-menu)
(callback
(let ((edit-menu:replace-and-find-again-callback
(λ (item evt) (edit-menu:replace-and-find-again-callback item evt))))
edit-menu:replace-and-find-again-callback))
(shortcut #\r)
(shortcut-prefix (get-default-shortcut-prefix))
(help-string (edit-menu:replace-and-find-again-help-string))
(demand-callback (λ (menu-item) (edit-menu:replace-and-find-again-on-demand menu-item))))))
(define edit-menu:replace-and-find-again-backwards-item
(and (edit-menu:create-replace-and-find-again-backwards?)
(new
(get-menu-item%)
(label (edit-menu:replace-and-find-again-backwards-string))
(parent edit-menu)
(callback
(let ((edit-menu:replace-and-find-again-backwards-callback
(λ (item evt) (edit-menu:replace-and-find-again-backwards-callback item evt))))
edit-menu:replace-and-find-again-backwards-callback))
(shortcut #\r)
(shortcut-prefix (cons 'shift (get-default-shortcut-prefix)))
(help-string (edit-menu:replace-and-find-again-backwards-help-string))
(demand-callback (λ (menu-item) (edit-menu:replace-and-find-again-backwards-on-demand menu-item))))))
(define edit-menu:replace-all-item
(and (edit-menu:create-replace-all?)
(new
@ -751,21 +769,6 @@
(shortcut-prefix (get-default-shortcut-prefix))
(help-string (edit-menu:replace-all-help-string))
(demand-callback (λ (menu-item) (edit-menu:replace-all-on-demand menu-item))))))
(define edit-menu:toggle-find-focus-item
(and (edit-menu:create-toggle-find-focus?)
(new
(get-menu-item%)
(label (edit-menu:toggle-find-focus-string))
(parent edit-menu)
(callback
(let ((edit-menu:toggle-find-focus-callback
(λ (item evt) (edit-menu:toggle-find-focus-callback item evt))))
edit-menu:toggle-find-focus-callback))
(shortcut #\f)
(shortcut-prefix
(cons (case (system-type) ((macosx) 'option) (else 'alt)) (get-default-shortcut-prefix)))
(help-string (edit-menu:toggle-find-focus-help-string))
(demand-callback (λ (menu-item) (edit-menu:toggle-find-focus-on-demand menu-item))))))
(define edit-menu:find-case-sensitive-item
(and (edit-menu:create-find-case-sensitive?)
(new

View File

@ -279,15 +279,12 @@ WARNING: printf is rebound in the body of the unit to always
;; we don't need to consider the first or the last line,
;; since they are already covered
;; by `start-x' and `end-x'
(let loop ([l start-x]
[r end-x]
[line (+ (position-line start start-eol?) 1)])
(let loop ([l (min start-x end-x)]
[r (max start-x end-x)]
[line (position-line start start-eol?)])
(cond
[(>= line end-line)
;; techincally, the > should not be needed, but we
;; would rather have bad drawing than an infinite loop
;; in the case that there is a bug ...
[(> line end-line)
(cons
(make-rectangle l
top-start-y
@ -301,8 +298,8 @@ WARNING: printf is rebound in the body of the unit to always
[line-end (line-end-position line)])
(position-location line-start b1 #f #t)
(position-location line-end b2 #f #t)
(loop (min (unbox b1) l)
(max (unbox b2) r)
(loop (min (unbox b1) (unbox b2) l)
(max (unbox b1) (unbox b2) r)
(+ line 1)))])))]
[else
(list*
@ -627,18 +624,26 @@ WARNING: printf is rebound in the body of the unit to always
(define updating-search? #f)
(define timer #f)
(define/private (content-changed)
(when searching-str
(run-after-edit-sequence
(λ ()
(set! updating-search? #t)
(redo-search)
(let ([tlw (get-top-level-window)])
(when (and tlw
(is-a? tlw frame:searchable<%>))
(send tlw search-results-changed)))
(set! updating-search? #f))
'framework:search-results-changed)))
(unless timer
(set! timer
(new timer%
[notify-callback
(λ ()
(run-after-edit-sequence
(λ ()
(set! updating-search? #t)
(redo-search)
(let ([tlw (get-top-level-window)])
(when (and tlw
(is-a? tlw frame:searchable<%>))
(send tlw search-results-changed)))
(set! updating-search? #f))
'framework:search-results-changed))]
[just-once? #t])))
(send timer start 500 #t)))
(inherit get-top-level-window)
(define/override (on-focus on?)

View File

@ -953,51 +953,60 @@ framework)) @(require (for-label scheme/gui)) @(require
@scheme[editor<%>]
in this frame.
@defmethod*[#:mode override (((edit-menu:find-callback (item (is-a?/c menu-item%)) (evt (is-a?/c control-event%))) void?))]{
Calls @method[frame:searchable unhide-search] and then
@method[frame:searchable<%> search].
@defmethod*[#:mode override (((edit-menu:find-callback) boolean?))]{
Toggles the focus between the find window and the window being searched.
When moving to the window with the search string, selects the entire
range in the buffer.
}
@defmethod*[#:mode override (((edit-menu:create-find?) boolean?))]{
returns @scheme[#t].
}
@defmethod*[#:mode override (((edit-menu:find-backwards-callback (item (is-a?/c menu-item%)) (evt (is-a?/c control-event%))) void?))]{
@defmethod*[#:mode override (((edit-menu:find-again-callback (item (is-a?/c menu-item%)) (evt (is-a?/c control-event%))) void?))]{
Calls @method[frame:searchable unhide-search] and then
@method[frame:searchable<%> search].
}
@defmethod*[#:mode override (((edit-menu:create-find-backwards?) boolean?))]{
@defmethod*[#:mode override (((edit-menu:create-find-again?) boolean?))]{
returns @scheme[#t].
}
@defmethod*[#:mode override (((edit-menu:find-again-backwards-callback (item (is-a?/c menu-item%)) (evt (is-a?/c control-event%))) void?))]{
Calls @method[frame:searchable unhide-search] and then
@method[frame:searchable<%> search].
}
@defmethod*[#:mode override (((edit-menu:create-find-again-backwards?) boolean?))]{
returns @scheme[#t].
}
@defmethod*[#:mode override (((edit-menu:replace-and-find-callback) boolean?))]{
@defmethod*[#:mode override (((edit-menu:replace-and-find-again-callback) boolean?))]{
Calls @method[frame:searchable unhide-search] and then
calls @method[frame:searchable<%> replace&search].
}
@defmethod*[#:mode override (((edit-menu:replace-and-find-on-demand (item menu-item%)) void))]{
@defmethod*[#:mode override (((edit-menu:replace-and-find-again-on-demand (item menu-item%)) void))]{
Disables @scheme[item] when
@method[frame:searchable<%> can-replace?]
returns @scheme[#f] and enables it when that method returns
@scheme[#t].
}
@defmethod*[#:mode override (((edit-menu:create-replace-and-find?) boolean?))]{
@defmethod*[#:mode override (((edit-menu:create-replace-and-find-again?) boolean?))]{
returns @scheme[#t].
}
@defmethod*[#:mode override (((edit-menu:replace-and-find-backwards-callback) boolean?))]{
@defmethod*[#:mode override (((edit-menu:replace-and-find-again-backwards-callback) boolean?))]{
Calls @method[frame:searchable unhide-search] and then
calls @method[frame:searchable<%> replace&search].
}
@defmethod*[#:mode override (((edit-menu:replace-and-find-backwards-on-demand (item menu-item%)) void))]{
@defmethod*[#:mode override (((edit-menu:replace-and-find-again-backwards-on-demand (item menu-item%)) void))]{
Disables @scheme[item] when
@method[frame:searchable<%> can-replace?]
returns @scheme[#f] and enables it when that method returns
@scheme[#t].
}
@defmethod*[#:mode override (((edit-menu:create-replace-and-find-backwards?) boolean?))]{
@defmethod*[#:mode override (((edit-menu:create-replace-and-find-again-backwards?) boolean?))]{
returns @scheme[#t].
}
@ -1031,17 +1040,6 @@ framework)) @(require (for-label scheme/gui)) @(require
returns @scheme[#t].
}
@defmethod*[#:mode override (((edit-menu:toggle-find-focus-callback) boolean?))]{
toggles the focus between the find window and the window being searched.
}
@defmethod*[#:mode override (((edit-menu:create-toggle-find-focus?) boolean?))]{
returns @scheme[#t].
}
@defmethod*[#:mode override (((make-root-area-container) (is-a?/c area-container<%>)))]{
Builds a panel for the searching information.

View File

@ -245,41 +245,53 @@
@(defmethod (edit-menu:find-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant find-info)) ".")
@(defmethod (edit-menu:get-find-backwards-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-find-backwards?) ").")
@(defmethod (edit-menu:get-find-again-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-find-again?) ").")
@(defmethod (edit-menu:create-find-backwards?) boolean? "The result of this method determines if the corresponding" "\n" "menu item is created. Override it to control the creation of the menu item." "\n" "\n" "Defaults to " (scheme #f) ".")
@(defmethod (edit-menu:create-find-again?) boolean? "The result of this method determines if the corresponding" "\n" "menu item is created. Override it to control the creation of the menu item." "\n" "\n" "Defaults to " (scheme #f) ".")
@(defmethod (edit-menu:find-backwards-callback (item (is-a?/c menu-item%)) (control (is-a?/c control-event%))) void? "Defaults to " (schemeblock (void)) " ")
@(defmethod (edit-menu:find-again-callback (item (is-a?/c menu-item%)) (control (is-a?/c control-event%))) void? "Defaults to " (schemeblock (void)) " ")
@(defmethod (edit-menu:find-backwards-on-demand (item (is-a?/c menu-item%))) void? "The menu item's on-demand proc calls this method." "\n" "\n" "Defaults to " (schemeblock (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
@(defmethod (edit-menu:find-again-on-demand (item (is-a?/c menu-item%))) void? "The menu item's on-demand proc calls this method." "\n" "\n" "Defaults to " (schemeblock (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
@(defmethod (edit-menu:find-backwards-string) string? "The result of this method is used as the name of the " (scheme menu-item%) "." "\n" "\n" "Defaults to " (scheme (string-constant find-backwards-menu-item)) ".")
@(defmethod (edit-menu:find-again-string) string? "The result of this method is used as the name of the " (scheme menu-item%) "." "\n" "\n" "Defaults to " (scheme (string-constant find-again-menu-item)) ".")
@(defmethod (edit-menu:find-backwards-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant find-backwards-info)) ".")
@(defmethod (edit-menu:find-again-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant find-again-info)) ".")
@(defmethod (edit-menu:get-replace-and-find-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-replace-and-find?) ").")
@(defmethod (edit-menu:get-find-again-backwards-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-find-again-backwards?) ").")
@(defmethod (edit-menu:create-replace-and-find?) boolean? "The result of this method determines if the corresponding" "\n" "menu item is created. Override it to control the creation of the menu item." "\n" "\n" "Defaults to " (scheme #f) ".")
@(defmethod (edit-menu:create-find-again-backwards?) boolean? "The result of this method determines if the corresponding" "\n" "menu item is created. Override it to control the creation of the menu item." "\n" "\n" "Defaults to " (scheme #f) ".")
@(defmethod (edit-menu:replace-and-find-callback (item (is-a?/c menu-item%)) (control (is-a?/c control-event%))) void? "Defaults to " (schemeblock (void)) " ")
@(defmethod (edit-menu:find-again-backwards-callback (item (is-a?/c menu-item%)) (control (is-a?/c control-event%))) void? "Defaults to " (schemeblock (void)) " ")
@(defmethod (edit-menu:replace-and-find-on-demand (item (is-a?/c menu-item%))) void? "The menu item's on-demand proc calls this method." "\n" "\n" "Defaults to " (schemeblock (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
@(defmethod (edit-menu:find-again-backwards-on-demand (item (is-a?/c menu-item%))) void? "The menu item's on-demand proc calls this method." "\n" "\n" "Defaults to " (schemeblock (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
@(defmethod (edit-menu:replace-and-find-string) string? "The result of this method is used as the name of the " (scheme menu-item%) "." "\n" "\n" "Defaults to " (scheme (string-constant replace-and-find-menu-item)) ".")
@(defmethod (edit-menu:find-again-backwards-string) string? "The result of this method is used as the name of the " (scheme menu-item%) "." "\n" "\n" "Defaults to " (scheme (string-constant find-again-backwards-menu-item)) ".")
@(defmethod (edit-menu:replace-and-find-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant replace-and-find-info)) ".")
@(defmethod (edit-menu:find-again-backwards-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant find-again-backwards-info)) ".")
@(defmethod (edit-menu:get-replace-and-find-backwards-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-replace-and-find-backwards?) ").")
@(defmethod (edit-menu:get-replace-and-find-again-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-replace-and-find-again?) ").")
@(defmethod (edit-menu:create-replace-and-find-backwards?) boolean? "The result of this method determines if the corresponding" "\n" "menu item is created. Override it to control the creation of the menu item." "\n" "\n" "Defaults to " (scheme #f) ".")
@(defmethod (edit-menu:create-replace-and-find-again?) boolean? "The result of this method determines if the corresponding" "\n" "menu item is created. Override it to control the creation of the menu item." "\n" "\n" "Defaults to " (scheme #f) ".")
@(defmethod (edit-menu:replace-and-find-backwards-callback (item (is-a?/c menu-item%)) (control (is-a?/c control-event%))) void? "Defaults to " (schemeblock (void)) " ")
@(defmethod (edit-menu:replace-and-find-again-callback (item (is-a?/c menu-item%)) (control (is-a?/c control-event%))) void? "Defaults to " (schemeblock (void)) " ")
@(defmethod (edit-menu:replace-and-find-backwards-on-demand (item (is-a?/c menu-item%))) void? "The menu item's on-demand proc calls this method." "\n" "\n" "Defaults to " (schemeblock (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
@(defmethod (edit-menu:replace-and-find-again-on-demand (item (is-a?/c menu-item%))) void? "The menu item's on-demand proc calls this method." "\n" "\n" "Defaults to " (schemeblock (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
@(defmethod (edit-menu:replace-and-find-backwards-string) string? "The result of this method is used as the name of the " (scheme menu-item%) "." "\n" "\n" "Defaults to " (scheme (string-constant replace-and-find-backwards-menu-item)) ".")
@(defmethod (edit-menu:replace-and-find-again-string) string? "The result of this method is used as the name of the " (scheme menu-item%) "." "\n" "\n" "Defaults to " (scheme (string-constant replace-and-find-again-menu-item)) ".")
@(defmethod (edit-menu:replace-and-find-backwards-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant replace-and-find-backwards-info)) ".")
@(defmethod (edit-menu:replace-and-find-again-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant replace-and-find-again-info)) ".")
@(defmethod (edit-menu:get-replace-and-find-again-backwards-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-replace-and-find-again-backwards?) ").")
@(defmethod (edit-menu:create-replace-and-find-again-backwards?) boolean? "The result of this method determines if the corresponding" "\n" "menu item is created. Override it to control the creation of the menu item." "\n" "\n" "Defaults to " (scheme #f) ".")
@(defmethod (edit-menu:replace-and-find-again-backwards-callback (item (is-a?/c menu-item%)) (control (is-a?/c control-event%))) void? "Defaults to " (schemeblock (void)) " ")
@(defmethod (edit-menu:replace-and-find-again-backwards-on-demand (item (is-a?/c menu-item%))) void? "The menu item's on-demand proc calls this method." "\n" "\n" "Defaults to " (schemeblock (send item enable (let ((target (get-edit-target-object))) (and target (is-a? target editor<%>))))))
@(defmethod (edit-menu:replace-and-find-again-backwards-string) string? "The result of this method is used as the name of the " (scheme menu-item%) "." "\n" "\n" "Defaults to " (scheme (string-constant replace-and-find-again-backwards-menu-item)) ".")
@(defmethod (edit-menu:replace-and-find-again-backwards-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant replace-and-find-again-backwards-info)) ".")
@(defmethod (edit-menu:get-replace-all-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-replace-all?) ").")
@ -293,18 +305,6 @@
@(defmethod (edit-menu:replace-all-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant replace-all-info)) ".")
@(defmethod (edit-menu:get-toggle-find-focus-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-toggle-find-focus?) ").")
@(defmethod (edit-menu:create-toggle-find-focus?) boolean? "The result of this method determines if the corresponding" "\n" "menu item is created. Override it to control the creation of the menu item." "\n" "\n" "Defaults to " (scheme #f) ".")
@(defmethod (edit-menu:toggle-find-focus-callback (item (is-a?/c menu-item%)) (control (is-a?/c control-event%))) void? "Defaults to " (schemeblock (void)) " ")
@(defmethod (edit-menu:toggle-find-focus-on-demand (item (is-a?/c menu-item%))) void? "The menu item's on-demand proc calls this method." "\n" "\n" "Defaults to " (schemeblock (void)))
@(defmethod (edit-menu:toggle-find-focus-string) string? "The result of this method is used as the name of the " (scheme menu-item%) "." "\n" "\n" "Defaults to " (scheme (string-constant toggle-find-focus)) ".")
@(defmethod (edit-menu:toggle-find-focus-help-string) string? "The result of this method is used as the help string" "\n" "when the " (scheme menu-item%) " object is created." "\n" "\n" "Defaults to " (scheme (string-constant toggle-find-focus-info)) ".")
@(defmethod (edit-menu:get-find-case-sensitive-item) (or/c false/c (is-a?/c menu-item%)) "This method returns the " (scheme menu-item%) " object corresponding" "\n" "to this menu item, if it has been created (as controlled by" "\n" (method frame:standard-menus<%> edit-menu:create-find-case-sensitive?) ").")
@(defmethod (edit-menu:create-find-case-sensitive?) boolean? "The result of this method determines if the corresponding" "\n" "menu item is created. Override it to control the creation of the menu item." "\n" "\n" "Defaults to " (scheme #f) ".")

View File

@ -508,13 +508,11 @@ please adhere to these guidelines:
(replace "Replace")
(dock "Dock")
(undock "Undock")
(replace&find-again "Replace && Find Again") ;;; need double & to get a single &
(replace&find "Replace && Find") ;;; need double & to get a single &
(forward "Forward")
(backward "Backward")
(hide "Hide")
(find-case-sensitive "Case sensitive") ;; the check box in both the docked & undocked search
(toggle-find-focus "Toggle Search Focus") ;; menu item
(toggle-find-focus-info "Toggles the keyboard focus between the window being searched and the search bar")
;;; multi-file-search
@ -649,17 +647,20 @@ please adhere to these guidelines:
(select-all-info "Select the entire document")
(select-all-menu-item "Select A&ll")
(find-info "Skip to the next occurrence of the string in the find window")
(find-menu-item "Find")
(find-backwards-info "Skip to the previous occurrence of the string in the find window")
(find-backwards-menu-item "Find Backwards")
(find-menu-item "Find") ;; menu item
(find-info "Toggles the keyboard focus between the window being searched and the search bar")
(replace-and-find-info "Replace the current text and skip to the next occurrence")
(replace-and-find-menu-item "Replace && Find")
(find-again-info "Skip to the next occurrence of the string in the find window")
(find-again-menu-item "Find Again")
(find-again-backwards-info "Skip to the previous occurrence of the string in the find window")
(find-again-backwards-menu-item "Find Again Backwards")
(replace-and-find-again-info "Replace the current text and skip to the next occurrence")
(replace-and-find-again-menu-item "Replace && Find Again")
(replace-and-find-backwards-info "Replace the current text and skip to the previous occurrence")
(replace-and-find-backwards-menu-item "Replace && Find Backwards")
(replace-and-find-again-backwards-info "Replace the current text and skip to the previous occurrence")
(replace-and-find-again-backwards-menu-item "Replace && Find Again Backwards")
(replace-all-info "Replace all occurrences of the search string")
(replace-all-menu-item "Replace All")