Community
    • Login

    Detect file saved or closed

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    19 Posts 4 Posters 1.3k 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.
    • EkopalypseE
      Ekopalypse @Gregory D.
      last edited by Ekopalypse

      @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
      • EkopalypseE
        Ekopalypse @Gregory D.
        last edited by Ekopalypse

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

        1 Reply Last reply Reply Quote 0
        • Gregory D.G
          Gregory D.
          last edited by

          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.

          EkopalypseE Alan KilbornA 2 Replies Last reply Reply Quote 0
          • EkopalypseE
            Ekopalypse @Gregory D.
            last edited by

            @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
            • Gregory D.G
              Gregory D.
              last edited by

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

              EkopalypseE 1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @Gregory D.
                last edited by

                @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
                • EkopalypseE
                  Ekopalypse @Gregory D.
                  last edited by

                  @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
                  • Gregory D.G
                    Gregory D.
                    last edited by

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

                    EkopalypseE 1 Reply Last reply Reply Quote 0
                    • EkopalypseE
                      Ekopalypse @Gregory D.
                      last edited by Ekopalypse

                      @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
                      • Gregory D.G
                        Gregory D.
                        last edited by

                        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.

                        EkopalypseE 1 Reply Last reply Reply Quote 0
                        • EkopalypseE
                          Ekopalypse @Gregory D.
                          last edited by Ekopalypse

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

                          Alan KilbornA 1 Reply Last reply Reply Quote 2
                          • Alan KilbornA
                            Alan Kilborn @Ekopalypse
                            last edited by Alan Kilborn

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

                            EkopalypseE 1 Reply Last reply Reply Quote 0
                            • EkopalypseE
                              Ekopalypse @Alan Kilborn
                              last edited by Ekopalypse

                              @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
                              • rinku singhR
                                rinku singh
                                last edited by

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

                                EkopalypseE 1 Reply Last reply Reply Quote 0
                                • EkopalypseE
                                  Ekopalypse @rinku singh
                                  last edited by

                                  @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
                                  • Gregory D.G
                                    Gregory D.
                                    last edited by

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

                                    Alan KilbornA 1 Reply Last reply Reply Quote 2
                                    • Alan KilbornA
                                      Alan Kilborn @Gregory D.
                                      last edited by

                                      @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
                                      • First post
                                        Last post
                                      The Community of users of the Notepad++ text editor.
                                      Powered by NodeBB | Contributors