[Need Help] npp c++ plugin
-
@long-tv ,
Getting selected text from the editor is done using the Scintilla message SCI_GETSELTEXT
Creating a panel and writing text into that panel is not something I know how to do (I haven’t actually written a plugin). But maybe you could look at the source for PythonScript or NppConsole which make console windows, so presumably show how to write text into there, or maybe the NppFTP which will write statuses into one of its windows…
-
@peterjones said in [Need Help] npp c++ plugin:
Creating a panel and writing text into that panel is not something I know how to do (I haven’t actually written a plugin).
Me, neither – the scripting plugins are just THAT good that writing a true plugin seems like too much trouble.
BTW, @Long-TV , you have seen this section of the N++ user manual, right?: https://npp-user-manual.org/docs/plugin-communication/
-
@alan-kilborn
I got the template here https://github.com/npp-plugins/plugintemplate
I am learning c++ now, so I chosed c++ to make the plugin. -
@peterjones
thank you for suggestion… I will look for PythonScript for code sample. -
BTW, @Long-TV , you have seen this section of the N++ user manual, right?: https://npp-user-manual.org/docs/plugin-communication/
I have read it and did some practice code. but it too many… I just need 2 actions I mentioned.
-
@long-tv said in [Need Help] npp c++ plugin:
I have read it and did some practice code. but it too many… I just need 2 actions I mentioned.
I gave you the Scintilla message for grabbing selected text. If you don’t know how to send that message to Scintilla, your problems go deeper, and you probably need to start with a C++ project that isn’t as complicated as a plugin.
And as far as creating a window/panel inside Notepad++ and writing text into it: that’s a much more complicated task, and isn’t just “one” action from the “just need 2 actions” you mentioned. It is a large series of steps which you will have to learn how to do – and we cannot be expected to spoonfeed such things – because that would be us writing the plugin for you (and because not all of us even know how to create that window; it’s a more complicated task, though I thought the c++ plugin template including a “docking window” example in a subfolder… so I would start there).
But honestly, as Alan suggested, if you wanted to learn the PythonScript plugin (rather than using its source code as an example of how to implement something), and use that plugin that to write and run a script in Notepad++ environment, then you could leverage the development-time-saving features built into a solution like the PythonScript plugin. For example:
from Npp import * console.show() selected_text = editor.getSelText() console.write(selected_text+"\n")
That script will do everything you described you wanted your plugin to do. In 4 lines of code.
As Alan says, using a scripting plugin rather than having to deal with all the overhead of writing a full plugin is a definite timesaver. Unless you are doing something computationally expensive, or something that’s trying to change the styles of large documents, it’s usually best to just stick with that.
–
edited: added more details on the adding a window task -
@peterjones
thank you for your advice! -
@peterjones said in [Need Help] npp c++ plugin:
That script will do everything you described you wanted your plugin to do
Well… scripting plugins would NOT be great if you have to have a “docking panel” or similar kind of “fancy” output presentation.
-
Well, the PythonScript console is a docking panel of sorts, and could be used for outputting such data, as long as the OP just wants a simple text output, and doesn’t care about fancy formatting.
-
@peterjones said in [Need Help] npp c++ plugin:
Well, the PythonScript console is a docking panel of sorts, and could be used for outputting such data, as long as the OP just wants a simple text output, and doesn’t care about fancy formatting.
All true, but I think the OP is going for something more sophisticated.