diff --git a/PythonScript/src/ConsoleDialog.cpp b/PythonScript/src/ConsoleDialog.cpp index eddc9106..14879be9 100644 --- a/PythonScript/src/ConsoleDialog.cpp +++ b/PythonScript/src/ConsoleDialog.cpp @@ -8,6 +8,7 @@ #include "PluginInterface.h" #include "Docking.h" #include "WcharMbcsConverter.h" +#include "MenuManager.h" namespace NppPythonScript @@ -625,12 +626,13 @@ void ConsoleDialog::doDialog() callScintilla(SCI_COLOURISE, 0, -1); } } - + MenuManager::getInstance()->checkShowConsole(true); display(true); } void ConsoleDialog::hide() { + MenuManager::getInstance()->checkShowConsole(false); display(false); } diff --git a/PythonScript/src/MenuManager.cpp b/PythonScript/src/MenuManager.cpp index b04e0e39..f08c475b 100644 --- a/PythonScript/src/MenuManager.cpp +++ b/PythonScript/src/MenuManager.cpp @@ -1132,3 +1132,8 @@ bool MenuManager::inFixedRange(idx_t commandID) assert(m_originalDynamicMenuManager != NULL); return m_originalDynamicMenuManager && m_originalDynamicMenuManager->inRange(commandID); } + +void MenuManager::checkShowConsole(bool checked) +{ + ::SendMessage(m_hNotepad, NPPM_SETMENUITEMCHECK, (WPARAM)m_funcItems[1]._cmdID, (LPARAM)checked); +} \ No newline at end of file diff --git a/PythonScript/src/MenuManager.h b/PythonScript/src/MenuManager.h index e97aa6f9..6b6a140c 100644 --- a/PythonScript/src/MenuManager.h +++ b/PythonScript/src/MenuManager.h @@ -81,6 +81,7 @@ class MenuManager static bool s_menuItemClicked; static WNDPROC s_origWndProc; + void checkShowConsole(bool checked); private: diff --git a/PythonScript/src/PythonConsole.cpp b/PythonScript/src/PythonConsole.cpp index c8649b3e..d94fd133 100644 --- a/PythonScript/src/PythonConsole.cpp +++ b/PythonScript/src/PythonConsole.cpp @@ -136,6 +136,7 @@ void PythonConsole::pythonShowDialog() else { mp_consoleDlg->doDialog(); + consoleVisible = true; } } } @@ -147,6 +148,7 @@ void PythonConsole::showDialog() { GILRelease release; mp_consoleDlg->doDialog(); + consoleVisible = true; } } @@ -157,6 +159,7 @@ void PythonConsole::hideDialog() { GILRelease release; mp_consoleDlg->hide(); + consoleVisible = false; } } diff --git a/PythonScript/src/PythonConsole.h b/PythonScript/src/PythonConsole.h index c74d20df..c275c541 100644 --- a/PythonScript/src/PythonConsole.h +++ b/PythonScript/src/PythonConsole.h @@ -72,6 +72,8 @@ class PythonConsole : public PyProducerConsumer, public ConsoleInte boost::shared_ptr mp_scintillaWrapper; static boost::python::str getEncoding() { return boost::python::str("utf-8"); } + + bool consoleVisible = false; protected: virtual void consume(std::shared_ptr statement); diff --git a/PythonScript/src/PythonScript.cpp b/PythonScript/src/PythonScript.cpp index 41cfb464..24a1b9ae 100644 --- a/PythonScript/src/PythonScript.cpp +++ b/PythonScript/src/PythonScript.cpp @@ -58,7 +58,7 @@ static std::vector< std::pair* > g_toolbarScripts; static void doAbout(); static void newScript(); -static void showConsole(); +static void toggleConsole(); static void showShortcutDlg(); static void stopScript(); static void runScript(idx_t number); @@ -70,8 +70,6 @@ static void previousScript(); static FuncItem* getGeneratedFuncItemArray(int *nbF); - - // Run script functions @@ -171,7 +169,7 @@ static FuncItem* getGeneratedFuncItemArray(int *nbF) idx_t runPreviousIndex; items.push_back(std::pair(_T("New Script"), newScript)); - items.push_back(std::pair(_T("Show Console"), showConsole)); + items.push_back(std::pair(_T("Show Console"), toggleConsole)); items.push_back(std::pair(_T("--"), reinterpret_cast(NULL))); @@ -570,12 +568,19 @@ static void showShortcutDlg() } } -static void showConsole() +static void toggleConsole() { if (g_console) { CHECK_INITIALISED(); - g_console->showDialog(); + if (g_console->consoleVisible) + { + g_console->hideDialog(); + } + else + { + g_console->showDialog(); + } } }