Skip to content

Commit 76a0f0b

Browse files
committed
Add console.editor to allow changing colours, styles, fonts etc.
- Text changes not allowed, as Scintilla window remains readonly I think that's probably best :)
1 parent cd26891 commit 76a0f0b

5 files changed

Lines changed: 15 additions & 6 deletions

File tree

PythonScript/src/ConsoleDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ void ConsoleDialog::createOutputWindow(HWND hParentWindow)
409409

410410
void ConsoleDialog::writeText(int length, const char *text)
411411
{
412-
::SendMessage(m_scintilla, SCI_SETREADONLY, 0, 0);
412+
::SendMessage(m_scintilla, SCI_SETREADONLY, 0, 0);
413413
for (int i = 0; i < length; ++i)
414414
{
415415
if (text[i] == '\r')

PythonScript/src/ConsoleDialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ConsoleDialog : public DockingDlgInterface
3737
void createOutputWindow(HWND hParentWindow);
3838
void runStatement();
3939
void stopStatement();
40-
40+
4141
LRESULT run_inputWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
4242
static LRESULT inputWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
4343
void historyNext();

PythonScript/src/PythonConsole.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "PythonHandler.h"
77
#include "ProcessExecute.h"
88
#include "PluginInterface.h"
9+
#include "ScintillaWrapper.h"
910
#include "Notepad_plus_msgs.h"
1011
#include "PythonScript/NppPythonScript.h"
1112

@@ -20,9 +21,11 @@ using namespace NppPythonScript;
2021
PythonConsole::PythonConsole(HWND hNotepad) :
2122
PyProducerConsumer<const char *>(),
2223
m_consumerStarted(false),
23-
m_hNotepad(hNotepad)
24+
m_hNotepad(hNotepad),
25+
mp_scintillaWrapper(NULL)
2426
{
2527
mp_consoleDlg = new ConsoleDialog();
28+
2629
m_statementRunning = CreateEvent(NULL, FALSE, TRUE, NULL);
2730

2831
}
@@ -37,6 +40,7 @@ void PythonConsole::init(HINSTANCE hInst, NppData nppData)
3740
{
3841
mp_consoleDlg->init(hInst, nppData, this);
3942
m_nppData = nppData;
43+
mp_scintillaWrapper.setHandle(mp_consoleDlg->getScintillaHwnd());
4044

4145
}
4246

@@ -226,8 +230,8 @@ void export_console()
226230
.def("hide", &PythonConsole::hideDialog, "Hides the console")
227231
.def("run", &PythonConsole::runCommand, "Runs a command on the console")
228232
.def("run", &PythonConsole::runCommandNoStderr, "Runs a command on the console")
229-
.def("run", &PythonConsole::runCommandNoStdout, "Runs a command on the console");
230-
233+
.def("run", &PythonConsole::runCommandNoStdout, "Runs a command on the console")
234+
.def_readonly("editor", &PythonConsole::mp_scintillaWrapper, "Gets an Editor object for the console window");
231235

232236
}
233237

PythonScript/src/PythonConsole.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#include "ConsoleDialog.h"
77
#include "PyProducerConsumer.h"
88
#include "ConsoleInterface.h"
9+
#include "ScintillaWrapper.h"
910

1011
class PythonHandler;
12+
class ScintillaWrapper;
1113
struct RunStatementArgs;
1214

1315
class PythonConsole : public NppPythonScript::PyProducerConsumer<const char *>, ConsoleInterface
@@ -30,11 +32,13 @@ class PythonConsole : public NppPythonScript::PyProducerConsumer<const char *>,
3032
void clear();
3133
void stopScript();
3234

35+
3336
/* Console Interface members */
3437
void runStatement(const char *statement);
3538
void stopStatement();
3639
void setPrompt(const char *prompt);
3740
void openFile(const char *filename, int lineNumber);
41+
3842
/* ConsoleInterface end */
3943

4044

@@ -63,11 +67,13 @@ class PythonConsole : public NppPythonScript::PyProducerConsumer<const char *>,
6367
HWND getScintillaHwnd() { return mp_consoleDlg->getScintillaHwnd(); };
6468

6569

70+
ScintillaWrapper mp_scintillaWrapper;
6671
protected:
6772
virtual void queueComplete();
6873

6974
private:
7075
ConsoleDialog *mp_consoleDlg;
76+
7177
boost::python::object m_console;
7278
boost::python::object m_pushFunc;
7379
boost::python::object m_sys;

PythonScript/src/ScintillaPython.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,5 +696,4 @@ void importConsole(PythonConsole* instance)
696696

697697
// Create an instance variable buffer in __main__ that points to the PythonConsole instance
698698
main_namespace["console"] = ptr(instance);
699-
700699
}

0 commit comments

Comments
 (0)