Commit e875e314 authored by Victor Zverovich's avatar Victor Zverovich

Fix print_colored on Windows

parent 9368b6a4
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
# include <cstring> # include <cstring>
# endif # endif
# include <windows.h> # include <windows.h>
# include <io.h> // for _get_osfhandle
#endif #endif
using fmt::internal::Arg; using fmt::internal::Arg;
...@@ -1112,9 +1113,7 @@ FMT_FUNC void fmt::print(std::ostream &os, StringRef format_str, ArgList args) { ...@@ -1112,9 +1113,7 @@ FMT_FUNC void fmt::print(std::ostream &os, StringRef format_str, ArgList args) {
FMT_FUNC void fmt::print_colored(Color c, StringRef format, ArgList args) { FMT_FUNC void fmt::print_colored(Color c, StringRef format, ArgList args) {
#ifdef _WIN32 #ifdef _WIN32
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); HANDLE handle = reinterpret_cast<HANDLE>(_get_osfhandle(_fileno(stdout)));
if (handle == INVALID_HANDLE_VALUE)
FMT_THROW(WindowsError(GetLastError(), "cannot get output handle"));
CONSOLE_SCREEN_BUFFER_INFO info_con; CONSOLE_SCREEN_BUFFER_INFO info_con;
if (!GetConsoleScreenBufferInfo(handle, &info_con)) if (!GetConsoleScreenBufferInfo(handle, &info_con))
FMT_THROW(WindowsError(GetLastError(), "cannot get console information")); FMT_THROW(WindowsError(GetLastError(), "cannot get console information"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment