• Login
Community
  • Login

Notification on update document without saving

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
10 Posts 4 Posters 674 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.
  • W
    WinterSilence
    last edited by Jun 17, 2020, 11:22 PM

    What’s NPPN_ constant using for notify at update document without saving?

    1 Reply Last reply Reply Quote 0
    • P
      PeterJones
      last edited by Jun 17, 2020, 11:49 PM

      Notifications are documented https://npp-user-manual.org/docs/plugin-communication/#notepad-notifications

      I’m not sure what you mean by “at update document without saving”. If you can clarify that…

      1 Reply Last reply Reply Quote 0
      • W
        WinterSilence
        last edited by Jun 18, 2020, 4:43 AM

        @PeterJones said in Notification on update document without saving:

        If you can clarify that

        notification called on change text(SCI_...TEXT message) in active view

        1 Reply Last reply Reply Quote 0
        • P
          Prahlad-Makwana4145
          last edited by Jun 18, 2020, 5:18 AM

          Hello,@WinterSilence

          New feature added in Notepad 6.6 for which the release notes say:

          • The main feature of this release is Session snapshot & periodic backup. If this feature is enabled (enabled by default), user won’t be asked to save unsaved file as he quits Notepad++, and on startup Notepad++ restores the unsaved file and unsaved untitled document of last session.

          This facility is controlled via menu => Settings => Preferences => Backup. For more details see also this section of the Notepad++ User Manual.

          I hope this information will be useful .
          Thank you.

          W 1 Reply Last reply Jun 18, 2020, 6:33 AM Reply Quote 0
          • W
            WinterSilence @Prahlad-Makwana4145
            last edited by Jun 18, 2020, 6:33 AM

            @Prahlad-Makwana4145

            Session notifications are sent by timer, not by updating doc text. I can check SCI GETTEXT by timer without this, but it’s 100% freeze npp+.

            1 Reply Last reply Reply Quote 0
            • W
              WinterSilence
              last edited by Jun 18, 2020, 6:36 AM

              I’m found:

              SCN_MODIFIED
              This notification is sent when the text or styling of the document changes or is about to change. You can set a mask for the notifications that are sent to the container with SCI_SETMODEVENTMASK. The notification structure contains information about what changed, how the change occurred and whether this changed the number of lines in the document. No modifications may be performed while in a SCN_MODIFIED event.

              W 1 Reply Last reply Jun 18, 2020, 6:40 AM Reply Quote 1
              • W
                WinterSilence @WinterSilence
                last edited by Jun 18, 2020, 6:40 AM

                @WinterSilence it’s better:

                SCEN_CHANGE (768) is fired when the text (not the style) of the document changes. This notification is sent using the WM_COMMAND message on Windows and the “command” signal on GTK as this is the behaviour of the standard Edit control (SCEN_CHANGE has the same value as the Windows Edit control EN_CHANGE). No other information is sent. If you need more detailed information use SCN_MODIFIED. You can filter the types of changes you are notified about with SCI_SETMODEVENTMASK and SCI_SETCOMMANDEVENTS.

                1 Reply Last reply Reply Quote 1
                • W
                  WinterSilence
                  last edited by WinterSilence Jun 18, 2020, 7:42 PM Jun 18, 2020, 7:40 PM

                  Need help, I dont work in Delphi 5-6 years and remembered only base, please check my Pascal code(Delphi10) for NppPlugin.pas:

                  constructor TNppPlugin.Create;
                  begin
                    // filter: send notifications on insert text
                    SendMessage(self.NppData.ScintillaMainHandle, SciSupport.SCI_SETMODEVENTMASK, SciSupport.SC_MOD_INSERTTEXT, 0);
                    inherited;
                  end;
                  
                  procedure TNppPlugin.BeNotified(sn: PSCNotification);
                  begin
                    if (HWND(sn^.nmhdr.hwndFrom) = self.NppData.NppHandle) and (sn^.nmhdr.code = NPPN_TB_MODIFICATION) then
                    begin
                      self.DoNppnToolbarModification;
                    end
                    else
                      if (HWND(sn^.nmhdr.hwndFrom) = self.NppData.NppHandle) and (sn^.nmhdr.code = NPPN_SHUTDOWN) then
                      begin
                          self.DoNppnShutdown;
                      end
                    else
                      // catch notification on insert
                      if (HWND(sn^.nmhdr.hwndFrom) == self.NppData.ScintillaMainHandle) and (sn.modificationType = SciSupport.SC_MOD_INSERTTEXT) and (sn^.nmhdr.code = SciSupport.SCN_MODIFIED) then
                      begin
                          self.DoNppnSciUpdate(sn);
                      end;
                  end;
                  
                  // overrides 
                  procedure TNppPlugin.DoNppnSciUpdate(sn: PSCNotification);
                  begin
                    // @todo check sn.text and sn.position in sn.line to detect `/**` at line end 
                  end;
                  
                  A 1 Reply Last reply Jun 18, 2020, 7:48 PM Reply Quote 0
                  • A
                    Alan Kilborn @WinterSilence
                    last edited by Jun 18, 2020, 7:48 PM

                    @WinterSilence

                    I don’t think anybody is going to “check your Pascal code”.
                    If you have a specific question about something relating to it, that is different…but you’re going to have to come out and actually ask the question.

                    W 1 Reply Last reply Jun 18, 2020, 7:52 PM Reply Quote 0
                    • W
                      WinterSilence @Alan Kilborn
                      last edited by WinterSilence Jun 18, 2020, 7:53 PM Jun 18, 2020, 7:52 PM

                      @Alan-Kilborn The question is, do I correctly catch notifications or is there a better solution?

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