aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-04-28 14:53:23 -0700
committerPatrick Walton <[email protected]>2011-04-28 14:54:00 -0700
commit660c742902e0f41898e329703a3f0c413b2016cf (patch)
tree55e7db85038e3a0dce7ee74fdf54800c47cb42c0
parentChange vec-ref-count to handle 1 or 2, so long as non-leaky and non-creeping.... (diff)
downloadrust-660c742902e0f41898e329703a3f0c413b2016cf.tar.xz
rust-660c742902e0f41898e329703a3f0c413b2016cf.zip
stdlib: Add a color_supported() function to Term
-rw-r--r--src/lib/GenericOS.rs4
-rw-r--r--src/lib/Term.rs4
-rw-r--r--src/lib/std.rc4
3 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/GenericOS.rs b/src/lib/GenericOS.rs
new file mode 100644
index 00000000..2d375652
--- /dev/null
+++ b/src/lib/GenericOS.rs
@@ -0,0 +1,4 @@
+fn getenv(str n) -> str {
+ ret _str.str_from_cstr(os.libc.getenv(_str.buf(n)));
+}
+
diff --git a/src/lib/Term.rs b/src/lib/Term.rs
index 9bf90b1c..0d925d7d 100644
--- a/src/lib/Term.rs
+++ b/src/lib/Term.rs
@@ -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);
diff --git a/src/lib/std.rc b/src/lib/std.rc
index 8a9ee42d..4efff14b 100644
--- a/src/lib/std.rc
+++ b/src/lib/std.rc
@@ -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;