]> gitweb.factorcode.org Git - factor.git/commitdiff
prettyprint.stylesheet: USING/USE/IN are now dimmed out. Added documentation.
authorKeith Lazuka <klazuka@gmail.com>
Wed, 9 Sep 2009 19:27:49 +0000 (15:27 -0400)
committerKeith Lazuka <klazuka@gmail.com>
Wed, 9 Sep 2009 19:27:49 +0000 (15:27 -0400)
basis/prettyprint/stylesheet/stylesheet-docs.factor [new file with mode: 0644]
basis/prettyprint/stylesheet/stylesheet.factor
basis/prettyprint/stylesheet/summary.txt [new file with mode: 0644]

diff --git a/basis/prettyprint/stylesheet/stylesheet-docs.factor b/basis/prettyprint/stylesheet/stylesheet-docs.factor
new file mode 100644 (file)
index 0000000..4f7a7f2
--- /dev/null
@@ -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"
index 2be959cc9be35df71c2310618505eace9abac905..eaed7cba0c1a10119cf8e2b30c90dd6fbf4f997b 100644 (file)
@@ -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 )
diff --git a/basis/prettyprint/stylesheet/summary.txt b/basis/prettyprint/stylesheet/summary.txt
new file mode 100644 (file)
index 0000000..39a50c8
--- /dev/null
@@ -0,0 +1 @@
+prettyprinter syntax highlighting and formatted output