Is there a way to be notified when a buffer becomes dirty or not?
I found DOCSTAUS_BUFFERDIRTY that gets sent via NPPN_READONLYCHANGED only when the readonly mode is changed.
Any help or suggestion would be greatly appreciated.
Thank you,
Franco
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-04-15
Hi,
I had the exact same problem.. It is quite a wonder that one cannot just ask if file X is dirty..
There is however a workaround. You need to maintain per file some flag which indicates if something is modified or not. This is done by tracking Scintilla events : SCN_SAVEPOINTLEFT,
SCN_SAVEPOINTREACHED
For a more concrete example have a look at FileModificationObserver class
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-04-15
SCI_GETMODIFY does not work if you close Notepad++ with dirty flag on some file. Same problem with my approach as well. I ended up cleaning the "cached" files of my plugin to prevent this from happening. I have also filed a bug about this problem:
From your first post I'm assuming you already can receive notifications from Notepad++. Scintilla is no different. Its just a different type of message. You can see an example here that handles both Notepad++ notifications and Scintilla notifications. Not sure what language you are using but you can see the general idea.
Last edit: Justin Dailey 2015-04-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a way to be notified when a buffer becomes dirty or not?
I found DOCSTAUS_BUFFERDIRTY that gets sent via NPPN_READONLYCHANGED only when the readonly mode is changed.
Any help or suggestion would be greatly appreciated.
Thank you,
Franco
Hi,
I had the exact same problem.. It is quite a wonder that one cannot just ask if file X is dirty..
There is however a workaround. You need to maintain per file some flag which indicates if something is modified or not. This is done by tracking Scintilla events : SCN_SAVEPOINTLEFT,
SCN_SAVEPOINTREACHED
For a more concrete example have a look at FileModificationObserver class
https://github.com/sanastasiou/RTextNpp/blob/master/RTextNpp/Utilities/FileModificationObserver.cs
Hope it helps.
Have you tried SCI_GETMODIFY?
SCI_GETMODIFY does not work if you close Notepad++ with dirty flag on some file. Same problem with my approach as well. I ended up cleaning the "cached" files of my plugin to prevent this from happening. I have also filed a bug about this problem:
http://sourceforge.net/p/notepad-plus/bugs/5155/
How do you get Scintilla notifications in a plugin?
From your first post I'm assuming you already can receive notifications from Notepad++. Scintilla is no different. Its just a different type of message. You can see an example here that handles both Notepad++ notifications and Scintilla notifications. Not sure what language you are using but you can see the general idea.
Last edit: Justin Dailey 2015-04-17
Thank you for the clarification