pub struct Console { /* private fields */ }Expand description
Writes widgets to one output stream, in the colour and at the width decided for that stream.
A console renders a Renderable at the stream’s width, encodes the lines
with Encoder, and writes them. With colour off it writes the plain text
of the lines. A stream with no width, because the fallback is off, renders
in an unbounded context, so a widget takes its
natural width.
Implementations§
Source§impl Console
impl Console
Sourcepub fn new(stream: Stream, terminal: Terminal) -> Self
pub fn new(stream: Stream, terminal: Terminal) -> Self
A console for stream that follows the decision in terminal.
Sourcepub fn from_process(
stream: Stream,
mode: ColorMode,
options: DetectOptions,
) -> Self
Available on crate feature detect only.
pub fn from_process( stream: Stream, mode: ColorMode, options: DetectOptions, ) -> Self
detect only.A console for stream that decides from the process environment and
the stream, under options. Needs the detect feature.
Sourcepub fn render(self, renderable: &dyn Renderable) -> String
pub fn render(self, renderable: &dyn Renderable) -> String
The text print writes for renderable, without writing it.
Sourcepub fn write_to(
self,
writer: &mut dyn Write,
renderable: &dyn Renderable,
) -> Result<(), Error>
pub fn write_to( self, writer: &mut dyn Write, renderable: &dyn Renderable, ) -> Result<(), Error>
Writes renderable to writer as print would write it to the
stream, then flushes.
§Errors
Error::BrokenPipe when the reader has closed writer, and
Error::Io for any other write or flush failure.
Sourcepub fn print(self, renderable: &dyn Renderable) -> Result<(), Error>
Available on crate feature detect only.
pub fn print(self, renderable: &dyn Renderable) -> Result<(), Error>
detect only.Writes renderable to the stream, then flushes. Needs the detect
feature.
§Errors
Error::BrokenPipe when the reader has closed the stream, and
Error::Io for any other write or flush failure.