Replace DOCSWITCHOFF/DOCSWITCHIN with BUFFERACTIVATED notifications to cover more situations

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@323 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
harrybharry 2008-09-16 20:33:20 +00:00
parent 836036890a
commit e58b8c2a2c
2 changed files with 15 additions and 20 deletions

View File

@ -320,25 +320,21 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID; //scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_SHUTDOWN (NPPN_FIRST + 9) // To notify plugins that Notepad++ is about to be shutdowned. #define NPPN_SHUTDOWN (NPPN_FIRST + 9) // To notify plugins that Notepad++ is about to be shutdowned.
//scnNotification->nmhdr.code = NPPN_SHUTDOWN; //scnNotification->nmhdr.code = NPPN_SHUTDOWN;
//scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = 0; //scnNotification->nmhdr.idFrom = 0;
#define NPPN_DOCSWITCHINGOFF (NPPN_FIRST + 10) // To notify plugins that current doc is about to be switched off. #define NPPN_BUFFERACTIVATED (NPPN_FIRST + 10) // To notify plugins that a buffer was activated (put to foreground).
//scnNotification->nmhdr.code = NPPN_DOCSWITCHINGOFF; //scnNotification->nmhdr.code = NPPN_BUFFERACTIVATED;
//scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = currentBufferID; //scnNotification->nmhdr.idFrom = activatedBufferID;
#define NPPN_DOCSWITCHINGIN (NPPN_FIRST + 11) // To notify plugins that current doc is about to be switched in. #define NPPN_LANGCHANGED (NPPN_FIRST + 11) // To notify plugins that the language in the current doc is just changed.
//scnNotification->nmhdr.code = NPPN_DOCSWITCHINGIN;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = newBufferID;
#define NPPN_LANGCHANGED (NPPN_FIRST + 12) // To notify plugins that the language in the current doc is just changed.
//scnNotification->nmhdr.code = NPPN_LANGCHANGED; //scnNotification->nmhdr.code = NPPN_LANGCHANGED;
//scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = currentBufferID; //scnNotification->nmhdr.idFrom = currentBufferID;
#endif //NOTEPAD_PLUS_MSGS_H #endif //NOTEPAD_PLUS_MSGS_H

View File

@ -4892,12 +4892,7 @@ void Notepad_plus::docGotoAnotherEditView(FileTransferMode mode)
bool Notepad_plus::activateBuffer(BufferID id, int whichOne) bool Notepad_plus::activateBuffer(BufferID id, int whichOne)
{ {
BufferID oldBuf = _pEditView->getCurrentBufferID(); //scnN.nmhdr.code = NPPN_DOCSWITCHINGOFF; //superseeded by NPPN_BUFFERACTIVATED
SCNotification scnN;
scnN.nmhdr.code = NPPN_DOCSWITCHINGOFF;
scnN.nmhdr.hwndFrom = _hSelf;
scnN.nmhdr.idFrom = (uptr_t)oldBuf;
_pluginsManager.notify(&scnN);
Buffer * pBuf = MainFileManager->getBufferByID(id); Buffer * pBuf = MainFileManager->getBufferByID(id);
bool reload = pBuf->getNeedReload(); bool reload = pBuf->getNeedReload();
@ -4926,10 +4921,8 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne)
performPostReload(whichOne); performPostReload(whichOne);
} }
notifyBufferActivated(id, whichOne); notifyBufferActivated(id, whichOne);
scnN.nmhdr.code = NPPN_DOCSWITCHINGIN;
//scnN.nmhdr.hwndFrom = _hSelf; //scnN.nmhdr.code = NPPN_DOCSWITCHINGIN; //superseeded by NPPN_BUFFERACTIVATED
scnN.nmhdr.idFrom = (uptr_t)id;
_pluginsManager.notify(&scnN);
return true; return true;
} }
@ -8649,6 +8642,12 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view) {
::InvalidateRect(_mainDocTab.getHSelf(), NULL, FALSE); ::InvalidateRect(_mainDocTab.getHSelf(), NULL, FALSE);
::InvalidateRect(_subDocTab.getHSelf(), NULL, FALSE); ::InvalidateRect(_subDocTab.getHSelf(), NULL, FALSE);
SCNotification scnN;
scnN.nmhdr.code = NPPN_BUFFERACTIVATED;
scnN.nmhdr.hwndFrom = _hSelf;
scnN.nmhdr.idFrom = (uptr_t)bufid;
_pluginsManager.notify(&scnN);
_linkTriggered = true; _linkTriggered = true;
} }