From 15d3b7831f34ee2e264658e6816fdab0b69145b6 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sun, 8 Feb 2015 09:30:40 -0500 Subject: [PATCH] hide/show: Provide feedback on unsupported platforms --- library/Console-posix.cpp | 8 +++++--- library/Console-windows.cpp | 10 ++++++---- library/Core.cpp | 14 ++++++++++++-- library/include/Console.h | 4 ++-- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/library/Console-posix.cpp b/library/Console-posix.cpp index 74d998ea9..4f1fd563e 100644 --- a/library/Console-posix.cpp +++ b/library/Console-posix.cpp @@ -864,12 +864,14 @@ void Console::msleep (unsigned int msec) usleep((msec % 1000000) * 1000); } -void Console::hide() +bool Console::hide() { //Warmist: don't know if it's possible... + return false; } -void Console::show() +bool Console::show() { //Warmist: don't know if it's possible... -} \ No newline at end of file + return false; +} diff --git a/library/Console-windows.cpp b/library/Console-windows.cpp index 304e215e0..c11661a30 100644 --- a/library/Console-windows.cpp +++ b/library/Console-windows.cpp @@ -590,12 +590,14 @@ void Console::msleep (unsigned int msec) Sleep(msec); } -void Console::hide() +bool Console::hide() { - ShowWindow( GetConsoleWindow(), SW_HIDE ); + ShowWindow( GetConsoleWindow(), SW_HIDE ); + return true; } -void Console::show() +bool Console::show() { ShowWindow( GetConsoleWindow(), SW_RESTORE ); -} \ No newline at end of file + return true; +} diff --git a/library/Core.cpp b/library/Core.cpp index bae243358..63ea2fb48 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -790,11 +790,21 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve } else if(first=="hide") { - getConsole().hide(); + if (!getConsole().hide()) + { + con.printerr("Could not hide console\n"); + return CR_FAILURE; + } + return CR_OK; } else if(first=="show") { - getConsole().show(); + if (!getConsole().show()) + { + con.printerr("Could not show console\n"); + return CR_FAILURE; + } + return CR_OK; } else { diff --git a/library/include/Console.h b/library/include/Console.h index ac76ef1cf..0581f90e0 100644 --- a/library/include/Console.h +++ b/library/include/Console.h @@ -158,8 +158,8 @@ namespace DFHack bool is_console() { return true; } - void hide(); - void show(); + bool hide(); + bool show(); private: Private * d; tthread::recursive_mutex * wlock;