Skip to content

Commit c8c87f5

Browse files
committed
fix problems with search bubbles and embedded editors
The main problem was that embedded editors weren't notifying the outermost enclosing editor when their state changed, which could corrupt the state and lead to strange behavior. There were several other small improvements and a bunch of Rackety closes racket/drracket#720
1 parent 5c0bae0 commit c8c87f5

File tree

8 files changed

+401
-188
lines changed

8 files changed

+401
-188
lines changed

gui-doc/scribblings/framework/text.scrbl

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@
698698
@racket['framework:anchored-search] preference is on.
699699
}
700700

701-
@defmethod[(get-search-hit-count) (values number? number?)]{
701+
@defmethod[(get-search-hit-count) (values natural? natural?)]{
702702
Returns the number of hits for the search in the buffer before the
703703
insertion point and the total number of hits. Both are based on the count
704704
found last time that a search completed.
@@ -711,7 +711,7 @@
711711

712712
}
713713

714-
@defmethod[(get-replace-search-hit) (or/c number? #f)]{
714+
@defmethod[(get-replace-search-hit) (or/c (list*of (is-a?/c text%) natural?) #f)]{
715715
Returns the position of the nearest search hit that comes after the
716716
insertion point.
717717

@@ -722,7 +722,7 @@
722722
@method[text:searching<%> finish-pending-search-work].
723723
}
724724

725-
@defmethod[(set-replace-start [pos (or/c number? #f)]) void?]{
725+
@defmethod[(set-replace-start [pos (or/c natural? #f)]) void?]{
726726
This method is ignored. (The next replacement start is now
727727
tracked via the @method[text% after-set-position] method.)
728728
}
@@ -758,7 +758,7 @@
758758
}
759759

760760
@defmixin[text:searching-mixin (editor:keymap<%> text:basic<%>) (text:searching<%>)]{
761-
This @racket[text%] can be searched.
761+
This @racket[text%] can be searched. See also @racket[text:searching-embedded-mixin]
762762

763763
The result of this mixin uses the same initialization arguments as the
764764
mixin's argument.
@@ -784,6 +784,44 @@
784784
}
785785
}
786786

787+
@definterface[text:searching-embedded<%> ()]{
788+
Classes that implement this interface are produced by
789+
@racket[text:searching-exmbedded-mixin] and have overridden
790+
observer methods that forward information about changes to the editor
791+
that can affect the searching results state.
792+
793+
@history[#:added "1.80"]
794+
795+
}
796+
797+
@defmixin[text:searching-embedded-mixin (text%) (text:searching-embedded<%>)]{
798+
This mixin is expected to be used with editors that appear inside @racket[editor-snip%]s
799+
and that can have search results. I cooperates with the enclosing @racket[text:searching<%>]
800+
object to inform it when a change to the editor has occurred that can affect
801+
the current search results and how they are displayed.
802+
803+
@history[#:added "1.80"]
804+
805+
@defmethod[#:mode augment (after-insert [start exact-nonnegative-integer?]
806+
[len exact-nonnegative-integer?]) void?]{
807+
Tells the outermost enclosing editor that the contents
808+
of the editor has changed, which can affect the way
809+
search results are displayed.
810+
}
811+
812+
@defmethod[#:mode augment (after-delete [start exact-nonnegative-integer?]
813+
[len exact-nonnegative-integer?]) void?]{
814+
Tells the outermost enclosing editor that the contents
815+
of the editor has changed, which can affect the way
816+
search results are displayed.
817+
}
818+
819+
@defmethod[#:mode augment (after-set-position) void?]{
820+
Tells the outermost enclosing editor that the position
821+
of the editor has changed, which can affect the way
822+
search results are displayed.
823+
}
824+
}
787825
@definterface[text:return<%> (text%)]{
788826
Objects supporting this interface were created by @racket[text:return-mixin].
789827
}

gui-lib/framework/private/comment-box.rkt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
(define-unit comment-box@
1616

1717
(import [prefix racket: framework:racket^]
18-
[prefix keymap: framework:keymap^])
18+
[prefix keymap: framework:keymap^]
19+
[prefix text: framework:text^])
1920
(export (rename framework:comment-box^
2021
(-snip% snip%)))
2122

2223
(define snipclass%
2324
(class decorated-editor-snipclass%
2425
(define/override (make-snip stream-in) (instantiate -snip% ()))
25-
(super-instantiate ())))
26+
(super-new)))
2627

2728
(define snipclass (make-object snipclass%))
2829
(send snipclass set-version 1)
@@ -35,7 +36,7 @@
3536
(define (get-scheme+copy-self%)
3637
(unless scheme+copy-self%
3738
(set! scheme+copy-self%
38-
(class racket:text%
39+
(class (text:searching-embedded-mixin racket:text%)
3940
(inherit copy-self-to)
4041
(define/override (copy-self)
4142
(let ([ed (new scheme+copy-self%)])
@@ -119,6 +120,6 @@
119120

120121
(define/public (read-special source line column position)
121122
(make-special-comment "comment"))
122-
(super-instantiate ())
123+
(super-new)
123124
(inherit set-snipclass)
124125
(set-snipclass snipclass))))

0 commit comments

Comments
 (0)