Skip to content

Commit

Permalink
Revert "Downgrade term crate back down to 0.2 (from 0.4)."
Browse files Browse the repository at this point in the history
This reverts commit 75e0371.
  • Loading branch information
Stebalien committed Jan 30, 2016
1 parent c4c6f39 commit fd463d6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ regex = "0.1"
rustc-serialize = "0.3"
semver = "0.2.0"
tar = "0.4"
term = "0.2"
term = "0.4"
time = "0.1"
toml = "0.1"
url = "0.2"
Expand Down
23 changes: 13 additions & 10 deletions src/cargo/core/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::prelude::*;
use std::io;

use term::color::{Color, BLACK, RED, GREEN, YELLOW};
use term::{Terminal, TerminfoTerminal, color, Attr};
use term::{self, Terminal, TerminfoTerminal, color, Attr};

use self::AdequateTerminal::{NoColor, Colored};
use self::Verbosity::{Verbose, Normal, Quiet};
Expand Down Expand Up @@ -193,22 +193,24 @@ impl Shell {
Ok(())
}

fn fg(&mut self, color: color::Color) -> io::Result<bool> {
fn fg(&mut self, color: color::Color) -> CargoResult<bool> {
let colored = self.colored();

match self.terminal {
Colored(ref mut c) if colored => c.fg(color),
_ => Ok(false),
Colored(ref mut c) if colored => try!(c.fg(color)),
_ => return Ok(false),
}
Ok(true)
}

fn attr(&mut self, attr: Attr) -> io::Result<bool> {
fn attr(&mut self, attr: Attr) -> CargoResult<bool> {
let colored = self.colored();

match self.terminal {
Colored(ref mut c) if colored => c.attr(attr),
_ => Ok(false)
Colored(ref mut c) if colored => try!(c.attr(attr)),
_ => return Ok(false)
}
Ok(true)
}

fn supports_attr(&self, attr: Attr) -> bool {
Expand All @@ -220,13 +222,14 @@ impl Shell {
}
}

fn reset(&mut self) -> io::Result<()> {
fn reset(&mut self) -> term::Result<()> {
let colored = self.colored();

match self.terminal {
Colored(ref mut c) if colored => c.reset().map(|_| ()),
_ => Ok(())
Colored(ref mut c) if colored => try!(c.reset()),
_ => ()
}
Ok(())
}

fn colored(&self) -> bool {
Expand Down
3 changes: 3 additions & 0 deletions src/cargo/util/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use curl;
use git2;
use rustc_serialize::json;
use semver;
use term;
use toml;
use url;

Expand Down Expand Up @@ -306,6 +307,7 @@ from_error! {
url::ParseError,
toml::DecodeError,
ffi::NulError,
term::Error,
}

impl<E: CargoError> From<Human<E>> for Box<CargoError> {
Expand All @@ -325,6 +327,7 @@ impl CargoError for toml::Error {}
impl CargoError for toml::DecodeError {}
impl CargoError for url::ParseError {}
impl CargoError for ffi::NulError {}
impl CargoError for term::Error {}

// =============================================================================
// Construction helpers
Expand Down

0 comments on commit fd463d6

Please sign in to comment.