From 2b448194926582fa449a1d27c15296b43772c2df Mon Sep 17 00:00:00 2001 From: donho Date: Tue, 9 Sep 2008 00:25:02 +0000 Subject: [PATCH] [NEW] Add 2 notification (NPPN_DOCSWITCHINGIN and NPPN_DOCSWITCHINGOFF)messages. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@310 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../MISC/PluginsManager/Notepad_plus_msgs.h | 10 +++++++ PowerEditor/src/Notepad_plus.cpp | 28 +++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index d10ef43f7..fddadfc43 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -326,4 +326,14 @@ 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.idFrom = 0; + #define NPPN_DOCSWITCHINGOFF (NPPN_FIRST + 10) // To notify plugins that current doc is about to be switched off. + //scnNotification->nmhdr.code = NPPN_DOCSWITCHINGOFF; + //scnNotification->nmhdr.hwndFrom = hwndNpp; + //scnNotification->nmhdr.idFrom = currentBufferID; + + #define NPPN_DOCSWITCHINGIN (NPPN_FIRST + 11) // To notify plugins that current doc is about to be switched in. + //scnNotification->nmhdr.code = NPPN_DOCSWITCHINGIN; + //scnNotification->nmhdr.hwndFrom = hwndNpp; + //scnNotification->nmhdr.idFrom = newBufferID; + #endif //NOTEPAD_PLUS_MSGS_H diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 1ac0994ff..e50e721b4 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -4828,30 +4828,46 @@ void Notepad_plus::docGotoAnotherEditView(FileTransferMode mode) //_linkTriggered = true; } -bool Notepad_plus::activateBuffer(BufferID id, int whichOne) { +bool Notepad_plus::activateBuffer(BufferID id, int whichOne) +{ + BufferID oldBuf = _pEditView->getCurrentBufferID(); + SCNotification scnN; + scnN.nmhdr.code = NPPN_DOCSWITCHINGOFF; + scnN.nmhdr.hwndFrom = _hSelf; + scnN.nmhdr.idFrom = oldBuf; + _pluginsManager.notify(&scnN); + Buffer * pBuf = MainFileManager->getBufferByID(id); bool reload = pBuf->getNeedReload(); - if (reload) { + if (reload) + { MainFileManager->reloadBuffer(id); pBuf->setNeedReload(false); } - if (whichOne == MAIN_VIEW) { + if (whichOne == MAIN_VIEW) + { if (_mainDocTab.activateBuffer(id)) //only activate if possible _mainEditView.activateBuffer(id); else return false; - } else { + } + else + { if (_subDocTab.activateBuffer(id)) _subEditView.activateBuffer(id); else return false; } - if (reload) { + if (reload) + { performPostReload(whichOne); } - notifyBufferActivated(id, whichOne); + scnN.nmhdr.code = NPPN_DOCSWITCHINGIN; + scnN.nmhdr.hwndFrom = _hSelf; + scnN.nmhdr.idFrom = id; + _pluginsManager.notify(&scnN); return true; }