]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/theme/switching/switching.factor
help.stylesheet: adding text-color to code-blocks.
[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 memoize namespaces
5 prettyprint.stylesheet sequences ui.gadgets.panes.private
6 ui.theme ui.tools.listener vocabs.prettyprint words ;
7 IN: ui.theme.switching
8
9 SYMBOL: default-theme?
10 t default-theme? set-global
11
12 <PRIVATE
13
14 : update-style ( style color elt -- )
15     '[ _ _ rot ?set-at ] change-global ;
16
17 : update-stylesheet ( -- )
18     ! fonts
19     text-color default-font-foreground-color set-global
20     content-background default-font-background-color set-global
21
22     ! ui.gadgets.panes
23     \ specified-font reset-memoized
24
25     ! help.stylesheet
26     default-style text-color foreground update-style
27     link-style link-color foreground update-style
28     title-style title-color foreground update-style
29     title-style help-header-background page-color update-style
30     help-path-style text-color foreground update-style
31     help-path-style help-path-border-color table-border update-style
32     heading-style heading-color foreground update-style
33     snippet-style snippet-color foreground update-style
34     code-style code-background-color page-color update-style
35     code-style text-color foreground update-style
36     output-style output-color foreground update-style
37     url-style link-color foreground update-style
38     warning-style warning-background-color page-color update-style
39     warning-style warning-border-color border-color update-style
40     deprecated-style deprecated-background-color page-color update-style
41     deprecated-style deprecated-border-color border-color update-style
42     table-style table-border-color table-border update-style
43
44     ! help.tips
45     tip-of-the-day-style tip-background-color page-color update-style
46
47     ! ui.tools.listener
48     listener-input-style text-color foreground update-style
49     listener-word-style text-color foreground update-style
50
51     ! prettyprint.stylesheet
52     { POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: }
53     [ "word-style" word-prop [ dim-color foreground  ] dip set-at ] each
54     base-word-style text-color foreground update-style
55     highlighted-word-style highlighted-word-color foreground update-style
56     base-string-style string-color foreground update-style
57     base-vocab-style dim-color foreground update-style
58     base-effect-style stack-effect-color foreground update-style
59
60     ! listener
61     prompt-style prompt-background-color background update-style
62     prompt-style text-color foreground update-style
63
64     ! vocabs.prettyprint
65     manifest-style vocab-background-color page-color update-style
66     manifest-style vocab-border-color border-color update-style ;
67
68 PRIVATE>
69
70 : switch-theme ( theme -- )
71     theme set-global update-stylesheet
72     f default-theme? set-global ;
73
74 : switch-theme-if-default ( theme -- )
75     default-theme? get [
76         switch-theme t default-theme? set-global
77     ] [ drop ] if ;
78
79 : light-mode ( -- ) light-theme switch-theme ;
80
81 : dark-mode ( -- ) dark-theme switch-theme ;