Looking for tips/directions on how to best approach creating a custom plugin for Notepad++
-
One more question, while I still remember it. Is it possible, in any way, even a crude one at the moment (due to my lack of skills), that if one of the search regex finds a string, NPP would prompt a user with a pop up window/message in any other form, that “hey, this has been found in your file, you might want to take a look at it”?
-
@slusher59 said in Looking for tips/directions on how to best approach creating a custom plugin for Notepad++:
One more question, while I still remember it. Is it possible, in any way, even a crude one at the moment (due to my lack of skills), that if one of the search regex finds a string, NPP would prompt a user with a pop up window/message in any other form, that “hey, this has been found in your file, you might want to take a look at it”?
I don’t think so with just the Macro approach. If you implement the searches in PythonScript, then yes absolutely possible as with any other scripting solution (NppExec for example) and certainly with a proper plugin.
Cheers.
-
@slusher59 said in Looking for tips/directions on how to best approach creating a custom plugin for Notepad++:
Hey Guys,
sorry for late responseThere’s a lot going on with this thread starting with “Hey Guys”.
I’ll try to address some things further, in this and subsequent postings in this thread…@michael-vincent said in Looking for tips/directions on how to best approach creating a custom plugin for Notepad++:
Create your RegEx with the (?x) modifier to allow inline comments and free space
But using
(?x)
at the start can affect the meaning of what follows, unless you use(?-x)
at some point after.Why not avoid that possibility and just use the comment specifier, example:
(?#hello there I'm a comment)
at the start of the regex? -
@michael-vincent said in Looking for tips/directions on how to best approach creating a custom plugin for Notepad++:
if one of the search regex finds a string, NPP would prompt a user with a pop up window/message in any other form, that “hey, this has been found in your file, you might want to take a look at it”?
I don’t think so with just the Macro approach. If you implement the searches in PythonScript, then yes absolutely possible as with any other scripting solution (NppExec for example) and certainly with a proper plugin.
No way to do this in a macro, as stated. PythonScript has two functions for prompting the user:
notepad.prompt()
notepad.messageBox()
Each returns data which can impact script logic flow after the prompting box window is closed.
-
@slusher59 said in Looking for tips/directions on how to best approach creating a custom plugin for Notepad++:
I would also not want to lose on the great functionality of the search result window from Notepad++, that it provides on it’s own.
So that window and PythonScript don’t typically play well together. If you script searches, you have to find your own way of presenting the output to the user.
-
@alan-kilborn said in Looking for tips/directions on how to best approach creating a custom plugin for Notepad++:
Why not avoid that possibility and just use the comment specifier, example: (?#hello there I’m a comment) at the start of the regex?
Much nicer solution!
-
Plugins are usually shared libraries (dll) and creating them with Python is not as easy as with a language that is supposed to create them natively, like C++, C, D, Rust, C#, V or others. Yes, one way to create them is with Cython or also with cffi.
But I would recommend using another language instead, because as far as I know, including Python 3.10, there is still a problem if you want to embed more than one Python interpreter into a running process, which means that as long as you are the only one writing plugins for your own use, it’s fine, but as soon as another plugin developer decides to do so as well or someone wants to use the existing PythonScript plugin, then the problems start.
-
Thank you. As a temporary band-aid fix for this (until I learn how to do the thing properly), is it possible in NPP to display only the search results that have > 0 hits, and hide all searches that returned 0 results?
-
@slusher59
No, as far as I know there is neither a built-in option nor a plugin message that would allow you to do this. And hacking it might be a bad idea because it could then conflict with subsequent searches. -
@slusher59 said in Looking for tips/directions on how to best approach creating a custom plugin for Notepad++:
is it possible in NPP to display only the search results that have > 0 hits, and hide all searches that returned 0 results?
As I said before:
@alan-kilborn said in Looking for tips/directions on how to best approach creating a custom plugin for Notepad++:
So Search results window and PythonScript don’t typically play well together.
If you script searches, you have to find your own way of presenting the output to the user.
One way of doing this is having your script write output to a new (file) tab that it creates. That way you have total control of what goes into the output. You can even make it appear a lot like the usual Search results. If you want to get really fancy, you could even set it up so that double-clicking in this output would open the file where the hit was found.
It just depends if the time you want to spend on this is better spent scripting or developing a true plugin. But even a true plugin isn’t going to have an easy time of doing custom things with Notepad++'s Search results area.