|
|
|
|
|
|
|
|
#include <vector> |
|
|
#include <vector> |
|
|
|
|
|
|
|
|
#if NEO_OS_IS_WINDOWS |
|
|
#if NEO_OS_IS_WINDOWS |
|
|
bool fansi::detect_should_style() noexcept { return false; } |
|
|
|
|
|
|
|
|
#include <windows.h> |
|
|
|
|
|
|
|
|
|
|
|
bool fansi::detect_should_style() noexcept { |
|
|
|
|
|
auto stdio_console = ::GetStdHandle(STD_OUTPUT_HANDLE); |
|
|
|
|
|
if (stdio_console == INVALID_HANDLE_VALUE) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
DWORD mode = 0; |
|
|
|
|
|
if (!::GetConsoleMode(stdio_console, &mode)) { |
|
|
|
|
|
// Failed to get the mode |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
return (mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING); |
|
|
|
|
|
} |
|
|
#else |
|
|
#else |
|
|
#include <unistd.h> |
|
|
#include <unistd.h> |
|
|
bool fansi::detect_should_style() noexcept { return ::isatty(STDOUT_FILENO); } |
|
|
bool fansi::detect_should_style() noexcept { return ::isatty(STDOUT_FILENO); } |