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