Paste: revised prettyprinter syntax highlighting
Author: | klazuka |
Mode: | factor |
Date: | Sat, 12 Sep 2009 01:14:55 |
Plain Text |
USING: assocs colors.constants combinators
combinators.short-circuit hashtables io.styles kernel literals
namespaces sequences words words.symbol ;
IN: prettyprint.stylesheet
<PRIVATE
CONSTANT: dim-color COLOR: gray35
CONSTANT: alt-color COLOR: DarkSlateGray
{ POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: }
[
{ { foreground $ dim-color } }
"word-style" set-word-prop
] each
PRIVATE>
GENERIC: word-style ( word -- style )
M: word word-style
[ presented associate ]
[ "word-style" word-prop >hashtable ] bi assoc-union ;
PREDICATE: highlighted-word < word [ parsing-word? ] [ delimiter? ] bi or ;
M: highlighted-word word-style
call-next-method alt-color foreground associate swap assoc-union ;
: string-style ( str -- style )
[
presented set
COLOR: LightSalmon4 foreground set
] H{ } make-assoc ;
: vocab-style ( vocab -- style )
[
presented set
dim-color foreground set
] H{ } make-assoc ;
: effect-style ( effect -- style )
[
presented set
COLOR: DarkGreen foreground set
] H{ } make-assoc ;
Author: | klazuka |
Mode: | factor |
Date: | Sat, 12 Sep 2009 01:30:59 |
Plain Text |
USING: assocs colors.constants combinators
combinators.short-circuit hashtables io.styles kernel literals
namespaces sequences words words.symbol ;
IN: prettyprint.stylesheet
<PRIVATE
CONSTANT: dim-color COLOR: gray35
{ POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: }
[
{ { foreground $ dim-color } }
"word-style" set-word-prop
] each
PRIVATE>
GENERIC: word-style ( word -- style )
M: word word-style
[ presented associate ]
[ "word-style" word-prop >hashtable ] bi assoc-union ;
PREDICATE: highlighted-word < word [ parsing-word? ] [ delimiter? ] bi or ;
M: highlighted-word word-style
call-next-method COLOR: DarkSlateGray foreground associate
swap assoc-union ;
<PRIVATE
: colored-presentation-style ( obj color -- style )
[ presented associate ] [ foreground associate ] bi* assoc-union ;
PRIVATE>
: string-style ( str -- style )
COLOR: LightSalmon4 colored-presentation-style ;
: vocab-style ( vocab -- style )
dim-color colored-presentation-style ;
: effect-style ( effect -- style )
COLOR: DarkGreen colored-presentation-style ;
New Annotation