Yet Another C++ Plugin Template...
-
I felt the existing C++ notepad++ plugin template was a little unclear, left some things unexplained, and was prone to error (well, prone to the sort of errors I tend to make), and left it very unclear about how you’d fit in a docking dialogue.
Also it wasn’t really class oriented. And I like classes.
So I wrote my own. Complete with a demo plugin. And a fair amount of documentation in the readme (which could be better, sorry).
It’s still a little bit work in progress - in the way of computer projects, it’s hit 95% complete, and now I keep finding extra bits to do before it gets to 100%
It provides a layer between notepad++ and your plugin, enabling you to keep your code nicely in a few classes without loads of static or global variable, and attempts to hide some of the vagaries of the windows APIs. Or at least make them less horrifying.
It can be found here
Feel free to try it out and comment here or raise issues in the repo.
-
-
This was originally mentioned in THIS THREAD in the Dec 17 2023 1:04PM POSTING.
-
@ThosRTanner said in Yet Another C++ Plugin Template...:
One comment, just a thought…
Since you are making a C++ template, perhaps instead of:
LRESULT send_to_editor(UINT message, WPARAM = 0, LPARAM = 0) const noexcept LRESULT send_to_editor(UINT message, WPARAM wParam, void const *buff) const noexcept
it would be better to set up the Scintilla C++ API.
Because of an annoyance with exception handling — ScintillaCall.h defines an exception but doesn’t derive it from std::exception, which prevents Notepad++ from displaying a sensible error message — I created a macro wrapper for ScintillaCall.h for Columns++, which you can see here.
There is also an oddity whereby the C++ interface will raise an exception due to a leftover failure status code previously set but never cleared in the C interface, making it appear that something went wrong in the plugin using the C++ interface. Executing Scintilla::ScintillaCall::SetStatus(Scintilla::Status::Ok) before executing other C++ Scintilla calls avoids that, so it’s a good idea to call that somewhere in entry code each time before the plugin gets control.
-
I like it, guys, keep up the good work!
-
@Coises thanks. I shall go and have a look at that. I possibly need to fiddle with scintilla a bit before I release that…
-
…mapped shortcuts other than Scintilla commands are sent to Notepad++ when used in a non-modal dialog that doesn’t register with NPPM_MODELESSDIALOG. Apparently many plugins never did this, because the most commonly used shortcuts were Scintilla commands. Moving three very common shortcuts from Scintilla commands to Notepad++ accelerators changes that.
Maybe it is appropriate to have the correct way of doing the above shown in a plugin template. Then future plugin authors are less likely to do it wrong. Just a thought.
-
@Alan-Kilborn Indeed. On my todo list.
Addendum - it actually already does that for docking dialogues.
Not for non-docking dialogues which I don’t currently support. Though if someone would like to point me to a plugin that creates floating dialogues, I’d be happy to have a play.
-
@ThosRTanner said in Yet Another C++ Plugin Template...:
a plugin that creates floating dialogues
-
Latest version now has a Non_Modal_Dialogue_Interface class (after a chunk of refactoring!)