1 //! Helper module which provides a function to test
2 //! if stdout is a tty.
5 target_os = "cloudabi", target_os = "hermit",
6 all(target_arch = "wasm32", not(target_os = "emscripten")),
7 all(target_vendor = "fortanix", target_env = "sgx")
9 pub fn stdout_isatty() -> bool {
10 // FIXME: Implement isatty on SGX
14 pub fn stdout_isatty() -> bool {
15 unsafe { libc::isatty(libc::STDOUT_FILENO) != 0 }
18 pub fn stdout_isatty() -> bool {
21 type HANDLE = *mut u8;
22 type LPDWORD = *mut u32;
23 const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
25 fn GetStdHandle(which: DWORD) -> HANDLE;
26 fn GetConsoleMode(hConsoleHandle: HANDLE, lpMode: LPDWORD) -> BOOL;
29 let handle = GetStdHandle(STD_OUTPUT_HANDLE);
31 GetConsoleMode(handle, &mut out) != 0