extra::term overhaul
This commit is contained in:
parent
55c23bc557
commit
cf64324e19
9 changed files with 715 additions and 81 deletions
|
|
@ -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 term = 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));
|
||||
|
||||
match term {
|
||||
Ok(t) => {
|
||||
if stderr.get_type() == io::Screen {
|
||||
t.fg(diagnosticcolor(lvl));
|
||||
stderr.write_str(fmt!("%s: ", diagnosticstr(lvl)));
|
||||
t.reset();
|
||||
stderr.write_str(fmt!("%s\n", msg));
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
stderr.write_str(fmt!("%s: %s\n", diagnosticstr(lvl), msg));
|
||||
}
|
||||
}
|
||||
io::stderr().write_str(fmt!("%s:", diagnosticstr(lvl)));
|
||||
if use_color {
|
||||
term::reset(io::stderr());
|
||||
}
|
||||
io::stderr().write_str(fmt!(" %s\n", msg));
|
||||
}
|
||||
|
||||
pub fn collect(messages: @mut ~[~str])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue