]> gitweb.factorcode.org Git - factor.git/blob - basis/prettyprint/stylesheet/stylesheet.factor
Merge branch 'master' of git://github.com/slavapestov/factor
[factor.git] / basis / prettyprint / stylesheet / stylesheet.factor
1 ! Copyright (C) 2009 Keith Lazuka.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs colors colors.constants combinators
4 combinators.short-circuit hashtables io.styles kernel literals
5 namespaces sequences words words.symbol ;
6 IN: prettyprint.stylesheet
7
8 <PRIVATE
9
10 CONSTANT: dim-color COLOR: gray35
11
12 { POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: }
13 [
14     { { foreground $ dim-color } }
15     "word-style" set-word-prop
16 ] each
17
18 PREDICATE: highlighted-word < word [ parsing-word? ] [ delimiter? ] bi or ;
19
20 PRIVATE>
21
22 GENERIC: word-style ( word -- style )
23
24 M: word word-style
25     [ presented associate ]
26     [ "word-style" word-prop >hashtable ] bi assoc-union ;
27
28 M: highlighted-word word-style
29     call-next-method COLOR: DarkSlateGray foreground associate
30     swap assoc-union ;
31
32 <PRIVATE
33
34 : colored-presentation-style ( obj color -- style )
35     [ presented associate ] [ foreground associate ] bi* assoc-union ;
36
37 PRIVATE>
38
39 : string-style ( str -- style )
40     COLOR: LightSalmon4 colored-presentation-style ;
41
42 : vocab-style ( vocab -- style )
43     dim-color colored-presentation-style ;
44
45 SYMBOL: stack-effect-style
46
47 H{
48     { foreground COLOR: FactorDarkGreen }
49     { font-style plain }
50 } stack-effect-style set-global
51
52 : effect-style ( effect -- style )
53     presented associate stack-effect-style get assoc-union ;