Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Colored table output win
HANDLE hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
const int aDefaultColor = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
auto printTable = [&](const std::set<Standard_Integer>& theRemSet) {
return; // disabled
std::cout << setw (3) << " ";
for (int j = 0; j < aTableSize; ++j) {
std::cout << setw (6) << j;
}
std::cout << std::endl;
for (int i = 0; i < aTableSize; ++i) {
bool isIRemoved = theRemSet.find (i) != theRemSet.end();
if (isIRemoved) { SetConsoleTextAttribute (hConsole, FOREGROUND_RED); } else { SetConsoleTextAttribute (hConsole, aDefaultColor); }
std::cout << setw (3) << i;
for (int j = 0; j < aTableSize; ++j) {
bool isRemoved = isIRemoved || theRemSet.find (j) != theRemSet.end();
if (isRemoved) { SetConsoleTextAttribute (hConsole, FOREGROUND_RED); } else { SetConsoleTextAttribute (hConsole, aDefaultColor); }
std::cout << setw (6) << setiosflags (ios::fixed) << setprecision (1) << getCoherence (i, j);
}
std::cout << std::endl;
}
std::cout << std::endl;
SetConsoleTextAttribute (hConsole, aDefaultColor);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment