[][src]Struct winapi_util::console::Console

pub struct Console { /* fields omitted */ }

A Windows console.

This represents a very limited set of functionality available to a Windows console. In particular, it can only change text attributes such as color and intensity. This may grow over time. If you need more routines, please file an issue and/or PR.

There is no way to "write" to this console. Simply write to stdout or stderr instead, while interleaving instructions to the console to change text attributes.

A common pitfall when using a console is to forget to flush writes to stdout before setting new text attributes.

Example

use winapi_util::console::{Console, Color, Intense};

let mut con = Console::stdout().unwrap();
con.fg(Intense::Yes, Color::Cyan).unwrap();
println!("This text will be intense cyan.");
con.reset().unwrap();
println!("This text will be normal.");

Methods

impl Console[src]

pub fn stdout() -> Result<Console>[src]

Create a new Console to stdout.

If there was a problem creating the console, then an error is returned.

pub fn stderr() -> Result<Console>[src]

Create a new Console to stderr.

If there was a problem creating the console, then an error is returned.

pub fn fg(&mut self, intense: Intense, color: Color) -> Result<()>[src]

Apply the given intensity and color attributes to the console foreground.

If there was a problem setting attributes on the console, then an error is returned.

pub fn bg(&mut self, intense: Intense, color: Color) -> Result<()>[src]

Apply the given intensity and color attributes to the console background.

If there was a problem setting attributes on the console, then an error is returned.

pub fn reset(&mut self) -> Result<()>[src]

Reset the console text attributes to their original settings.

The original settings correspond to the text attributes on the console when this Console value was created.

If there was a problem setting attributes on the console, then an error is returned.

pub fn set_virtual_terminal_processing(&mut self, yes: bool) -> Result<()>[src]

Toggle virtual terminal processing.

This method attempts to toggle virtual terminal processing for this console. If there was a problem toggling it, then an error returned. On success, the caller may assume that toggling it was successful.

When virtual terminal processing is enabled, characters emitted to the console are parsed for VT100 and similar control character sequences that control color and other similar operations.

Trait Implementations

impl Debug for Console[src]

Auto Trait Implementations

impl RefUnwindSafe for Console

impl Send for Console

impl Sync for Console

impl Unpin for Console

impl UnwindSafe for Console

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.