summaryrefslogtreecommitdiffstats
path: root/vendor/ansi_term-0.11.0
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ansi_term-0.11.0')
-rw-r--r--vendor/ansi_term-0.11.0/.cargo-checksum.json1
-rw-r--r--vendor/ansi_term-0.11.0/Cargo.toml27
-rw-r--r--vendor/ansi_term-0.11.0/LICENCE21
-rw-r--r--vendor/ansi_term-0.11.0/README.md174
-rw-r--r--vendor/ansi_term-0.11.0/examples/colours.rs13
-rw-r--r--vendor/ansi_term-0.11.0/src/ansi.rs258
-rw-r--r--vendor/ansi_term-0.11.0/src/debug.rs122
-rw-r--r--vendor/ansi_term-0.11.0/src/difference.rs179
-rw-r--r--vendor/ansi_term-0.11.0/src/display.rs279
-rw-r--r--vendor/ansi_term-0.11.0/src/lib.rs205
-rw-r--r--vendor/ansi_term-0.11.0/src/style.rs259
-rw-r--r--vendor/ansi_term-0.11.0/src/windows.rs40
-rw-r--r--vendor/ansi_term-0.11.0/src/write.rs40
13 files changed, 1618 insertions, 0 deletions
diff --git a/vendor/ansi_term-0.11.0/.cargo-checksum.json b/vendor/ansi_term-0.11.0/.cargo-checksum.json
new file mode 100644
index 00000000..c1b9d1b6
--- /dev/null
+++ b/vendor/ansi_term-0.11.0/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.toml":"48df4570f3bbfba5b3c19731a54abf70ac8608e4dab6f4dae6a694b18d6ad102","LICENCE":"a24742368cf773bbb8b6f0fcbe86ca4b802c2b7c081bc8bebf14ac38618e7c63","README.md":"779b02ebacd6f4d08e01ef289bd7976a4467054f40355593817fd6df7e8c9dd4","examples/colours.rs":"e4870671adb9574607e37a0e4145643f9047c881c310113de114ec20d76aaf4b","src/ansi.rs":"b8f5de966e7ec2fba7a4d5a373d0aceafe19ea6e20a3f4daaf448e119c989ae7","src/debug.rs":"0ab28b65c39538825707d8b7e81c6f91c78310856c936bba0ee609e06d138543","src/difference.rs":"da68156310cbaf57a3619160d0fb966f496f970c32a2e57601127cc8f54a2fbf","src/display.rs":"a43f19b7cf4d95e90e4f3954399405d8350523d423f0beed9f01399e17527b17","src/lib.rs":"b6df00ab61ca0d82c9f7b3798d516384dd2617fe73e8981f37125ecccc970dd7","src/style.rs":"7c5c2524428f0dfbe3b8d5876ddb81c47d8635704ee31ef63ddeb2429a67f457","src/windows.rs":"3b52469eed89fdc258139e4fd978f0e30c72168863966247df781da8715f0841","src/write.rs":"247c518f8b0c103c970bbe7bc70caba3ee961ab0d37095e2da5c69db98d2fc24"},"package":"ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"} \ No newline at end of file
diff --git a/vendor/ansi_term-0.11.0/Cargo.toml b/vendor/ansi_term-0.11.0/Cargo.toml
new file mode 100644
index 00000000..56a7f2d3
--- /dev/null
+++ b/vendor/ansi_term-0.11.0/Cargo.toml
@@ -0,0 +1,27 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g. crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+name = "ansi_term"
+version = "0.11.0"
+authors = ["ogham@bsago.me", "Ryan Scheel (Havvy) <ryan.havvy@gmail.com>", "Josh Triplett <josh@joshtriplett.org>"]
+description = "Library for ANSI terminal colours and styles (bold, underline)"
+homepage = "https://github.com/ogham/rust-ansi-term"
+documentation = "https://docs.rs/ansi_term"
+readme = "README.md"
+license = "MIT"
+
+[lib]
+name = "ansi_term"
+[target."cfg(target_os=\"windows\")".dependencies.winapi]
+version = "0.3.4"
+features = ["errhandlingapi", "consoleapi", "processenv"]
diff --git a/vendor/ansi_term-0.11.0/LICENCE b/vendor/ansi_term-0.11.0/LICENCE
new file mode 100644
index 00000000..3f39e72b
--- /dev/null
+++ b/vendor/ansi_term-0.11.0/LICENCE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Benjamin Sago
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/ansi_term-0.11.0/README.md b/vendor/ansi_term-0.11.0/README.md
new file mode 100644
index 00000000..1cb56a19
--- /dev/null
+++ b/vendor/ansi_term-0.11.0/README.md
@@ -0,0 +1,174 @@
+# rust-ansi-term [![ansi-term on crates.io](http://meritbadge.herokuapp.com/ansi-term)](https://crates.io/crates/ansi_term) [![Build status](https://travis-ci.org/ogham/rust-ansi-term.svg?branch=master)](https://travis-ci.org/ogham/rust-ansi-term) [![Coverage status](https://coveralls.io/repos/ogham/rust-ansi-term/badge.svg?branch=master&service=github)](https://coveralls.io/github/ogham/rust-ansi-term?branch=master)
+
+This is a library for controlling colours and formatting, such as red bold text or blue underlined text, on ANSI terminals.
+
+### [View the Rustdoc](https://docs.rs/ansi_term/0.9.0/ansi_term/)
+
+
+# Installation
+
+This crate works with [Cargo](http://crates.io). Add the following to your `Cargo.toml` dependencies section:
+
+```toml
+[dependencies]
+ansi_term = "0.9"
+```
+
+
+## Basic usage
+
+There are two main data structures in this crate that you need to be concerned with: `ANSIString` and `Style`.
+A `Style` holds stylistic information: colours, whether the text should be bold, or blinking, or whatever.
+There are also `Colour` variants that represent simple foreground colour styles.
+An `ANSIString` is a string paired with a `Style`.
+
+(Yes, itā€™s British English, but you wonā€™t have to write ā€œcolourā€ very often. `Style` is used the majority of the time.)
+
+To format a string, call the `paint` method on a `Style` or a `Colour`, passing in the string you want to format as the argument.
+For example, hereā€™s how to get some red text:
+
+```rust
+use ansi_term::Colour::Red;
+println!("This is in red: {}", Red.paint("a red string"));
+```
+
+Itā€™s important to note that the `paint` method does *not* actually return a string with the ANSI control characters surrounding it.
+Instead, it returns an `ANSIString` value that has a `Display` implementation that, when formatted, returns the characters.
+This allows strings to be printed with a minimum of `String` allocations being performed behind the scenes.
+
+If you *do* want to get at the escape codes, then you can convert the `ANSIString` to a string as you would any other `Display` value:
+
+```rust
+use ansi_term::Colour::Red;
+use std::string::ToString;
+let red_string = Red.paint("a red string").to_string();
+```
+
+**Note for Windows 10 users:** On Windows 10, the application must enable ANSI support first:
+
+```rust
+let enabled = ansi_term::enable_ansi_support();
+```
+
+## Bold, underline, background, and other styles
+
+For anything more complex than plain foreground colour changes, you need to construct `Style` objects themselves, rather than beginning with a `Colour`.
+You can do this by chaining methods based on a new `Style`, created with `Style::new()`.
+Each method creates a new style that has that specific property set.
+For example:
+
+```rust
+use ansi_term::Style;
+println!("How about some {} and {}?",
+ Style::new().bold().paint("bold"),
+ Style::new().underline().paint("underline"));
+```
+
+For brevity, these methods have also been implemented for `Colour` values, so you can give your styles a foreground colour without having to begin with an empty `Style` value:
+
+```rust
+use ansi_term::Colour::{Blue, Yellow};
+println!("Demonstrating {} and {}!",
+ Blue.bold().paint("blue bold"),
+ Yellow.underline().paint("yellow underline"));
+println!("Yellow on blue: {}", Yellow.on(Blue).paint("wow!"));
+```
+
+The complete list of styles you can use are:
+`bold`, `dimmed`, `italic`, `underline`, `blink`, `reverse`, `hidden`, and `on` for background colours.
+
+In some cases, you may find it easier to change the foreground on an existing `Style` rather than starting from the appropriate `Colour`.
+You can do this using the `fg` method:
+
+```rust
+ use ansi_term::Style;
+ use ansi_term::Colour::{Blue, Cyan, Yellow};
+ println!("Yellow on blue: {}", Style::new().on(Blue).fg(Yellow).paint("yow!"));
+ println!("Also yellow on blue: {}", Cyan.on(Blue).fg(Yellow).paint("zow!"));
+```
+
+Finally, you can turn a `Colour` into a `Style` with the `normal` method.
+This will produce the exact same `ANSIString` as if you just used the `paint` method on the `Colour` directly, but itā€™s useful in certain cases: for example, you may have a method that returns `Styles`, and need to represent both the ā€œred boldā€ and ā€œred, but not boldā€ styles with values of the same type. The `Style` struct also has a `Default` implementation if you want to have a style with *nothing* set.
+
+```rust
+use ansi_term::Style;
+use ansi_term::Colour::Red;
+Red.normal().paint("yet another red string");
+Style::default().paint("a completely regular string");
+```
+
+
+## Extended colours
+
+You can access the extended range of 256 colours by using the `Fixed` colour variant, which takes an argument of the colour number to use.
+This can be included wherever you would use a `Colour`:
+
+```rust
+use ansi_term::Colour::Fixed;
+Fixed(134).paint("A sort of light purple");
+Fixed(221).on(Fixed(124)).paint("Mustard in the ketchup");
+```
+
+The first sixteen of these values are the same as the normal and bold standard colour variants.
+Thereā€™s nothing stopping you from using these as `Fixed` colours instead, but thereā€™s nothing to be gained by doing so either.
+
+You can also access full 24-bit color by using the `RGB` colour variant, which takes separate `u8` arguments for red, green, and blue:
+
+```rust
+ use ansi_term::Colour::RGB;
+ RGB(70, 130, 180).paint("Steel blue");
+```
+
+## Combining successive coloured strings
+
+The benefit of writing ANSI escape codes to the terminal is that they *stack*: you do not need to end every coloured string with a reset code if the text that follows it is of a similar style.
+For example, if you want to have some blue text followed by some blue bold text, itā€™s possible to send the ANSI code for blue, followed by the ANSI code for bold, and finishing with a reset code without having to have an extra one between the two strings.
+
+This crate can optimise the ANSI codes that get printed in situations like this, making life easier for your terminal renderer.
+The `ANSIStrings` struct takes a slice of several `ANSIString` values, and will iterate over each of them, printing only the codes for the styles that need to be updated as part of its formatting routine.
+
+The following code snippet uses this to enclose a binary number displayed in red bold text inside some red, but not bold, brackets:
+
+```rust
+use ansi_term::Colour::Red;
+use ansi_term::{ANSIString, ANSIStrings};
+let some_value = format!("{:b}", 42);
+let strings: &[ANSIString<'static>] = &[
+ Red.paint("["),
+ Red.bold().paint(some_value),
+ Red.paint("]"),
+];
+println!("Value: {}", ANSIStrings(strings));
+```
+
+There are several things to note here.
+Firstly, the `paint` method can take *either* an owned `String` or a borrowed `&str`.
+Internally, an `ANSIString` holds a copy-on-write (`Cow`) string value to deal with both owned and borrowed strings at the same time.
+This is used here to display a `String`, the result of the `format!` call, using the same mechanism as some statically-available `&str` slices.
+Secondly, that the `ANSIStrings` value works in the same way as its singular counterpart, with a `Display` implementation that only performs the formatting when required.
+
+## Byte strings
+
+This library also supports formatting `[u8]` byte strings; this supports
+applications working with text in an unknown encoding. `Style` and
+`Color` support painting `[u8]` values, resulting in an `ANSIByteString`.
+This type does not implement `Display`, as it may not contain UTF-8, but
+it does provide a method `write_to` to write the result to any
+`io::Write`:
+
+```rust
+use ansi_term::Colour::Green;
+Green.paint("user data".as_bytes()).write_to(&mut std::io::stdout()).unwrap();
+```
+
+Similarly, the type `ANSIByteStrings` supports writing a list of
+`ANSIByteString` values with minimal escape sequences:
+
+```rust
+use ansi_term::Colour::Green;
+use ansi_term::ANSIByteStrings;
+ANSIByteStrings(&[
+ Green.paint("user data 1\n".as_bytes()),
+ Green.bold().paint("user data 2\n".as_bytes()),
+]).write_to(&mut std::io::stdout()).unwrap();
+```
diff --git a/vendor/ansi_term-0.11.0/examples/colours.rs b/vendor/ansi_term-0.11.0/examples/colours.rs
new file mode 100644
index 00000000..18703106
--- /dev/null
+++ b/vendor/ansi_term-0.11.0/examples/colours.rs
@@ -0,0 +1,13 @@
+extern crate ansi_term;
+use ansi_term::Colour::*;
+
+fn main() {
+ println!("{}", Black.paint("Black"));
+ println!("{}", Red.paint("Red"));
+ println!("{}", Green.paint("Green"));
+ println!("{}", Yellow.paint("Yellow"));
+ println!("{}", Blue.paint("Blue"));
+ println!("{}", Purple.paint("Purple"));
+ println!("{}", Cyan.paint("Cyan"));
+ println!("{}", White.paint("White"));
+}
diff --git a/vendor/ansi_term-0.11.0/src/ansi.rs b/vendor/ansi_term-0.11.0/src/ansi.rs
new file mode 100644
index 00000000..009043ff
--- /dev/null
+++ b/vendor/ansi_term-0.11.0/src/ansi.rs
@@ -0,0 +1,258 @@
+use style::{Colour, Style};
+
+use std::fmt;
+
+use write::AnyWrite;
+
+
+// ---- generating ANSI codes ----
+
+impl Style {
+
+ /// Write any ANSI codes that go *before* a piece of text. These should be
+ /// the codes to set the terminal to a different colour or font style.
+ fn write_prefix<W: AnyWrite + ?Sized>(&self, f: &mut W) -> Result<(), W::Error> {
+
+ // If there are actually no styles here, then donā€™t write *any* codes
+ // as the prefix. An empty ANSI code may not affect the terminal
+ // output at all, but a user may just want a code-free string.
+ if self.is_plain() {
+ return Ok(());
+ }
+
+ // Write the codesā€™ prefix, then write numbers, separated by
+ // semicolons, for each text style we want to apply.
+ write!(f, "\x1B[")?;
+ let mut written_anything = false;
+
+ {
+ let mut write_char = |c| {
+ if written_anything { write!(f, ";")?; }
+ written_anything = true;
+ write!(f, "{}", c)?;
+ Ok(())
+ };
+
+ if self.is_bold { write_char('1')? }
+ if self.is_dimmed { write_char('2')? }
+ if self.is_italic { write_char('3')? }
+ if self.is_underline { write_char('4')? }
+ if self.is_blink { write_char('5')? }
+ if self.is_reverse { write_char('7')? }
+ if self.is_hidden { write_char('8')? }
+ if self.is_strikethrough { write_char('9')? }
+ }
+
+ // The foreground and background colours, if specified, need to be
+ // handled specially because the number codes are more complicated.
+ // (see `write_background_code` and `write_foreground_code`)
+ if let Some(bg) = self.background {
+ if written_anything { write!(f, ";")?; }
+ written_anything = true;
+ bg.write_background_code(f)?;
+ }
+
+ if let Some(fg) = self.foreground {
+ if written_anything { write!(f, ";")?; }
+ fg.write_foreground_code(f)?;
+ }
+
+ // All the codes end with an `m`, because reasons.
+ write!(f, "m")?;
+
+ Ok(())
+ }
+
+ /// Write any ANSI codes that go *after* a piece of text. These should be
+ /// the codes to *reset* the terminal back to its normal colour and style.
+ fn write_suffix<W: AnyWrite + ?Sized>(&self, f: &mut W) -> Result<(), W::Error> {
+ if self.is_plain() {
+ Ok(())
+ }
+ else {
+ write!(f, "{}", RESET)
+ }
+ }
+}
+
+
+/// The code to send to reset all styles and return to `Style::default()`.
+pub static RESET: &str = "\x1B[0m";
+
+
+
+impl Colour {
+ fn write_foreground_code<W: AnyWrite + ?Sized>(&self, f: &mut W) -> Result<(), W::Error> {
+ match *self {
+ Colour::Black => write!(f, "30"),
+ Colour::Red => write!(f, "31"),
+ Colour::Green => write!(f, "32"),
+ Colour::Yellow => write!(f, "33"),
+ Colour::Blue => write!(f, "34"),
+ Colour::Purple => write!(f, "35"),
+ Colour::Cyan => write!(f, "36"),
+ Colour::White => write!(f, "37"),
+ Colour::Fixed(num) => write!(f, "38;5;{}", &num),
+ Colour::RGB(r,g,b) => write!(f, "38;2;{};{};{}", &r, &g, &b),
+ }
+ }
+
+ fn write_background_code<W: AnyWrite + ?Sized>(&self, f: &mut W) -> Result<(), W::Error> {
+ match *self {
+ Colour::Black => write!(f, "40"),
+ Colour::Red => write!(f, "41"),
+ Colour::Green => write!(f, "42"),
+ Colour::Yellow => write!(f, "43"),
+ Colour::Blue => write!(f, "44"),
+ Colour::Purple => write!(f, "45"),
+ Colour::Cyan => write!(f, "46"),
+ Colour::White => write!(f, "47"),
+ Colour::Fixed(num) => write!(f, "48;5;{}", &num),
+ Colour::RGB(r,g,b) => write!(f, "48;2;{};{};{}", &r, &g, &b),
+ }
+ }
+}
+
+
+/// Like `ANSIString`, but only displays the style prefix.
+#[derive(Clone, Copy, Debug)]
+pub struct Prefix(Style);
+
+/// Like `ANSIString`, but only displays the difference between two
+/// styles.
+#[derive(Clone, Copy, Debug)]
+pub struct Infix(Style, Style);
+
+/// Like `ANSIString`, but only displays the style suffix.
+#[derive(Clone, Copy, Debug)]
+pub struct Suffix(Style);
+
+
+impl Style {
+
+ /// The prefix for this style.
+ pub fn prefix(self) -> Prefix {
+ Prefix(self)
+ }
+
+ /// The infix between this style and another.
+ pub fn infix(self, other: Style) -> Infix {
+ Infix(self, other)
+ }
+
+ /// The suffix for this style.
+ pub fn suffix(self) -> Suffix {
+ Suffix(self)
+ }
+}
+
+
+impl Colour {
+
+ /// The prefix for this colour.
+ pub fn prefix(self) -> Prefix {
+ Prefix(self.normal())
+ }
+
+ /// The infix between this colour and another.
+ pub fn infix(self, other: Colour) -> Infix {
+ Infix(self.normal(), other.normal())
+ }
+
+ /// The suffix for this colour.
+ pub fn suffix(self) -> Suffix {
+ Suffix(self.normal())
+ }
+}
+
+
+impl fmt::Display for Prefix {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ let f: &mut fmt::Write = f;
+ self.0.write_prefix(f)
+ }
+}
+
+
+impl fmt::Display for Infix {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ use difference::Difference;
+
+ match Difference::between(&self.0, &self.1) {
+ Difference::ExtraStyles(style) => {
+ let f: &mut fmt::Write = f;
+ style.write_prefix(f)
+ },
+ Difference::Reset => {
+ let f: &mut fmt::Write = f;
+ write!(f, "{}{}", RESET, self.0.prefix())
+ },
+ Difference::NoDifference => {
+ Ok(()) // nothing to write
+ },
+ }
+ }
+}
+
+
+impl fmt::Display for Suffix {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ let f: &mut fmt::Write = f;
+ self.0.write_suffix(f)
+ }
+}
+
+
+
+#[cfg(test)]
+mod test {
+ use style::Style;
+ use style::Colour::*;
+
+ macro_rules! test {
+ ($name: ident: $style: expr; $input: expr => $result: expr) => {
+ #[test]
+ fn $name() {
+ assert_eq!($style.paint($input).to_string(), $result.to_string());
+
+ let mut v = Vec::new();
+ $style.paint($input.as_bytes()).write_to(&mut v).unwrap();
+ assert_eq!(v.as_slice(), $result.as_bytes());
+ }
+ };
+ }
+
+ test!(plain: Style::default(); "text/plain" => "text/plain");
+ test!(red: Red; "hi" => "\x1B[31mhi\x1B[0m");
+ test!(black: Black.normal(); "hi" => "\x1B[30mhi\x1B[0m");
+ test!(yellow_bold: Yellow.bold(); "hi" => "\x1B[1;33mhi\x1B[0m");
+ test!(yellow_bold_2: Yellow.normal().bold(); "hi" => "\x1B[1;33mhi\x1B[0m");
+ test!(blue_underline: Blue.underline(); "hi" => "\x1B[4;34mhi\x1B[0m");
+ test!(green_bold_ul: Green.bold().underline(); "hi" => "\x1B[1;4;32mhi\x1B[0m");
+ test!(green_bold_ul_2: Green.underline().bold(); "hi" => "\x1B[1;4;32mhi\x1B[0m");
+ test!(purple_on_white: Purple.on(White); "hi" => "\x1B[47;35mhi\x1B[0m");
+ test!(purple_on_white_2: Purple.normal().on(White); "hi" => "\x1B[47;35mhi\x1B[0m");
+ test!(yellow_on_blue: Style::new().on(Blue).fg(Yellow); "hi" => "\x1B[44;33mhi\x1B[0m");
+ test!(yellow_on_blue_2: Cyan.on(Blue).fg(Yellow); "hi" => "\x1B[44;33mhi\x1B[0m");
+ test!(cyan_bold_on_white: Cyan.bold().on(White); "hi" => "\x1B[1;47;36mhi\x1B[0m");
+ test!(cyan_ul_on_white: Cyan.underline().on(White); "hi" => "\x1B[4;47;36mhi\x1B[0m");
+ test!(cyan_bold_ul_on_white: Cyan.bold().underline().on(White); "hi" => "\x1B[1;4;47;36mhi\x1B[0m");
+ test!(cyan_ul_bold_on_white: Cyan.underline().bold().on(White); "hi" => "\x1B[1;4;47;36mhi\x1B[0m");
+ test!(fixed: Fixed(100); "hi" => "\x1B[38;5;100mhi\x1B[0m");
+ test!(fixed_on_purple: Fixed(100).on(Purple); "hi" => "\x1B[45;38;5;100mhi\x1B[0m");
+ test!(fixed_on_fixed: Fixed(100).on(Fixed(200)); "hi" => "\x1B[48;5;200;38;5;100mhi\x1B[0m");
+ test!(rgb: RGB(70,130,180); "hi" => "\x1B[38;2;70;130;180mhi\x1B[0m");
+ test!(rgb_on_blue: RGB(70,130,180).on(Blue); "hi" => "\x1B[44;38;2;70;130;180mhi\x1B[0m");
+ test!(blue_on_rgb: Blue.on(RGB(70,130,180)); "hi" => "\x1B[48;2;70;130;180;34mhi\x1B[0m");
+ test!(rgb_on_rgb: RGB(70,130,180).on(RGB(5,10,15)); "hi" => "\x1B[48;2;5;10;15;38;2;70;130;180mhi\x1B[0m");
+ test!(bold: Style::new().bold(); "hi" => "\x1B[1mhi\x1B[0m");
+ test!(underline: Style::new().underline(); "hi" => "\x1B[4mhi\x1B[0m");
+ test!(bunderline: Style::new().bold().underline(); "hi" => "\x1B[1;4mhi\x1B[0m");
+ test!(dimmed: Style::new().dimmed(); "hi" => "\x1B[2mhi\x1B[0m");
+ test!(italic: Style::new().italic(); "hi" => "\x1B[3mhi\x1B[0m");
+ test!(blink: Style::new().blink(); "hi" => "\x1B[5mhi\x1B[0m");
+ test!(reverse: Style::new().reverse(); "hi" => "\x1B[7mhi\x1B[0m");
+ test!(hidden: Style::new().hidden(); "hi" => "\x1B[8mhi\x1B[0m");
+ test!(stricken: Style::new().strikethrough(); "hi" => "\x1B[9mhi\x1B[0m");
+
+}
diff --git a/vendor/ansi_term-0.11.0/src/debug.rs b/vendor/ansi_term-0.11.0/src/debug.rs
new file mode 100644
index 00000000..da30c625
--- /dev/null
+++ b/vendor/ansi_term-0.11.0/src/debug.rs
@@ -0,0 +1,122 @@
+use std::fmt;
+
+use style::Style;
+
+
+/// Styles have a special `Debug` implementation that only shows the fields that
+/// are set. Fields that havenā€™t been touched arenā€™t included in the output.
+///
+/// This behaviour gets bypassed when using the alternate formatting mode
+/// `format!("{:#?}")`.
+///
+/// use ansi_term::Colour::{Red, Blue};
+/// assert_eq!("Style { fg(Red), on(Blue), bold, italic }",
+/// format!("{:?}", Red.on(Blue).bold().italic()));
+impl fmt::Debug for Style {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ if fmt.alternate() {
+ fmt.debug_struct("Style")
+ .field("foreground", &self.foreground)
+ .field("background", &self.background)
+ .field("blink", &self.is_blink)
+ .field("bold", &self.is_bold)
+ .field("dimmed", &self.is_dimmed)
+ .field("hidden", &self.is_hidden)
+ .field("italic", &self.is_italic)
+ .field("reverse", &self.is_reverse)
+ .field("strikethrough", &self.is_strikethrough)
+ .field("underline", &self.is_underline)
+ .finish()
+ }
+ else if self.is_plain() {
+ fmt.write_str("Style {}")
+ }
+ else {
+ fmt.write_str("Style { ")?;
+
+ let mut written_anything = false;
+
+ if let Some(fg) = self.foreground {
+ if written_anything { fmt.write_str(", ")? }
+ written_anything = true;
+ write!(fmt, "fg({:?})", fg)?
+ }
+
+ if let Some(bg) = self.background {
+ if written_anything { fmt.write_str(", ")? }
+ written_anything = true;
+ write!(fmt, "on({:?})", bg)?
+ }
+
+ {
+ let mut write_flag = |name| {
+ if written_anything { fmt.write_str(", ")? }
+ written_anything = true;
+ fmt.write_str(name)
+ };
+
+ if self.is_blink { write_flag("blink")? }
+ if self.is_bold { write_flag("bold")? }
+ if self.is_dimmed { write_flag("dimmed")? }
+ if self.is_hidden { write_flag("hidden")? }
+ if self.is_italic { write_flag("italic")? }
+ if self.is_reverse { write_flag("reverse")? }
+ if self.is_strikethrough { write_flag("strikethrough")? }
+ if self.is_underline { write_flag("underline")? }
+ }
+
+ write!(fmt, " }}")
+ }
+ }
+}
+
+
+#[cfg(test)]
+mod test {
+ use style::Colour::*;
+ use style::Style;
+
+ fn style() -> Style {
+ Style::new()
+ }
+
+ macro_rules! test {
+ ($name: ident: $obj: expr => $result: expr) => {
+ #[test]
+ fn $name() {
+ assert_eq!($result, format!("{:?}", $obj));
+ }
+ };
+ }
+
+ test!(empty: style() => "Style {}");
+ test!(bold: style().bold() => "Style { bold }");
+ test!(italic: style().italic() => "Style { italic }");
+ test!(both: style().bold().italic() => "Style { bold, italic }");
+
+ test!(red: Red.normal() => "Style { fg(Red) }");
+ test!(redblue: Red.normal().on(RGB(3, 2, 4)) => "Style { fg(Red), on(RGB(3, 2, 4)) }");
+
+ test!(everything:
+ Red.on(Blue).blink().bold().dimmed().hidden().italic().reverse().strikethrough().underline() =>
+ "Style { fg(Red), on(Blue), blink, bold, dimmed, hidden, italic, reverse, strikethrough, underline }");
+
+ #[test]
+ fn long_and_detailed() {
+ let debug = r##"Style {
+ foreground: Some(
+ Blue
+ ),
+ background: None,
+ blink: false,
+ bold: true,
+ dimmed: false,
+ hidden: false,
+ italic: false,
+ reverse: false,
+ strikethrough: false,
+ underline: false
+}"##;
+ assert_eq!(debug, format!("{:#?}", Blue.bold()));
+ }
+}
diff --git a/vendor/ansi_term-0.11.0/src/difference.rs b/vendor/ansi_term-0.11.0/src/difference.rs
new file mode 100644
index 00000000..57157463
--- /dev/null
+++ b/vendor/ansi_term-0.11.0/src/difference.rs
@@ -0,0 +1,179 @@
+use super::Style;
+
+
+/// When printing out one coloured string followed by another, use one of
+/// these rules to figure out which *extra* control codes need to be sent.
+#[derive(PartialEq, Clone, Copy, Debug)]
+pub enum Difference {
+
+ /// Print out the control codes specified by this style to end up looking
+ /// like the second string's styles.
+ ExtraStyles(Style),
+
+ /// Converting between these two is impossible, so just send a reset
+ /// command and then the second string's styles.
+ Reset,
+
+ /// The before style is exactly the same as the after style, so no further
+ /// control codes need to be printed.
+ NoDifference,
+}
+
+
+impl Difference {
+
+ /// Compute the 'style difference' required to turn an existing style into
+ /// the given, second style.
+ ///
+ /// For example, to turn green text into green bold text, it's redundant
+ /// to write a reset command then a second green+bold command, instead of
+ /// just writing one bold command. This method should see that both styles
+ /// use the foreground colour green, and reduce it to a single command.
+ ///
+ /// This method returns an enum value because it's not actually always
+ /// possible to turn one style into another: for example, text could be
+ /// made bold and underlined, but you can't remove the bold property
+ /// without also removing the underline property. So when this has to
+ /// happen, this function returns None, meaning that the entire set of
+ /// styles should be reset and begun again.
+ pub fn between(first: &Style, next: &Style) -> Difference {
+ use self::Difference::*;
+
+ // XXX(Havvy): This algorithm is kind of hard to replicate without
+ // having the Plain/Foreground enum variants, so I'm just leaving
+ // it commented out for now, and defaulting to Reset.
+
+ if first == next {
+ return NoDifference;
+ }
+
+ // Cannot un-bold, so must Reset.
+ if first.is_bold && !next.is_bold {
+ return Reset;
+ }
+
+ if first.is_dimmed && !next.is_dimmed {
+ return Reset;
+ }
+
+ if first.is_italic && !next.is_italic {
+ return Reset;
+ }
+
+ // Cannot un-underline, so must Reset.
+ if first.is_underline && !next.is_underline {
+ return Reset;
+ }
+
+ if first.is_blink && !next.is_blink {
+ return Reset;
+ }
+
+ if first.is_reverse && !next.is_reverse {
+ return Reset;
+ }
+
+ if first.is_hidden && !next.is_hidden {
+ return Reset;
+ }
+
+ if first.is_strikethrough && !next.is_strikethrough {
+ return Reset;
+ }
+
+ // Cannot go from foreground to no foreground, so must Reset.
+ if first.foreground.is_some() && next.foreground.is_none() {
+ return Reset;
+ }
+
+ // Cannot go from background to no background, so must Reset.
+ if first.background.is_some() && next.background.is_none() {
+ return Reset;
+ }
+
+ let mut extra_styles = Style::default();
+
+ if first.is_bold != next.is_bold {
+ extra_styles.is_bold = true;
+ }
+
+ if first.is_dimmed != next.is_dimmed {
+ extra_styles.is_dimmed = true;
+ }
+
+ if first.is_italic != next.is_italic {
+ extra_styles.is_italic = true;
+ }
+
+ if first.is_underline != next.is_underline {
+ extra_styles.is_underline = true;
+ }
+
+ if first.is_blink != next.is_blink {
+ extra_styles.is_blink = true;
+ }
+
+ if first.is_reverse != next.is_reverse {
+ extra_styles.is_reverse = true;
+ }
+
+ if first.is_hidden != next.is_hidden {
+ extra_styles.is_hidden = true;
+ }
+
+ if first.is_strikethrough != next.is_strikethrough {
+ extra_styles.is_strikethrough = true;
+ }
+
+ if first.foreground != next.foreground {
+ extra_styles.foreground = next.foreground;
+ }
+
+ if first.background != next.background {
+ extra_styles.background = next.background;
+ }
+
+ ExtraStyles(extra_styles)
+ }
+}
+
+
+#[cfg(test)]
+mod test {
+ use super::*;
+ use super::Difference::*;
+ use style::Colour::*;
+ use style::Style;
<