Attempt to check whether output stream is a TTY before using escapes

This doesn't check full termcap attributes, but it checks with isatty(3).

Also, this follows the current #ifdef _WIN32 #else assume Unix #endif
pattern; this will need to be changed if more platforms are added.