rustc: Only use color if it's supported

This commit is contained in:
Patrick Walton 2011-04-28 14:59:16 -07:00
parent 660c742902
commit 171883f437
1 changed files with 10 additions and 2 deletions

View File

@ -33,9 +33,17 @@ fn emit_diagnostic(span sp, str msg, str kind, u8 color, codemap.codemap cm) {
auto hi = codemap.lookup_pos(cm, sp.hi);
io.stdout().write_str(#fmt("%s:%u:%u:%u:%u: ", lo.filename, lo.line,
lo.col, hi.line, hi.col));
Term.fg(io.stdout().get_buf_writer(), color);
if (Term.color_supported()) {
Term.fg(io.stdout().get_buf_writer(), color);
}
io.stdout().write_str(#fmt("%s:", kind));
Term.reset(io.stdout().get_buf_writer());
if (Term.color_supported()) {
Term.reset(io.stdout().get_buf_writer());
}
io.stdout().write_str(#fmt(" %s\n", msg));
}