Handbook
Glossary
stream-format ( str style stream -- )
Factor handbook
»
Input and output
»
Formatted output
»
Formatted stream protocol
Next:
make-span-stream ( style stream -- stream' )
Vocabulary
io
.
styles
Inputs
str
a
string
style
an
assoc
stream
an output stream
Outputs
None
Generic word contract
Writes formatted text to the stream. If the stream does buffering, output may not be performed immediately; use
stream-flush
to force output.
The
style
assoc holds character style information. See
Character styles
.
Notes
Most code only works on one stream at a time and should instead use
format
; see
Default input and output streams
.
Errors
Throws an error if the I/O operation fails.
Definition
IN:
io.styles
GENERIC:
stream-format
( str style stream -- )
Methods
USING:
accessors
assocs
io
io.streams.256color.private
io.streams.escape-codes
io.styles
kernel
;
M::
256color
stream-format
( str style stream -- )
stream
stream>>
:>
out style
foreground
of
[
color>foreground
out
stream-write
t
]
[
f
]
if*
style
background
of
[
color>background
out
stream-write
drop
t
]
when*
style
font-style
of
[
ansi-font-style
out
stream-write
drop
t
]
when*
str out
stream-write
[
"\e[0m"
out
stream-write
]
when
;
USING:
accessors
assocs
io
io.streams.ansi.private
io.streams.escape-codes
io.styles
kernel
;
M::
ansi
stream-format
( str style stream -- )
stream
stream>>
:>
out style
foreground
of
[
stream
color>foreground
out
stream-write
t
]
[
f
]
if*
style
background
of
[
stream
color>background
out
stream-write
drop
t
]
when*
style
font-style
of
[
ansi-font-style
out
stream-write
drop
t
]
when*
str out
stream-write
[
"\e[0m"
out
stream-write
]
when
;
USING:
accessors
io.streams.duplex
io.styles
kernel
;
M:
duplex-stream
stream-format
[
out>>
]
call
\
stream-format
execute
;
USING:
accessors
io.styles
kernel
;
M:
filter-writer
stream-format
[
stream>>
]
call
\
stream-format
execute
;
USING:
html.streams
html.streams.private
io.styles
;
M:
html-writer
stream-format
format-html-span
;
USING:
io.styles
kernel
ui.gadgets.panes
ui.gadgets.panes.private
;
M:
pane-stream
stream-format
[
[
pane-format
]
2curry
split-pane
]
do-pane-stream
;
USING:
accessors
io.styles
kernel
pdf.streams
pdf.streams.private
sequences
;
M:
pdf-writer
stream-format
[
string>texts
]
[
data>>
]
bi*
push-all
;
USING:
io
io.streams.plain
io.styles
kernel
;
M:
plain-writer
stream-format
nip
stream-write
;
USING:
io.styles
io.styles.private
;
M:
style-stream
stream-format
nested-style
stream-format
;