From dedd7e418589c32f9dbfd4739b9d7a8a13efbdf5 Mon Sep 17 00:00:00 2001 From: Warmist Date: Mon, 26 May 2014 18:29:27 +0300 Subject: [PATCH] Adds new console methods and commands to hide/show console. Only on windows (for now?) --- library/Console-darwin.cpp | 10 ++++++++++ library/Console-linux.cpp | 10 ++++++++++ library/Console-windows.cpp | 10 ++++++++++ library/Core.cpp | 8 ++++++++ library/include/Console.h | 3 +++ 5 files changed, 41 insertions(+) diff --git a/library/Console-darwin.cpp b/library/Console-darwin.cpp index 86cd657a1..6df6a33a5 100644 --- a/library/Console-darwin.cpp +++ b/library/Console-darwin.cpp @@ -770,4 +770,14 @@ void Console::msleep (unsigned int msec) { if (msec > 1000) sleep(msec/1000000); usleep((msec % 1000000) * 1000); +} + +void Console::hide() +{ + //Warmist: don't know if it's possible... +} + +void Console::show() +{ + //Warmist: don't know if it's possible... } \ No newline at end of file diff --git a/library/Console-linux.cpp b/library/Console-linux.cpp index f32fa1c2a..3453e78ef 100644 --- a/library/Console-linux.cpp +++ b/library/Console-linux.cpp @@ -777,3 +777,13 @@ void Console::msleep (unsigned int msec) if (msec > 1000) sleep(msec/1000000); usleep((msec % 1000000) * 1000); } + +void Console::hide() +{ + //Warmist: don't know if it's possible... +} + +void Console::show() +{ + //Warmist: don't know if it's possible... +} \ No newline at end of file diff --git a/library/Console-windows.cpp b/library/Console-windows.cpp index f0cdda387..304e215e0 100644 --- a/library/Console-windows.cpp +++ b/library/Console-windows.cpp @@ -589,3 +589,13 @@ void Console::msleep (unsigned int msec) { Sleep(msec); } + +void Console::hide() +{ + ShowWindow( GetConsoleWindow(), SW_HIDE ); +} + +void Console::show() +{ + ShowWindow( GetConsoleWindow(), SW_RESTORE ); +} \ No newline at end of file diff --git a/library/Core.cpp b/library/Core.cpp index 96fd3903f..84c445cc6 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -760,6 +760,14 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve return CR_WRONG_USAGE; } } + else if(first=="hide") + { + getConsole().hide(); + } + else if(first=="show") + { + getConsole().show(); + } else { command_result res = plug_mgr->InvokeCommand(con, first, parts); diff --git a/library/include/Console.h b/library/include/Console.h index 2f2f68cfa..85eb7cd42 100644 --- a/library/include/Console.h +++ b/library/include/Console.h @@ -155,6 +155,9 @@ namespace DFHack bool isInited (void) { return inited; }; bool is_console() { return true; } + + void hide(); + void show(); private: Private * d; tthread::recursive_mutex * wlock;