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