Skip to content

Commit

Permalink
Auto merge of #2339 - pnkfelix:downgrade-term-crate-for-emacs-shell, …
Browse files Browse the repository at this point in the history
…r=alexcrichton

Downgrade term crate back down to 0.2 (from 0.4).

This is undoing part of commit dd34296

Fix #2338

(Unfortunately I do not have a suggestion for how to make a unit test for this problem; doing so would require putting in a bit more effort than I have time for at the moment.)
  • Loading branch information
bors committed Jan 30, 2016
2 parents 4b447ed + 75e0371 commit d635b2d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 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.4"
term = "0.2"
time = "0.1"
toml = "0.1"
url = "0.2"
Expand Down
23 changes: 10 additions & 13 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::{self, Terminal, TerminfoTerminal, color, Attr};
use term::{Terminal, TerminfoTerminal, color, Attr};

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

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

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

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

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

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

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

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

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

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

impl<E: CargoError> From<Human<E>> for Box<CargoError> {
Expand All @@ -327,7 +325,6 @@ 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 d635b2d

Please sign in to comment.