Skip to content

Commit

Permalink
add the set-matches method and racket:default-paren-matches
Browse files Browse the repository at this point in the history
  • Loading branch information
rfindler committed Sep 11, 2021
1 parent 2a4fd01 commit e5c1201
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
12 changes: 10 additions & 2 deletions gui-doc/scribblings/framework/color.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,16 @@
Sets the @racket[get-token] function used to color the contents
of the editor.

See @method[color:text<%> start-colorer]'s @racket[get-token] argument
for the contract on this method's @racket[get-token] argument.
See @method[color:text<%> start-colorer]'s @racket[_get-token] argument
for the contract on this method's @racket[_get-token] argument.
}
@defmethod[(set-matches [matches (listof (list/c symbol? symbol?))]) void?]{
Sets the matching parentheses pairs for this editor.

See @method[color:text<%> start-colorer]'s @racket[_pairs] argument
for more information about this argument.

@history[#:added "1.60"]
}
}

Expand Down
7 changes: 7 additions & 0 deletions gui-lib/framework/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,13 @@
@racket[open-input-text-editor] and then uses @racket[read] to parse the
range of the buffer.})

(thing-doc
racket:default-paren-matches
(listof (list/c symbol? symbol?))
@{The default parentheses that are matched when using @racket[racket:text-mode-mixin].

@history[#:added "1.60"]})

(proc-doc/names
racket:add-preferences-panel
(-> void?)
Expand Down
5 changes: 4 additions & 1 deletion gui-lib/framework/private/color.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ added get-regions

(define -text% (text-mixin text:keymap%))

(define -text-mode<%> (interface () set-get-token))
(define -text-mode<%> (interface () set-get-token set-matches))

(define text-mode-mixin
(mixin (mode:surrogate-text<%>) (-text-mode<%>)
Expand All @@ -1381,6 +1381,9 @@ added get-regions

(define/public (set-get-token _get-token)
(set! get-token _get-token))

(define/public (set-matches _matches)
(set! matches _matches))

(super-new)))

Expand Down
9 changes: 6 additions & 3 deletions gui-lib/framework/private/racket.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1378,9 +1378,12 @@

(super-new (get-token (wrap-get-token module-lexer/waived (λ () tabify-pref)))
(token-sym->style short-sym->style-name)
(matches '((|(| |)|)
(|[| |]|)
(|{| |}|))))))
(matches default-paren-matches))))

(define default-paren-matches
'((|(| |)|)
(|[| |]|)
(|{| |}|)))

(define (wrap-get-token get-token- get-tabify-pref)
(define wrapped-get-token
Expand Down
4 changes: 3 additions & 1 deletion gui-lib/framework/private/sig.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@
short-sym->pref-name
short-sym->style-name

text-balanced?))
text-balanced?

default-paren-matches))

(define-signature main-class^ ())
(define-signature main^ extends main-class^ ())
Expand Down
2 changes: 1 addition & 1 deletion gui-lib/info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@

(define pkg-authors '(mflatt robby))

(define version "1.59")
(define version "1.60")

0 comments on commit e5c1201

Please sign in to comment.