diff --git a/basis/prettyprint/stylesheet/stylesheet-docs.factor b/basis/prettyprint/stylesheet/stylesheet-docs.factor new file mode 100644 index 0000000000..4f7a7f2141 --- /dev/null +++ b/basis/prettyprint/stylesheet/stylesheet-docs.factor @@ -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" diff --git a/basis/prettyprint/stylesheet/stylesheet.factor b/basis/prettyprint/stylesheet/stylesheet.factor index 2be959cc9b..eaed7cba0c 100644 --- a/basis/prettyprint/stylesheet/stylesheet.factor +++ b/basis/prettyprint/stylesheet/stylesheet.factor @@ -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 + + : 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 ) diff --git a/basis/prettyprint/stylesheet/summary.txt b/basis/prettyprint/stylesheet/summary.txt new file mode 100644 index 0000000000..39a50c8d9f --- /dev/null +++ b/basis/prettyprint/stylesheet/summary.txt @@ -0,0 +1 @@ +prettyprinter syntax highlighting and formatted output