1
Fork 0

auto merge of #6826 : cmr/rust/terminfo, r=thestinger

This will let *everyone* (non-windows, at least) who can see colors see the glorious colors rustc produces.
This commit is contained in:
bors 2013-06-03 13:34:56 -07:00
commit 8a43b318bf
9 changed files with 795 additions and 82 deletions

View file

@ -162,43 +162,31 @@ pub fn need_dir(s: &Path) {
}
}
pub fn note(msg: ~str) {
let out = io::stdout();
if term::color_supported() {
term::fg(out, term::color_green);
out.write_str("note: ");
term::reset(out);
out.write_line(msg);
} else {
out.write_line(~"note: " + msg);
fn pretty_message<'a>(msg: &'a str, prefix: &'a str, color: u8, out: @io::Writer) {
let term = term::Terminal::new(out);
match term {
Ok(ref t) => {
t.fg(color);
out.write_str(prefix);
t.reset();
},
_ => {
out.write_str(prefix);
}
}
out.write_line(msg);
}
pub fn warn(msg: ~str) {
let out = io::stdout();
if term::color_supported() {
term::fg(out, term::color_yellow);
out.write_str("warning: ");
term::reset(out);
out.write_line(msg);
} else {
out.write_line(~"warning: " + msg);
}
pub fn note(msg: &str) {
pretty_message(msg, "note: ", term::color_green, io::stdout())
}
pub fn error(msg: ~str) {
let out = io::stdout();
pub fn warn(msg: &str) {
pretty_message(msg, "warning: ", term::color_yellow, io::stdout())
}
if term::color_supported() {
term::fg(out, term::color_red);
out.write_str("error: ");
term::reset(out);
out.write_line(msg);
} else {
out.write_line(~"error: " + msg);
}
pub fn error(msg: &str) {
pretty_message(msg, "error: ", term::color_red, io::stdout())
}
// FIXME (#4432): Use workcache to only compile when needed