two questions on my first plugin
-
Hello,
i now programing on my first npp plugin (in C#) and i have any little questions ;-)
a) Is there exist an event or an message when the user change to another document?
b) Is exist an example or dev-guide for using localization?Thats all for the begin.
regards Mario
-
I’m only able to tell you something about your question a)
There is a notification called NPPM_BUFFERACTIVATED (see here (slightly outdated) and here (up to date)). It is send to a plugin whenever a document’s text buffer (i.e. its tab) gets activated.
I’m a plugin author too (see here) thus I know that there are some pitfalls with NPPM_BUFFERACTIVATED. Activating a buffer often happens even in situations where you do not expect it.
Especially if your plugin does something with a text buffer which has to be done only one times you need to implement some sort of buffer management to remember that a certain buffer already has undergone your manipulations.
I personally ended up with a dictionary: The keys are buffer IDs and the values are the full paths of the related files. I solved it this way because it can happen that an already closed buffer ID gets reused by another file.
-
Hello dinkumoil,
thanks for suggestion, it is exactly what i search.
For all other C#-developers:
-
In file Main.cs write a new function with header “internal static void bufferIsActivated()”
this function is called by eventmanager on 2. -
In file PluginInfrastructure/UnmanagedExports.cs in the function “static void beNotified(IntPtr notifyCode)” add follow code above the else statement:
else if (notification.Header.Code == (uint)NppMsg.NPPN_BUFFERACTIVATED) { Main.bufferIsActivated(); }
And now is calling your “bufferIsActivated”-function by change / activate a other tab.
thanks and regards
Mario -
-
Hello everyone,
“see the forest for the trees” 8-)
in file PluginInfrastructure/UnmanagedExports.cs in the function “static void beNotified(IntPtr notifyCode)” in the else statement
else { Main.OnNotification(notification); }… Main.OnNotification(notification); … oh no
That is an callback. I am so stup…have a nice day
Mario
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login