diff --git a/Cargo.toml b/Cargo.toml index 8f33a04..a8f7e45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,3 +18,7 @@ travis-ci = { repository = "colin-kiegel/rust-pretty-assertions" } [dependencies] difference = "2.0.0" ansi_term = "0.11" + +[target.'cfg(windows)'.dependencies] +output_vt100 = "0.1" +ctor = "0.1.7" diff --git a/README.md b/README.md index d07cf7f..e593348 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,8 @@ extern crate pretty_assertions; you include. * `assert_ne` is also switched to multi-line presentation, but does _not_ show a diff. +* Under Windows, the terminal state is modified to properly handle VT100 + escape sequences, which may break display for certain use cases. ## License diff --git a/src/lib.rs b/src/lib.rs index a388b3c..057349e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,7 @@ //! //! When writing tests in Rust, you'll probably use `assert_eq!(a, b)` _a lot_. //! -//! If such a test fails, it will present all the details of `a` and `b`. +//! If such a test fails, it will present all the details of `a` and `b`. //! But you have to spot the differences yourself, which is not always straightforward, //! like here: //! @@ -67,6 +67,12 @@ extern crate difference; extern crate ansi_term; + +#[cfg(windows)] +extern crate output_vt100; +#[cfg(windows)] +extern crate ctor; + mod format_changeset; use std::fmt::{self, Debug, Display}; @@ -75,6 +81,14 @@ use difference::Changeset; use format_changeset::format_changeset; pub use ansi_term::Style; +#[cfg(windows)] +use ctor::*; +#[cfg(windows)] +#[ctor] +fn init() { + output_vt100::init(); +} + #[doc(hidden)] pub struct Comparison(Changeset);