separate out state for spell checking string constants

from that for spell checking scribble {} content
This commit is contained in:
Robby Findler 2013-10-25 22:28:42 -05:00
parent 5a2332609c
commit ae623ed82d
3 changed files with 44 additions and 6 deletions

View File

@ -200,7 +200,19 @@
@defmethod[(set-spell-check-strings [b? boolean?]) void?]{
If called with @racket[#t], tell the colorer to spell-check
string constants. Otherwise, disable spell-checking of constants.
string constants. Otherwise, disable spell-checking of
string constants.
}
@defmethod[(get-spell-check-text) boolean?]{
Returns @racket[#t] if the colorer will attempt to
spell-check text (e.g., the words inside @litchar[@"{"] and
@litchar[@"}"] in Scribble documents).
}
@defmethod[(set-spell-check-text [b? boolean?]) void?]{
If called with @racket[#t], tell the colorer to spell-check
text constants. Otherwise, disable spell-checking of text.
}
@defmethod[(set-spell-current-dict [dict (or/c string? #f)]) void?]{

View File

@ -67,6 +67,8 @@ added get-regions
set-spell-check-strings
get-spell-check-strings
set-spell-check-text
get-spell-check-text
get-spell-current-dict))
(define text-mixin
@ -233,15 +235,24 @@ added get-regions
;; ---------------------- Preferences -------------------------------
(define should-color? #t)
(define token-sym->style #f)
(define spell-check-strings? (preferences:get 'framework:spell-check-on?))
(define spell-check-strings? (preferences:get 'framework:spell-check-strings?))
(define spell-check-text? (preferences:get 'framework:spell-check-text?))
(define/public (get-spell-check-strings) spell-check-strings?)
(define/public (get-spell-check-text) spell-check-text?)
(define/public (set-spell-check-strings s)
(define new-val (and s #t))
(unless (eq? new-val spell-check-strings?)
(unless (equal? new-val spell-check-strings?)
(set! spell-check-strings? s)
(reset-tokens)
(start-colorer token-sym->style get-token pairs)))
(spell-checking-values-changed)))
(define/public (set-spell-check-text s)
(define new-val (and s #t))
(unless (equal? new-val spell-check-text?)
(set! spell-check-text? s)
(spell-checking-values-changed)))
(define/private (spell-checking-values-changed)
(reset-tokens)
(start-colorer token-sym->style get-token pairs))
(define current-dict (preferences:get 'framework:aspell-dict))
(define/public (set-spell-current-dict d)
(unless (equal? d current-dict)
@ -390,8 +401,13 @@ added get-regions
(define ep (+ in-start-pos (sub1 new-token-end)))
(define style-name (token-sym->style type))
(define color (send (get-style-list) find-named-style style-name))
(define do-spell-check?
(cond
[(equal? type 'string) spell-check-strings?]
[(equal? type 'text) spell-check-text?]
[else #f]))
(cond
[(and spell-check-strings? (eq? type 'string))
[do-spell-check?
(define misspelled-color (send (get-style-list) find-named-style misspelled-text-color-style-name))
(cond
[misspelled-color

View File

@ -40,7 +40,17 @@
;; used to time how long it takes to set a preference; the value is not actually used.
(preferences:set-default 'drracket:prefs-debug #f (λ (x) #t))
;; 'framework:spell-check-on? is only for people who had set
;; prefs in old versions; it isn't used except to provide the
;; default values for the newer prefs: 'framework:spell-check-strings?
;; and 'framework:spell-check-text?
(preferences:set-default 'framework:spell-check-on? #f boolean?)
(preferences:set-default 'framework:spell-check-strings?
(preferences:get 'framework:spell-check-on?)
boolean?)
(preferences:set-default 'framework:spell-check-text?
(preferences:get 'framework:spell-check-on?)
boolean?)
(preferences:set-default 'framework:always-use-platform-specific-linefeed-convention #f boolean?)