17 # define isatty _isatty
28 class windows_coutt :
public std::streambuf
32 std::streamsize xsputn(
const char_type *s, std::streamsize n)
override
36 auto wide_string =
widen(std::string(s, n));
38 HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
42 (DWORD)wide_string.size(),
48 std::cout.write(s, n);
54 int_type overflow(int_type c)
override
57 std::wcout << wchar_t(c);
87 HANDLE out_handle = GetStdHandle(STD_OUTPUT_HANDLE);
90 if(GetConsoleMode(out_handle, &consoleMode))
92 consoleMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
93 if(SetConsoleMode(out_handle, consoleMode))
97 std::cout.rdbuf(&windows_cout);
107 return str <<
"\x1b[34m";
115 return str <<
"\x1b[36m";
123 return str <<
"\x1b[32m";
131 return str <<
"\x1b[31m";
139 return str <<
"\x1b[33m";
147 return str <<
"\x1b[38;5;214m";
155 return str <<
"\x1b[1m";
163 return str <<
"\x1b[2m";
171 return str <<
"\x1b[4m";
179 return str <<
"\x1b[m";
187 return str <<
"\x1b[1A";
193 return str <<
"\x1b[0K";
207 HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
208 CONSOLE_SCREEN_BUFFER_INFO info;
209 GetConsoleScreenBufferInfo(h, &info);
210 _width = info.srWindow.Right - info.srWindow.Left + 1;
212 std::ostringstream width_stream;
213 run(
"stty", {
"stty",
"size"},
"", width_stream,
"");
214 auto stty_output =
split_string(width_stream.str(),
' ');
216 stty_output.size() >= 1 && !stty_output[1].empty() &&
219 auto width_l =
atol(stty_output[1].c_str());
220 if(width_l >= 10 && width_l <= 400)
230 std::ostream &__console_out,
231 std::ostream &__console_err)
bitvector_typet char_type()
redirectt(std::ostream &__console_out, std::ostream &__console_err)
static std::size_t _width
static std::ostream & cursorup(std::ostream &)
static std::ostream & yellow(std::ostream &)
static std::ostream * _err
static std::ostream & blue(std::ostream &)
static std::ostream & underline(std::ostream &)
static std::ostream * _out
static std::ostream & reset(std::ostream &)
static std::ostream & cyan(std::ostream &)
static std::ostream & green(std::ostream &)
static std::size_t width()
static bool is_terminal()
static std::ostream & faint(std::ostream &)
static std::ostream & bold(std::ostream &)
static std::ostream & red(std::ostream &)
static bool _width_is_set
static std::ostream & orange(std::ostream &)
static std::ostream & cleareol(std::ostream &)
int run(const std::string &what, const std::vector< std::string > &argv)
#define PRECONDITION(CONDITION)
long atol(const char *nptr)
void split_string(const std::string &s, char delim, std::vector< std::string > &result, bool strip, bool remove_empty)
std::wstring widen(const char *s)