mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-06-17 03:50:03 +02:00
src/console_win32.cpp: define _getNativeHandle() and use that instead of hard coded stdout.
This commit is contained in:
parent
26b96add30
commit
53fcc9df53
1 changed files with 12 additions and 2 deletions
|
|
@ -48,10 +48,20 @@ namespace eoskeygen {
|
|||
|
||||
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) {
|
||||
|
||||
if (isColorsSupported(os)) {
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_OUTPUT_HANDLE), FG_DEFAULT);
|
||||
::SetConsoleTextAttribute(_getNativeHandle(os), FG_DEFAULT);
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
|
@ -84,7 +94,7 @@ std::ostream& operator<<(std::ostream& os, const fg& obj) {
|
|||
code = FG_DEFAULT;
|
||||
}
|
||||
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_OUTPUT_HANDLE), code);
|
||||
::SetConsoleTextAttribute(_getNativeHandle(os), code);
|
||||
}
|
||||
|
||||
// WinAPI does not support text attributes in the console.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue