]> gitweb.factorcode.org Git - factor.git/blob - basis/prettyprint/stylesheet/stylesheet.factor
help browser: tweaked the colors based on user feedback.
[factor.git] / basis / prettyprint / stylesheet / stylesheet.factor
1 ! Copyright (C) 2009 Your name.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: colors.constants combinators combinators.short-circuit
4 hashtables io.styles kernel namespaces sequences words
5 words.symbol ;
6 IN: prettyprint.stylesheet
7
8 <PRIVATE
9
10 CONSTANT: dim-color COLOR: gray35
11 CONSTANT: alt-color COLOR: DarkSlateGray
12
13 : dimly-lit-word? ( word -- ? )
14     { POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: } memq? ;
15
16 : parsing-or-delim-word? ( word -- ? )
17     [ parsing-word? ] [ delimiter? ] bi or ;
18
19 : word-color ( word -- color )
20     {
21         { [ dup dimly-lit-word? ] [ drop dim-color ] }
22         { [ dup parsing-or-delim-word? ] [ drop alt-color ] }
23         [ drop COLOR: black ]
24     } cond ;
25
26 PRIVATE>
27
28 : word-style ( word -- style )
29     dup "word-style" word-prop >hashtable [
30         [
31             [ presented set ] [ word-color foreground set ] bi
32         ] bind
33     ] keep ;
34
35 : string-style ( str -- style )
36     [
37         presented set
38         COLOR: LightSalmon4 foreground set
39     ] H{ } make-assoc ;
40
41 : vocab-style ( vocab -- style )
42     [
43         presented set
44         dim-color foreground set
45     ] H{ } make-assoc ;
46
47 : effect-style ( effect -- style )
48     [
49         presented set
50         COLOR: DarkGreen foreground set
51     ] H{ } make-assoc ;