]> gitweb.factorcode.org Git - factor.git/blob - basis/prettyprint/stylesheet/stylesheet.factor
51544e5b3c4a74a32f6f8552d20bb35ce362fbc1
[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.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     text-color foreground pick set-at ;
26
27 M: highlighted-word word-style
28     call-next-method
29     highlighted-word-color foreground pick set-at ;
30
31 <PRIVATE
32
33 : colored-presentation-style ( obj color -- style )
34     2 <hashtable> [
35         [ presented foreground ] dip
36         [ set-at ] curry bi-curry@ bi*
37     ] keep ;
38
39 PRIVATE>
40
41 : string-style ( str -- style )
42     string-color colored-presentation-style ;
43
44 : vocab-style ( vocab -- style )
45     dim-color colored-presentation-style ;
46
47 SYMBOL: stack-effect-style
48
49 H{
50     { foreground $ stack-effect-color }
51     { font-style plain }
52 } stack-effect-style set-global
53
54 : effect-style ( effect -- style )
55     presented associate stack-effect-style get assoc-union! ;