...
original commit: c09af85a7c6060bad099cfcc6ccc9a1a690603bb
This commit is contained in:
parent
ada771440d
commit
4214a99403
|
@ -358,6 +358,36 @@
|
||||||
[get-editor% (lambda () pasteboard:keymap%)])
|
[get-editor% (lambda () pasteboard:keymap%)])
|
||||||
(sequence (apply super-init args))))
|
(sequence (apply super-init args))))
|
||||||
|
|
||||||
|
(define (search-dialog frame)
|
||||||
|
(init-find/replace-edits)
|
||||||
|
(let* ([dialog (make-object dialog% "Find String")]
|
||||||
|
[canvas-panel (make-object horizontal-panel% dialog)]
|
||||||
|
[text (make-object text%)]
|
||||||
|
[canvas (make-object editor-canvas% canvas-panel text)]
|
||||||
|
[button-panel (make-object horizontal-panel% dialog)]
|
||||||
|
[cancel-button (make-object button% "Cancel" button-panel
|
||||||
|
(lambda x
|
||||||
|
(send dialog show #f)))]
|
||||||
|
[find-button (make-object button% "Find" button-panel
|
||||||
|
(lambda x
|
||||||
|
(send find-edit erase)
|
||||||
|
(let loop ([snip (send text find-first-snip)])
|
||||||
|
(when snip
|
||||||
|
(send find-edit insert (send snip copy))
|
||||||
|
(loop (send snip next))))
|
||||||
|
(send dialog show #f)
|
||||||
|
(send find-edit search #t #t)))])
|
||||||
|
(let loop ([snip (send find-edit find-first-snip)])
|
||||||
|
(when snip
|
||||||
|
(send text insert (send snip copy))
|
||||||
|
(loop (send snip next))))
|
||||||
|
(send canvas min-width 400)
|
||||||
|
(send canvas set-line-count 2)
|
||||||
|
(send canvas focus)
|
||||||
|
(send button-panel set-alignment 'right 'center)
|
||||||
|
(send dialog center 'both)
|
||||||
|
(send dialog show #t)))
|
||||||
|
|
||||||
(define searchable<%> (interface (text<%>)
|
(define searchable<%> (interface (text<%>)
|
||||||
get-text-to-search
|
get-text-to-search
|
||||||
hide-search
|
hide-search
|
||||||
|
@ -369,7 +399,7 @@
|
||||||
toggle-search-focus
|
toggle-search-focus
|
||||||
move-to-search-or-search
|
move-to-search-or-search
|
||||||
move-to-search-or-reverse-search
|
move-to-search-or-reverse-search
|
||||||
search))
|
search-again))
|
||||||
(define search-anchor 0)
|
(define search-anchor 0)
|
||||||
(define searching-direction 'forward)
|
(define searching-direction 'forward)
|
||||||
(define (set-searching-direction x)
|
(define (set-searching-direction x)
|
||||||
|
@ -658,7 +688,8 @@
|
||||||
(set! hidden? #t))]
|
(set! hidden? #t))]
|
||||||
[unhide-search
|
[unhide-search
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(when hidden?
|
(when (and hidden?
|
||||||
|
'(not (preferences:get 'framework:search-using-dialog?)))
|
||||||
(set! hidden? #f)
|
(set! hidden? #f)
|
||||||
(send search-panel focus)
|
(send search-panel focus)
|
||||||
(send super-root add-child search-panel)
|
(send super-root add-child search-panel)
|
||||||
|
@ -683,7 +714,7 @@
|
||||||
[replace&search
|
[replace&search
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(when (replace)
|
(when (replace)
|
||||||
(search)))]
|
(search-again)))]
|
||||||
[replace-all
|
[replace-all
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let* ([replacee-edit (get-text-to-search)]
|
(let* ([replacee-edit (get-text-to-search)]
|
||||||
|
@ -700,7 +731,7 @@
|
||||||
(send* replacee-edit
|
(send* replacee-edit
|
||||||
(begin-edit-sequence)
|
(begin-edit-sequence)
|
||||||
(set-position pos))
|
(set-position pos))
|
||||||
(when (search)
|
(when (search-again)
|
||||||
(send replacee-edit set-position pos)
|
(send replacee-edit set-position pos)
|
||||||
(let loop ()
|
(let loop ()
|
||||||
(when (send find-edit search #t #f #f)
|
(when (send find-edit search #t #f #f)
|
||||||
|
@ -739,24 +770,28 @@
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(set-searching-frame this)
|
(set-searching-frame this)
|
||||||
(unhide-search)
|
(unhide-search)
|
||||||
(if (or (send find-canvas has-focus?)
|
(cond
|
||||||
(send replace-canvas has-focus?))
|
[(preferences:get 'framework:search-using-dialog?)
|
||||||
(search 'forward)
|
(search-dialog this)]
|
||||||
(send find-canvas focus)))]
|
[else
|
||||||
|
(if (or (send find-canvas has-focus?)
|
||||||
|
(send replace-canvas has-focus?))
|
||||||
|
(search-again 'forward)
|
||||||
|
(send find-canvas focus))]))]
|
||||||
[move-to-search-or-reverse-search
|
[move-to-search-or-reverse-search
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(set-searching-frame this)
|
(set-searching-frame this)
|
||||||
(unhide-search)
|
(unhide-search)
|
||||||
(if (or (send find-canvas has-focus?)
|
(if (or (send find-canvas has-focus?)
|
||||||
(send replace-canvas has-focus?))
|
(send replace-canvas has-focus?))
|
||||||
(search 'backward)
|
(search-again 'backward)
|
||||||
(send find-canvas focus)))]
|
(send find-canvas focus)))]
|
||||||
[search
|
[search-again
|
||||||
(opt-lambda ([direction searching-direction] [beep? #t])
|
(opt-lambda ([direction searching-direction] [beep? #t])
|
||||||
(set-searching-frame this)
|
(set-searching-frame this)
|
||||||
(unhide-search)
|
(unhide-search)
|
||||||
(set-search-direction direction)
|
(set-search-direction direction)
|
||||||
(send find-edit search #t beep?))])
|
(send find-edit search #t beep?))])
|
||||||
(sequence
|
(sequence
|
||||||
(apply super-init args))
|
(apply super-init args))
|
||||||
(private
|
(private
|
||||||
|
@ -773,7 +808,7 @@
|
||||||
[search-button (make-object button%
|
[search-button (make-object button%
|
||||||
"Search"
|
"Search"
|
||||||
middle-left-panel
|
middle-left-panel
|
||||||
(lambda args (search)))]
|
(lambda args (search-again)))]
|
||||||
|
|
||||||
[replace&search-button (make-object button%
|
[replace&search-button (make-object button%
|
||||||
"Replace && Search"
|
"Replace && Search"
|
||||||
|
|
|
@ -769,7 +769,7 @@
|
||||||
|
|
||||||
(add "move-to-search-or-search" (send-frame 'move-to-search-or-search)) ;; key 1
|
(add "move-to-search-or-search" (send-frame 'move-to-search-or-search)) ;; key 1
|
||||||
(add "move-to-search-or-reverse-search" (send-frame 'move-to-search-or-reverse-search)) ;; key 1b, backwards
|
(add "move-to-search-or-reverse-search" (send-frame 'move-to-search-or-reverse-search)) ;; key 1b, backwards
|
||||||
(add "find-string" (send-frame 'search)) ;; key 2
|
(add "find-string-again" (send-frame 'search-again)) ;; key 2
|
||||||
(add "toggle-search-focus" (send-frame 'toggle-search-focus)) ;; key 3
|
(add "toggle-search-focus" (send-frame 'toggle-search-focus)) ;; key 3
|
||||||
(add "hide-search" (send-frame 'hide-search)) ;; key 4
|
(add "hide-search" (send-frame 'hide-search)) ;; key 4
|
||||||
|
|
||||||
|
@ -778,21 +778,27 @@
|
||||||
(map "c:s" "move-to-search-or-search")
|
(map "c:s" "move-to-search-or-search")
|
||||||
(map-meta "%" "move-to-search-or-search")
|
(map-meta "%" "move-to-search-or-search")
|
||||||
(map "c:r" "move-to-search-or-reverse-search")
|
(map "c:r" "move-to-search-or-reverse-search")
|
||||||
(map "f3" "find-string")
|
(map "f3" "find-string-again")
|
||||||
(map "c:i" "toggle-search-focus")
|
(map "c:i" "toggle-search-focus")
|
||||||
(map "c:g" "hide-search")]
|
(map "c:g" "hide-search")]
|
||||||
[(windows)
|
[(windows)
|
||||||
(map "c:f" "move-to-search-or-search")
|
|
||||||
(map "c:r" "move-to-search-or-reverse-search")
|
(map "c:r" "move-to-search-or-reverse-search")
|
||||||
(map "f3" "find-string")
|
(map "f3" "find-string-again")
|
||||||
(map "c:g" "find-string")
|
(map "c:g" "find-string-again")
|
||||||
|
|
||||||
|
;; covered by menu
|
||||||
|
;(map "c:f" "move-to-search-or-search")
|
||||||
|
|
||||||
(map "c:i" "toggle-search-focus")]
|
(map "c:i" "toggle-search-focus")]
|
||||||
[(macos)
|
[(macos)
|
||||||
(map "c:s" "move-to-search-or-search")
|
(map "c:s" "move-to-search-or-search")
|
||||||
(map "c:g" "hide-search")
|
(map "c:g" "hide-search")
|
||||||
(map "d:f" "move-to-search-or-search")
|
|
||||||
|
;; covered by menu
|
||||||
|
;(map "d:f" "move-to-search-or-search")
|
||||||
|
|
||||||
(map "d:r" "move-to-search-or-reverse-search")
|
(map "d:r" "move-to-search-or-reverse-search")
|
||||||
(map "d:g" "find-string")
|
(map "d:g" "find-string-again")
|
||||||
(map "c:i" "toggle-search-focus")])))))
|
(map "c:i" "toggle-search-focus")])))))
|
||||||
|
|
||||||
(define setup-file
|
(define setup-file
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
;; preferences
|
;; preferences
|
||||||
|
|
||||||
|
(preferences:set-default 'framework:search-using-dialog? #t boolean?)
|
||||||
|
|
||||||
(preferences:set-default 'framework:windows-mdi #f boolean?)
|
(preferences:set-default 'framework:windows-mdi #f boolean?)
|
||||||
|
|
||||||
(preferences:set-default 'framework:menu-bindings #t boolean?)
|
(preferences:set-default 'framework:menu-bindings #t boolean?)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user