diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2009-03-20 18:25:36 +0000 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2009-03-20 18:25:36 +0000 |
| commit | eacb9ccd803945ee9aa0a32ea3a6ef6b227c6d40 (patch) | |
| tree | 0e0708bf073ae582f7544d529a82341c4bf35e5f /Source/Core/Common | |
| parent | 7d910a5e4a48134201f99f3e098a531ceffe9c4d (diff) | |
Improve behavior of the console window on windows. Remove coloring from logwindow for the time being. Now you can use wxGetApp if you #include Main.h, and GetCFrame, etc...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2694 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/Common.vcproj | 4 | ||||
| -rw-r--r-- | Source/Core/Common/Src/ConsoleListener.cpp | 50 | ||||
| -rw-r--r-- | Source/Core/Common/Src/LogManager.h | 7 |
3 files changed, 38 insertions, 23 deletions
diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj index 37705b1f21..80d3bd6911 100644 --- a/Source/Core/Common/Common.vcproj +++ b/Source/Core/Common/Common.vcproj @@ -546,10 +546,6 @@ >
</File>
<File
- RelativePath=".\Src\ConsoleListener.h"
- >
- </File>
- <File
RelativePath=".\Src\LogManager.cpp"
>
</File>
diff --git a/Source/Core/Common/Src/ConsoleListener.cpp b/Source/Core/Common/Src/ConsoleListener.cpp index 59f8971fba..137fc9782b 100644 --- a/Source/Core/Common/Src/ConsoleListener.cpp +++ b/Source/Core/Common/Src/ConsoleListener.cpp @@ -15,7 +15,6 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ - #include <string> // System: To be able to add strings with "+" #include <stdio.h> #ifdef _WIN32 @@ -28,9 +27,19 @@ #include "LogManager.h" // Common -/* Start console window - width and height is the size of console window */ -ConsoleListener::ConsoleListener(int Width, int Height, char * Name) : - Listener("console") +// Inits as a Listener +ConsoleListener::ConsoleListener() : Listener("console") +{ +} + +ConsoleListener::~ConsoleListener() +{ + Close(); +} + +// Open console window - width and height is the size of console window +// Name is the window title +void ConsoleListener::Open(int Width, int Height, char * Name) { #ifdef _WIN32 // Open the console window and create the window handle for GetStdHandle() @@ -46,29 +55,38 @@ ConsoleListener::ConsoleListener(int Width, int Height, char * Name) : COORD co = {Width, Height}; SetConsoleScreenBufferSize(m_hStdOut, co); - /* Set the window size in number of letters. The height is hardcoded here - because it can be changed with MoveWindow() later */ + /* Set the window size in number of letters. The height is hard coded here + because it can be changed with MoveWindow() later */ SMALL_RECT coo = {0,0, (Width - 1),50}; // Top, left, right, bottom SetConsoleWindowInfo(m_hStdOut, TRUE, &coo); #endif - } - -/* Close the console window and close the eventual file handle */ -ConsoleListener::~ConsoleListener() +// Close the console window and close the eventual file handle +void ConsoleListener::Close() { #ifdef _WIN32 - FreeConsole(); // Close the console window + if (m_hStdOut == NULL) + return; + FreeConsole(); + m_hStdOut = NULL; #else fflush(NULL); #endif } +bool ConsoleListener::IsOpen() +{ +#ifdef _WIN32 + return (m_hStdOut != NULL); +#else + return true; +#endif +} + // Logs the message to screen void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char *text) { - #if defined(_WIN32) DWORD cCharsWritten; // We will get a value back here WORD color; @@ -101,8 +119,7 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char *text) } SetConsoleTextAttribute(m_hStdOut, color); - WriteConsole(m_hStdOut, text, (DWORD)strlen(text), - &cCharsWritten, NULL); + WriteConsole(m_hStdOut, text, (DWORD)strlen(text), &cCharsWritten, NULL); #else fprintf(stderr, "%s", text); #endif @@ -132,8 +149,8 @@ void ConsoleListener::ClearScreen() } -/* Get window handle of console window to be able to resize it. We use - GetConsoleTitle() and FindWindow() to locate the console window handle. */ +// Get window handle of console window to be able to resize it. We use +// GetConsoleTitle() and FindWindow() to locate the console window handle. #if defined(_WIN32) HWND GetHwnd(void) { @@ -163,4 +180,3 @@ HWND GetHwnd(void) return(hwndFound); } #endif // _WIN32 - diff --git a/Source/Core/Common/Src/LogManager.h b/Source/Core/Common/Src/LogManager.h index b911037101..e93db2e47b 100644 --- a/Source/Core/Common/Src/LogManager.h +++ b/Source/Core/Common/Src/LogManager.h @@ -70,10 +70,13 @@ private: class ConsoleListener : public Listener { public: - ConsoleListener(int Width = 150, int Height = 100, - char * Name = "Console"); + ConsoleListener(); ~ConsoleListener(); + void Open(int Width = 100, int Height = 100, + char * Name = "Console"); + void Close(); + bool IsOpen(); void Log(LogTypes::LOG_LEVELS, const char *text); void ClearScreen(); |
