1
Fork 0

stdlib: Add a color_supported() function to Term

This commit is contained in:
Patrick Walton 2011-04-28 14:53:23 -07:00
parent f0e1bb75d1
commit 660c742902
3 changed files with 12 additions and 0 deletions

4
src/lib/GenericOS.rs Normal file
View file

@ -0,0 +1,4 @@
fn getenv(str n) -> str {
ret _str.str_from_cstr(os.libc.getenv(_str.buf(n)));
}

View file

@ -30,6 +30,10 @@ fn reset(io.buf_writer writer) {
writer.write(vec('0' as u8, 'm' as u8));
}
fn color_supported() -> bool {
ret _str.eq(GenericOS.getenv("TERM"), "xterm-color");
}
fn set_color(io.buf_writer writer, u8 first_char, u8 color) {
check (color < 16u8);

View file

@ -42,6 +42,9 @@ auth rand.mk_rng = unsafe;
// Target-OS module.
// TODO: Have each OS module re-export everything from GenericOS.
mod GenericOS;
alt (target_os) {
case ("win32") {
mod os = "win32_os.rs";
@ -54,6 +57,7 @@ alt (target_os) {
mod os_fs = "posix_fs.rs";
}
}
mod run = "run_program.rs";
mod fs;