about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-03 13:34:56 -0700
committerbors <bors@rust-lang.org>2013-06-03 13:34:56 -0700
commit8a43b318bf30c26f4e9f3557b6c7036fcb9d5342 (patch)
tree402e0be1b130574e325c772b0ab8e8346566d0fb /src/libsyntax
parentc68c015798998448dd51af138f4a223fb94ea387 (diff)
parentae5f3de5f00368cd8c5e62a472ab0062115d97df (diff)
downloadrust-8a43b318bf30c26f4e9f3557b6c7036fcb9d5342.tar.gz
rust-8a43b318bf30c26f4e9f3557b6c7036fcb9d5342.zip
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.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/diagnostic.rs28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs
index 76ede098ac3..fa4a74b8954 100644
--- a/src/libsyntax/diagnostic.rs
+++ b/src/libsyntax/diagnostic.rs
@@ -191,19 +191,27 @@ fn diagnosticcolor(lvl: level) -> u8 {
 }
 
 fn print_diagnostic(topic: &str, lvl: level, msg: &str) {
-    let use_color = term::color_supported() &&
-        io::stderr().get_type() == io::Screen;
+    let t = term::Terminal::new(io::stderr());
+
+    let stderr = io::stderr();
+
     if !topic.is_empty() {
-        io::stderr().write_str(fmt!("%s ", topic));
+        stderr.write_str(fmt!("%s ", topic));
     }
-    if use_color {
-        term::fg(io::stderr(), diagnosticcolor(lvl));
-    }
-    io::stderr().write_str(fmt!("%s:", diagnosticstr(lvl)));
-    if use_color {
-        term::reset(io::stderr());
+
+    match t {
+        Ok(term) => {
+            if stderr.get_type() == io::Screen {
+                term.fg(diagnosticcolor(lvl));
+                stderr.write_str(fmt!("%s: ", diagnosticstr(lvl)));
+                term.reset();
+                stderr.write_str(fmt!("%s\n", msg));
+            } else {
+                stderr.write_str(fmt!("%s: %s\n", diagnosticstr(lvl), msg));
+            }
+        },
+        _ => stderr.write_str(fmt!("%s: %s\n", diagnosticstr(lvl), msg))
     }
-    io::stderr().write_str(fmt!(" %s\n", msg));
 }
 
 pub fn collect(messages: @mut ~[~str])