pub trait Terminal: Write {
// Required methods
fn fg(&mut self, color: u32) -> Result<bool>;
fn reset(&mut self) -> Result<bool>;
}
🔬This is a nightly-only experimental API. (
test
)Expand description
A terminal with similar capabilities to an ANSI Terminal (foreground/background colors etc).
Required Methods§
sourcefn fg(&mut self, color: u32) -> Result<bool>
fn fg(&mut self, color: u32) -> Result<bool>
🔬This is a nightly-only experimental API. (
test
)Sets the foreground color to the given color.
If the color is a bright color, but the terminal only supports 8 colors, the corresponding normal color will be used instead.
Returns Ok(true)
if the color was set, Ok(false)
otherwise, and Err(e)
if there was an I/O error.
sourcefn reset(&mut self) -> Result<bool>
fn reset(&mut self) -> Result<bool>
🔬This is a nightly-only experimental API. (
test
)Resets all terminal attributes and colors to their defaults.
Returns Ok(true)
if the terminal was reset, Ok(false)
otherwise, and Err(e)
if there
was an I/O error.
Note: This does not flush.
That means the reset command may get buffered so, if you aren’t planning on doing anything else that might flush stdout’s buffer (e.g., writing a line of text), you should flush after calling reset.