I’m having a problem retrieving the document index and view.
If I use the code below I get a view=3 and index=very large number.
const UINT nBufferPos = SendMessage(nppData._nppHandle, NPPM_GETPOSFROMBUFFERID, notifyCode->nmhdr.idFrom, 0);
const UINT nView = nBufferPos >> 30;
const UINT nIndex = (nBufferPos << 2) >> 2;
I would make sure
nBufferPos != -1. I don’t think
notifyCode->nmhdr.idFromis supposed to hold the buffer ID is it?
I see you point.
I assumed that it would work similarly to NPPN_FILEOPENED.
How can I figure out which buffer caused the notification?
Thank you for your help,
The major difference is that SCN_SAVEPOINTLEFT is a notification from Scintilla and does not know anything about buffer IDs, whereas NPPN_FILEOPENED is generated by Notepad++ and has access to the buffer ID. You will probably have to use
Buffer causing the notification may not be the current buffer.
Ah! Yeah that’s what I was kind of afraid of. Looking at the API it doesn’t look like there is a way to do that. I guess you maybe able to instead catch
NPPN_BUFFERACTIVATEDand then use
SCI_GETMODIFYto see if it is in a “saved” state or not…but depending on what the plugin needs to do this may not work since you have to wait for the unsaved buffer to get activated…
sanastasiou last edited by
There’s also a problem here, with the “unsaved” files after closing Npp. Npp knows that some files were unsaved because it saves copies of them. However SCI_GETMODIFY reports that no changes have been made to the files once you reopen them. It would have been really helpful, if this was consistent with the small “save” icon on top of the tab.
It would even be more helpful, so simply be able to ask NPP “isFileDirty” i.e. get the status of the “save” button somehow.
Right now, I have to duplicate all the work the NPP does, i.e. chekc if there’s a copy of the file saved upon opening etc.