diff --git a/.gitignore b/.gitignore index 0d8fb8a1..9fb44074 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ Release_Archive/ installer/build/ installer/temp/ Thumbs.db -installer/buildPaths.bat \ No newline at end of file +installer/buildPaths.bat +.vs/ \ No newline at end of file diff --git a/PythonScript/src/NotepadPlusWrapper.cpp b/PythonScript/src/NotepadPlusWrapper.cpp index f7c0bd7b..8dac4fbe 100644 --- a/PythonScript/src/NotepadPlusWrapper.cpp +++ b/PythonScript/src/NotepadPlusWrapper.cpp @@ -23,7 +23,9 @@ NotepadPlusWrapper::NotepadPlusWrapper(HINSTANCE hInst, HWND nppHandle) m_hInst(hInst), m_notificationsEnabled(false), m_callbackMutex(::CreateMutex(NULL, FALSE, NULL)) -{ } +{ + hwnd = (intptr_t)nppHandle; +} NotepadPlusWrapper::~NotepadPlusWrapper() { @@ -40,6 +42,7 @@ NotepadPlusWrapper::~NotepadPlusWrapper() // To please Lint, let's NULL these handles and pointers m_nppHandle = NULL; m_hInst = NULL; + hwnd = NULL; } void NotepadPlusWrapper::notify(SCNotification *notifyCode) diff --git a/PythonScript/src/NotepadPlusWrapper.h b/PythonScript/src/NotepadPlusWrapper.h index 10683cb7..9ab350a9 100644 --- a/PythonScript/src/NotepadPlusWrapper.h +++ b/PythonScript/src/NotepadPlusWrapper.h @@ -668,6 +668,8 @@ class NotepadPlusWrapper void setStatusBar(StatusBarSection section, const char *text); intptr_t getPluginMenuHandle(); + + intptr_t hwnd; void activateIndex(int view, int index); diff --git a/PythonScript/src/NotepadPython.cpp b/PythonScript/src/NotepadPython.cpp index 28e29164..a4c53a4f 100644 --- a/PythonScript/src/NotepadPython.cpp +++ b/PythonScript/src/NotepadPython.cpp @@ -21,6 +21,7 @@ void export_notepad() boost::python::register_exception_translator(&translateInvalidValueProvidedException); boost::python::class_, boost::noncopyable>("Notepad", boost::python::no_init) + .add_property("hwnd", &NotepadPlusWrapper::hwnd) .def("new", &NotepadPlusWrapper::newDocument, "Create a new document") .def("new", &NotepadPlusWrapper::newDocumentWithFilename, "Create a new document with the given filename") .def("save", &NotepadPlusWrapper::save, "Save the current file") diff --git a/PythonScript/src/PythonConsole.cpp b/PythonScript/src/PythonConsole.cpp index fef24f8f..a68d4294 100644 --- a/PythonScript/src/PythonConsole.cpp +++ b/PythonScript/src/PythonConsole.cpp @@ -344,7 +344,6 @@ void export_console() .def("run", &PythonConsole::runCommand, "Runs a command on the console") .def("run", &PythonConsole::runCommandNoStderr, "Runs a command on the console") .def("run", &PythonConsole::runCommandNoStdout, "Runs a command on the console") - .def("getScintillaHwnd", &PythonConsole::getScintillaHwndPython, "Provide HWnd for scintilla of console") .add_static_property("encoding", &PythonConsole::getEncoding) .add_property("editor", &PythonConsole::getScintillaWrapper); //lint +e1793 diff --git a/PythonScript/src/PythonConsole.h b/PythonScript/src/PythonConsole.h index d52da9ec..7dead868 100644 --- a/PythonScript/src/PythonConsole.h +++ b/PythonScript/src/PythonConsole.h @@ -66,7 +66,6 @@ class PythonConsole : public PyProducerConsumer, public ConsoleInte } HWND getScintillaHwnd(); - intptr_t getScintillaHwndPython() { return (intptr_t)getScintillaHwnd(); } boost::shared_ptr getScintillaWrapper() { return mp_scintillaWrapper; } diff --git a/PythonScript/src/ScintillaPython.cpp b/PythonScript/src/ScintillaPython.cpp index 5230a416..72592180 100644 --- a/PythonScript/src/ScintillaPython.cpp +++ b/PythonScript/src/ScintillaPython.cpp @@ -28,6 +28,7 @@ BOOST_PYTHON_MODULE(Npp) boost::python::register_exception_translator(&translateNotAllowedInCallbackException); boost::python::class_, boost::noncopyable >("Editor", boost::python::no_init) + .add_property("hwnd", &ScintillaWrapper::hwnd) .def("write", &ScintillaWrapper::AddText, "Add text to the document at current position (alias for addText).") .def("callbackSync", &ScintillaWrapper::addSyncCallback, boost::python::args("callable", "listOfNotifications"), "Registers a callback to a Python function when a Scintilla event occurs. See also callback() to register an asynchronous callback. Callbacks are called synchronously with the event, so try not to perform too much work in the event handler.\nCertain operations cannot be performed in a synchronous callback. setDocPointer, searchInTarget or findText calls are examples. Scintilla doesn't allow recursively modifying the text, so you can't modify the text in a SCINTILLANOTIFICATION.MODIFIED callback - use a standard Asynchronous callback to do this.\ne.g. editor.callbackSync(my_function, [SCINTILLANOTIFICATION.CHARADDED])") .def("callback", &ScintillaWrapper::addAsyncCallback, boost::python::args("callable", "listOfNotifications"), "Registers a callback to call a Python function synchronously when a Scintilla event occurs. Events are queued up, and run in the order they arrive, one after the other, but asynchronously with the main GUI. See editor.callbackSync() to register a synchronous callback. e.g. editor.callback(my_function, [SCINTILLANOTIFICATION.CHARADDED])") diff --git a/PythonScript/src/ScintillaWrapper.cpp b/PythonScript/src/ScintillaWrapper.cpp index ade3903f..25547a56 100644 --- a/PythonScript/src/ScintillaWrapper.cpp +++ b/PythonScript/src/ScintillaWrapper.cpp @@ -33,12 +33,14 @@ ScintillaWrapper::ScintillaWrapper(const HWND handle, const HWND notepadHandle) m_notificationsEnabled(false), m_callbackMutex(::CreateMutex(NULL, FALSE, NULL)) { + hwnd = (intptr_t)handle; } ScintillaWrapper::~ScintillaWrapper() { // m_handle isn't allocated here. Let's just NULL out reference to it, then. m_handle = NULL; + hwnd = NULL; } diff --git a/PythonScript/src/ScintillaWrapper.h b/PythonScript/src/ScintillaWrapper.h index 8a195766..e04aee86 100644 --- a/PythonScript/src/ScintillaWrapper.h +++ b/PythonScript/src/ScintillaWrapper.h @@ -58,7 +58,11 @@ class ScintillaWrapper : public PyProducerConsumer explicit ScintillaWrapper(HWND handle, HWND notepadHandle); virtual ~ScintillaWrapper(); - void setHandle(const HWND handle) { m_handle = handle; }; + intptr_t hwnd; + void setHandle(const HWND handle) { + m_handle = handle; + hwnd = (intptr_t)handle; + }; HWND getHandle() { return m_handle; }; void invalidateHandle() { m_handle = NULL; }; diff --git a/docs/source/console.rst b/docs/source/console.rst index eb43a0da..283fd9f1 100644 --- a/docs/source/console.rst +++ b/docs/source/console.rst @@ -4,6 +4,9 @@ Console Object .. class:: Console +.. property:: hwnd + + Returns the handle of the Scintilla window of the editor object used in the console. .. method:: console.write(string) diff --git a/docs/source/notepad.rst b/docs/source/notepad.rst index 6be77258..ba9a47cb 100644 --- a/docs/source/notepad.rst +++ b/docs/source/notepad.rst @@ -4,6 +4,10 @@ Notepad++ Object .. class:: Notepad +.. property:: hwnd + + Returns the handle of the Notepad++ window. + .. method:: notepad.activateBufferID(bufferID) diff --git a/docs/source/scintilla.rst b/docs/source/scintilla.rst index a3ab9e40..6aa363e8 100644 --- a/docs/source/scintilla.rst +++ b/docs/source/scintilla.rst @@ -47,6 +47,11 @@ Scintilla Methods ----------------- .. class:: Editor +.. property:: hwnd + + Returns the handles of the two Scintilla windows of the editor object. + Editor.hwnd refers to the active window handle, while editor1 and editor2 return the concrete handles. + .. method:: editor.getCharacterPointer() -> str Gets a copy of the text of the document, without first allowing Scintilla to make it's copy of it.