Skip to content

Commit 47f6805

Browse files
committed
improve new color scheme preference defaults
In particular, adjust the color scheme preference keys so the new organization exclusively uses new keys, which lets the value of those new preferences be determined by the values of the old preferences
1 parent f01591b commit 47f6805

File tree

2 files changed

+77
-25
lines changed

2 files changed

+77
-25
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,8 @@ on top's background stays in the wrong mode.
758758
(sort (set->list known-color-names) symbol<?)
759759
(sort (set->list known-style-names) symbol<?))
760760
(define preferred-color-scheme (if (white-on-black-color-scheme?)
761-
(preferences:get 'framework:color-scheme-wob)
762-
(preferences:get 'framework:color-scheme)))
761+
(preferences:get 'framework:color-scheme-dark)
762+
(preferences:get 'framework:color-scheme-light)))
763763
(for ([dir (in-list (find-relevant-directories '(framework:color-schemes)))])
764764
(define info (with-handlers ([exn:fail?
765765
(λ (x)
@@ -1033,7 +1033,7 @@ on top's background stays in the wrong mode.
10331033
;; if some color scheme goes away, we have some
10341034
;; reasonable backup plan (and, if it comes back
10351035
;; we don't lose the prefs)
1036-
(define pref-name (if wob? 'framework:color-scheme-wob 'framework:color-scheme))
1036+
(define pref-name (if wob? 'framework:color-scheme-dark 'framework:color-scheme-light))
10371037
(define pref-val (preferences:get pref-name))
10381038
(define found-color-scheme (lookup-color-scheme pref-val))
10391039
(cond
@@ -1060,8 +1060,8 @@ on top's background stays in the wrong mode.
10601060
known-color-scheme))
10611061
(car known-color-schemes)))
10621062
(preferences:set (if (color-scheme-white-on-black-base? color-scheme)
1063-
'framework:color-scheme-wob
1064-
'framework:color-scheme)
1063+
'framework:color-scheme-dark
1064+
'framework:color-scheme-light)
10651065
(color-scheme-name color-scheme))
10661066
(when (equal? (color-scheme-white-on-black-base? color-scheme)
10671067
(white-on-black-color-scheme?))
@@ -1323,8 +1323,8 @@ on top's background stays in the wrong mode.
13231323
i))))
13241324
(preferences:add-callback pref-sym (λ (sym val) (update-choice val)))
13251325
(update-choice (preferences:get pref-sym)))
1326-
(setup-color-scheme-choice #f (string-constant light-mode-scheme) 'framework:color-scheme)
1327-
(setup-color-scheme-choice #t (string-constant dark-mode-scheme) 'framework:color-scheme-wob)
1326+
(setup-color-scheme-choice #f (string-constant light-color-scheme) 'framework:color-scheme-light)
1327+
(setup-color-scheme-choice #t (string-constant dark-color-scheme) 'framework:color-scheme-dark)
13281328

13291329
(define color-scheme-examples-vp
13301330
(new-vertical-panel%

gui-lib/framework/private/main.rkt

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,6 @@
4343

4444
(preferences:set-default 'framework:ascii-art-enlarge #f boolean?)
4545

46-
;; the name of the color scheme that the user prefers when in black-on-white mode
47-
(preferences:set-default 'framework:color-scheme
48-
'classic
49-
symbol?)
50-
;; the name of the color scheme that the user prefers when in white-on-black mode
51-
(preferences:set-default 'framework:color-scheme-wob
52-
'white-on-black
53-
symbol?)
54-
5546
(preferences:set-default 'framework:column-guide-width
5647
'(#f 102)
5748
(list/c boolean? (and/c exact-integer? (>=/c 2))))
@@ -229,14 +220,75 @@
229220

230221
(set-square-bracket-nonum-pref 'framework:square-bracket:for/fold for/folds)
231222

223+
;; this preference shouldn't be used any more; we keep it here
224+
;; only so we can access it's old value
225+
(preferences:set-default 'framework:color-scheme 'classic symbol?)
226+
227+
(define dark-mode-with-previous-preferences-organization?
228+
;; all of the color schemes on the package server with
229+
;; 'white-on-black-base? set to #t
230+
(and (member (preferences:get 'framework:color-scheme)
231+
'(white-on-black
232+
|Tol's White on Black|
233+
|Catppuccin Frappe|
234+
|Catppuccin Macchiato|
235+
|Catppuccin Mocha|
236+
|Dracula|
237+
|Cyberpunk|
238+
|Everforest Dark Hard|
239+
|Everforest Dark Medium|
240+
|Everforest Dark Low|
241+
|Material|
242+
|One Dark|
243+
|Dark Green - blue style|
244+
|Dark Green - orange style|
245+
|Solarized Dark|
246+
|Sonokai|
247+
|fairyfloss|
248+
|Funktionuckelt Dark|
249+
250+
;; these two have a #f set in the info.rkt file, but
251+
;; seems to actually intended to be dark color schemes
252+
|ayu mirage|
253+
|Zenburn|
254+
))
255+
#t))
256+
257+
;; the name of the color scheme that the user prefers when in black-on-white mode
258+
;; the default is based on the previous preferences organization, preserving the
259+
;; chosen preference if we can.
260+
(preferences:set-default 'framework:color-scheme-light
261+
(if dark-mode-with-previous-preferences-organization?
262+
'classic
263+
(preferences:get 'framework:color-scheme))
264+
symbol?)
265+
;; the name of the color scheme that the user prefers when in white-on-black mode
266+
(preferences:set-default 'framework:color-scheme-dark
267+
(if dark-mode-with-previous-preferences-organization?
268+
(preferences:get 'framework:color-scheme)
269+
'white-on-black)
270+
symbol?)
271+
272+
232273
;; either:
233-
;; #t (meaning we always treat it as white-on-black mode)
234-
;; #f (meaning we always treat it as black-on-white mode), or
274+
;; #t (meaning we always treat it as white-on-black aka dark mode)
275+
;; #f (meaning we always treat it as black-on-white aka light mode), or
235276
;; 'platform (meaning we use `white-on-black-panel-scheme?` to determine what to do)
236277
(preferences:set-default 'framework:white-on-black-mode?
278+
;; in the past, the 'framework:color-scheme preference
279+
;; determined a single color scheme; use that scheme's
280+
;; dark/light mode category to determine the default
281+
;; preference for this preference, preferring 'platform
282+
;; if 'platform seems to make sense
237283
(case (system-type)
238-
[(windows) #f]
239-
[else 'platform])
284+
[(windows)
285+
dark-mode-with-previous-preferences-organization?]
286+
[else
287+
(cond
288+
[(equal? dark-mode-with-previous-preferences-organization?
289+
(white-on-black-panel-scheme?))
290+
'platform]
291+
[else dark-mode-with-previous-preferences-organization?])])
240292
(or/c boolean? 'platform))
241293

242294
;; this is an old setting that has been replaced with 'framework:white-on-black-mode?
@@ -606,8 +658,8 @@
606658
'platform)
607659
(define pref
608660
(if (white-on-black-panel-scheme?)
609-
'framework:color-scheme-wob
610-
'framework:color-scheme))
661+
'framework:color-scheme-dark
662+
'framework:color-scheme-light))
611663
(define scheme-name (preferences:get pref))
612664
(color-prefs:change-colors-to-match-color-scheme
613665
(or (color-prefs:lookup-color-scheme scheme-name)
@@ -616,15 +668,15 @@
616668
(color-prefs:built-in-color-scheme)))))))
617669

618670
(preferences:add-callback
619-
'framework:color-scheme
671+
'framework:color-scheme-light
620672
(λ (sym val)
621673
(unless (color-prefs:white-on-black-color-scheme?)
622674
(color-prefs:change-colors-to-match-color-scheme
623675
(or (color-prefs:lookup-color-scheme val)
624676
(color-prefs:built-in-color-scheme))))))
625677

626678
(preferences:add-callback
627-
'framework:color-scheme-wob
679+
'framework:color-scheme-dark
628680
(λ (sym val)
629681
(when (color-prefs:white-on-black-color-scheme?)
630682
(color-prefs:change-colors-to-match-color-scheme
@@ -639,7 +691,7 @@
639691
['platform (white-on-black-panel-scheme?)]
640692
[#t #t]
641693
[#f #f]))
642-
(define pref-name (if wob? 'framework:color-scheme-wob 'framework:color-scheme))
694+
(define pref-name (if wob? 'framework:color-scheme-dark 'framework:color-scheme-light))
643695
(define pref-val (preferences:get pref-name))
644696
(define found-color-scheme (color-prefs:lookup-color-scheme pref-val))
645697
(color-prefs:change-colors-to-match-color-scheme

0 commit comments

Comments
 (0)