! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-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 ;
+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 ;
[ vocab-name ] sort-with ;
: pprint-using ( seq -- )
- [ "syntax" vocab = not ] filter
+ "syntax" lookup-vocab '[ _ = ] reject
sort-vocabs [
\ USING: pprint-word
[ pprint-vocab ] each
GENERIC: pprint-qualified ( qualified -- )
-M: qualified pprint-qualified ( qualified -- )
+M: qualified pprint-qualified
[
dup [ vocab>> vocab-name ] [ prefix>> ] bi = [
\ QUALIFIED: pprint-word
] if
] with-pprint ;
-M: from pprint-qualified ( from -- )
+M: from pprint-qualified
[
\ FROM: pprint-word
[ vocab>> pprint-vocab "=>" text ]
\ ; pprint-word
] with-pprint ;
-M: exclude pprint-qualified ( exclude -- )
+M: exclude pprint-qualified
[
\ EXCLUDE: pprint-word
[ vocab>> pprint-vocab "=>" text ]
\ ; pprint-word
] with-pprint ;
-M: rename pprint-qualified ( rename -- )
+M: rename pprint-qualified
[
\ RENAME: pprint-word
[ word>> text ]
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 ;
: 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" } } [
"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 COLOR: FactorLightTan }
- { border-color COLOR: FactorDarkTan }
- { inset { 5 5 } }
- } [ 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