1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-keygen synced 2026-07-04 12:03:41 +02:00

src/console_win32.cpp: define _getNativeHandle() and use that instead of hard coded stdout.

This commit is contained in:
Henrik Hautakoski 2020-03-02 14:44:53 +01:00
parent 26b96add30
commit 53fcc9df53

View file

@ -48,10 +48,20 @@ namespace eoskeygen {
namespace console { namespace console {
HANDLE _getNativeHandle(const std::ostream& os) {
if (&os == &std::cout) {
return ::GetStdHandle(STD_OUTPUT_HANDLE);
} else if (&os == &std::cerr) {
return ::GetStdHandle(STD_ERROR_HANDLE);
}
return NULL;
}
std::ostream& reset(std::ostream& os) { std::ostream& reset(std::ostream& os) {
if (isColorsSupported(os)) { if (isColorsSupported(os)) {
::SetConsoleTextAttribute(::GetStdHandle(STD_OUTPUT_HANDLE), FG_DEFAULT); ::SetConsoleTextAttribute(_getNativeHandle(os), FG_DEFAULT);
} }
return os; return os;
} }
@ -84,7 +94,7 @@ std::ostream& operator<<(std::ostream& os, const fg& obj) {
code = FG_DEFAULT; code = FG_DEFAULT;
} }
::SetConsoleTextAttribute(::GetStdHandle(STD_OUTPUT_HANDLE), code); ::SetConsoleTextAttribute(_getNativeHandle(os), code);
} }
// WinAPI does not support text attributes in the console. // WinAPI does not support text attributes in the console.