prettyprint.stylesheet: USING/USE/IN are now dimmed out. Added documentation.
parent
28b8703b5b
commit
5421f4fcb4
|
@ -0,0 +1,44 @@
|
|||
! Copyright (C) 2009 Your name.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: help.markup help.syntax kernel words ;
|
||||
IN: prettyprint.stylesheet
|
||||
|
||||
HELP: effect-style
|
||||
{ $values
|
||||
{ "effect" "an effect" }
|
||||
{ "style" "a style assoc" }
|
||||
}
|
||||
{ $description "The styling hook for stack effects" } ;
|
||||
|
||||
HELP: string-style
|
||||
{ $values
|
||||
{ "str" "a string" }
|
||||
{ "style" "a style assoc" }
|
||||
}
|
||||
{ $description "The styling hook for string literals" } ;
|
||||
|
||||
HELP: vocab-style
|
||||
{ $values
|
||||
{ "vocab" "a vocabulary specifier" }
|
||||
{ "style" "a style assoc" }
|
||||
}
|
||||
{ $description "The styling hook for vocab names" } ;
|
||||
|
||||
HELP: word-style
|
||||
{ $values
|
||||
{ "word" "a word" }
|
||||
{ "style" "a style assoc" }
|
||||
}
|
||||
{ $description "The styling hook for word names" } ;
|
||||
|
||||
ARTICLE: "prettyprint.stylesheet" "Prettyprinter Formatted Output"
|
||||
{ $vocab-link "prettyprint.stylesheet" }
|
||||
$nl
|
||||
"Control the way that the prettyprinter formats output based on object type. These hooks form a basic \"syntax\" highlighting system."
|
||||
{ $subsection word-style }
|
||||
{ $subsection string-style }
|
||||
{ $subsection vocab-style }
|
||||
{ $subsection effect-style }
|
||||
;
|
||||
|
||||
ABOUT: "prettyprint.stylesheet"
|
|
@ -1,16 +1,32 @@
|
|||
! Copyright (C) 2009 Your name.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: colors.constants hashtables io.styles kernel namespaces
|
||||
words words.symbol ;
|
||||
USING: colors.constants combinators combinators.short-circuit
|
||||
hashtables io.styles kernel namespaces sequences words
|
||||
words.symbol ;
|
||||
IN: prettyprint.stylesheet
|
||||
|
||||
<PRIVATE
|
||||
|
||||
CONSTANT: dim-color COLOR: cornsilk4
|
||||
|
||||
: dimly-lit-word? ( word -- ? )
|
||||
{ POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: } memq? ;
|
||||
|
||||
: parsing-word-color ( word -- color )
|
||||
dimly-lit-word? dim-color COLOR: DarkSlateGray ? ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
: word-style ( word -- style )
|
||||
dup "word-style" word-prop >hashtable [
|
||||
[
|
||||
[ presented set ] [
|
||||
[ parsing-word? ] [ delimiter? ] [ symbol? ] tri
|
||||
or or [ COLOR: DarkSlateGray ] [ COLOR: black ] if
|
||||
foreground set
|
||||
{
|
||||
{ [ dup parsing-word? ] [ parsing-word-color ] }
|
||||
{ [ dup delimiter? ] [ drop COLOR: DarkSlateGray ] }
|
||||
{ [ dup symbol? ] [ drop COLOR: DarkSlateGray ] }
|
||||
[ drop COLOR: black ]
|
||||
} cond foreground set
|
||||
] bi
|
||||
] bind
|
||||
] keep ;
|
||||
|
@ -24,7 +40,7 @@ IN: prettyprint.stylesheet
|
|||
: vocab-style ( vocab -- style )
|
||||
[
|
||||
presented set
|
||||
COLOR: cornsilk4 foreground set
|
||||
dim-color foreground set
|
||||
] H{ } make-assoc ;
|
||||
|
||||
: effect-style ( effect -- style )
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
prettyprinter syntax highlighting and formatted output
|
Loading…
Reference in New Issue