Alex Bikfalvi
SimStream Documentation
Console.cpp
00001 #include "Headers.h" 00002 #include "Console.h" 00003 00004 #ifdef _WINDOWS 00005 #include <windows.h> 00006 #endif 00007 00008 void CConsole::SetColor(CConsole::EColor color) 00009 { 00010 #ifdef _WINDOWS 00011 HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); 00012 switch(color) 00013 { 00014 case CConsole::BLACK: SetConsoleTextAttribute(console, 0); break; 00015 case CConsole::DARK_BLUE: SetConsoleTextAttribute(console, FOREGROUND_BLUE); break; 00016 case CConsole::DARK_GREEN: SetConsoleTextAttribute(console, FOREGROUND_GREEN); break; 00017 case CConsole::DARK_CYAN: SetConsoleTextAttribute(console, FOREGROUND_BLUE | FOREGROUND_GREEN); break; 00018 case CConsole::DARK_RED: SetConsoleTextAttribute(console, FOREGROUND_RED); break; 00019 case CConsole::DARK_MAGENTA: SetConsoleTextAttribute(console, FOREGROUND_RED | FOREGROUND_BLUE); break; 00020 case CConsole::DARK_YELLOW: SetConsoleTextAttribute(console, FOREGROUND_RED | FOREGROUND_GREEN); break; 00021 case CConsole::DARK_GRAY: SetConsoleTextAttribute(console, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); break; 00022 case CConsole::LIGHT_GRAY: SetConsoleTextAttribute(console, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); break; 00023 case CConsole::LIGHT_BLUE: SetConsoleTextAttribute(console, FOREGROUND_BLUE | FOREGROUND_INTENSITY); break; 00024 case CConsole::LIGHT_GREEN: SetConsoleTextAttribute(console, FOREGROUND_GREEN | FOREGROUND_INTENSITY); break; 00025 case CConsole::LIGHT_CYAN: SetConsoleTextAttribute(console, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); break; 00026 case CConsole::LIGHT_RED: SetConsoleTextAttribute(console, FOREGROUND_RED | FOREGROUND_INTENSITY); break; 00027 case CConsole::LIGHT_MAGENTA: SetConsoleTextAttribute(console, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY); break; 00028 case CConsole::LIGHT_YELLOW: SetConsoleTextAttribute(console, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY); break; 00029 case CConsole::WHITE: SetConsoleTextAttribute(console, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); break; 00030 } 00031 #endif 00032 } 00033 00034 void CConsole::MoveCursorBeginLine() 00035 { 00036 #ifdef _WINDOWS 00037 HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); 00038 CONSOLE_SCREEN_BUFFER_INFO consoleInfo; 00039 00040 00041 GetConsoleScreenBufferInfo(console, &consoleInfo); 00042 00043 consoleInfo.dwCursorPosition.X = 0; 00044 consoleInfo.dwCursorPosition.Y -= 1; 00045 00046 SetConsoleCursorPosition(console, consoleInfo.dwCursorPosition); 00047 #endif 00048 }
Last updated: February 8, 2011