Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion PythonScript/src/ConsoleDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "PluginInterface.h"
#include "Docking.h"
#include "WcharMbcsConverter.h"
#include "MenuManager.h"


namespace NppPythonScript
Expand Down Expand Up @@ -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);
}

Expand Down
5 changes: 5 additions & 0 deletions PythonScript/src/MenuManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions PythonScript/src/MenuManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class MenuManager
static bool s_menuItemClicked;
static WNDPROC s_origWndProc;

void checkShowConsole(bool checked);


private:
Expand Down
3 changes: 3 additions & 0 deletions PythonScript/src/PythonConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void PythonConsole::pythonShowDialog()
else
{
mp_consoleDlg->doDialog();
consoleVisible = true;
}
}
}
Expand All @@ -147,6 +148,7 @@ void PythonConsole::showDialog()
{
GILRelease release;
mp_consoleDlg->doDialog();
consoleVisible = true;
}
}

Expand All @@ -157,6 +159,7 @@ void PythonConsole::hideDialog()
{
GILRelease release;
mp_consoleDlg->hide();
consoleVisible = false;
}
}

Expand Down
2 changes: 2 additions & 0 deletions PythonScript/src/PythonConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class PythonConsole : public PyProducerConsumer<std::string>, public ConsoleInte
boost::shared_ptr<ScintillaWrapper> mp_scintillaWrapper;

static boost::python::str getEncoding() { return boost::python::str("utf-8"); }

bool consoleVisible = false;

protected:
virtual void consume(std::shared_ptr<std::string> statement);
Expand Down
17 changes: 11 additions & 6 deletions PythonScript/src/PythonScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static std::vector< std::pair<std::string*, HICON>* > 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);
Expand All @@ -70,8 +70,6 @@ static void previousScript();

static FuncItem* getGeneratedFuncItemArray(int *nbF);



// Run script functions


Expand Down Expand Up @@ -171,7 +169,7 @@ static FuncItem* getGeneratedFuncItemArray(int *nbF)
idx_t runPreviousIndex;

items.push_back(std::pair<tstring, void(*)()>(_T("New Script"), newScript));
items.push_back(std::pair<tstring, void(*)()>(_T("Show Console"), showConsole));
items.push_back(std::pair<tstring, void(*)()>(_T("Show Console"), toggleConsole));

items.push_back(std::pair<tstring, void(*)()>(_T("--"), reinterpret_cast<void(*)()>(NULL)));

Expand Down Expand Up @@ -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();
}
}
}

Expand Down