diff options
author | Steven Noonan <steven@uplinklabs.net> | 2009-10-12 13:48:08 -0700 |
---|---|---|
committer | Steven Noonan <steven@uplinklabs.net> | 2009-10-12 13:48:08 -0700 |
commit | fa9a5721b1e903f5e2435d928183621071d45cc4 (patch) | |
tree | 068336d9099453bd303096c53b36c268c51261aa /crawl-ref/source/initfile.cc | |
parent | 8abd03d4485e187aed31b8ac908e5908dc2666cc (diff) | |
download | crawl-ref-fa9a5721b1e903f5e2435d928183621071d45cc4.tar.gz crawl-ref-fa9a5721b1e903f5e2435d928183621071d45cc4.zip |
8 color terminals: switch to conditional usage based on terminal type
Apple's Terminal.app sets a TERM_PROGRAM environment variable to
"Apple_Terminal". This gives us a good way to detect at runtime
whether or not the terminal supports more than 8 colors.
The main reason for checking at runtime is that Mac users are
able to run other terminal apps (xterm, rxvt, etc), and should
expect to see more than 8 colors in terminals that support it.
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
Diffstat (limited to 'crawl-ref/source/initfile.cc')
-rw-r--r-- | crawl-ref/source/initfile.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 2a796af899..a5b1a86a72 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -961,14 +961,20 @@ void game_options::reset_options() #endif // map each colour to itself as default -#ifdef USE_8_COLOUR_TERM_MAP - for (int i = 0; i < 16; i++) - colour[i] = i % 8; - - colour[ DARKGREY ] = COL_TO_REPLACE_DARKGREY; -#else - for (int i = 0; i < 16; i++) - colour[i] = i; + // If USE_8_COLOUR_TERM_MAP is defined, then we force 8 colors. + // Otherwise, do a check to see if we're using Apple_Terminal. +#ifndef USE_8_COLOUR_TERM_MAP + if (strcmp(getenv("TERM_PROGRAM"), "Apple_Terminal") == 0) { +#endif + for (int i = 0; i < 16; i++) + colour[i] = i % 8; + + colour[ DARKGREY ] = COL_TO_REPLACE_DARKGREY; +#ifndef USE_8_COLOUR_TERM_MAP + } else { + for (int i = 0; i < 16; i++) + colour[i] = i; + } #endif // map each channel to plain (well, default for now since I'm testing) |