]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/obj/print/print.factor
Conflict resolution
[factor.git] / unmaintained / obj / print / print.factor
1
2 USING: kernel arrays strings sequences assocs io io.styles prettyprint colors
3        combinators.conditional ;
4
5 IN: obj.print
6
7 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8
9 : write-wrapped ( string -- ) H{ { wrap-margin 500 } } [ write ] with-nesting ;
10
11 ! : print-elt ( val -- )
12 !   {
13 !     { [ string? ] [ write-wrapped ] }
14 !     { [ array?  ] [ [ . ] each    ] }
15 !     { [ drop t  ] [ . ] }
16 !   }
17 !   1cond ;
18
19 USING: accessors vocabs help.markup ;
20
21 : print-elt ( val -- )
22   {
23     { [ vocab?  ] [ [ name>> ] [ ] bi write-object ] }
24     { [ string? ] [ write-wrapped ] }
25     { [ array?  ] [ [ . ] each    ] }
26     { [ drop t  ] [ . ] }
27   }
28   1cond ;
29
30 : print-grid ( grid -- )
31   H{ { table-gap { 10 10 } } { table-border T{ rgba f 0 0 0 1 } } }
32   [ [ [ [ [ print-elt ] with-cell ] each ] with-row ] each ] tabular-output ;
33
34 : print-table ( assoc -- ) >alist print-grid ;
35
36 : print-seq ( seq -- ) [ 1array ] map print-grid ;
37