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.
    • WinterSilenceW
      WinterSilence
      last edited by

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

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        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
        • WinterSilenceW
          WinterSilence
          last edited by

          @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
          • Prahlad-Makwana4145P
            Prahlad-Makwana4145
            last edited by

            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.

            WinterSilenceW 1 Reply Last reply Reply Quote 0
            • WinterSilenceW
              WinterSilence @Prahlad-Makwana4145
              last edited by

              @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
              • WinterSilenceW
                WinterSilence
                last edited by

                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.

                WinterSilenceW 1 Reply Last reply Reply Quote 1
                • WinterSilenceW
                  WinterSilence @WinterSilence
                  last edited by

                  @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
                  • WinterSilenceW
                    WinterSilence
                    last edited by WinterSilence

                    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;
                    
                    Alan KilbornA 1 Reply Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @WinterSilence
                      last edited by

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

                      WinterSilenceW 1 Reply Last reply Reply Quote 0
                      • WinterSilenceW
                        WinterSilence @Alan Kilborn
                        last edited by WinterSilence

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

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