]> gitweb.factorcode.org Git - factor.git/blob - basis/prettyprint/stylesheet/stylesheet.factor
factor: trim using lists
[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 io.styles kernel namespaces sequences words ;
4 IN: prettyprint.stylesheet
5
6 <PRIVATE
7
8 { POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: }
9 [
10     { { foreground COLOR: gray35 } }
11     "word-style" set-word-prop
12 ] each
13
14 PREDICATE: highlighted-word < word [ parsing-word? ] [ delimiter? ] bi or ;
15
16 PRIVATE>
17
18 SYMBOL: base-word-style
19 H{ } base-word-style set-global
20
21 GENERIC: word-style ( word -- style )
22
23 M: word word-style
24     [ presented base-word-style get clone [ set-at ] keep ]
25     [ "word-style" word-prop ] bi assoc-union! ;
26
27 SYMBOL: highlighted-word-style
28 H{
29     { foreground COLOR: DarkSlateGray }
30 } highlighted-word-style set-global
31
32 M: highlighted-word word-style
33     call-next-method highlighted-word-style get assoc-union! ;
34
35 SYMBOL: base-string-style
36 H{
37     { foreground COLOR: LightSalmon4 }
38 } base-string-style set-global
39
40 : string-style ( str -- style )
41     presented base-string-style get clone [ set-at ] keep ;
42
43 SYMBOL: base-vocab-style
44 H{
45     { foreground COLOR: gray35 }
46 } base-vocab-style set-global
47
48 : vocab-style ( vocab -- style )
49     presented base-vocab-style get clone [ set-at ] keep ;
50
51 SYMBOL: base-effect-style
52 H{
53     { foreground COLOR: FactorDarkSlateBlue }
54     { font-style plain }
55 } base-effect-style set-global
56
57 : effect-style ( effect -- style )
58     presented base-effect-style get clone [ set-at ] keep ;