Notification on update document without saving
-
What’s
NPPN_constant using for notify at update document without saving? -
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…
-
@PeterJones said in Notification on update document without saving:
If you can clarify that
notification called on change text(
SCI_...TEXTmessage) in active view -
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. -
Session notifications are sent by timer, not by updating doc text. I can check
SCI GETTEXTby timer without this, but it’s 100% freeze npp+. -
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. -
@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.
-
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; -
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. -
@Alan-Kilborn The question is, do I correctly catch notifications or is there a better solution?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login