Detect file saved or closed
-
@Gregory-D did you go to the link where I pointed to the documentation and did you read it?
You want to write a c++ plugin so I assume you know how to read a header file, don’t you? -
@Ekopalypse said in Detect file saved or closed:
@Gregory-D did you go to the link where I pointed to the documentation and did you read it?
You want to write a c++ plugin so I assume you know how to read a header file, don’t you?I don’t know what you mean by “read a header file”.
First link:
#define NPPN_FILESAVED (NPPN_FIRST + 8) // To notify plugins that the current file is just saved //scnNotification->nmhdr.code = NPPN_FILESAVED; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = BufferID;
Ok, it says the event I need to check is NPPN_FILESAVED and that I can get that BufferID.
Second link:
A notification is sent using a WM_NOTIFY message...
Ok, and I received it beNotified , nice but that doesn’t explain how to make the relation between that message and the file that is saved.
-
and then it says
The notification IDs for each of these named notifications can be found in the source code in Notepad_plus_msgs.h.
and Notepad_plus_msgs.h is a link to the file on github.
And if you scroll on top of the documentation you see something like
What exactly are you missing?
Note, I’m not going to write a documentation like msdn.
Neither do I have the resources like MS has not am I in the mood
to waste my time for pointless content. -
As it seems so simple to you I will try to understand that, because is is it still doesn’t help.
I don’t ask for something like msdn but more than one single demo, at least demos for all features. Maybe a simple schema of how communications between notepad++ and the plugin work, there’s several dlgproc and I really don’t get it. -
the whole concept is using SendMessage api to
instruct npp to do something and to “listen” on beNotified to get the notifications.
That’s it.
You can workaround this concept by hooking into various message procs
but this is a totally different story and has, more or less,
nothing to do what npp overs as its official API.In your case, you “listen” on a notification with for example a
switch(notifyCode->nmhdr.code) { case NPPN_READY: { ... }
for example like here
Writing an example for each message would be nice but unrealistic as,
for example, scintilla has over 700 functions. -
@Ekopalypse said in Detect file saved or closed:
Writing an example for each message would be nice but unrealistic as,
for example, scintilla has over 700 functionsSo I’m NOT a plugin writer, but looking over the materials this does seem a bit fuzzy.
Is there a C++ plugin template that people start from that demos the notification process (probably)?
You mentioned the docs were going to be improved; perhaps when that happens it will take care of the OP’s need.
If not, perhaps taking ONE N++ notification and/or ONE Scintilla notification and walking it through the complete process in the documentation is appropriate? 700 would be silly as you say.
Or maybe not; I don’t know; as I say I’ve never tried to develop a plugin. -
I think that this has everything to get started but I might be wrong.
It would be nice to get comments as to why it isn’t sufficient
and what could be done to improve it.You mentioned the docs were going to be improved
I’m going to add the missing api calls to the existing documentation
but I will not reinvent the wheel as I think this is going to be “pointless”. -
-
@gurikbal-singh
I would say if the content on the disc is the same as the content of the buffer and buffer is dirty is not set then it is saved or do I miss something here?
-
I read again the demo source and finally found how to do. Thank you for your time.
-
@Gregory-D said in Detect file saved or closed:
I read again the demo source and finally found how to do. Thank you for your time.
I suppose we judge it sufficient then, as someone actually trying to do it has found success. :-)