Skip to content

Commit 9ce33ae

Browse files
committed
fix up calls to get-current-color-scheme and documentation of the functions that call it
1 parent c25c493 commit 9ce33ae

File tree

2 files changed

+39
-35
lines changed

2 files changed

+39
-35
lines changed

gui-lib/framework/main.rkt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,19 +2343,18 @@ for code that supports @tech{color scheme}s.
23432343
(-> symbol? void?)
23442344
(name)
23452345
@{
2346-
Updates the colors in DrRacket's GUI to the colors in
2347-
the @tech{color scheme} named @racket[name],
2348-
if @racket[name] names one of the color schemes and
2349-
the named color scheme matches the dark/light mode that the GUI is in.
2350-
Otherwise, sets the color scheme to either the
2351-
light or dark mode default color scheme, depending
2352-
on the user's preference for the current mode.
2346+
Set's the user's preferred @tech{color scheme} to
2347+
the one whose name is @racket[name].
2348+
Also, updates the colors in DrRacket's GUI to the colors in
2349+
that color scheme if the named color scheme matches the
2350+
dark/light mode that the GUI is in.
23532351
})
23542352

2355-
(proc-doc
2353+
(proc-doc/names
23562354
color-prefs:get-current-color-scheme-name
2357-
(-> symbol?)
2358-
@{Returns the current @tech{color scheme}'s name.})
2355+
(->* () (#:wob? boolean?) symbol?)
2356+
(() ((wob? (white-on-black-color-scheme?))))
2357+
@{Returns the name of either the user's preferred dark mode or light mode @tech{color scheme}.})
23592358

23602359
(proc-doc/names
23612360
color-prefs:known-color-scheme-name?
@@ -2400,14 +2399,15 @@ of color scheme named @racket[name], if it has one.
24002399
passed as the first argument to @racket[color-prefs:add-color-scheme-entry]
24012400
and the @racket[#:style] argument must have also been omitted or be @racket[#f].})
24022401

2403-
(proc-doc
2402+
(proc-doc
24042403
color-prefs:lookup-in-color-scheme
24052404
(->i ([name color-prefs:known-color-scheme-name?])
2406-
()
2405+
(#:wob? [wob boolean?])
24072406
[result (name)
24082407
(if (color-prefs:color-scheme-style-name? name)
24092408
(is-a?/c style-delta%)
24102409
(is-a?/c color%))])
2410+
((white-on-black-color-scheme?))
24112411
@{Returns the current style delta or color associated with @racket[name].})
24122412

24132413
(proc-doc

gui-lib/framework/private/color-prefs.rkt

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -944,11 +944,11 @@
944944
1.0)))
945945

946946
;; returns the user's preferred color, wrt to the current color scheme
947-
(define (lookup-in-color-scheme color-name)
947+
(define (lookup-in-color-scheme color-name #:wob? [wob? (white-on-black-color-scheme?)])
948948
(lookup-in-color-scheme/given-mapping
949949
color-name
950950
(preferences:get (color-scheme-entry-name->pref-name color-name))
951-
(get-current-color-scheme)))
951+
(get-current-color-scheme #:wob? wob?)))
952952

953953
(define (lookup-in-given-color-scheme color-name color-scheme)
954954
(lookup-in-color-scheme/given-mapping
@@ -980,7 +980,7 @@
980980
;; set-color : symbol (or/c string? (is-a?/c color%) (is-a?/c style-delta%)) -> void
981981
(define (set-in-color-scheme color-name clr/sd)
982982
(define table (preferences:get (color-scheme-entry-name->pref-name color-name)))
983-
(define current-color-scheme (get-current-color-scheme))
983+
(define current-color-scheme (get-current-color-scheme #:wob? (white-on-black-color-scheme?)))
984984
(define scheme-name (color-scheme-name current-color-scheme))
985985
(define new-table
986986
(cond
@@ -1011,7 +1011,7 @@
10111011
(= (send c1 blue) (send c2 blue))
10121012
(= (send c1 alpha) (send c2 alpha))))
10131013

1014-
(define (get-current-color-scheme #:wob? [wob? #f])
1014+
(define (get-current-color-scheme #:wob? wob?)
10151015
;; if pref is not recognized as an existing color scheme name,
10161016
;; return one of the two original color schemes so that
10171017
;; if some color scheme goes away, we have some
@@ -1025,7 +1025,7 @@
10251025
[wob? (built-in-wob-color-scheme)]
10261026
[else (built-in-color-scheme)]))
10271027

1028-
(define (get-current-color-scheme-name #:wob? [wob? #f])
1028+
(define (get-current-color-scheme-name #:wob? [wob? (white-on-black-color-scheme?)])
10291029
(color-scheme-name (get-current-color-scheme #:wob? wob?)))
10301030

10311031
;; string -> (or/c #f color-scheme?)
@@ -1107,7 +1107,8 @@
11071107
(fn (lookup-in-color-scheme/given-mapping
11081108
color
11091109
ht
1110-
(get-current-color-scheme)))))))
1110+
(get-current-color-scheme
1111+
#:wob? (white-on-black-color-scheme?))))))))
11111112
(void))
11121113

11131114
;; we remove elements of the list when the function isn't reachable anymore
@@ -1315,13 +1316,7 @@
13151316
(preferences:set 'framework:white-on-black-mode?
13161317
(match (send white-on-black-mode-choice get-selection)
13171318
[0 #f]
1318-
[1 #t])))])
1319-
(preferences:add-callback
1320-
'framework:white-on-black-mode?
1321-
(λ (_1 val)
1322-
(send white-on-black-mode-choice
1323-
set-selection
1324-
(if val 1 0))))]
1319+
[1 #t])))])]
13251320
[else
13261321
(new choice%
13271322
[parent bottom-hp]
@@ -1335,16 +1330,25 @@
13351330
(match (send white-on-black-mode-choice get-selection)
13361331
[0 'platform]
13371332
[1 #f]
1338-
[2 #t])))])
1339-
(preferences:add-callback
1340-
'framework:white-on-black-mode?
1341-
(λ (_1 val)
1342-
(send white-on-black-mode-choice
1343-
set-selection
1344-
(match val
1345-
['platform 0]
1346-
[#t 2]
1347-
[#f 1]))))]))
1333+
[2 #t])))])]))
1334+
(case (system-type)
1335+
[(windows)
1336+
(preferences:add-callback
1337+
'framework:white-on-black-mode?
1338+
(λ (_1 val)
1339+
(send white-on-black-mode-choice
1340+
set-selection
1341+
(if val 1 0))))]
1342+
[else
1343+
(preferences:add-callback
1344+
'framework:white-on-black-mode?
1345+
(λ (_1 val)
1346+
(send white-on-black-mode-choice
1347+
set-selection
1348+
(match val
1349+
['platform 0]
1350+
[#t 2]
1351+
[#f 1]))))])
13481352
(define wid (apply max (map (λ (x) (send x get-width)) buttons)))
13491353
(for ([b (in-list buttons)])
13501354
(send b min-width wid))

0 commit comments

Comments
 (0)