stream-write-table ( table-cells style stream -- )
Factor documentation > Factor handbook > Input and output > Formatted output > Formatted stream protocol
Prev:make-cell-stream ( style stream -- stream' )


Vocabulary
io.styles

Inputs and outputs
table-cellsa sequence of sequences of table cells
stylean assoc
streaman output stream


Generic word contract
Prints a table of cells produced by with-cell.

The style hashtable holds table style information. See Table styles.

Notes
Most code only works on one stream at a time and should instead use tabular-output; see Default input and output streams.

Errors
Throws an error if the I/O operation fails.

See also
table-gap, table-border, tabular-output

Definition
IN: io.styles

GENERIC: stream-write-table ( table-cells style stream -- )


Methods
USING: accessors io io.streams.256color.private io.styles
kernel sequences strings strings.tables ;

M: 256color stream-write-table
[
drop [ [ stream>> >string ] map ] map format-table
[ nl ] [ write ] interleave
] with-output-stream* ;


USING: accessors io.streams.duplex io.styles kernel ;

M: duplex-stream stream-write-table
[ out>> ] call \ stream-write-table execute ;


USING: accessors io.styles kernel ;

M: filter-writer stream-write-table
[ stream>> ] call \ stream-write-table execute ;


USING: accessors html.streams html.streams.private io.styles
kernel sequences xml.data xml.syntax.private ;

M: html-writer stream-write-table
[
table-style swap [
[
data>> 2 nenum
T{ xml-chunk { seq ~vector~ } } interpolate-xml
] with map 1 nenum
T{ xml-chunk { seq V{ "" ~tag~ "" } } }
interpolate-xml
] with map 1 nenum T{ xml-chunk
{ seq
V{
""
T{ tag
{ name ~name~ }
{ attrs ~attrs~ }
{ children ~vector~ }
}
""
}
}
} interpolate-xml
] emit-html ;


USING: accessors io.styles kernel sequences ui.gadgets.panes
ui.gadgets.panes.private ;

M: pane-stream stream-write-table
[ swap [ [ pane>> smash-pane ] map ] map styled-grid ] dip
write-gadget ;


USING: accessors io.styles kernel pdf.layout pdf.streams
sequences ;

M: pdf-writer stream-write-table
nip swap [ [ data>> <table-cell> ] map <table-row> ] map
<table> swap data>> push ;


USING: io io.streams.plain io.styles kernel sequences strings
strings.tables ;

M: plain-writer stream-write-table
[
drop [ [ >string ] map ] map format-table
[ nl ] [ write ] interleave
] with-output-stream* ;


USING: accessors io.styles kernel sequences ;

M: style-stream stream-write-table
[ [ [ stream>> ] map ] map ] [ ] [ stream>> ] tri*
stream-write-table ;