]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/theme/switching/switching.factor
ui.theme.switching: track whether we've changed the theme.
[factor.git] / basis / ui / theme / switching / switching.factor
1 ! Copyright (C) 2016 Nicolas PĂ©net.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs fonts hashtables help.stylesheet help.tips
4 io.styles kernel listener namespaces prettyprint.stylesheet
5 sequences ui.theme ui.tools.listener vocabs.prettyprint words ;
6 IN: ui.theme.switching
7
8 SYMBOL: default-theme?
9 t default-theme? set-global
10
11 <PRIVATE
12
13 : update-style ( style color elt -- )
14     '[ _ _ rot ?set-at ] change-global ;
15
16 : update-stylesheet ( -- )
17     ! fonts
18     text-color default-font-foreground-color set-global
19     content-background default-font-background-color set-global
20
21     ! help.stylesheet
22     default-style text-color foreground update-style
23     link-style link-color foreground update-style
24     title-style title-color foreground update-style
25     title-style help-header-background page-color update-style
26     help-path-style help-path-border-color table-border update-style
27     heading-style heading-color foreground update-style
28     snippet-style snippet-color foreground update-style
29     code-style code-background-color page-color update-style
30     output-style output-color foreground update-style
31     url-style link-color foreground update-style
32     warning-style warning-background-color page-color update-style
33     warning-style warning-border-color border-color update-style
34     deprecated-style deprecated-background-color page-color update-style
35     deprecated-style deprecated-border-color border-color update-style
36     table-style table-border-color table-border update-style
37
38     ! help.tips
39     tip-of-the-day-style tip-background-color page-color update-style
40
41     ! ui.tools.listener
42     listener-input-style text-color foreground update-style
43     listener-word-style text-color foreground update-style
44
45     ! prettyprint.stylesheet
46     { POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: }
47     [ "word-style" word-prop [ dim-color foreground  ] dip set-at ] each
48     base-word-style text-color foreground update-style
49     highlighted-word-style highlighted-word-color foreground update-style
50     base-string-style string-color foreground update-style
51     base-vocab-style dim-color foreground update-style
52     base-effect-style stack-effect-color foreground update-style
53
54     ! listener
55     prompt-style prompt-background-color background update-style
56     prompt-style text-color foreground update-style
57
58     ! vocabs.prettyprint
59     manifest-style vocab-background-color page-color update-style
60     manifest-style vocab-border-color border-color update-style ;
61
62 PRIVATE>
63
64 : switch-theme ( theme -- )
65     theme set-global update-stylesheet
66     f default-theme? set-global ;
67
68 : light-mode ( -- ) light-theme switch-theme ;
69
70 : dark-mode ( -- ) dark-theme switch-theme ;