From e5cb582ed552a309660d23dc72b8a6af6abc24dd Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 14 Sep 2015 09:43:19 -0500 Subject: [PATCH] change the preferences defaults so that the default for bold in the color schemes isn't "turn it off" but instead "defer to the default" --- gui-lib/framework/main.rkt | 7 +++++-- gui-lib/framework/private/color-prefs.rkt | 25 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gui-lib/framework/main.rkt b/gui-lib/framework/main.rkt index 310cd6e3..946be03a 100644 --- a/gui-lib/framework/main.rkt +++ b/gui-lib/framework/main.rkt @@ -1876,7 +1876,7 @@ [white-on-black-color (or/c string? (is-a?/c color%))]) (#:style [style (or/c #f string?)] - #:bold? [bold? (style) (if style boolean? #f)] + #:bold? [bold (style) (if style (or/c boolean? 'base) #f)] #:underline? [underline? (style) (if style boolean? #f)] #:italic? [italic? (style) (if style boolean? #f)] #:background @@ -1888,7 +1888,10 @@ (#f #f #f #f #f) @{Registers a new color or style named @racket[name] for use in the color schemes. If @racket[style] is provided, a new style is registered; if not a color is - registered.}) + registered. + + The default values of all of the keyword arguments are @racket[#f], except + @racket[bold], which defaults to @racket['base] (if @racket[style] is not @racket[#f]).}) (proc-doc/names color-prefs:add-color-scheme-preferences-panel diff --git a/gui-lib/framework/private/color-prefs.rkt b/gui-lib/framework/private/color-prefs.rkt index bcea7559..6181511a 100644 --- a/gui-lib/framework/private/color-prefs.rkt +++ b/gui-lib/framework/private/color-prefs.rkt @@ -324,11 +324,14 @@ style)) - (define (make-style-delta color bold? underline? italic? #:background [background #f]) + (define (make-style-delta color bold underline? italic? #:background [background #f]) (define sd (make-object style-delta%)) (send sd set-delta-foreground color) (cond - [bold? + [(equal? bold 'base) + (send sd set-weight-on 'base) + (send sd set-weight-off 'base)] + [bold (send sd set-weight-on 'bold) (send sd set-weight-off 'base)] [else @@ -913,7 +916,7 @@ (define (add-color-scheme-entry name _b-o-w-color _w-o-b-color #:style [style-name #f] - #:bold? [bold? #f] + #:bold? [bold 'base] #:underline? [underline? #f] #:italic? [italic? #f] #:background [background #f]) @@ -929,7 +932,7 @@ (hash-set! (color-scheme-mapping (lookup-color-scheme scheme-name)) name (if style-name - (make-style-delta color bold? underline? italic? #:background background) + (make-style-delta color bold underline? italic? #:background background) color))) (update-color white-on-black-color-scheme-name w-o-b-color) (update-color black-on-white-color-scheme-name b-o-w-color) @@ -1071,10 +1074,24 @@ (send standard-delta set-size-mult 0) (send standard-delta set-size-add (editor:get-current-preferred-font-size)) (send standard-delta set-delta-face (preferences:get 'framework:standard-style-list:font-name)) + (send standard-delta set-weight-on (preferences:get 'framework:standard-style-list:weight)) + (send standard-delta set-smoothing-on (preferences:get 'framework:standard-style-list:smoothing)) (send style-list new-named-style "Standard" (send style-list find-or-create-style (send style-list basic-style) standard-delta)) + (define (update-standard-delta f) + (define delta (make-object style-delta%)) + (define std (send style-list find-named-style "Standard")) + (send std get-delta delta) + (f delta) + (send std set-delta delta)) + (preferences:add-callback + 'framework:standard-style-list:weight + (λ (p v) (update-standard-delta (lambda (delta) (send delta set-weight-on v))))) + (preferences:add-callback + 'framework:standard-style-list:smoothing + (λ (p v) (update-standard-delta (lambda (delta) (send delta set-smoothing-on v))))) (for ([name (in-set known-style-names)]) (define pref-hash (preferences:get (color-scheme-entry-name->pref-name name))) (define delta