]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/vocabs/prettyprint/prettyprint.factor
use reject instead of [ ... not ] filter.
[factor.git] / basis / vocabs / prettyprint / prettyprint.factor
index d491acd33b7bf0fd60ec2cba99d9ded1f01d5793..07fecef4a2d96e352ba731d6324b9de7fa2254a5 100644 (file)
@@ -1,12 +1,14 @@
 ! 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
-vocabs.parser make fry math.order ;
+USING: accessors arrays assocs colors colors.constants fry io
+io.styles kernel make math.order namespaces parser
+prettyprint.backend prettyprint.sections prettyprint.stylesheet
+sequences sets sorting vocabs vocabs.parser ;
+FROM: io.styles => inset ;
 IN: vocabs.prettyprint
 
 : pprint-vocab ( vocab -- )
-    [ vocab-name ] [ vocab ] bi present-text ;
+    [ vocab-name ] [ lookup-vocab vocab-style ] bi styled-text ;
 
 : pprint-in ( vocab -- )
     [ \ IN: pprint-word pprint-vocab ] with-pprint ;
@@ -14,10 +16,10 @@ IN: vocabs.prettyprint
 <PRIVATE
 
 : sort-vocabs ( seq -- seq' )
-    [ [ vocab-name ] compare ] sort ;
+    [ vocab-name ] sort-with ;
 
 : pprint-using ( seq -- )
-    [ "syntax" vocab = not ] filter
+    [ "syntax" lookup-vocab = ] reject
     sort-vocabs [
         \ USING: pprint-word
         [ pprint-vocab ] each
@@ -62,25 +64,36 @@ M: rename pprint-qualified ( rename -- )
         tri
     ] with-pprint ;
 
+: filter-interesting ( seq -- seq' )
+    [ [ vocab? ] [ extra-words? ] bi or ] reject ;
+
 PRIVATE>
 
-: pprint-manifest ( manifest -- )
+: (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
+    ] { } make ;
+
+: pprint-manifest) ( quots -- )
     [ nl ] [ call( -- ) ] interleave ;
 
+: pprint-manifest ( manifest -- )
+    (pprint-manifest pprint-manifest) ;
+
 [
     nl
     { { font-style bold } { font-name "sans-serif" } } [
         "Restarts were invoked adding vocabularies to the search path." print
-        "To avoid doing this in the future, add the following USING:" print
-        "and IN: forms at the top of the source file:" print nl
+        "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.8 0.8 0.8 1.0 } } }
-    [ manifest get pprint-manifest ] with-nesting
+    {
+        { page-color COLOR: FactorLightTan }
+        { border-color COLOR: FactorDarkTan }
+        { inset { 5 5 } }
+    } [ manifest get pprint-manifest ] with-nesting
     nl nl
-] print-use-hook set-global
\ No newline at end of file
+] print-use-hook set-global