• Login
Community
  • Login

Detect file saved or closed

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
19 Posts 4 Posters 1.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E
    Ekopalypse @Gregory D.
    last edited by Ekopalypse May 17, 2020, 10:45 AM May 17, 2020, 10:45 AM

    @Gregory-D
    documentation about plugin development is here but not everything is included yet.

    @PeterJones - as I promised to do it, I going to finish my task to include the missing api calls next week.
    Because of the markdown issues I will create pure html tables if you haven’t any other idea, do you agree?

    1 Reply Last reply Reply Quote 1
    • E
      Ekopalypse @Gregory D.
      last edited by Ekopalypse May 17, 2020, 10:49 AM May 17, 2020, 10:49 AM

      @Gregory-D
      Here the code you are interested in.

      1 Reply Last reply Reply Quote 0
      • G
        Gregory D.
        last edited by May 17, 2020, 12:11 PM

        As I said I found about NPPN_FILESAVED, but I don’t find how send that to my plugin nor how to know witch file as been saved.

        E A 2 Replies Last reply May 17, 2020, 12:14 PM Reply Quote 0
        • E
          Ekopalypse @Gregory D.
          last edited by May 17, 2020, 12:14 PM

          @Gregory-D

          you said that you found that beNotified is the function which gets called and my link shows that the notification hold the bufferid. Now you can query the open files and compare the id. Done.

          1 Reply Last reply Reply Quote 1
          • G
            Gregory D.
            last edited by May 17, 2020, 12:20 PM

            Still the same problem, there’s no doc, what is the bufferid, how I query open files ?

            E 1 Reply Last reply May 17, 2020, 12:24 PM Reply Quote 0
            • A
              Alan Kilborn @Gregory D.
              last edited by May 17, 2020, 12:20 PM

              @Gregory-D said in Detect file saved or closed:

              …but I don’t find how send that to my plugin

              You don’t…Notepad++ does.

              1 Reply Last reply Reply Quote 0
              • E
                Ekopalypse @Gregory D.
                last edited by May 17, 2020, 12:24 PM

                @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?

                1 Reply Last reply Reply Quote 0
                • G
                  Gregory D.
                  last edited by May 17, 2020, 12:40 PM

                  @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.

                  E 1 Reply Last reply May 17, 2020, 12:50 PM Reply Quote 0
                  • E
                    Ekopalypse @Gregory D.
                    last edited by Ekopalypse May 17, 2020, 12:51 PM May 17, 2020, 12:50 PM

                    @Gregory-D

                    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

                    712d4fdf-1e0d-46b0-a4b2-5ceac99c8c77-image.png

                    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.

                    1 Reply Last reply Reply Quote 1
                    • G
                      Gregory D.
                      last edited by May 17, 2020, 12:59 PM

                      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.

                      E 1 Reply Last reply May 17, 2020, 1:10 PM Reply Quote 0
                      • E
                        Ekopalypse @Gregory D.
                        last edited by Ekopalypse May 17, 2020, 1:11 PM May 17, 2020, 1:10 PM

                        @Gregory-D

                        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.

                        A 1 Reply Last reply May 17, 2020, 1:27 PM Reply Quote 2
                        • A
                          Alan Kilborn @Ekopalypse
                          last edited by Alan Kilborn May 17, 2020, 1:28 PM May 17, 2020, 1:27 PM

                          @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 functions

                          So 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.

                          E 1 Reply Last reply May 17, 2020, 1:36 PM Reply Quote 0
                          • E
                            Ekopalypse @Alan Kilborn
                            last edited by Ekopalypse May 17, 2020, 1:39 PM May 17, 2020, 1:36 PM

                            @Alan-Kilborn

                            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”.

                            1 Reply Last reply Reply Quote 1
                            • R
                              rinku singh
                              last edited by May 17, 2020, 1:46 PM

                              https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5195#issuecomment-455575898

                              E 1 Reply Last reply May 17, 2020, 1:53 PM Reply Quote 0
                              • E
                                Ekopalypse @rinku singh
                                last edited by May 17, 2020, 1:53 PM

                                @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?

                                1 Reply Last reply Reply Quote 0
                                • G
                                  Gregory D.
                                  last edited by May 17, 2020, 1:57 PM

                                  I read again the demo source and finally found how to do. Thank you for your time.

                                  A 1 Reply Last reply May 17, 2020, 2:03 PM Reply Quote 2
                                  • A
                                    Alan Kilborn @Gregory D.
                                    last edited by May 17, 2020, 2:03 PM

                                    @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. :-)

                                    1 Reply Last reply Reply Quote 1
                                    12 out of 19
                                    • First post
                                      12/19
                                      Last post
                                    The Community of users of the Notepad++ text editor.
                                    Powered by NodeBB | Contributors