From 492ddab085a1d87a70843df772b044ceb84adb3d Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 4 Aug 2013 16:03:08 -0500 Subject: [PATCH] set the background and the foreground color (not just the foreground) when switching to white-on-black mode (or back). this causes the cursor in embedded editors to pick up the right colors (since it is selected by the inverse of the background color of the style of the enclosing editor snip) closes PR 13943 --- pkgs/gui-pkgs/gui-lib/framework/main.rkt | 10 ++++++---- pkgs/gui-pkgs/gui-lib/framework/private/editor.rkt | 13 +++++++------ pkgs/gui-pkgs/gui-lib/framework/private/main.rkt | 10 ++++++++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/pkgs/gui-pkgs/gui-lib/framework/main.rkt b/pkgs/gui-pkgs/gui-lib/framework/main.rkt index 459a459ef2..ec0b4ed1f8 100644 --- a/pkgs/gui-pkgs/gui-lib/framework/main.rkt +++ b/pkgs/gui-pkgs/gui-lib/framework/main.rkt @@ -1605,10 +1605,12 @@ (proc-doc/names editor:set-default-font-color - (-> (is-a?/c color%) void?) - (color) - @{Sets the color of the style named - @racket[editor:get-default-color-style-name].}) + (->* ((is-a?/c color%)) ((or/c #f (is-a?/c color%))) void?) + ((fg-color) ((bg-color #f))) + @{Sets the foreground color of the style named + @racket[editor:get-default-color-style-name] to @racket[fg-color]. + If @racket[bg-color] is not @racket[#f], then @racket[editor:set-default-font-color] + sets the background color to @racket[bg-color].}) (proc-doc/names editor:get-default-color-style-name diff --git a/pkgs/gui-pkgs/gui-lib/framework/private/editor.rkt b/pkgs/gui-pkgs/gui-lib/framework/private/editor.rkt index 5605b10168..0862811c68 100644 --- a/pkgs/gui-pkgs/gui-lib/framework/private/editor.rkt +++ b/pkgs/gui-pkgs/gui-lib/framework/private/editor.rkt @@ -359,12 +359,13 @@ (send standard-style-list find-named-style "Standard") delta)))) - (define (set-default-font-color color) - (let* ([the-standard (send standard-style-list find-named-style default-color-style-name)] - [the-delta (make-object style-delta%)]) - (send the-standard get-delta the-delta) - (send the-delta set-delta-foreground color) - (send the-standard set-delta the-delta))) +(define (set-default-font-color color [bg-color #f]) + (define the-standard (send standard-style-list find-named-style default-color-style-name)) + (define the-delta (make-object style-delta%)) + (send the-standard get-delta the-delta) + (send the-delta set-delta-foreground color) + (when bg-color (send the-delta set-delta-background bg-color)) + (send the-standard set-delta the-delta)) (define (set-font-size size) (update-standard-style diff --git a/pkgs/gui-pkgs/gui-lib/framework/private/main.rkt b/pkgs/gui-pkgs/gui-lib/framework/private/main.rkt index 059c763005..f7332e225d 100644 --- a/pkgs/gui-pkgs/gui-lib/framework/private/main.rkt +++ b/pkgs/gui-pkgs/gui-lib/framework/private/main.rkt @@ -413,10 +413,16 @@ (preferences:set-default 'framework:coloring-active #t boolean?) (color-prefs:set-default/color-scheme 'framework:default-text-color "black" "white") +(define (invert-a-color color) + (make-object color% + (- 255 (send color red)) + (- 255 (send color green)) + (- 255 (send color blue)))) (preferences:add-callback 'framework:default-text-color (λ (p v) - (editor:set-default-font-color v))) -(editor:set-default-font-color (preferences:get 'framework:default-text-color)) + (editor:set-default-font-color v (invert-a-color v)))) +(editor:set-default-font-color (preferences:get 'framework:default-text-color) + (invert-a-color (preferences:get 'framework:default-text-color))) (color-prefs:set-default/color-scheme 'framework:misspelled-text-color "black" "white")