2009-09-08 12:43:47 -04:00
|
|
|
! Copyright (C) 2009 Your name.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-09-09 15:27:49 -04:00
|
|
|
USING: colors.constants combinators combinators.short-circuit
|
|
|
|
hashtables io.styles kernel namespaces sequences words
|
|
|
|
words.symbol ;
|
2009-09-08 12:43:47 -04:00
|
|
|
IN: prettyprint.stylesheet
|
|
|
|
|
2009-09-09 15:27:49 -04:00
|
|
|
<PRIVATE
|
|
|
|
|
2009-09-10 09:48:20 -04:00
|
|
|
CONSTANT: dim-color COLOR: gray35
|
|
|
|
CONSTANT: alt-color COLOR: DarkSlateGray
|
2009-09-09 15:27:49 -04:00
|
|
|
|
|
|
|
: dimly-lit-word? ( word -- ? )
|
|
|
|
{ POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: } memq? ;
|
|
|
|
|
2009-09-10 09:48:20 -04:00
|
|
|
: parsing-or-delim-word? ( word -- ? )
|
|
|
|
[ parsing-word? ] [ delimiter? ] bi or ;
|
|
|
|
|
|
|
|
: word-color ( word -- color )
|
|
|
|
{
|
|
|
|
{ [ dup dimly-lit-word? ] [ drop dim-color ] }
|
|
|
|
{ [ dup parsing-or-delim-word? ] [ drop alt-color ] }
|
|
|
|
[ drop COLOR: black ]
|
|
|
|
} cond ;
|
2009-09-09 15:27:49 -04:00
|
|
|
|
|
|
|
PRIVATE>
|
|
|
|
|
2009-09-08 12:43:47 -04:00
|
|
|
: word-style ( word -- style )
|
|
|
|
dup "word-style" word-prop >hashtable [
|
|
|
|
[
|
2009-09-10 09:48:20 -04:00
|
|
|
[ presented set ] [ word-color foreground set ] bi
|
2009-09-08 12:43:47 -04:00
|
|
|
] bind
|
|
|
|
] keep ;
|
|
|
|
|
2009-09-09 16:46:05 -04:00
|
|
|
: string-style ( str -- style )
|
2009-09-08 12:43:47 -04:00
|
|
|
[
|
|
|
|
presented set
|
|
|
|
COLOR: LightSalmon4 foreground set
|
|
|
|
] H{ } make-assoc ;
|
|
|
|
|
|
|
|
: vocab-style ( vocab -- style )
|
|
|
|
[
|
|
|
|
presented set
|
2009-09-09 15:27:49 -04:00
|
|
|
dim-color foreground set
|
2009-09-08 12:43:47 -04:00
|
|
|
] H{ } make-assoc ;
|
|
|
|
|
|
|
|
: effect-style ( effect -- style )
|
|
|
|
[
|
|
|
|
presented set
|
|
|
|
COLOR: DarkGreen foreground set
|
|
|
|
] H{ } make-assoc ;
|