From 69da3808444d71a39d3c05519a45d5186537cfcb Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Wed, 10 Jul 2013 23:35:13 -0700 Subject: [PATCH] Highlight rustc's warnings/errors in bold instead of bright white Clang actually highlights using bold, not using bright white. Match clang on this so our diagnostics are still readable on terminals with a white background. --- src/libsyntax/diagnostic.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 0180c2b31d7..fc0dc4c8f52 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -186,22 +186,22 @@ fn diagnosticcolor(lvl: level) -> term::color::Color { } } -fn print_maybe_colored(msg: &str, color: term::color::Color) { +fn print_maybe_styled(msg: &str, color: term::attr::Attr) { let stderr = io::stderr(); - let t = term::Terminal::new(stderr); + if stderr.get_type() == io::Screen { + let t = term::Terminal::new(stderr); - match t { - Ok(term) => { - if stderr.get_type() == io::Screen { - term.fg(color); + match t { + Ok(term) => { + term.attr(color); stderr.write_str(msg); term.reset(); - } else { - stderr.write_str(msg); - } - }, - _ => stderr.write_str(msg) + }, + _ => stderr.write_str(msg) + } + } else { + stderr.write_str(msg); } } @@ -212,8 +212,9 @@ fn print_diagnostic(topic: &str, lvl: level, msg: &str) { stderr.write_str(fmt!("%s ", topic)); } - print_maybe_colored(fmt!("%s: ", diagnosticstr(lvl)), diagnosticcolor(lvl)); - print_maybe_colored(fmt!("%s\n", msg), term::color::BRIGHT_WHITE); + print_maybe_styled(fmt!("%s: ", diagnosticstr(lvl)), + term::attr::ForegroundColor(diagnosticcolor(lvl))); + print_maybe_styled(fmt!("%s\n", msg), term::attr::Bold); } pub fn collect(messages: @mut ~[~str]) @@ -312,7 +313,7 @@ fn highlight_lines(cm: @codemap::CodeMap, s.push_char('~') } } - print_maybe_colored(s + "\n", diagnosticcolor(lvl)); + print_maybe_styled(s + "\n", term::attr::ForegroundColor(diagnosticcolor(lvl))); } }