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
10 { POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: }
12 { { foreground COLOR: gray35 } }
13 "word-style" set-word-prop
16 PREDICATE: highlighted-word < word [ parsing-word? ] [ delimiter? ] bi or ;
20 SYMBOL: base-word-style
21 H{ } base-word-style set-global
23 GENERIC: word-style ( word -- style )
26 [ presented base-word-style get clone [ set-at ] keep ]
27 [ "word-style" word-prop ] bi assoc-union! ;
29 SYMBOL: highlighted-word-style
31 { foreground COLOR: DarkSlateGray }
32 } highlighted-word-style set-global
34 M: highlighted-word word-style
35 call-next-method highlighted-word-style get assoc-union! ;
37 SYMBOL: base-string-style
39 { foreground COLOR: LightSalmon4 }
40 } base-string-style set-global
42 : string-style ( str -- style )
43 presented base-string-style get clone [ set-at ] keep ;
45 SYMBOL: base-vocab-style
47 { foreground COLOR: gray35 }
48 } base-vocab-style set-global
50 : vocab-style ( vocab -- style )
51 presented base-vocab-style get clone [ set-at ] keep ;
53 SYMBOL: stack-effect-style
55 { foreground COLOR: FactorDarkGreen }
57 } stack-effect-style set-global
59 : effect-style ( effect -- style )
60 presented stack-effect-style get clone [ set-at ] keep ;