]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/vocabs/prettyprint/prettyprint.factor
factor: trim using lists
[factor.git] / basis / vocabs / prettyprint / prettyprint.factor
index 20f7c15293009ff2ef0241b56b3b7626ae3460cb..986e07ae57b0e6cd9733b7563e4d60bf5447d041 100644 (file)
@@ -1,12 +1,13 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel sorting sequences vocabs io io.styles arrays assocs
-namespaces sets parser colors prettyprint.backend prettyprint.sections
-prettyprint.stylesheet vocabs.parser make fry math.order ;
+USING: accessors assocs colors io io.styles kernel
+make namespaces prettyprint.backend prettyprint.sections
+prettyprint.stylesheet sequences sorting vocabs vocabs.parser ;
+FROM: io.styles => inset ;
 IN: vocabs.prettyprint
 
 : pprint-vocab ( vocab -- )
-    [ vocab-name ] [ vocab vocab-style ] bi styled-text ;
+    [ vocab-name ] [ lookup-vocab vocab-style ] bi styled-text ;
 
 : pprint-in ( vocab -- )
     [ \ IN: pprint-word pprint-vocab ] with-pprint ;
@@ -17,7 +18,7 @@ IN: vocabs.prettyprint
     [ vocab-name ] sort-with ;
 
 : pprint-using ( seq -- )
-    [ "syntax" vocab = not ] filter
+    "syntax" lookup-vocab '[ _ = ] reject
     sort-vocabs [
         \ USING: pprint-word
         [ pprint-vocab ] each
@@ -26,7 +27,7 @@ IN: vocabs.prettyprint
 
 GENERIC: pprint-qualified ( qualified -- )
 
-M: qualified pprint-qualified ( qualified -- )
+M: qualified pprint-qualified
     [
         dup [ vocab>> vocab-name ] [ prefix>> ] bi = [
             \ QUALIFIED: pprint-word
@@ -37,7 +38,7 @@ M: qualified pprint-qualified ( qualified -- )
         ] if
     ] with-pprint ;
 
-M: from pprint-qualified ( from -- )
+M: from pprint-qualified
     [
         \ FROM: pprint-word
         [ vocab>> pprint-vocab "=>" text ]
@@ -45,7 +46,7 @@ M: from pprint-qualified ( from -- )
         \ ; pprint-word
     ] with-pprint ;
 
-M: exclude pprint-qualified ( exclude -- )
+M: exclude pprint-qualified
     [
         \ EXCLUDE: pprint-word
         [ vocab>> pprint-vocab "=>" text ]
@@ -53,7 +54,7 @@ M: exclude pprint-qualified ( exclude -- )
         \ ; pprint-word
     ] with-pprint ;
 
-M: rename pprint-qualified ( rename -- )
+M: rename pprint-qualified
     [
         \ RENAME: pprint-word
         [ word>> text ]
@@ -62,12 +63,15 @@ M: rename pprint-qualified ( rename -- )
         tri
     ] with-pprint ;
 
+: filter-interesting ( seq -- seq' )
+    [ [ vocab? ] [ extra-words? ] bi or ] reject ;
+
 PRIVATE>
 
 : (pprint-manifest ( manifest -- quots )
     [
         [ search-vocabs>> [ '[ _ pprint-using ] , ] unless-empty ]
-        [ qualified-vocabs>> [ extra-words? not ] filter [ '[ _ pprint-qualified ] , ] each ]
+        [ qualified-vocabs>> filter-interesting [ '[ _ pprint-qualified ] , ] each ]
         [ current-vocab>> [ '[ _ pprint-in ] , ] when* ]
         tri
     ] { } make ;
@@ -78,6 +82,12 @@ PRIVATE>
 : pprint-manifest ( manifest -- )
     (pprint-manifest pprint-manifest) ;
 
+CONSTANT: manifest-style H{
+    { page-color COLOR: FactorLightTan }
+    { border-color COLOR: FactorDarkTan }
+    { inset { 5 5 } }
+}
+
 [
     nl
     { { font-style bold } { font-name "sans-serif" } } [
@@ -85,7 +95,6 @@ PRIVATE>
         "To avoid doing this in the future, add the following forms" print
         "at the top of the source file:" print nl
     ] with-style
-    { { page-color T{ rgba f 0.94 0.94 0.91 1.0 } } }
-    [ manifest get pprint-manifest ] with-nesting
+    manifest-style [ manifest get pprint-manifest ] with-nesting
     nl nl
-] print-use-hook set-global
\ No newline at end of file
+] print-use-hook set-global