diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index 895e668b..e1a2a79f 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -29,6 +29,7 @@ #include #include #include +#include const bool dirUp = true; diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index e3eddbe5..89b9aedb 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -362,7 +362,7 @@ LRESULT Notepad_plus::init(HWND hwnd) bool isVertical = (nppGUI._splitterPos == POS_VERTICAL); _subSplitter.init(_pPublicInterface->getHinst(), hwnd); - _subSplitter.create(&_mainDocTab, &_subDocTab, 8, DYNAMIC, 50, isVertical); + _subSplitter.create(&_mainDocTab, &_subDocTab, 8, SplitterMode::DYNAMIC, 50, isVertical); //--Status Bar Section--// bool willBeShown = nppGUI._statusBarShow; @@ -3240,7 +3240,7 @@ void Notepad_plus::dockUserDlg() else pWindow = _pDocTab; - _pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, RIGHT_FIX, 45); + _pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, SplitterMode::RIGHT_FIX, 45); } if (bothActive()) diff --git a/PowerEditor/src/Notepad_plus_Window.h b/PowerEditor/src/Notepad_plus_Window.h index 30bc76d6..3bc3522c 100644 --- a/PowerEditor/src/Notepad_plus_Window.h +++ b/PowerEditor/src/Notepad_plus_Window.h @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -24,13 +24,11 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - -#ifndef NOTEPAD_PLUS_WINDOW_H -#define NOTEPAD_PLUS_WINDOW_H - +#pragma once #include "Notepad_plus.h" + + const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\ \r\ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-xLeftPos] [-yTopPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [-alwaysOnTop] [-openSession] [-r] [-qnEsterEggName | -qtText | -qfCntentFileName] [filePath]\r\ @@ -59,47 +57,57 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNum filePath : file or folder name to open (absolute or relative path name)\r\ "); -class Notepad_plus_Window : public Window { + + + + +class Notepad_plus_Window : public Window +{ public: - Notepad_plus_Window() : _isPrelaunch(false), _disablePluginsManager(false) {}; void init(HINSTANCE, HWND, const TCHAR *cmdLine, CmdLineParams *cmdLineParams); bool isDlgsMsg(MSG *msg) const; - - HACCEL getAccTable() const { + + HACCEL getAccTable() const + { return _notepad_plus_plus_core.getAccTable(); - }; - - bool emergency(generic_string emergencySavedDir) { + } + + bool emergency(generic_string emergencySavedDir) + { return _notepad_plus_plus_core.emergency(emergencySavedDir); - }; + } - bool isPrelaunch() const { + bool isPrelaunch() const + { return _isPrelaunch; - }; + } - void setIsPrelaunch(bool val) { + void setIsPrelaunch(bool val) + { _isPrelaunch = val; - }; + } - virtual void destroy(){ - ::DestroyWindow(_hSelf); - }; + virtual void destroy() + { + ::DestroyWindow(_hSelf); + } - static const TCHAR * getClassName() { + static const TCHAR * getClassName() + { return _className; - }; + } + static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant - + + private: Notepad_plus _notepad_plus_plus_core; static LRESULT CALLBACK Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); static const TCHAR _className[32]; - bool _isPrelaunch; - bool _disablePluginsManager; - std::string _userQuote; // keep the availability of this string for thread using + bool _isPrelaunch = false; + bool _disablePluginsManager = false; + std::string _userQuote; // keep the availability of this string for thread using }; - -#endif //NOTEPAD_PLUS_WINDOW_H diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 13026a73..81e2b3c4 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -43,7 +43,10 @@ using namespace std; #define WM_DPICHANGED 0x02E0 -struct SortTaskListPred + + + +struct SortTaskListPred final { DocTabView *_views[2]; @@ -70,44 +73,49 @@ LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT Message, switch(Message) { - case WM_NCCREATE : // First message we get the ptr of instantiated object - // then stock it into GWLP_USERDATA index in order to retrieve afterward + case WM_NCCREATE: { + // First message we get the ptr of instantiated object + // then stock it into GWLP_USERDATA index in order to retrieve afterward Notepad_plus_Window *pM30ide = (Notepad_plus_Window *)(((LPCREATESTRUCT)lParam)->lpCreateParams); pM30ide->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pM30ide); - return TRUE; } - default : + default: { return ((Notepad_plus_Window *)::GetWindowLongPtr(hwnd, GWLP_USERDATA))->runProc(hwnd, Message, wParam, lParam); } } } + LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { - LRESULT result = FALSE; switch (Message) { case WM_CREATE: { - try{ + try + { _notepad_plus_plus_core._pPublicInterface = this; - result = _notepad_plus_plus_core.init(hwnd); - } catch (std::exception ex) { + return _notepad_plus_plus_core.init(hwnd); + } + catch (std::exception ex) + { ::MessageBoxA(_notepad_plus_plus_core._pPublicInterface->getHSelf(), ex.what(), "Exception On WM_CREATE", MB_OK); exit(-1); } + break; } - break; - default: + default: + { if (this) return _notepad_plus_plus_core.process(hwnd, Message, wParam, lParam); + } } - return result; + return FALSE; } @@ -125,13 +133,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return ::DefWindowProc(hwnd, Message, wParam, lParam); } - case WM_DRAWITEM : + case WM_DRAWITEM: { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam; if (dis->CtlType == ODT_TAB) - { return ::SendMessage(dis->hwndItem, WM_DRAWITEM, wParam, lParam); - } + break; } case WM_DOCK_USERDEFINE_DLG: @@ -140,9 +147,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case WM_UNDOCK_USERDEFINE_DLG: + case WM_UNDOCK_USERDEFINE_DLG: { - undockUserDlg(); + undockUserDlg(); return TRUE; } @@ -151,80 +158,80 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa TCHAR *userLangName = (TCHAR *)lParam; if (!userLangName || !userLangName[0]) return FALSE; - generic_string name(userLangName); + + generic_string name{userLangName}; //loop through buffers and reset the language (L_USER, TEXT("")) if (L_USER, name) - Buffer * buf; - for(int i = 0; i < MainFileManager->getNrBuffers(); ++i) + for (int i = 0; i < MainFileManager->getNrBuffers(); ++i) { - buf = MainFileManager->getBufferByIndex(i); + Buffer* buf = MainFileManager->getBufferByIndex(i); if (buf->getLangType() == L_USER && name == buf->getUserDefineLangName()) buf->setLangType(L_USER, TEXT("")); } return TRUE; } - case WM_RENAME_USERLANG: + case WM_RENAME_USERLANG: { if (!lParam || !(((TCHAR *)lParam)[0]) || !wParam || !(((TCHAR *)wParam)[0])) return FALSE; - generic_string oldName((TCHAR *)lParam); - generic_string newName((TCHAR *)wParam); + generic_string oldName{(TCHAR *)lParam}; + generic_string newName{(TCHAR *)wParam}; //loop through buffers and reset the language (L_USER, newName) if (L_USER, oldName) - Buffer * buf; - for(int i = 0; i < MainFileManager->getNrBuffers(); ++i) + for (int i = 0; i < MainFileManager->getNrBuffers(); ++i) { - buf = MainFileManager->getBufferByIndex(i); + Buffer* buf = MainFileManager->getBufferByIndex(i); if (buf->getLangType() == L_USER && oldName == buf->getUserDefineLangName()) buf->setLangType(L_USER, newName.c_str()); } return TRUE; } - case WM_CLOSE_USERDEFINE_DLG : + case WM_CLOSE_USERDEFINE_DLG: { checkMenuItem(IDM_LANG_USER_DLG, false); _toolBar.setCheck(IDM_LANG_USER_DLG, false); return TRUE; } - case WM_REPLACEALL_INOPENEDDOC : + case WM_REPLACEALL_INOPENEDDOC: { replaceInOpenedFiles(); return TRUE; } - case WM_FINDALL_INOPENEDDOC : + case WM_FINDALL_INOPENEDDOC: { findInOpenedFiles(); return TRUE; } - case WM_FINDALL_INCURRENTDOC : + case WM_FINDALL_INCURRENTDOC: { findInCurrentFile(); return TRUE; } - - case WM_FINDINFILES : + + case WM_FINDINFILES: { return findInFiles(); } - case WM_REPLACEINFILES : + case WM_REPLACEINFILES: { replaceInFiles(); return TRUE; } - case NPPM_LAUNCHFINDINFILESDLG : + + case NPPM_LAUNCHFINDINFILESDLG: { // Find in files function code should be here due to the number of parameters (2) cannot be passed via WM_COMMAND const int strSize = FINDREPLACE_MAXLENGTH; TCHAR str[strSize]; - bool isFirstTime = !_findReplaceDlg.isCreated(); + bool isFirstTime = not _findReplaceDlg.isCreated(); _findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL()); _pEditView->getGenericSelectedText(str, strSize); @@ -233,6 +240,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _nativeLangSpeaker.changeDlgLang(_findReplaceDlg.getHSelf(), "Find"); _findReplaceDlg.launchFindInFilesDlg(); setFindReplaceFolderFilter((const TCHAR*) wParam, (const TCHAR*) lParam); + return TRUE; } @@ -241,11 +249,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { BufferID id = doOpen((const TCHAR *)lParam); if (id != BUFFER_INVALID) - { return switchToFile(id); - } + break; } - break; case NPPM_INTERNAL_SETFILENAME: { @@ -259,7 +265,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } return FALSE; } - break; case NPPM_GETBUFFERLANGTYPE: { @@ -269,7 +274,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa Buffer * b = MainFileManager->getBufferByID(id); return b->getLangType(); } - break; case NPPM_SETBUFFERLANGTYPE: { @@ -283,7 +287,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa b->setLangType((LangType)lParam); return TRUE; } - break; case NPPM_GETBUFFERENCODING: { @@ -293,7 +296,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa Buffer * b = MainFileManager->getBufferByID(id); return b->getUnicodeMode(); } - break; case NPPM_SETBUFFERENCODING: { @@ -309,7 +311,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa b->setUnicodeMode((UniMode)lParam); return TRUE; } - break; case NPPM_GETBUFFERFORMAT: { @@ -319,7 +320,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa Buffer * b = MainFileManager->getBufferByID(id); return b->getFormat(); } - break; case NPPM_SETBUFFERFORMAT: { @@ -333,30 +333,27 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa b->setFormat((formatType)lParam); return TRUE; } - break; case NPPM_GETBUFFERIDFROMPOS: { - DocTabView * pView = NULL; - if (lParam == MAIN_VIEW) { + DocTabView* pView = nullptr; + if (lParam == MAIN_VIEW) pView = &_mainDocTab; - } else if (lParam == SUB_VIEW) { + else if (lParam == SUB_VIEW) pView = &_subDocTab; - } else { + else return (LRESULT)BUFFER_INVALID; - } - if ((int)wParam < pView->nbItem()) { + + if ((int)wParam < pView->nbItem()) return (LRESULT)(pView->getBufferByIndex((int)wParam)); - } + return (LRESULT)BUFFER_INVALID; } - break; case NPPM_GETCURRENTBUFFERID: { return (LRESULT)(_pEditView->getCurrentBufferID()); } - break; case NPPM_RELOADBUFFERID: { @@ -364,15 +361,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return FALSE; return doReload((BufferID)wParam, lParam != 0); } - break; case NPPM_RELOADFILE: { BufferID id = MainFileManager->getBufferFromName((const TCHAR *)lParam); if (id != BUFFER_INVALID) doReload(id, wParam != 0); + break; } - break; case NPPM_SWITCHTOFILE : { @@ -386,7 +382,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { return fileSave(); } - break; case NPPM_SAVECURRENTFILEAS: { @@ -396,19 +391,16 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (!filename) return FALSE; return doSave(currentBufferID, filename, asCopy); } - break; case NPPM_SAVEALLFILES: { return fileSaveAll(); } - break; case NPPM_GETCURRENTNATIVELANGENCODING: { return _nativeLangSpeaker.getLangEncoding(); } - break; case NPPM_INTERNAL_DOCORDERCHANGED : { @@ -422,15 +414,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _pluginsManager.notify(&scnN); return TRUE; } - break; case WM_SIZE: { RECT rc; _pPublicInterface->getClientRect(rc); - if (lParam == 0) { + if (lParam == 0) lParam = MAKELPARAM(rc.right - rc.left, rc.bottom - rc.top); - } ::MoveWindow(_rebarTop.getHSelf(), 0, 0, rc.right, _rebarTop.getHeight(), TRUE); _statusBar.adjustParts(rc.right); @@ -439,7 +429,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa int rebarBottomHeight = _rebarBottom.getHeight(); int statusBarHeight = _statusBar.getHeight(); ::MoveWindow(_rebarBottom.getHSelf(), 0, rc.bottom - rebarBottomHeight - statusBarHeight, rc.right, rebarBottomHeight, TRUE); - + getMainClientRect(rc); _dockingManager.reSizeTo(rc); @@ -450,14 +440,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } result = TRUE; + break; } - break; case WM_MOVE: { result = TRUE; + break; } - break; case WM_MOVING: { @@ -466,31 +456,31 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _pDocMap->doMove(); } result = FALSE; + break; } - break; case WM_SIZING: { result = FALSE; + break; } - break; - - case WM_COPYDATA : - { - COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT *)lParam; + + case WM_COPYDATA: + { + COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT *)lParam; switch (pCopyData->dwData) { - case COPYDATA_PARAMS : + case COPYDATA_PARAMS: { - CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData; + CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData; pNppParam->setCmdlineParam(*cmdLineParam); NppGUI nppGui = (NppGUI)pNppParam->getNppGUI(); nppGui._isCmdlineNosessionActivated = cmdLineParam->_isNoSession; break; } - case COPYDATA_FILENAMESA : + case COPYDATA_FILENAMESA: { char *fileNamesA = (char *)pCopyData->lpData; CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); @@ -500,7 +490,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa break; } - case COPYDATA_FILENAMESW : + case COPYDATA_FILENAMESW: { wchar_t *fileNamesW = (wchar_t *)pCopyData->lpData; CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); @@ -509,13 +499,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } } - return TRUE; - } + return TRUE; + } case WM_COMMAND: { - if (HIWORD(wParam) == SCEN_SETFOCUS) - { + if (HIWORD(wParam) == SCEN_SETFOCUS) + { HWND hMain = _mainEditView.getHSelf(), hSec = _subEditView.getHSelf(); HWND hFocus = (HWND)lParam; if (hMain == hFocus) @@ -526,13 +516,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa //Other Scintilla, ignore } return TRUE; - } - else + } + else { command(LOWORD(wParam)); } + return TRUE; } - return TRUE; case NPPM_INTERNAL_SAVECURRENTSESSION: { @@ -544,21 +534,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa Session currentSession; getCurrentOpenedFiles(currentSession, true); nppParam->writeSession(currentSession); - } + } + return TRUE; } - return TRUE; case NPPM_INTERNAL_RELOADNATIVELANG: { reloadLang(); + return TRUE; } - return TRUE; case NPPM_INTERNAL_RELOADSTYLERS: { loadStyles(); + return TRUE; } - return TRUE; case NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED: { @@ -567,8 +557,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa scnN.nmhdr.hwndFrom = (void *)lParam; // ShortcutKey structure scnN.nmhdr.idFrom = (uptr_t)wParam; // cmdID _pluginsManager.notify(&scnN); + return TRUE; } - return TRUE; case NPPM_GETSHORTCUTBYCMDID: { @@ -578,15 +568,17 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return _pluginsManager.getShortcutByCmdID(cmdID, sk); } - case NPPM_MENUCOMMAND : + case NPPM_MENUCOMMAND: + { command(lParam); return TRUE; + } - case NPPM_GETFULLCURRENTPATH : - case NPPM_GETCURRENTDIRECTORY : - case NPPM_GETFILENAME : - case NPPM_GETNAMEPART : - case NPPM_GETEXTPART : + case NPPM_GETFULLCURRENTPATH: + case NPPM_GETCURRENTDIRECTORY: + case NPPM_GETFILENAME: + case NPPM_GETNAMEPART: + case NPPM_GETEXTPART: { TCHAR str[MAX_PATH]; // par defaut : NPPM_GETCURRENTDIRECTORY @@ -619,9 +611,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case NPPM_GETCURRENTWORD : + case NPPM_GETCURRENTWORD: { - const int strSize = CURRENTWORD_MAXLENGTH; + const int strSize = CURRENTWORD_MAXLENGTH; TCHAR str[strSize]; _pEditView->getGenericSelectedText((TCHAR *)str, strSize); @@ -645,7 +637,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case NPPM_GETNPPDIRECTORY : + case NPPM_GETNPPDIRECTORY: { const int strSize = MAX_PATH; TCHAR str[strSize]; @@ -668,62 +660,64 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case NPPM_GETCURRENTLINE : + case NPPM_GETCURRENTLINE: { return _pEditView->getCurrentLineNumber(); } - case NPPM_GETCURRENTCOLUMN : + case NPPM_GETCURRENTCOLUMN: { return _pEditView->getCurrentColumnNumber(); } - case NPPM_GETCURRENTSCINTILLA : - { - if (_pEditView == &_mainEditView) - *((int *)lParam) = MAIN_VIEW; - else if (_pEditView == &_subEditView) - *((int *)lParam) = SUB_VIEW; - else - *((int *)lParam) = -1; - return TRUE; - } + case NPPM_GETCURRENTSCINTILLA: + { + if (_pEditView == &_mainEditView) + *((int *)lParam) = MAIN_VIEW; + else if (_pEditView == &_subEditView) + *((int *)lParam) = SUB_VIEW; + else + *((int *)lParam) = -1; + return TRUE; + } - case NPPM_GETCURRENTLANGTYPE : + case NPPM_GETCURRENTLANGTYPE: { *((LangType *)lParam) = _pEditView->getCurrentBuffer()->getLangType(); return TRUE; } - case NPPM_SETCURRENTLANGTYPE : + case NPPM_SETCURRENTLANGTYPE: { _pEditView->getCurrentBuffer()->setLangType((LangType)lParam); return TRUE; } - case NPPM_GETNBOPENFILES : + case NPPM_GETNBOPENFILES: { int nbDocPrimary = _mainDocTab.nbItem(); int nbDocSecond = _subDocTab.nbItem(); if (lParam == ALL_OPEN_FILES) return nbDocPrimary + nbDocSecond; else if (lParam == PRIMARY_VIEW) - return nbDocPrimary; + return nbDocPrimary; else if (lParam == SECOND_VIEW) - return nbDocSecond; + return nbDocSecond; } - case NPPM_GETOPENFILENAMESPRIMARY : - case NPPM_GETOPENFILENAMESSECOND : - case NPPM_GETOPENFILENAMES : + case NPPM_GETOPENFILENAMESPRIMARY: + case NPPM_GETOPENFILENAMESSECOND: + case NPPM_GETOPENFILENAMES: { - if (!wParam) return 0; + if (!wParam) + return 0; - TCHAR **fileNames = (TCHAR **)wParam; + TCHAR** fileNames = (TCHAR**) wParam; int nbFileNames = lParam; int j = 0; - if (Message != NPPM_GETOPENFILENAMESSECOND) { + if (Message != NPPM_GETOPENFILENAMESSECOND) + { for (int i = 0 ; i < _mainDocTab.nbItem() && j < nbFileNames ; ++i) { BufferID id = _mainDocTab.getBufferByIndex(i); @@ -731,7 +725,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa lstrcpy(fileNames[j++], buf->getFullPathName()); } } - if (Message != NPPM_GETOPENFILENAMESPRIMARY) { + + if (Message != NPPM_GETOPENFILENAMESPRIMARY) + { for (int i = 0 ; i < _subDocTab.nbItem() && j < nbFileNames ; ++i) { BufferID id = _subDocTab.getBufferByIndex(i); @@ -742,9 +738,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return j; } - case WM_GETTASKLISTINFO : + case WM_GETTASKLISTINFO: { - if (!wParam) return 0; + if (!wParam) + return 0; + TaskListInfo * tli = (TaskListInfo *)wParam; getTaskListInfo(tli); @@ -761,6 +759,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } return TRUE; } + if (NppParameters::getInstance()->getNppGUI()._styleMRU) { tli->_currentIndex = 0; @@ -768,10 +767,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } else { - for(int idx = 0; idx < (int)tli->_tlfsLst.size(); ++idx) + for (int idx = 0; idx < (int)tli->_tlfsLst.size(); ++idx) { if(tli->_tlfsLst[idx]._iView == currentView() && - tli->_tlfsLst[idx]._docIndex == _pDocTab->getCurrentTabIndex()) + tli->_tlfsLst[idx]._docIndex == _pDocTab->getCurrentTabIndex()) { tli->_currentIndex = idx; break; @@ -781,9 +780,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case WM_MOUSEWHEEL : + case WM_MOUSEWHEEL: { - if (LOWORD(wParam) & MK_RBUTTON) + if (0 != (LOWORD(wParam) & MK_RBUTTON)) { // redirect to the IDC_PREV_DOC or IDC_NEXT_DOC so that we have the unified process @@ -793,40 +792,43 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } return TRUE; } - - case WM_APPCOMMAND : + + case WM_APPCOMMAND: { switch(GET_APPCOMMAND_LPARAM(lParam)) { - case APPCOMMAND_BROWSER_BACKWARD : - case APPCOMMAND_BROWSER_FORWARD : + case APPCOMMAND_BROWSER_BACKWARD: + case APPCOMMAND_BROWSER_FORWARD: + { int nbDoc = viewVisible(MAIN_VIEW)?_mainDocTab.nbItem():0; nbDoc += viewVisible(SUB_VIEW)?_subDocTab.nbItem():0; if (nbDoc > 1) activateNextDoc((GET_APPCOMMAND_LPARAM(lParam) == APPCOMMAND_BROWSER_FORWARD)?dirDown:dirUp); _linkTriggered = true; + break; + } } return ::DefWindowProc(hwnd, Message, wParam, lParam); } - case NPPM_GETNBSESSIONFILES : + case NPPM_GETNBSESSIONFILES: { const TCHAR *sessionFileName = (const TCHAR *)lParam; - if ((!sessionFileName) || (sessionFileName[0] == '\0')) return 0; + if ((!sessionFileName) || (sessionFileName[0] == '\0')) + return 0; Session session2Load; if (pNppParam->loadSession(session2Load, sessionFileName)) - { return session2Load.nbMainFiles() + session2Load.nbSubFiles(); - } return 0; } - - case NPPM_GETSESSIONFILES : + + case NPPM_GETSESSIONFILES: { const TCHAR *sessionFileName = (const TCHAR *)lParam; TCHAR **sessionFileArray = (TCHAR **)wParam; - if ((!sessionFileName) || (sessionFileName[0] == '\0')) return FALSE; + if ((!sessionFileName) || (sessionFileName[0] == '\0')) + return FALSE; Session session2Load; if (pNppParam->loadSession(session2Load, sessionFileName)) @@ -851,26 +853,22 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_DECODESCI: { // convert to ASCII - Utf8_16_Write UnicodeConvertor; - UINT length = 0; - char* buffer = NULL; ScintillaEditView *pSci; - if (wParam == MAIN_VIEW) pSci = &_mainEditView; else if (wParam == SUB_VIEW) pSci = &_subEditView; else return -1; - // get text of current scintilla - length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1; - buffer = new char[length]; + UINT length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1; + char* buffer = new char[length]; pSci->execute(SCI_GETTEXT, length, (LPARAM)buffer); - // convert here + // convert here UniMode unicodeMode = pSci->getCurrentBuffer()->getUnicodeMode(); + Utf8_16_Write UnicodeConvertor; UnicodeConvertor.setEncoding(unicodeMode); length = UnicodeConvertor.convert(buffer, length-1); @@ -893,11 +891,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_ENCODESCI: { // convert - Utf8_16_Read UnicodeConvertor; - UINT length = 0; - char* buffer = NULL; ScintillaEditView *pSci; - if (wParam == MAIN_VIEW) pSci = &_mainEditView; else if (wParam == SUB_VIEW) @@ -906,18 +900,17 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return -1; // get text of current scintilla - length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1; - buffer = new char[length]; + UINT length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1; + char* buffer = new char[length]; pSci->execute(SCI_GETTEXT, length, (LPARAM)buffer); + Utf8_16_Read UnicodeConvertor; length = UnicodeConvertor.convert(buffer, length-1); // set text in target pSci->execute(SCI_CLEARALL); pSci->addText(length, UnicodeConvertor.getNewBuf()); - - pSci->execute(SCI_EMPTYUNDOBUFFER); // set cursor position @@ -933,7 +926,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return um; } - case NPPM_ACTIVATEDOC : + case NPPM_ACTIVATEDOC: case NPPM_TRIGGERTABBARCONTEXTMENU: { // similar to NPPM_ACTIVEDOC @@ -968,7 +961,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa for (int i = 0 ; verStr[i] ; ++i) { if (verStr[i] == '.') + { isDot = true; + } else { if (!isDot) @@ -977,6 +972,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa auxVerStr[k++] = verStr[i]; } } + mainVerStr[j] = '\0'; auxVerStr[k] = '\0'; @@ -990,17 +986,24 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return MAKELONG(auxVer, mainVer); } - case WM_GETCURRENTMACROSTATUS : - if (_recordingMacro) return MACRO_RECORDING_IN_PROGRESS; + case WM_GETCURRENTMACROSTATUS: + { + if (_recordingMacro) + return MACRO_RECORDING_IN_PROGRESS; return (_macro.empty())?0:MACRO_RECORDING_HAS_STOPPED; + } case WM_FRSAVE_INT: + { _macro.push_back(recordedMacroStep(wParam, 0, lParam, NULL, recordedMacroStep::mtSavedSnR)); break; + } case WM_FRSAVE_STR: + { _macro.push_back(recordedMacroStep(wParam, 0, 0, (const TCHAR *)lParam, recordedMacroStep::mtSavedSnR)); break; + } case WM_MACRODLGRUNMACRO: { @@ -1008,18 +1011,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { int times = 1; if (_runMacroDlg.getMode() == RM_RUN_MULTI) - { times = _runMacroDlg.getTimes(); - } else if (_runMacroDlg.getMode() == RM_RUN_EOF) - { times = -1; - } else - { break; - } - + int counter = 0; int lastLine = int(_pEditView->execute(SCI_GETLINECOUNT)) - 1; int currLine = _pEditView->getCurrentLineNumber(); @@ -1036,13 +1033,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } _pEditView->execute(SCI_BEGINUNDOACTION); - for(;;) + for (;;) { macroPlayback(m); ++counter; if ( times >= 0 ) { - if ( counter >= times ) break; + if ( counter >= times ) + break; } else // run until eof { @@ -1063,17 +1061,19 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa currLine += deltaCurrLine; // eof? - if ((currLine >= lastLine) || (currLine < 0) + if ((currLine >= lastLine) || (currLine < 0) || ((deltaCurrLine == 0) && (currLine == 0) && ((deltaLastLine >= 0) || cursorMovedUp))) + { break; + } } } _pEditView->execute(SCI_ENDUNDOACTION); } + break; } - break; - case NPPM_CREATESCINTILLAHANDLE : + case NPPM_CREATESCINTILLAHANDLE: { return (LRESULT)_scintillaCtrls4Plugins.createSintilla((lParam == NULL?_pPublicInterface->getHSelf():(HWND)lParam)); } @@ -1089,20 +1089,19 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - - case NPPM_DESTROYSCINTILLAHANDLE : + case NPPM_DESTROYSCINTILLAHANDLE: { return _scintillaCtrls4Plugins.destroyScintilla((HWND)lParam); } - case NPPM_GETNBUSERLANG : + case NPPM_GETNBUSERLANG: { if (lParam) *((int *)lParam) = IDM_LANG_USER; return pNppParam->getNbUserLang(); } - case NPPM_GETCURRENTDOCINDEX : + case NPPM_GETCURRENTDOCINDEX: { if (lParam == SUB_VIEW) { @@ -1118,7 +1117,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } } - case NPPM_SETSTATUSBAR : + case NPPM_SETSTATUSBAR: { TCHAR *str2set = (TCHAR *)lParam; if (!str2set || !str2set[0]) @@ -1126,12 +1125,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa switch (wParam) { - case STATUSBAR_DOC_TYPE : - case STATUSBAR_DOC_SIZE : - case STATUSBAR_CUR_POS : - case STATUSBAR_EOF_FORMAT : - case STATUSBAR_UNICODE_TYPE : - case STATUSBAR_TYPING_MODE : + case STATUSBAR_DOC_TYPE: + case STATUSBAR_DOC_SIZE: + case STATUSBAR_CUR_POS: + case STATUSBAR_EOF_FORMAT: + case STATUSBAR_UNICODE_TYPE: + case STATUSBAR_TYPING_MODE: _statusBar.setText(str2set, wParam); return TRUE; default : @@ -1139,7 +1138,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } } - case NPPM_GETMENUHANDLE : + case NPPM_GETMENUHANDLE: { if (wParam == NPPPLUGINMENU) return (LRESULT)_pluginsManager.getMenuHandle(); @@ -1149,54 +1148,54 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return NULL; } - case NPPM_LOADSESSION : + case NPPM_LOADSESSION: { fileLoadSession((const TCHAR *)lParam); return TRUE; } - case NPPM_SAVECURRENTSESSION : + case NPPM_SAVECURRENTSESSION: { return (LRESULT)fileSaveSession(0, NULL, (const TCHAR *)lParam); } - case NPPM_SAVESESSION : + case NPPM_SAVESESSION: { sessionInfo *pSi = (sessionInfo *)lParam; return (LRESULT)fileSaveSession(pSi->nbFile, pSi->files, pSi->sessionFilePathName); } - case NPPM_INTERNAL_CLEARSCINTILLAKEY : + case NPPM_INTERNAL_CLEARSCINTILLAKEY: { _mainEditView.execute(SCI_CLEARCMDKEY, wParam); _subEditView.execute(SCI_CLEARCMDKEY, wParam); - return TRUE; + return TRUE; } - case NPPM_INTERNAL_BINDSCINTILLAKEY : + case NPPM_INTERNAL_BINDSCINTILLAKEY: { _mainEditView.execute(SCI_ASSIGNCMDKEY, wParam, lParam); _subEditView.execute(SCI_ASSIGNCMDKEY, wParam, lParam); - return TRUE; } - case NPPM_INTERNAL_CMDLIST_MODIFIED : + + case NPPM_INTERNAL_CMDLIST_MODIFIED: { //changeMenuShortcut(lParam, (const TCHAR *)wParam); ::DrawMenuBar(_pPublicInterface->getHSelf()); return TRUE; } - case NPPM_INTERNAL_MACROLIST_MODIFIED : + case NPPM_INTERNAL_MACROLIST_MODIFIED: { return TRUE; } - case NPPM_INTERNAL_USERCMDLIST_MODIFIED : + case NPPM_INTERNAL_USERCMDLIST_MODIFIED: { return TRUE; } - case NPPM_INTERNAL_SETCARETWIDTH : + case NPPM_INTERNAL_SETCARETWIDTH: { NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); @@ -1225,15 +1224,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case NPPM_INTERNAL_SETMULTISELCTION : - { - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); - _mainEditView.execute(SCI_SETMULTIPLESELECTION, nppGUI._enableMultiSelection); + case NPPM_INTERNAL_SETMULTISELCTION: + { + NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + _mainEditView.execute(SCI_SETMULTIPLESELECTION, nppGUI._enableMultiSelection); _subEditView.execute(SCI_SETMULTIPLESELECTION, nppGUI._enableMultiSelection); - return TRUE; - } + return TRUE; + } - case NPPM_INTERNAL_SETCARETBLINKRATE : + case NPPM_INTERNAL_SETCARETBLINKRATE: { NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); _mainEditView.execute(SCI_SETCARETPERIOD, nppGUI._caretBlinkRate); @@ -1241,38 +1240,46 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case NPPM_INTERNAL_ISTABBARREDUCED : + case NPPM_INTERNAL_ISTABBARREDUCED: { return _toReduceTabBar?TRUE:FALSE; } // ADD: success->hwnd; failure->NULL // REMOVE: success->NULL; failure->hwnd - case NPPM_MODELESSDIALOG : + case NPPM_MODELESSDIALOG: { if (wParam == MODELESSDIALOGADD) { for (size_t i = 0, len = _hModelessDlgs.size() ; i < len ; ++i) + { if (_hModelessDlgs[i] == (HWND)lParam) return NULL; + } + _hModelessDlgs.push_back((HWND)lParam); return lParam; } - else if (wParam == MODELESSDIALOGREMOVE) + else { - for (size_t i = 0, len = _hModelessDlgs.size(); i < len ; ++i) - if (_hModelessDlgs[i] == (HWND)lParam) + if (wParam == MODELESSDIALOGREMOVE) + { + for (size_t i = 0, len = _hModelessDlgs.size(); i < len ; ++i) { - vector::iterator hDlg = _hModelessDlgs.begin() + i; - _hModelessDlgs.erase(hDlg); - return NULL; + if (_hModelessDlgs[i] == (HWND)lParam) + { + vector::iterator hDlg = _hModelessDlgs.begin() + i; + _hModelessDlgs.erase(hDlg); + return NULL; + } } - return lParam; + return lParam; + } } return TRUE; } - case WM_CONTEXTMENU : + case WM_CONTEXTMENU: { if (pNppParam->_isTaskListRBUTTONUP_Active) { @@ -1282,15 +1289,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { if ((HWND(wParam) == _mainEditView.getHSelf()) || (HWND(wParam) == _subEditView.getHSelf())) { - if ((HWND(wParam) == _mainEditView.getHSelf())) { + if ((HWND(wParam) == _mainEditView.getHSelf())) switchEditViewTo(MAIN_VIEW); - } else { + else switchEditViewTo(SUB_VIEW); - } + POINT p; ::GetCursorPos(&p); ContextMenu scintillaContextmenu; - vector & tmp = pNppParam->getContextMenuItems(); + std::vector& tmp = pNppParam->getContextMenuItems(); scintillaContextmenu.create(_pPublicInterface->getHSelf(), tmp, _mainMenuHandle); scintillaContextmenu.display(p); return TRUE; @@ -1314,12 +1321,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa notification->wParam = LINKTRIGGERED; _pluginsManager.notify(notification); - + return notify(notification); } - case NPPM_INTERNAL_CHECKDOCSTATUS : - case WM_ACTIVATEAPP : + case NPPM_INTERNAL_CHECKDOCSTATUS: + case WM_ACTIVATEAPP: { if (wParam == TRUE) // if npp is about to be activated { @@ -1334,12 +1341,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa break; } - case NPPM_INTERNAL_GETCHECKDOCOPT : + case NPPM_INTERNAL_GETCHECKDOCOPT: { return (LRESULT)((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection; } - case NPPM_INTERNAL_SETCHECKDOCOPT : + case NPPM_INTERNAL_SETCHECKDOCOPT: { // If nothing is changed by user, then we allow to set this value if (((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetection == ((NppGUI &)(pNppParam->getNppGUI()))._fileAutoDetectionOriginalValue) @@ -1347,7 +1354,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case NPPM_GETPOSFROMBUFFERID : + case NPPM_GETPOSFROMBUFFERID: { int i; @@ -1384,11 +1391,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return -1; } - case NPPM_GETFULLPATHFROMBUFFERID : + case NPPM_GETFULLPATHFROMBUFFERID: { return MainFileManager->getFileNameFromBuffer((BufferID)wParam, (TCHAR *)lParam); } - + case NPPM_INTERNAL_ENABLECHECKDOCOPT: { NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); @@ -1403,10 +1410,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - - case WM_ACTIVATE : + + case WM_ACTIVATE: + { _pEditView->getFocus(); return TRUE; + } case WM_DROPFILES: { @@ -1422,7 +1431,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _subEditView.defineDocType(_subEditView.getCurrentBuffer()->getLangType()); _subEditView.performGlobalStyles(); - + _findReplaceDlg.updateFinderScintilla(); drawTabbarColoursFromStylerArray(); @@ -1465,20 +1474,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _pProjectPanel_1->setBackgroundColor(style._bgColor); _pProjectPanel_1->setForegroundColor(style._fgColor); } + if (_pProjectPanel_2) { _pProjectPanel_2->setBackgroundColor(style._bgColor); _pProjectPanel_2->setForegroundColor(style._fgColor); } + if (_pProjectPanel_3) { _pProjectPanel_3->setBackgroundColor(style._bgColor); _pProjectPanel_3->setForegroundColor(style._fgColor); } + if (_pDocMap) - { _pDocMap->setSyntaxHiliting(); - } // Notify plugins of update to styles xml SCNotification scnN; @@ -1496,87 +1506,84 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { SendMessage(_pPublicInterface->getHSelf(), WM_SYSCOMMAND, SC_MINIMIZE, 0); } - else - { + else + { SCNotification scnN; scnN.nmhdr.code = NPPN_BEFORESHUTDOWN; scnN.nmhdr.hwndFrom = _pPublicInterface->getHSelf(); scnN.nmhdr.idFrom = 0; _pluginsManager.notify(&scnN); - if (_pTrayIco) - _pTrayIco->doTrayIcon(REMOVE); + if (_pTrayIco) + _pTrayIco->doTrayIcon(REMOVE); + + const NppGUI & nppgui = pNppParam->getNppGUI(); - const NppGUI & nppgui = pNppParam->getNppGUI(); - bool isSnapshotMode = nppgui.isSnapshotMode(); if (isSnapshotMode) + { ::LockWindowUpdate(_pPublicInterface->getHSelf()); - - if (isSnapshotMode) MainFileManager->backupCurrentBuffer(); + } - Session currentSession; - if (nppgui._rememberLastSession) - { - getCurrentOpenedFiles(currentSession, true); - //Lock the recent file list so it isnt populated with opened files - //Causing them to show on restart even though they are loaded by session - _lastRecentFileList.setLock(true); //only lock when the session is remembered - } + Session currentSession; + if (nppgui._rememberLastSession) + { + getCurrentOpenedFiles(currentSession, true); + //Lock the recent file list so it isnt populated with opened files + //Causing them to show on restart even though they are loaded by session + _lastRecentFileList.setLock(true); //only lock when the session is remembered + } bool allClosed = fileCloseAll(false, isSnapshotMode); //try closing files before doing anything else - - if (nppgui._rememberLastSession) - { - _lastRecentFileList.setLock(false); //only lock when the session is remembered - } - if (!allClosed) - { - //User cancelled the shutdown + if (nppgui._rememberLastSession) + _lastRecentFileList.setLock(false); //only lock when the session is remembered + + if (!allClosed) + { + //User cancelled the shutdown scnN.nmhdr.code = NPPN_CANCELSHUTDOWN; _pluginsManager.notify(&scnN); + return FALSE; + } - return FALSE; - } + if (_beforeSpecialView.isFullScreen) //closing, return to windowed mode + fullScreenToggle(); + if (_beforeSpecialView.isPostIt) //closing, return to windowed mode + postItToggle(); - if (_beforeSpecialView.isFullScreen) //closing, return to windowed mode - fullScreenToggle(); - if (_beforeSpecialView.isPostIt) //closing, return to windowed mode - postItToggle(); + if (_configStyleDlg.isCreated() && ::IsWindowVisible(_configStyleDlg.getHSelf())) + _configStyleDlg.restoreGlobalOverrideValues(); - if (_configStyleDlg.isCreated() && ::IsWindowVisible(_configStyleDlg.getHSelf())) - _configStyleDlg.restoreGlobalOverrideValues(); + scnN.nmhdr.code = NPPN_SHUTDOWN; + _pluginsManager.notify(&scnN); - scnN.nmhdr.code = NPPN_SHUTDOWN; - _pluginsManager.notify(&scnN); - - saveFindHistory(); //writeFindHistory - _lastRecentFileList.saveLRFL(); //writeRecentFileHistorySettings, writeHistory - saveScintillaParams(); //writeScintillaParams - saveGUIParams(); //writeGUIParams + saveFindHistory(); //writeFindHistory + _lastRecentFileList.saveLRFL(); //writeRecentFileHistorySettings, writeHistory + saveScintillaParams(); //writeScintillaParams + saveGUIParams(); //writeGUIParams saveProjectPanelsParams(); //writeProjectPanelsSettings // // saving config.xml // pNppParam->saveConfig_xml(); - + // // saving userDefineLang.xml // - saveUserDefineLangs(); - + saveUserDefineLangs(); + // // saving shortcuts.xml // - saveShortcuts(); + saveShortcuts(); // // saving session.xml // - if (nppgui._rememberLastSession && !nppgui._isCmdlineNosessionActivated) - saveSession(currentSession); + if (nppgui._rememberLastSession && !nppgui._isCmdlineNosessionActivated) + saveSession(currentSession); // write settings on cloud if enabled, if the settings files don't exist if (nppgui._cloudPath != TEXT("") && pNppParam->isCloudPathChanged()) @@ -1596,11 +1603,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (not isSnapshotMode) ::LockWindowUpdate(_pPublicInterface->getHSelf()); - //Sends WM_DESTROY, Notepad++ will end + //Sends WM_DESTROY, Notepad++ will end if (Message == WM_CLOSE) ::DestroyWindow(hwnd); - ::LockWindowUpdate(NULL); + if (not isSnapshotMode) + ::LockWindowUpdate(NULL); } return TRUE; } @@ -1613,8 +1621,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } case WM_DESTROY: - { - killAllChildren(); + { + killAllChildren(); ::PostQuitMessage(0); _pPublicInterface->gNppHWND = NULL; return TRUE; @@ -1625,14 +1633,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); if ((nppgui._isMinimizedToTray || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE)) { - if (!_pTrayIco) + if (nullptr == _pTrayIco) _pTrayIco = new trayIconControler(_pPublicInterface->getHSelf(), IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_M30ICON)), TEXT("")); _pTrayIco->doTrayIcon(ADD); ::ShowWindow(hwnd, SW_HIDE); return TRUE; } - + if (wParam == SC_KEYMENU && lParam == VK_SPACE) { _sysMenuEntering = true; @@ -1657,33 +1665,36 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { //case WM_LBUTTONDBLCLK: case WM_LBUTTONUP : + { _pEditView->getFocus(); ::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW); if (!_pPublicInterface->isPrelaunch()) _pTrayIco->doTrayIcon(REMOVE); ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); return TRUE; + } case WM_MBUTTONUP: + { command(IDM_SYSTRAYPOPUP_NEW_AND_PASTE); return TRUE; + } - case WM_RBUTTONUP: - { - POINT p; - GetCursorPos(&p); + case WM_RBUTTONUP: + { + POINT p; + GetCursorPos(&p); - HMENU hmenu; // menu template - HMENU hTrayIconMenu; // shortcut menu + HMENU hmenu; // menu template + HMENU hTrayIconMenu; // shortcut menu hmenu = ::LoadMenu(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDR_SYSTRAYPOPUP_MENU)); - hTrayIconMenu = ::GetSubMenu(hmenu, 0); + hTrayIconMenu = ::GetSubMenu(hmenu, 0); SetForegroundWindow(_pPublicInterface->getHSelf()); TrackPopupMenu(hTrayIconMenu, TPM_LEFTALIGN, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); PostMessage(_pPublicInterface->getHSelf(), WM_NULL, 0, 0); - DestroyMenu(hmenu); - return TRUE; - } - + DestroyMenu(hmenu); + return TRUE; + } } return TRUE; } @@ -1726,21 +1737,24 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_DMMGETPLUGINHWNDBYNAME : //(const TCHAR *windowName, const TCHAR *moduleName) { - if (!lParam) return NULL; + if (!lParam) + return NULL; TCHAR *moduleName = (TCHAR *)lParam; TCHAR *windowName = (TCHAR *)wParam; - vector dockContainer = _dockingManager.getContainerInfo(); + std::vector dockContainer = _dockingManager.getContainerInfo(); + for (size_t i = 0, len = dockContainer.size(); i < len ; ++i) { - vector tbData = dockContainer[i]->getDataOfAllTb(); + std::vector tbData = dockContainer[i]->getDataOfAllTb(); for (size_t j = 0, len2 = tbData.size() ; j < len2 ; ++j) { if (generic_stricmp(moduleName, tbData[j]->pszModuleName) == 0) { if (!windowName) return (LRESULT)tbData[j]->hClient; - else if (generic_stricmp(windowName, tbData[j]->pszName) == 0) + + if (generic_stricmp(windowName, tbData[j]->pszName) == 0) return (LRESULT)tbData[j]->hClient; } } @@ -1766,34 +1780,34 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return (NppParameters::getInstance())->getWinVersion(); } - case NPPM_MAKECURRENTBUFFERDIRTY : + case NPPM_MAKECURRENTBUFFERDIRTY: { _pEditView->getCurrentBuffer()->setDirty(true); return TRUE; } - case NPPM_GETENABLETHEMETEXTUREFUNC : + case NPPM_GETENABLETHEMETEXTUREFUNC: { return (LRESULT)pNppParam->getEnableThemeDlgTexture(); } - case NPPM_GETPLUGINSCONFIGDIR : + case NPPM_GETPLUGINSCONFIGDIR: { if (!lParam || !wParam) return FALSE; generic_string pluginsConfigDirPrefix = pNppParam->getAppDataNppDir(); - + if (pluginsConfigDirPrefix == TEXT("")) pluginsConfigDirPrefix = pNppParam->getNppPath(); const TCHAR *secondPart = TEXT("plugins\\Config"); - + size_t len = wParam; if (len < pluginsConfigDirPrefix.length() + lstrlen(secondPart)) return FALSE; - TCHAR *pluginsConfigDir = (TCHAR *)lParam; + TCHAR *pluginsConfigDir = (TCHAR *)lParam; lstrcpy(pluginsConfigDir, pluginsConfigDirPrefix.c_str()); ::PathAppend(pluginsConfigDir, secondPart); @@ -1806,15 +1820,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } case NPPM_ALLOCATESUPPORTED: + { return TRUE; + } case NPPM_ALLOCATECMDID: + { return _pluginsManager.allocateCmdID(wParam, reinterpret_cast(lParam)); + } case NPPM_ALLOCATEMARKER: + { return _pluginsManager.allocateMarker(wParam, reinterpret_cast(lParam)); + } - case NPPM_HIDETABBAR : + case NPPM_HIDETABBAR: { bool hide = (lParam != 0); bool oldVal = DocTabView::getHideTabBarStatus(); @@ -1831,13 +1851,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return oldVal; } - case NPPM_ISTABBARHIDDEN : + + case NPPM_ISTABBARHIDDEN: { return _mainDocTab.getHideTabBarStatus(); } - - case NPPM_HIDETOOLBAR : + case NPPM_HIDETOOLBAR: { bool show = (lParam != TRUE); bool currentStatus = _rebarTop.getIDVisible(REBAR_BAR_TOOLBAR); @@ -1845,12 +1865,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _rebarTop.setIDVisible(REBAR_BAR_TOOLBAR, show); return currentStatus; } + case NPPM_ISTOOLBARHIDDEN : { return !_rebarTop.getIDVisible(REBAR_BAR_TOOLBAR); } - case NPPM_HIDEMENU : + case NPPM_HIDEMENU: { bool hide = (lParam == TRUE); bool isHidden = ::GetMenu(_pPublicInterface->getHSelf()) == NULL; @@ -1866,7 +1887,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return isHidden; } - case NPPM_ISMENUHIDDEN : + + case NPPM_ISMENUHIDDEN: { return (::GetMenu(_pPublicInterface->getHSelf()) == NULL); } @@ -1877,82 +1899,59 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); bool oldVal = nppGUI._statusBarShow; if (show == oldVal) - { return oldVal; - } - RECT rc; + + RECT rc; _pPublicInterface->getClientRect(rc); - + nppGUI._statusBarShow = show; _statusBar.display(nppGUI._statusBarShow); - ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, SIZE_RESTORED, MAKELONG(rc.bottom, rc.right)); - return oldVal; - } + ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, SIZE_RESTORED, MAKELONG(rc.bottom, rc.right)); + return oldVal; + } - case NPPM_ISSTATUSBARHIDDEN : + case NPPM_ISSTATUSBARHIDDEN: { NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); return !nppGUI._statusBarShow; } - case NPPM_GETCURRENTVIEW : + case NPPM_GETCURRENTVIEW: { return _activeView; } -/* - case NPPM_ADDREBAR : - { - if (!lParam) - return FALSE; - _rebarTop.addBand((REBARBANDINFO*)lParam, false); - return TRUE; - } - case NPPM_UPDATEREBAR : - { - if (!lParam || wParam < REBAR_BAR_EXTERNAL) - return FALSE; - _rebarTop.reNew((int)wParam, (REBARBANDINFO*)lParam); - return TRUE; - } - - case NPPM_REMOVEREBAR : - { - if (wParam < REBAR_BAR_EXTERNAL) - return FALSE; - _rebarTop.removeBand((int)wParam); - return TRUE; - } -*/ - case NPPM_INTERNAL_ISFOCUSEDTAB : + case NPPM_INTERNAL_ISFOCUSEDTAB: { HWND hTabToTest = (currentView() == MAIN_VIEW)?_mainDocTab.getHSelf():_subDocTab.getHSelf(); return (HWND)lParam == hTabToTest; } - case NPPM_INTERNAL_GETMENU : + case NPPM_INTERNAL_GETMENU: { return (LRESULT)_mainMenuHandle; } - - case NPPM_INTERNAL_CLEARINDICATOR : + + case NPPM_INTERNAL_CLEARINDICATOR: { _pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART); return TRUE; } - case NPPM_INTERNAL_CLEARINDICATORTAGMATCH : + + case NPPM_INTERNAL_CLEARINDICATORTAGMATCH: { _pEditView->clearIndicator(SCE_UNIVERSAL_TAGMATCH); _pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR); return TRUE; } - case NPPM_INTERNAL_CLEARINDICATORTAGATTR : + + case NPPM_INTERNAL_CLEARINDICATORTAGATTR: { _pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR); return TRUE; } - case NPPM_INTERNAL_SWITCHVIEWFROMHWND : + case NPPM_INTERNAL_SWITCHVIEWFROMHWND: { HWND handle = (HWND)lParam; if (_mainEditView.getHSelf() == handle || _mainDocTab.getHSelf() == handle) @@ -1966,20 +1965,20 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case NPPM_INTERNAL_UPDATETITLEBAR : + case NPPM_INTERNAL_UPDATETITLEBAR: { setTitle(); return TRUE; } - case NPPM_INTERNAL_DISABLEAUTOUPDATE : + case NPPM_INTERNAL_DISABLEAUTOUPDATE: { //printStr(TEXT("you've got me")); NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); nppGUI._autoUpdateOpt._doAutoUpdate = false; return TRUE; } - + case NPPM_GETLANGUAGENAME: { generic_string langName = getLangDesc((LangType)wParam, true); @@ -2013,13 +2012,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR: case NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR: { - return (Message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR?(NppParameters::getInstance())->getCurrentDefaultFgColor():(NppParameters::getInstance())->getCurrentDefaultBgColor()); - /* - StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers(); - int i = globalStyles.getStylerIndexByID(STYLE_DEFAULT); - Style & style = globalStyles.getStyler(i); - return (Message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR?style._fgColor:style._bgColor); - */ + return (Message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR + ?(NppParameters::getInstance())->getCurrentDefaultFgColor() + :(NppParameters::getInstance())->getCurrentDefaultBgColor()); } case NPPM_SHOWDOCSWITCHER: @@ -2067,8 +2062,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _lastRecentFileList.setUserMaxNbLRF(pNppParam->getNbMaxRecentFile()); break; } - - case NPPM_INTERNAL_SETTING_EDGE_SIZE : + + case NPPM_INTERNAL_SETTING_EDGE_SIZE: { ScintillaViewParams & svp = (ScintillaViewParams &)(NppParameters::getInstance())->getSVP(); _mainEditView.execute(SCI_SETEDGECOLUMN, svp._edgeNbColumn); @@ -2079,7 +2074,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_SETTING_TAB_REPLCESPACE: case NPPM_INTERNAL_SETTING_TAB_SIZE: { - _pEditView->setTabSettings(_pEditView->getCurrentBuffer()->getCurrentLang()); + _pEditView->setTabSettings(_pEditView->getCurrentBuffer()->getCurrentLang()); break; } @@ -2107,7 +2102,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); if (!nppgui._menuBarShow && !wParam && !_sysMenuEntering) ::SetMenu(_pPublicInterface->getHSelf(), _mainMenuHandle); - + return TRUE; } @@ -2122,8 +2117,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_DPICHANGED: { - //printInt(LOWORD(wParam)); - //printInt(HIWORD(wParam)); return TRUE; } @@ -2135,9 +2128,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa switch (nmdlg->type) { case WDT_ACTIVATE: + { activateDoc(nmdlg->curSel); nmdlg->processed = TRUE; break; + } + case WDT_SAVE: { //loop through nmdlg->nItems, get index and save it @@ -2146,51 +2142,52 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa fileSave(_pDocTab->getBufferByIndex(i)); } nmdlg->processed = TRUE; + break; } - break; + case WDT_CLOSE: { - bool closed; - //loop through nmdlg->nItems, get index and close it for (int i = 0; i < (int)nmdlg->nItems; ++i) - { - closed = fileClose(_pDocTab->getBufferByIndex(nmdlg->Items[i]), currentView()); + { + bool closed = fileClose(_pDocTab->getBufferByIndex(nmdlg->Items[i]), currentView()); UINT pos = nmdlg->Items[i]; // The window list only needs to be rearranged when the file was actually closed if (closed) - { + { nmdlg->Items[i] = 0xFFFFFFFF; // indicate file was closed // Shift the remaining items downward to fill the gap for (int j = i + 1; j < (int)nmdlg->nItems; ++j) - { + { if (nmdlg->Items[j] > pos) - { nmdlg->Items[j]--; - } } } } nmdlg->processed = TRUE; + break; } - break; + case WDT_SORT: + { if (nmdlg->nItems != (unsigned int)_pDocTab->nbItem()) //sanity check, if mismatch just abort break; + //Collect all buffers std::vector tempBufs; - for(int i = 0; i < (int)nmdlg->nItems; ++i) + for (int i = 0; i < (int)nmdlg->nItems; ++i) { tempBufs.push_back(_pDocTab->getBufferByIndex(i)); } //Reset buffers - for(int i = 0; i < (int)nmdlg->nItems; ++i) + for (int i = 0; i < (int)nmdlg->nItems; ++i) { _pDocTab->setBuffer(i, tempBufs[nmdlg->Items[i]]); } activateBuffer(_pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex()), currentView()); break; + } } return TRUE; } diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index cc1d328d..af04ab02 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -55,7 +55,7 @@ void Notepad_plus::macroPlayback(Macro macro) _pEditView->execute(SCI_ENDUNDOACTION); } -void Notepad_plus::command(int id) +void Notepad_plus::command(int id) { switch (id) { @@ -127,7 +127,7 @@ void Notepad_plus::command(int id) checkDocState(); break; } - + case IDM_FILE_CLOSEALL_BUT_CURRENT : fileCloseAllButCurrent(); checkDocState(); @@ -234,12 +234,12 @@ void Notepad_plus::command(int id) unsigned char *lpucharCopy = (unsigned char *)GlobalLock(hglbCopy); memcpy(lpucharCopy, pBinText, textLen * sizeof(unsigned char)); lpucharCopy[textLen] = 0; // null character - + GlobalUnlock(hglbCopy); - + // Place the handle on the clipboard. SetClipboardData(CF_TEXT, hglbCopy); - + // Allocate a global memory object for the text length. HGLOBAL hglbLenCopy = GlobalAlloc(GMEM_MOVEABLE, sizeof(unsigned long)); @@ -248,13 +248,13 @@ void Notepad_plus::command(int id) CloseClipboard(); return; } - - // Lock the handle and copy the text to the buffer. - unsigned long *lpLenCopy = (unsigned long *)GlobalLock(hglbLenCopy); + + // Lock the handle and copy the text to the buffer. + unsigned long *lpLenCopy = (unsigned long *)GlobalLock(hglbLenCopy); *lpLenCopy = textLen; - - GlobalUnlock(hglbLenCopy); - + + GlobalUnlock(hglbLenCopy); + // Place the handle on the clipboard. UINT f = RegisterClipboardFormat(CF_NPPTEXTLEN); SetClipboardData(f, hglbLenCopy); @@ -276,33 +276,33 @@ void Notepad_plus::command(int id) break; case IDM_EDIT_PASTE_BINARY: - { + { LongRunningOperation op; if (!IsClipboardFormatAvailable(CF_TEXT)) return; if (!OpenClipboard(NULL)) - return; - - HGLOBAL hglb = GetClipboardData(CF_TEXT); - if (hglb != NULL) - { - char *lpchar = (char *)GlobalLock(hglb); - if (lpchar != NULL) + return; + + HGLOBAL hglb = GetClipboardData(CF_TEXT); + if (hglb != NULL) + { + char *lpchar = (char *)GlobalLock(hglb); + if (lpchar != NULL) { UINT cf_nppTextLen = RegisterClipboardFormat(CF_NPPTEXTLEN); if (IsClipboardFormatAvailable(cf_nppTextLen)) { - HGLOBAL hglbLen = GetClipboardData(cf_nppTextLen); - if (hglbLen != NULL) - { - unsigned long *lpLen = (unsigned long *)GlobalLock(hglbLen); - if (lpLen != NULL) + HGLOBAL hglbLen = GetClipboardData(cf_nppTextLen); + if (hglbLen != NULL) + { + unsigned long *lpLen = (unsigned long *)GlobalLock(hglbLen); + if (lpLen != NULL) { _pEditView->execute(SCI_REPLACESEL, 0, (LPARAM)""); _pEditView->execute(SCI_ADDTEXT, *lpLen, (LPARAM)lpchar); - GlobalUnlock(hglb); + GlobalUnlock(hglb); } } } @@ -311,7 +311,7 @@ void Notepad_plus::command(int id) _pEditView->execute(SCI_REPLACESEL, 0, (LPARAM)lpchar); } - GlobalUnlock(hglb); + GlobalUnlock(hglb); } } CloseClipboard(); @@ -325,27 +325,27 @@ void Notepad_plus::command(int id) LongRunningOperation op; UINT f = RegisterClipboardFormat(id==IDM_EDIT_PASTE_AS_HTML?CF_HTML:CF_RTF); - if (!IsClipboardFormatAvailable(f)) + if (!IsClipboardFormatAvailable(f)) return; - + if (!OpenClipboard(NULL)) - return; - - HGLOBAL hglb = GetClipboardData(f); - if (hglb != NULL) - { - LPSTR lptstr = (LPSTR)GlobalLock(hglb); - if (lptstr != NULL) - { - // Call the application-defined ReplaceSelection - // function to insert the text and repaint the - // window. + return; + + HGLOBAL hglb = GetClipboardData(f); + if (hglb != NULL) + { + LPSTR lptstr = (LPSTR)GlobalLock(hglb); + if (lptstr != NULL) + { + // Call the application-defined ReplaceSelection + // function to insert the text and repaint the + // window. _pEditView->execute(SCI_REPLACESEL, 0, (LPARAM)lptstr); - GlobalUnlock(hglb); + GlobalUnlock(hglb); } } - CloseClipboard(); + CloseClipboard(); } break; @@ -551,7 +551,7 @@ void Notepad_plus::command(int id) } } break; - + case IDM_VIEW_TAB1: case IDM_VIEW_TAB2: case IDM_VIEW_TAB3: @@ -613,10 +613,10 @@ void Notepad_plus::command(int id) // STOP !!! _mainEditView.execute(SCI_STOPRECORD); _subEditView.execute(SCI_STOPRECORD); - + _mainEditView.execute(SCI_SETCURSOR, (WPARAM)SC_CURSORNORMAL); _subEditView.execute(SCI_SETCURSOR, (WPARAM)SC_CURSORNORMAL); - + _recordingMacro = false; _runMacroDlg.initMacroList(); } @@ -646,13 +646,13 @@ void Notepad_plus::command(int id) { bool isFirstTime = !_runMacroDlg.isCreated(); _runMacroDlg.doDialog(_nativeLangSpeaker.isRTL()); - + if (isFirstTime) { _nativeLangSpeaker.changeDlgLang(_runMacroDlg.getHSelf(), "MultiMacro"); } break; - + } } break; @@ -693,7 +693,7 @@ void Notepad_plus::command(int id) TCHAR str[strSize]; bool isFirstTime = !_findReplaceDlg.isCreated(); - + DIALOG_TYPE dlgID = FIND_DLG; if (id == IDM_SEARCH_REPLACE) dlgID = REPLACE_DLG; @@ -898,7 +898,7 @@ void Notepad_plus::command(int id) break; } - + case IDM_SEARCH_GOPREVMARKER1 : case IDM_SEARCH_GOPREVMARKER2 : case IDM_SEARCH_GOPREVMARKER3 : @@ -1004,11 +1004,11 @@ void Notepad_plus::command(int id) case IDM_SEARCH_CLEAR_BOOKMARKS: bookmarkClearAll(); break; - + case IDM_LANG_USER_DLG : { bool isUDDlgVisible = false; - + UserDefineDialog *udd = _pEditView->getUserDefineDlg(); if (!udd->isCreated()) @@ -1034,7 +1034,7 @@ void Notepad_plus::command(int id) _pMainWindow = _pDocTab; ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); - + udd->display(false); _mainWindowStatus &= ~WindowUserActive; } @@ -1051,7 +1051,7 @@ void Notepad_plus::command(int id) else pWindow = _pDocTab; - _pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, RIGHT_FIX, 45); + _pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, SplitterMode::RIGHT_FIX, 45); } _pMainWindow = _pMainSplitter; @@ -1137,7 +1137,7 @@ void Notepad_plus::command(int id) case IDM_EDIT_BLOCK_COMMENT: doBlockComment(cm_toggle); break; - + case IDM_EDIT_BLOCK_COMMENT_SET: doBlockComment(cm_comment); break; @@ -1213,11 +1213,11 @@ void Notepad_plus::command(int id) case IDM_EDIT_CLEARREADONLY: { Buffer * buf = _pEditView->getCurrentBuffer(); - - DWORD dwFileAttribs = ::GetFileAttributes(buf->getFullPathName()); - dwFileAttribs ^= FILE_ATTRIBUTE_READONLY; - ::SetFileAttributes(buf->getFullPathName(), dwFileAttribs); + DWORD dwFileAttribs = ::GetFileAttributes(buf->getFullPathName()); + dwFileAttribs ^= FILE_ATTRIBUTE_READONLY; + + ::SetFileAttributes(buf->getFullPathName(), dwFileAttribs); buf->setFileReadOnly(false); } break; @@ -1367,7 +1367,7 @@ void Notepad_plus::command(int id) ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); break; } - + case IDM_VIEW_REFRESHTABAR : { ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); @@ -1397,7 +1397,7 @@ void Notepad_plus::command(int id) TabBarPlus::setDrawTabCloseButton(!TabBarPlus::drawTabCloseButton()); // This part is just for updating (redraw) the tabs - { + { int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(TabBarPlus::drawTabCloseButton()?21:20); int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(TabBarPlus::drawTabCloseButton() ? 60:45); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); @@ -1412,18 +1412,18 @@ void Notepad_plus::command(int id) TabBarPlus::setDbClk2Close(!TabBarPlus::isDbClk2Close()); break; } - + case IDM_VIEW_DRAWTABBAR_VERTICAL : { TabBarPlus::setVertical(!TabBarPlus::isVertical()); ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); break; } - + case IDM_VIEW_DRAWTABBAR_MULTILINE : { TabBarPlus::setMultiLine(!TabBarPlus::isMultiLine()); - ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); + ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); break; } @@ -1555,7 +1555,7 @@ void Notepad_plus::command(int id) case IDM_VIEW_SYNSCROLLV: { bool isSynScollV = !_syncInfo._isSynScollV; - + checkMenuItem(IDM_VIEW_SYNSCROLLV, isSynScollV); _toolBar.setCheck(IDM_VIEW_SYNSCROLLV, isSynScollV); @@ -1566,7 +1566,7 @@ void Notepad_plus::command(int id) int subCurrentLine = _subEditView.execute(SCI_GETFIRSTVISIBLELINE); _syncInfo._line = mainCurrentLine - subCurrentLine; } - + } break; @@ -1699,7 +1699,7 @@ void Notepad_plus::command(int id) case IDM_FORMAT_TOMAC : { Buffer * buf = _pEditView->getCurrentBuffer(); - + int f = int((id == IDM_FORMAT_TODOS)?SC_EOL_CRLF:(id == IDM_FORMAT_TOUNIX)?SC_EOL_LF:SC_EOL_CR); buf->setFormat((formatType)f); @@ -1708,7 +1708,7 @@ void Notepad_plus::command(int id) } case IDM_FORMAT_ANSI : - case IDM_FORMAT_UTF_8 : + case IDM_FORMAT_UTF_8 : case IDM_FORMAT_UCS_2BE : case IDM_FORMAT_UCS_2LE : case IDM_FORMAT_AS_UTF_8 : @@ -1723,7 +1723,7 @@ void Notepad_plus::command(int id) shoulBeDirty = buf->getUnicodeMode() != uni8Bit; um = uniCookie; break; - + case IDM_FORMAT_UTF_8: um = uniUTF8; break; @@ -1842,7 +1842,7 @@ void Notepad_plus::command(int id) case IDM_FORMAT_KOREAN_WIN : case IDM_FORMAT_EUC_KR : case IDM_FORMAT_TIS_620 : - case IDM_FORMAT_MAC_CYRILLIC : + case IDM_FORMAT_MAC_CYRILLIC : case IDM_FORMAT_KOI8U_CYRILLIC : case IDM_FORMAT_KOI8R_CYRILLIC : { @@ -1883,7 +1883,7 @@ void Notepad_plus::command(int id) TEXT("You should save the current modification.\rAll the saved modifications can not be undone.\r\rContinue?"), TEXT("Lose Undo Ability Waning"), MB_YESNO); - + if (answer == IDYES) { // Do nothing @@ -1906,7 +1906,7 @@ void Notepad_plus::command(int id) case IDM_FORMAT_CONV2_ANSI: case IDM_FORMAT_CONV2_AS_UTF_8: case IDM_FORMAT_CONV2_UTF_8: - case IDM_FORMAT_CONV2_UCS_2BE: + case IDM_FORMAT_CONV2_UCS_2BE: case IDM_FORMAT_CONV2_UCS_2LE: { int idEncoding = -1; @@ -1927,7 +1927,7 @@ void Notepad_plus::command(int id) { if (um == uni8Bit) return; - + // set scintilla to ANSI idEncoding = IDM_FORMAT_ANSI; } @@ -1978,7 +1978,7 @@ void Notepad_plus::command(int id) } break; } - + case IDM_FORMAT_CONV2_UCS_2BE: { if (encoding != -1) @@ -2001,7 +2001,7 @@ void Notepad_plus::command(int id) } break; } - + case IDM_FORMAT_CONV2_UCS_2LE: { if (encoding != -1) @@ -2037,8 +2037,8 @@ void Notepad_plus::command(int id) LPVOID clipboardData2 = ::GlobalLock(allocClipboardData); ::memcpy(clipboardData2, clipboardDataPtr, len); - ::GlobalUnlock(clipboardData); - ::GlobalUnlock(allocClipboardData); + ::GlobalUnlock(clipboardData); + ::GlobalUnlock(allocClipboardData); ::CloseClipboard(); _pEditView->saveCurrentPos(); @@ -2049,7 +2049,7 @@ void Notepad_plus::command(int id) _pEditView->execute(SCI_CLEARALL); // Change to the proper buffer, save buffer status - + ::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, idEncoding, 0); // Paste the texte, restore buffer status @@ -2058,7 +2058,7 @@ void Notepad_plus::command(int id) // Restore the previous clipboard data ::OpenClipboard(_pPublicInterface->getHSelf()); - ::EmptyClipboard(); + ::EmptyClipboard(); ::SetClipboardData(CF_TEXT, clipboardData2); ::CloseClipboard(); @@ -2106,7 +2106,7 @@ void Notepad_plus::command(int id) for (size_t i = 0, len = copiedFiles.size(); i < len ; ++i) { generic_string themeName(themeSwitcher.getThemeFromXmlFileName(copiedFiles[i].c_str())); - if (!themeSwitcher.themeNameExists(themeName.c_str())) + if (!themeSwitcher.themeNameExists(themeName.c_str())) { themeSwitcher.addThemeFromXml(copiedFiles[i].c_str()); if (_configStyleDlg.isCreated()) @@ -2134,7 +2134,7 @@ void Notepad_plus::command(int id) { bool isFirstTime = !_preference.isCreated(); _preference.doDialog(_nativeLangSpeaker.isRTL()); - + if (isFirstTime) { _nativeLangSpeaker.changePrefereceDlgLang(_preference); @@ -2209,7 +2209,7 @@ void Notepad_plus::command(int id) char author[maxSelLen+1] = ""; _pEditView->getSelectedText(author, maxSelLen + 1); int iQuote = getQuoteIndexFrom(author); - + if (iQuote == -1) { doAboutDlg = true; @@ -2229,7 +2229,7 @@ void Notepad_plus::command(int id) if (!::PathFileExists(noEasterEggsPath.c_str())) showQuoteFromIndex(iQuote); return; - } + } } if (doAboutDlg) { @@ -2444,7 +2444,7 @@ void Notepad_plus::command(int id) { int nbDoc = viewVisible(MAIN_VIEW)?_mainDocTab.nbItem():0; nbDoc += viewVisible(SUB_VIEW)?_subDocTab.nbItem():0; - + bool doTaskList = ((NppParameters::getInstance())->getNppGUI())._doTaskList; if (nbDoc > 1) { @@ -2455,7 +2455,7 @@ void Notepad_plus::command(int id) activateNextDoc(direction); } else - { + { TaskListDlg tld; HIMAGELIST hImgLst = _docTabIconList.getHandle(); tld.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst, direction); @@ -2507,7 +2507,7 @@ void Notepad_plus::command(int id) { WindowsDlg _windowsDlg; _windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab); - + const TiXmlNodeA *nativeLangA = _nativeLangSpeaker.getNativeLangA(); TiXmlNodeA *dlgNode = NULL; if (nativeLangA) @@ -2545,11 +2545,11 @@ void Notepad_plus::command(int id) if (!buf->isUntitled() || buf->docLength() != 0) { fileNew(); - } + } command(IDM_EDIT_PASTE); } break; - + case IDM_SYSTRAYPOPUP_OPENFILE: { NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); @@ -2687,7 +2687,7 @@ void Notepad_plus::command(int id) { int i = id - ID_MACRO; vector & theMacros = (NppParameters::getInstance())->getMacroList(); - macroPlayback(theMacros[i].getMacro()); + macroPlayback(theMacros[i].getMacro()); } else if ((id >= ID_USER_CMD) && (id < ID_USER_CMD_LIMIT)) { @@ -2707,7 +2707,7 @@ void Notepad_plus::command(int id) { _pluginsManager.relayNppMessages(WM_COMMAND, id, 0); } -/*UNLOAD +/*UNLOAD else if ((id >= ID_PLUGINS_REMOVING) && (id < ID_PLUGINS_REMOVING_END)) { int i = id - ID_PLUGINS_REMOVING; @@ -2716,11 +2716,11 @@ void Notepad_plus::command(int id) */ else if ((id >= IDM_WINDOW_MRU_FIRST) && (id <= IDM_WINDOW_MRU_LIMIT)) { - activateDoc(id-IDM_WINDOW_MRU_FIRST); + activateDoc(id-IDM_WINDOW_MRU_FIRST); } } - - if (_recordingMacro) + + if (_recordingMacro) switch (id) { case IDM_FILE_NEW : @@ -2817,15 +2817,15 @@ void Notepad_plus::command(int id) case IDM_VIEW_GOTO_ANOTHER_VIEW: case IDM_VIEW_SYNSCROLLV: case IDM_VIEW_SYNSCROLLH: - case IDM_VIEW_TAB1: - case IDM_VIEW_TAB2: - case IDM_VIEW_TAB3: - case IDM_VIEW_TAB4: - case IDM_VIEW_TAB5: - case IDM_VIEW_TAB6: - case IDM_VIEW_TAB7: - case IDM_VIEW_TAB8: - case IDM_VIEW_TAB9: + case IDM_VIEW_TAB1: + case IDM_VIEW_TAB2: + case IDM_VIEW_TAB3: + case IDM_VIEW_TAB4: + case IDM_VIEW_TAB5: + case IDM_VIEW_TAB6: + case IDM_VIEW_TAB7: + case IDM_VIEW_TAB8: + case IDM_VIEW_TAB9: case IDM_VIEW_TAB_NEXT: case IDM_VIEW_TAB_PREV: case IDC_PREV_DOC : diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 9e35b868..42fa8413 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -36,6 +36,10 @@ using namespace std; + + + + BOOL Notepad_plus::notify(SCNotification *notification) { //Important, keep track of which element generated the message @@ -44,7 +48,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) ScintillaEditView * notifyView = isFromPrimary?&_mainEditView:&_subEditView; DocTabView *notifyDocTab = isFromPrimary?&_mainDocTab:&_subDocTab; TBHDR * tabNotification = (TBHDR*) notification; - switch (notification->nmhdr.code) + switch (notification->nmhdr.code) { case SCN_MODIFIED: { @@ -65,7 +69,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (notification->modificationType & SC_MOD_CHANGEFOLD) { - if (prevWasEdit) + if (prevWasEdit) { notifyView->foldChanged(notification->line, notification->foldLevelNow, notification->foldLevelPrev); prevWasEdit = false; @@ -76,9 +80,8 @@ BOOL Notepad_plus::notify(SCNotification *notification) prevWasEdit = false; } - + break; } - break; case SCN_SAVEPOINTREACHED: case SCN_SAVEPOINTLEFT: @@ -96,7 +99,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) { //Done by invisibleEditView? BufferID id = BUFFER_INVALID; - if (notification->nmhdr.hwndFrom == _invisibleEditView.getHSelf()) + if (notification->nmhdr.hwndFrom == _invisibleEditView.getHSelf()) { id = MainFileManager->getBufferFromDocument(_invisibleEditView.execute(SCI_GETDOCPOINTER)); } @@ -104,20 +107,17 @@ BOOL Notepad_plus::notify(SCNotification *notification) { id = MainFileManager->getBufferFromDocument(_fileEditView.execute(SCI_GETDOCPOINTER)); } - else - { + else break; //wrong scintilla - } if (id != BUFFER_INVALID) { buf = MainFileManager->getBufferByID(id); } else - { break; - } } + bool isDirty = notification->nmhdr.code == SCN_SAVEPOINTLEFT; bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode(); if (isSnapshotMode && !isDirty) @@ -127,805 +127,814 @@ BOOL Notepad_plus::notify(SCNotification *notification) isDirty = true; } buf->setDirty(isDirty); - break; + break; } - case SCN_MODIFYATTEMPTRO : - // on fout rien + case SCN_MODIFYATTEMPTRO: + { + // nothing to do break; + } case SCN_KEY: + { break; + } - case TCN_TABDROPPEDOUTSIDE: - case TCN_TABDROPPED: - { - TabBarPlus *sender = reinterpret_cast(notification->nmhdr.idFrom); - bool isInCtrlStat = (::GetKeyState(VK_LCONTROL) & 0x80000000) != 0; - if (notification->nmhdr.code == TCN_TABDROPPEDOUTSIDE) - { - POINT p = sender->getDraggingPoint(); - - //It's the coordinate of screen, so we can call - //"WindowFromPoint" function without converting the point - HWND hWin = ::WindowFromPoint(p); - if (hWin == _pEditView->getHSelf()) // In the same view group + case TCN_TABDROPPEDOUTSIDE: + case TCN_TABDROPPED: + { + TabBarPlus *sender = reinterpret_cast(notification->nmhdr.idFrom); + bool isInCtrlStat = (::GetKeyState(VK_LCONTROL) & 0x80000000) != 0; + if (notification->nmhdr.code == TCN_TABDROPPEDOUTSIDE) { - if (!_tabPopupDropMenu.isCreated()) + POINT p = sender->getDraggingPoint(); + + //It's the coordinate of screen, so we can call + //"WindowFromPoint" function without converting the point + HWND hWin = ::WindowFromPoint(p); + if (hWin == _pEditView->getHSelf()) // In the same view group { - TCHAR goToView[32] = TEXT("Move to other view"); - TCHAR cloneToView[32] = TEXT("Clone to other View"); - vector itemUnitArray; - itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_ANOTHER_VIEW, goToView)); - itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_CLONE_TO_ANOTHER_VIEW, cloneToView)); - _tabPopupDropMenu.create(_pPublicInterface->getHSelf(), itemUnitArray, _mainMenuHandle); - _nativeLangSpeaker.changeLangTabDrapContextMenu(_tabPopupDropMenu.getMenuHandle()); + if (!_tabPopupDropMenu.isCreated()) + { + TCHAR goToView[32] = TEXT("Move to other view"); + TCHAR cloneToView[32] = TEXT("Clone to other View"); + vector itemUnitArray; + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_ANOTHER_VIEW, goToView)); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_CLONE_TO_ANOTHER_VIEW, cloneToView)); + _tabPopupDropMenu.create(_pPublicInterface->getHSelf(), itemUnitArray, _mainMenuHandle); + _nativeLangSpeaker.changeLangTabDrapContextMenu(_tabPopupDropMenu.getMenuHandle()); + } + _tabPopupDropMenu.display(p); + } + else if ((hWin == _pNonDocTab->getHSelf()) || + (hWin == _pNonEditView->getHSelf())) // In the another view group + { + docGotoAnotherEditView(isInCtrlStat?TransferClone:TransferMove); + } + else + { + RECT nppZone; + ::GetWindowRect(_pPublicInterface->getHSelf(), &nppZone); + bool isInNppZone = (((p.x >= nppZone.left) && (p.x <= nppZone.right)) && (p.y >= nppZone.top) && (p.y <= nppZone.bottom)); + if (isInNppZone) + { + // Do nothing + return TRUE; + } + generic_string quotFileName = TEXT("\""); + quotFileName += _pEditView->getCurrentBuffer()->getFullPathName(); + quotFileName += TEXT("\""); + COPYDATASTRUCT fileNamesData; + fileNamesData.dwData = COPYDATA_FILENAMES; + fileNamesData.lpData = (void *)quotFileName.c_str(); + fileNamesData.cbData = long(quotFileName.length() + 1)*(sizeof(TCHAR)); + + HWND hWinParent = ::GetParent(hWin); + const rsize_t classNameBufferSize = MAX_PATH; + TCHAR className[classNameBufferSize]; + ::GetClassName(hWinParent,className, classNameBufferSize); + if (lstrcmp(className, _pPublicInterface->getClassName()) == 0 && hWinParent != _pPublicInterface->getHSelf()) // another Notepad++ + { + int index = _pDocTab->getCurrentTabIndex(); + BufferID bufferToClose = notifyDocTab->getBufferByIndex(index); + Buffer * buf = MainFileManager->getBufferByID(bufferToClose); + int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW; + if (buf->isDirty()) + { + generic_string msg, title; + _nativeLangSpeaker.messageBox("CannotMoveDoc", + _pPublicInterface->getHSelf(), + TEXT("Document is modified, save it then try again."), + TEXT("Move to new Notepad++ Instance"), + MB_OK); + } + else + { + ::SendMessage(hWinParent, NPPM_INTERNAL_SWITCHVIEWFROMHWND, 0, (LPARAM)hWin); + ::SendMessage(hWinParent, WM_COPYDATA, (WPARAM)_pPublicInterface->getHinst(), (LPARAM)&fileNamesData); + if (!isInCtrlStat) + { + fileClose(bufferToClose, iView); + if (noOpenedDoc()) + ::SendMessage(_pPublicInterface->getHSelf(), WM_CLOSE, 0, 0); + } + } + } + else // Not Notepad++, we open it here + { + docOpenInNewInstance(isInCtrlStat?TransferClone:TransferMove, p.x, p.y); + } } - _tabPopupDropMenu.display(p); } - else if ((hWin == _pNonDocTab->getHSelf()) || - (hWin == _pNonEditView->getHSelf())) // In the another view group + //break; + sender->resetDraggingPoint(); + return TRUE; + } + + case TCN_TABDELETE: + { + int index = tabNotification->tabOrigin; + BufferID bufferToClose = notifyDocTab->getBufferByIndex(index); + Buffer * buf = MainFileManager->getBufferByID(bufferToClose); + int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW; + if (buf->isDirty()) { - docGotoAnotherEditView(isInCtrlStat?TransferClone:TransferMove); + activateBuffer(bufferToClose, iView); + } + fileClose(bufferToClose, iView); + break; + } + + case TCN_SELCHANGE: + { + int iView = -1; + if (notification->nmhdr.hwndFrom == _mainDocTab.getHSelf()) + { + iView = MAIN_VIEW; + } + else if (notification->nmhdr.hwndFrom == _subDocTab.getHSelf()) + { + iView = SUB_VIEW; } else + break; + + switchEditViewTo(iView); + BufferID bufid = _pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex()); + if (bufid != BUFFER_INVALID) + activateBuffer(bufid, iView); + + break; + } + + case NM_CLICK : + { + if (notification->nmhdr.hwndFrom == _statusBar.getHSelf()) { - RECT nppZone; - ::GetWindowRect(_pPublicInterface->getHSelf(), &nppZone); - bool isInNppZone = (((p.x >= nppZone.left) && (p.x <= nppZone.right)) && (p.y >= nppZone.top) && (p.y <= nppZone.bottom)); - if (isInNppZone) + LPNMMOUSE lpnm = (LPNMMOUSE)notification; + if (lpnm->dwItemSpec == DWORD(STATUSBAR_TYPING_MODE)) { - // Do nothing + bool isOverTypeMode = (_pEditView->execute(SCI_GETOVERTYPE) != 0); + _pEditView->execute(SCI_SETOVERTYPE, !isOverTypeMode); + _statusBar.setText((_pEditView->execute(SCI_GETOVERTYPE))?TEXT("OVR"):TEXT("INS"), STATUSBAR_TYPING_MODE); + } + } + else if (notification->nmhdr.hwndFrom == _mainDocTab.getHSelf() && _activeView == SUB_VIEW) + { + bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode(); + if (isSnapshotMode) + { + // Before switching off, synchronize backup file + MainFileManager->backupCurrentBuffer(); + } + // Switch off + switchEditViewTo(MAIN_VIEW); + } + else if (notification->nmhdr.hwndFrom == _subDocTab.getHSelf() && _activeView == MAIN_VIEW) + { + bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode(); + if (isSnapshotMode) + { + // Before switching off, synchronize backup file + MainFileManager->backupCurrentBuffer(); + } + // Switch off + switchEditViewTo(SUB_VIEW); + } + + break; + } + + case NM_DBLCLK : + { + if (notification->nmhdr.hwndFrom == _statusBar.getHSelf()) + { + LPNMMOUSE lpnm = (LPNMMOUSE)notification; + if (lpnm->dwItemSpec == DWORD(STATUSBAR_CUR_POS)) + { + bool isFirstTime = !_goToLineDlg.isCreated(); + _goToLineDlg.doDialog(_nativeLangSpeaker.isRTL()); + if (isFirstTime) + _nativeLangSpeaker.changeDlgLang(_goToLineDlg.getHSelf(), "GoToLine"); + } + else if (lpnm->dwItemSpec == DWORD(STATUSBAR_DOC_SIZE)) + { + command(IDM_VIEW_SUMMARY); + } + else if (lpnm->dwItemSpec == DWORD(STATUSBAR_DOC_TYPE)) + { + POINT p; + ::GetCursorPos(&p); + HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE); + TrackPopupMenu(hLangMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); + } + else if (lpnm->dwItemSpec == DWORD(STATUSBAR_EOF_FORMAT)) + { + POINT p; + ::GetCursorPos(&p); + MenuPosition & menuPos = getMenuPosition("edit-eolConversion"); + HMENU hEditMenu = ::GetSubMenu(_mainMenuHandle, menuPos._x); + if (!hEditMenu) + return TRUE; + HMENU hEolFormatMenu = ::GetSubMenu(hEditMenu, menuPos._y); + if (!hEolFormatMenu) + return TRUE; + TrackPopupMenu(hEolFormatMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); + } + } + break; + } + + case NM_RCLICK : + { + POINT p; + ::GetCursorPos(&p); + + if (notification->nmhdr.hwndFrom == _mainDocTab.getHSelf()) + { + switchEditViewTo(MAIN_VIEW); + } + else if (notification->nmhdr.hwndFrom == _subDocTab.getHSelf()) + { + switchEditViewTo(SUB_VIEW); + } + else if (notification->nmhdr.hwndFrom == _statusBar.getHSelf()) // From Status Bar + { + LPNMMOUSE lpnm = (LPNMMOUSE)notification; + if (lpnm->dwItemSpec == DWORD(STATUSBAR_DOC_TYPE)) + { + POINT p; + ::GetCursorPos(&p); + HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE); + TrackPopupMenu(hLangMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); + } + else if (lpnm->dwItemSpec == DWORD(STATUSBAR_EOF_FORMAT)) + { + POINT p; + ::GetCursorPos(&p); + MenuPosition & menuPos = getMenuPosition("edit-eolConversion"); + HMENU hEditMenu = ::GetSubMenu(_mainMenuHandle, menuPos._x); + if (!hEditMenu) + return TRUE; + HMENU hEolFormatMenu = ::GetSubMenu(hEditMenu, menuPos._y); + if (!hEolFormatMenu) + return TRUE; + TrackPopupMenu(hEolFormatMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); + } + return TRUE; + } + else if (_pFileSwitcherPanel && notification->nmhdr.hwndFrom == _pFileSwitcherPanel->getHSelf()) + { + // Already switched, so do nothing here. + + if (_pFileSwitcherPanel->nbSelectedFiles() > 1) + { + if (!_fileSwitcherMultiFilePopupMenu.isCreated()) + { + vector itemUnitArray; + itemUnitArray.push_back(MenuItemUnit(IDM_FILESWITCHER_FILESCLOSE, TEXT("Close Selected files"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILESWITCHER_FILESCLOSEOTHERS, TEXT("Close others files"))); + + _fileSwitcherMultiFilePopupMenu.create(_pPublicInterface->getHSelf(), itemUnitArray); + _nativeLangSpeaker.changeLangTabContextMenu(_fileSwitcherMultiFilePopupMenu.getMenuHandle()); + } + _fileSwitcherMultiFilePopupMenu.display(p); return TRUE; } - generic_string quotFileName = TEXT("\""); - quotFileName += _pEditView->getCurrentBuffer()->getFullPathName(); - quotFileName += TEXT("\""); - COPYDATASTRUCT fileNamesData; - fileNamesData.dwData = COPYDATA_FILENAMES; - fileNamesData.lpData = (void *)quotFileName.c_str(); - fileNamesData.cbData = long(quotFileName.length() + 1)*(sizeof(TCHAR)); + } + else // From tool bar + return TRUE; + //break; - HWND hWinParent = ::GetParent(hWin); - const rsize_t classNameBufferSize = MAX_PATH; - TCHAR className[classNameBufferSize]; - ::GetClassName(hWinParent,className, classNameBufferSize); - if (lstrcmp(className, _pPublicInterface->getClassName()) == 0 && hWinParent != _pPublicInterface->getHSelf()) // another Notepad++ + if (!_tabPopupMenu.isCreated()) + { + std::vector itemUnitArray; + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSE, TEXT("Close"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_BUT_CURRENT, TEXT("Close All BUT This"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_TOLEFT, TEXT("Close All to the Left"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_TORIGHT, TEXT("Close All to the Right"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_SAVE, TEXT("Save"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_SAVEAS, TEXT("Save As..."))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_RENAME, TEXT("Rename"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_DELETE, TEXT("Move to Recycle Bin"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_RELOAD, TEXT("Reload"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_PRINT, TEXT("Print"))); + itemUnitArray.push_back(MenuItemUnit(0, NULL)); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_FOLDER, TEXT("Open Containing Folder in Explorer"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_CMD, TEXT("Open Containing Folder in cmd"))); + itemUnitArray.push_back(MenuItemUnit(0, NULL)); + itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_SETREADONLY, TEXT("Read-Only"))); + itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_CLEARREADONLY, TEXT("Clear Read-Only Flag"))); + itemUnitArray.push_back(MenuItemUnit(0, NULL)); + itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_FULLPATHTOCLIP, TEXT("Full File Path to Clipboard"))); + itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_FILENAMETOCLIP, TEXT("Filename to Clipboard"))); + itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_CURRENTDIRTOCLIP, TEXT("Current Dir. Path to Clipboard"))); + itemUnitArray.push_back(MenuItemUnit(0, NULL)); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_ANOTHER_VIEW, TEXT("Move to Other View"))); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_CLONE_TO_ANOTHER_VIEW, TEXT("Clone to Other View"))); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_NEW_INSTANCE, TEXT("Move to New Instance"))); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_LOAD_IN_NEW_INSTANCE, TEXT("Open in New Instance"))); + + _tabPopupMenu.create(_pPublicInterface->getHSelf(), itemUnitArray); + _nativeLangSpeaker.changeLangTabContextMenu(_tabPopupMenu.getMenuHandle()); + } + + bool isEnable = ((::GetMenuState(_mainMenuHandle, IDM_FILE_SAVE, MF_BYCOMMAND)&MF_DISABLED) == 0); + _tabPopupMenu.enableItem(IDM_FILE_SAVE, isEnable); + + Buffer * buf = _pEditView->getCurrentBuffer(); + bool isUserReadOnly = buf->getUserReadOnly(); + _tabPopupMenu.checkItem(IDM_EDIT_SETREADONLY, isUserReadOnly); + + bool isSysReadOnly = buf->getFileReadOnly(); + _tabPopupMenu.enableItem(IDM_EDIT_SETREADONLY, !isSysReadOnly); + _tabPopupMenu.enableItem(IDM_EDIT_CLEARREADONLY, isSysReadOnly); + + bool isFileExisting = PathFileExists(buf->getFullPathName()) != FALSE; + _tabPopupMenu.enableItem(IDM_FILE_DELETE, isFileExisting); + _tabPopupMenu.enableItem(IDM_FILE_RENAME, isFileExisting); + + bool isDirty = buf->isDirty(); + bool isUntitled = buf->isUntitled(); + _tabPopupMenu.enableItem(IDM_VIEW_GOTO_NEW_INSTANCE, !(isDirty||isUntitled)); + _tabPopupMenu.enableItem(IDM_VIEW_LOAD_IN_NEW_INSTANCE, !(isDirty||isUntitled)); + + _tabPopupMenu.display(p); + return TRUE; + } + + + case SCN_MARGINCLICK: + { + if (notification->nmhdr.hwndFrom == _mainEditView.getHSelf()) + switchEditViewTo(MAIN_VIEW); + else if (notification->nmhdr.hwndFrom == _subEditView.getHSelf()) + switchEditViewTo(SUB_VIEW); + + int lineClick = int(_pEditView->execute(SCI_LINEFROMPOSITION, notification->position)); + + if (notification->margin == ScintillaEditView::_SC_MARGE_FOLDER) + { + _pEditView->marginClick(notification->position, notification->modifiers); + if (_pDocMap) + _pDocMap->fold(lineClick, _pEditView->isFolded(lineClick)); + } + else if ((notification->margin == ScintillaEditView::_SC_MARGE_SYBOLE) && !notification->modifiers) + { + if (!_pEditView->markerMarginClick(lineClick)) + bookmarkToggle(lineClick); + } + break; + } + + case SCN_FOLDINGSTATECHANGED : + { + if ((notification->nmhdr.hwndFrom == _mainEditView.getHSelf()) || (notification->nmhdr.hwndFrom == _subEditView.getHSelf())) + { + int lineClicked = notification->line; + + if (!_isFolding) { - int index = _pDocTab->getCurrentTabIndex(); - BufferID bufferToClose = notifyDocTab->getBufferByIndex(index); - Buffer * buf = MainFileManager->getBufferByID(bufferToClose); - int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW; - if (buf->isDirty()) + int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; + if ((urlAction == 1) || (urlAction == 2)) + addHotSpot(); + } + + if (_pDocMap) + _pDocMap->fold(lineClicked, _pEditView->isFolded(lineClicked)); + } + return TRUE; + } + + case SCN_CHARADDED: + { + const NppGUI & nppGui = NppParameters::getInstance()->getNppGUI(); + bool indentMaintain = nppGui._maitainIndent; + if (indentMaintain) + maintainIndentation(static_cast(notification->ch)); + + AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; + bool isColumnMode = _pEditView->execute(SCI_GETSELECTIONS) > 1; // Multi-Selection || Column mode) + if (nppGui._matchedPairConf.hasAnyPairsPair() && !isColumnMode) + autoC->insertMatchedChars(notification->ch, nppGui._matchedPairConf); + autoC->update(notification->ch); + + break; + } + + case SCN_DOUBLECLICK: + { + if (notification->modifiers == SCMOD_CTRL) + { + const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI(); + + std::string bufstring; + + unsigned int position_of_click; + // For some reason Ctrl+DoubleClick on an empty line means that notification->position == 1. + // In that case we use SCI_GETCURRENTPOS to get the position. + if (notification->position != -1) + position_of_click = notification->position; + else + position_of_click = int(_pEditView->execute(SCI_GETCURRENTPOS)); + + // Anonymous scope to limit use of the buf pointer (much easier to deal with std::string). + { + char *buf; + int length; + + if (nppGUI._delimiterSelectionOnEntireDocument) { - generic_string msg, title; - _nativeLangSpeaker.messageBox("CannotMoveDoc", - _pPublicInterface->getHSelf(), - TEXT("Document is modified, save it then try again."), - TEXT("Move to new Notepad++ Instance"), - MB_OK); + // Get entire document. + length = notifyView->execute(SCI_GETLENGTH); + buf = new char[length + 1]; + notifyView->execute(SCI_GETTEXT, (LPARAM)(length + 1), (WPARAM)buf); } else { - ::SendMessage(hWinParent, NPPM_INTERNAL_SWITCHVIEWFROMHWND, 0, (LPARAM)hWin); - ::SendMessage(hWinParent, WM_COPYDATA, (WPARAM)_pPublicInterface->getHinst(), (LPARAM)&fileNamesData); - if (!isInCtrlStat) + // Get single line. + length = notifyView->execute(SCI_GETCURLINE); + buf = new char[length + 1]; + notifyView->execute(SCI_GETCURLINE, (WPARAM)length, (LPARAM)buf); + + // Compute the position of the click (relative to the beginning of the line). + const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber()); + position_of_click = position_of_click - line_position; + } + + bufstring = buf; + delete [] buf; + } + + int leftmost_position = -1; + int rightmost_position = -1; + + if (nppGUI._rightmostDelimiter == nppGUI._leftmostDelimiter) + { + // If the delimiters are the same (e.g. they are both a quotation mark), choose the ones + // which are closest to the clicked position. + for (int i = position_of_click; i >= 0; --i) + { + if (bufstring.at(i) == nppGUI._leftmostDelimiter) { - fileClose(bufferToClose, iView); - if (noOpenedDoc()) - ::SendMessage(_pPublicInterface->getHSelf(), WM_CLOSE, 0, 0); + // Respect escaped quotation marks. + if (nppGUI._leftmostDelimiter == '"') + { + if (! (i > 0 && bufstring.at(i - 1) == '\\')) + { + leftmost_position = i; + break; + } + } + else + { + leftmost_position = i; + break; + } + } + } + + if (leftmost_position == -1) + break; + + // Scan for right delimiter. + for (unsigned int i = position_of_click; i < bufstring.length(); ++i) + { + if (bufstring.at(i) == nppGUI._rightmostDelimiter) + { + // Respect escaped quotation marks. + if (nppGUI._rightmostDelimiter == '"') + { + if (! (i > 0 && bufstring.at(i - 1) == '\\')) + { + rightmost_position = i; + break; + } + } + else + { + rightmost_position = i; + break; + } } } } - else // Not Notepad++, we open it here - { - docOpenInNewInstance(isInCtrlStat?TransferClone:TransferMove, p.x, p.y); - } + else + { + // Find matching pairs of delimiters (e.g. parantheses). + // The pair where the distance from the left delimiter to position_of_click is at a minimum is the one we're looking for. + // Of course position_of_click must lie between the delimiters. + + // This logic is required to handle cases like this: + // (size_t i = function(); i < _buffers.size(); i++) + + std::stack leftmost_delimiter_positions; + + for (unsigned int i = 0; i < bufstring.length(); ++i) + { + if (bufstring.at(i) == nppGUI._leftmostDelimiter) + leftmost_delimiter_positions.push(i); + else if (bufstring.at(i) == nppGUI._rightmostDelimiter && ! leftmost_delimiter_positions.empty()) + { + unsigned int matching_leftmost = leftmost_delimiter_positions.top(); + leftmost_delimiter_positions.pop(); + + // We have either 1) chosen neither the left- or rightmost position, or 2) chosen both left- and rightmost position. + assert( (leftmost_position == -1 && rightmost_position == -1) || (leftmost_position >= 0 && rightmost_position >= 0) ); + + // Note: cast of leftmost_position to unsigned int is safe, since if leftmost_position is not -1 then it is guaranteed to be positive. + // If it was possible, leftmost_position and rightmost_position should be of type optional. + if ( matching_leftmost <= position_of_click && i >= position_of_click && (leftmost_position == -1 || matching_leftmost > (unsigned int)leftmost_position) ) + { + leftmost_position = matching_leftmost; + rightmost_position = i; + } + } + } + } + + // Set selection to the position we found (if any). + if (rightmost_position != -1 && leftmost_position != -1) + { + if (nppGUI._delimiterSelectionOnEntireDocument) + { + notifyView->execute(SCI_SETCURRENTPOS, rightmost_position); + notifyView->execute(SCI_SETANCHOR, leftmost_position + 1); + } + else + { + const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber()); + notifyView->execute(SCI_SETCURRENTPOS, line_position + rightmost_position); + notifyView->execute(SCI_SETANCHOR, line_position + leftmost_position + 1); + } + } + } + else if (_isHotspotDblClicked) + { + int pos = notifyView->execute(SCI_GETCURRENTPOS); + notifyView->execute(SCI_SETCURRENTPOS, pos); + notifyView->execute(SCI_SETANCHOR, pos); + _isHotspotDblClicked = false; } - } - //break; - sender->resetDraggingPoint(); - return TRUE; - } - case TCN_TABDELETE: - { - int index = tabNotification->tabOrigin; - BufferID bufferToClose = notifyDocTab->getBufferByIndex(index); - Buffer * buf = MainFileManager->getBufferByID(bufferToClose); - int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW; - if (buf->isDirty()) - { - activateBuffer(bufferToClose, iView); - } - fileClose(bufferToClose, iView); - break; - } - - case TCN_SELCHANGE: - { - int iView = -1; - if (notification->nmhdr.hwndFrom == _mainDocTab.getHSelf()) - { - iView = MAIN_VIEW; - } - else if (notification->nmhdr.hwndFrom == _subDocTab.getHSelf()) - { - iView = SUB_VIEW; - } - else - { break; } - switchEditViewTo(iView); - BufferID bufid = _pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex()); - if (bufid != BUFFER_INVALID) - activateBuffer(bufid, iView); - - break; - } - - case NM_CLICK : - { - if (notification->nmhdr.hwndFrom == _statusBar.getHSelf()) - { - LPNMMOUSE lpnm = (LPNMMOUSE)notification; - if (lpnm->dwItemSpec == DWORD(STATUSBAR_TYPING_MODE)) - { - bool isOverTypeMode = (_pEditView->execute(SCI_GETOVERTYPE) != 0); - _pEditView->execute(SCI_SETOVERTYPE, !isOverTypeMode); - _statusBar.setText((_pEditView->execute(SCI_GETOVERTYPE))?TEXT("OVR"):TEXT("INS"), STATUSBAR_TYPING_MODE); - } - } - else if (notification->nmhdr.hwndFrom == _mainDocTab.getHSelf() && _activeView == SUB_VIEW) + case SCN_UPDATEUI: { - bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode(); - if (isSnapshotMode) - { - // Before switching off, synchronize backup file - MainFileManager->backupCurrentBuffer(); - } - // Switch off - switchEditViewTo(MAIN_VIEW); - } - else if (notification->nmhdr.hwndFrom == _subDocTab.getHSelf() && _activeView == MAIN_VIEW) - { - bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode(); - if (isSnapshotMode) - { - // Before switching off, synchronize backup file - MainFileManager->backupCurrentBuffer(); - } - // Switch off - switchEditViewTo(SUB_VIEW); - } + NppParameters *nppParam = NppParameters::getInstance(); - break; - } - - case NM_DBLCLK : - { - if (notification->nmhdr.hwndFrom == _statusBar.getHSelf()) - { - LPNMMOUSE lpnm = (LPNMMOUSE)notification; - if (lpnm->dwItemSpec == DWORD(STATUSBAR_CUR_POS)) - { - bool isFirstTime = !_goToLineDlg.isCreated(); - _goToLineDlg.doDialog(_nativeLangSpeaker.isRTL()); - if (isFirstTime) - _nativeLangSpeaker.changeDlgLang(_goToLineDlg.getHSelf(), "GoToLine"); - } - else if (lpnm->dwItemSpec == DWORD(STATUSBAR_DOC_SIZE)) - { - command(IDM_VIEW_SUMMARY); - } - else if (lpnm->dwItemSpec == DWORD(STATUSBAR_DOC_TYPE)) - { - POINT p; - ::GetCursorPos(&p); - HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE); - TrackPopupMenu(hLangMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); - } - else if (lpnm->dwItemSpec == DWORD(STATUSBAR_EOF_FORMAT)) - { - POINT p; - ::GetCursorPos(&p); - MenuPosition & menuPos = getMenuPosition("edit-eolConversion"); - HMENU hEditMenu = ::GetSubMenu(_mainMenuHandle, menuPos._x); - if (!hEditMenu) - return TRUE; - HMENU hEolFormatMenu = ::GetSubMenu(hEditMenu, menuPos._y); - if (!hEolFormatMenu) - return TRUE; - TrackPopupMenu(hEolFormatMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); - } - } - break; - } - - case NM_RCLICK : - { - POINT p; - ::GetCursorPos(&p); - - if (notification->nmhdr.hwndFrom == _mainDocTab.getHSelf()) - { - switchEditViewTo(MAIN_VIEW); - } - else if (notification->nmhdr.hwndFrom == _subDocTab.getHSelf()) - { - switchEditViewTo(SUB_VIEW); - } - else if (notification->nmhdr.hwndFrom == _statusBar.getHSelf()) // From Status Bar - { - LPNMMOUSE lpnm = (LPNMMOUSE)notification; - if (lpnm->dwItemSpec == DWORD(STATUSBAR_DOC_TYPE)) - { - POINT p; - ::GetCursorPos(&p); - HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE); - TrackPopupMenu(hLangMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); - } - else if (lpnm->dwItemSpec == DWORD(STATUSBAR_EOF_FORMAT)) - { - POINT p; - ::GetCursorPos(&p); - MenuPosition & menuPos = getMenuPosition("edit-eolConversion"); - HMENU hEditMenu = ::GetSubMenu(_mainMenuHandle, menuPos._x); - if (!hEditMenu) - return TRUE; - HMENU hEolFormatMenu = ::GetSubMenu(hEditMenu, menuPos._y); - if (!hEolFormatMenu) - return TRUE; - TrackPopupMenu(hEolFormatMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); - } - return TRUE; - } - else if (_pFileSwitcherPanel && notification->nmhdr.hwndFrom == _pFileSwitcherPanel->getHSelf()) - { - // Already switched, so do nothing here. - - if (_pFileSwitcherPanel->nbSelectedFiles() > 1) - { - if (!_fileSwitcherMultiFilePopupMenu.isCreated()) - { - vector itemUnitArray; - itemUnitArray.push_back(MenuItemUnit(IDM_FILESWITCHER_FILESCLOSE, TEXT("Close Selected files"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILESWITCHER_FILESCLOSEOTHERS, TEXT("Close others files"))); - - _fileSwitcherMultiFilePopupMenu.create(_pPublicInterface->getHSelf(), itemUnitArray); - _nativeLangSpeaker.changeLangTabContextMenu(_fileSwitcherMultiFilePopupMenu.getMenuHandle()); - } - _fileSwitcherMultiFilePopupMenu.display(p); - return TRUE; - } - } - else // From tool bar - return TRUE; - //break; - - if (!_tabPopupMenu.isCreated()) - { - vector itemUnitArray; - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSE, TEXT("Close"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_BUT_CURRENT, TEXT("Close All BUT This"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_TOLEFT, TEXT("Close All to the Left"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_TORIGHT, TEXT("Close All to the Right"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_SAVE, TEXT("Save"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_SAVEAS, TEXT("Save As..."))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_RENAME, TEXT("Rename"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_DELETE, TEXT("Move to Recycle Bin"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_RELOAD, TEXT("Reload"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_PRINT, TEXT("Print"))); - itemUnitArray.push_back(MenuItemUnit(0, NULL)); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_FOLDER, TEXT("Open Containing Folder in Explorer"))); - itemUnitArray.push_back(MenuItemUnit(IDM_FILE_OPEN_CMD, TEXT("Open Containing Folder in cmd"))); - itemUnitArray.push_back(MenuItemUnit(0, NULL)); - itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_SETREADONLY, TEXT("Read-Only"))); - itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_CLEARREADONLY, TEXT("Clear Read-Only Flag"))); - itemUnitArray.push_back(MenuItemUnit(0, NULL)); - itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_FULLPATHTOCLIP, TEXT("Full File Path to Clipboard"))); - itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_FILENAMETOCLIP, TEXT("Filename to Clipboard"))); - itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_CURRENTDIRTOCLIP, TEXT("Current Dir. Path to Clipboard"))); - itemUnitArray.push_back(MenuItemUnit(0, NULL)); - itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_ANOTHER_VIEW, TEXT("Move to Other View"))); - itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_CLONE_TO_ANOTHER_VIEW, TEXT("Clone to Other View"))); - itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_NEW_INSTANCE, TEXT("Move to New Instance"))); - itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_LOAD_IN_NEW_INSTANCE, TEXT("Open in New Instance"))); - - _tabPopupMenu.create(_pPublicInterface->getHSelf(), itemUnitArray); - _nativeLangSpeaker.changeLangTabContextMenu(_tabPopupMenu.getMenuHandle()); - } - - bool isEnable = ((::GetMenuState(_mainMenuHandle, IDM_FILE_SAVE, MF_BYCOMMAND)&MF_DISABLED) == 0); - _tabPopupMenu.enableItem(IDM_FILE_SAVE, isEnable); - - Buffer * buf = _pEditView->getCurrentBuffer(); - bool isUserReadOnly = buf->getUserReadOnly(); - _tabPopupMenu.checkItem(IDM_EDIT_SETREADONLY, isUserReadOnly); - - bool isSysReadOnly = buf->getFileReadOnly(); - _tabPopupMenu.enableItem(IDM_EDIT_SETREADONLY, !isSysReadOnly); - _tabPopupMenu.enableItem(IDM_EDIT_CLEARREADONLY, isSysReadOnly); - - bool isFileExisting = PathFileExists(buf->getFullPathName()) != FALSE; - _tabPopupMenu.enableItem(IDM_FILE_DELETE, isFileExisting); - _tabPopupMenu.enableItem(IDM_FILE_RENAME, isFileExisting); - - bool isDirty = buf->isDirty(); - bool isUntitled = buf->isUntitled(); - _tabPopupMenu.enableItem(IDM_VIEW_GOTO_NEW_INSTANCE, !(isDirty||isUntitled)); - _tabPopupMenu.enableItem(IDM_VIEW_LOAD_IN_NEW_INSTANCE, !(isDirty||isUntitled)); - - _tabPopupMenu.display(p); - return TRUE; - } - - - case SCN_MARGINCLICK: - { - if (notification->nmhdr.hwndFrom == _mainEditView.getHSelf()) - switchEditViewTo(MAIN_VIEW); - else if (notification->nmhdr.hwndFrom == _subEditView.getHSelf()) - switchEditViewTo(SUB_VIEW); - - int lineClick = int(_pEditView->execute(SCI_LINEFROMPOSITION, notification->position)); - - if (notification->margin == ScintillaEditView::_SC_MARGE_FOLDER) - { - _pEditView->marginClick(notification->position, notification->modifiers); - if (_pDocMap) - _pDocMap->fold(lineClick, _pEditView->isFolded(lineClick)); - } - else if ((notification->margin == ScintillaEditView::_SC_MARGE_SYBOLE) && !notification->modifiers) - { - if (!_pEditView->markerMarginClick(lineClick)) - bookmarkToggle(lineClick); - } - break; - } - - case SCN_FOLDINGSTATECHANGED : - { - if ((notification->nmhdr.hwndFrom == _mainEditView.getHSelf()) - || (notification->nmhdr.hwndFrom == _subEditView.getHSelf())) - { - int lineClicked = notification->line; - - if (!_isFolding) + // replacement for obsolete custom SCN_SCROLLED + if (notification->updated & SC_UPDATE_V_SCROLL) { int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; if ((urlAction == 1) || (urlAction == 2)) addHotSpot(); } + // if it's searching/replacing, then do nothing + if (nppParam->_isFindReplacing) + break; + + if (notification->nmhdr.hwndFrom != _pEditView->getHSelf()) + break; + + braceMatch(); + + NppGUI & nppGui = (NppGUI &)nppParam->getNppGUI(); + + if (nppGui._enableTagsMatchHilite) + { + XmlMatchedTagsHighlighter xmlTagMatchHiliter(_pEditView); + xmlTagMatchHiliter.tagMatch(nppGui._enableTagAttrsHilite); + } + + if (nppGui._enableSmartHilite) + { + if (nppGui._disableSmartHiliteTmp) + nppGui._disableSmartHiliteTmp = false; + else + _smartHighlighter.highlightView(notifyView); + } + + updateStatusBar(); + AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; + autoC->update(0); + + break; + } + + case TTN_GETDISPINFO: + { + try + { + LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)notification; + + //Joce's fix + lpttt->hinst = NULL; + + POINT p; + ::GetCursorPos(&p); + ::ScreenToClient(_pPublicInterface->getHSelf(), &p); + HWND hWin = ::RealChildWindowFromPoint(_pPublicInterface->getHSelf(), p); + const int tipMaxLen = 1024; + static TCHAR docTip[tipMaxLen]; + docTip[0] = '\0'; + + generic_string tipTmp(TEXT("")); + int id = int(lpttt->hdr.idFrom); + + if (hWin == _rebarTop.getHSelf()) + { + getNameStrFromCmd(id, tipTmp); + if (tipTmp.length() >= 80) + return FALSE; + + lstrcpy(lpttt->szText, tipTmp.c_str()); + return TRUE; + } + else if (hWin == _mainDocTab.getHSelf()) + { + BufferID idd = _mainDocTab.getBufferByIndex(id); + Buffer * buf = MainFileManager->getBufferByID(idd); + tipTmp = buf->getFullPathName(); + + if (tipTmp.length() >= tipMaxLen) + return FALSE; + lstrcpy(docTip, tipTmp.c_str()); + lpttt->lpszText = docTip; + return TRUE; + } + else if (hWin == _subDocTab.getHSelf()) + { + BufferID idd = _subDocTab.getBufferByIndex(id); + Buffer * buf = MainFileManager->getBufferByID(idd); + tipTmp = buf->getFullPathName(); + + if (tipTmp.length() >= tipMaxLen) + return FALSE; + lstrcpy(docTip, tipTmp.c_str()); + lpttt->lpszText = docTip; + return TRUE; + } + else + return FALSE; + } + catch (...) + { + //printStr(TEXT("ToolTip crash is caught!")); + } + break; + } + + + case SCN_ZOOM: + { + break; + } + + case SCN_MACRORECORD: + { + _macro.push_back(recordedMacroStep(notification->message, notification->wParam, notification->lParam, _pEditView->execute(SCI_GETCODEPAGE))); + break; + } + + case SCN_PAINTED: + { + //--FLS: ViewMoveAtWrappingDisableFix: Disable wrapping messes up visible lines. Therefore save view position before in IDM_VIEW_WRAP and restore after SCN_PAINTED, as doc. says + if (_mainEditView.isWrapRestoreNeeded()) + { + _mainEditView.restoreCurrentPos(); + _mainEditView.setWrapRestoreNeeded(false); + } + + if (_subEditView.isWrapRestoreNeeded()) + { + _subEditView.restoreCurrentPos(); + _subEditView.setWrapRestoreNeeded(false); + } + notifyView->updateLineNumberWidth(); + if (_syncInfo.doSync()) + doSynScorll(HWND(notification->nmhdr.hwndFrom)); + + NppParameters *nppParam = NppParameters::getInstance(); + + // if it's searching/replacing, then do nothing + if ((_linkTriggered && !nppParam->_isFindReplacing) || notification->wParam == LINKTRIGGERED) + { + int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; + if ((urlAction == 1) || (urlAction == 2)) + addHotSpot(); + _linkTriggered = false; + } + if (_pDocMap) - _pDocMap->fold(lineClicked, _pEditView->isFolded(lineClicked)); + { + _pDocMap->wrapMap(); + _pDocMap->scrollMap(); + } + break; } - return TRUE; - } - case SCN_CHARADDED: - { - const NppGUI & nppGui = NppParameters::getInstance()->getNppGUI(); - bool indentMaintain = nppGui._maitainIndent; - if (indentMaintain) - maintainIndentation(static_cast(notification->ch)); - - AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; - bool isColumnMode = _pEditView->execute(SCI_GETSELECTIONS) > 1; // Multi-Selection || Column mode) - if (nppGui._matchedPairConf.hasAnyPairsPair() && !isColumnMode) - autoC->insertMatchedChars(notification->ch, nppGui._matchedPairConf); - autoC->update(notification->ch); - - break; - } - - case SCN_DOUBLECLICK : - { - if (notification->modifiers == SCMOD_CTRL) + case SCN_HOTSPOTDOUBLECLICK: { - const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI(); + notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.,:?&@=/%#()"); - std::string bufstring; - - unsigned int position_of_click; - // For some reason Ctrl+DoubleClick on an empty line means that notification->position == 1. - // In that case we use SCI_GETCURRENTPOS to get the position. - if (notification->position != -1) - position_of_click = notification->position; - else - position_of_click = int(_pEditView->execute(SCI_GETCURRENTPOS)); - - // Anonymous scope to limit use of the buf pointer (much easier to deal with std::string). - { - char *buf; - int length; - - if (nppGUI._delimiterSelectionOnEntireDocument) - { - // Get entire document. - length = notifyView->execute(SCI_GETLENGTH); - buf = new char[length + 1]; - notifyView->execute(SCI_GETTEXT, (LPARAM)(length + 1), (WPARAM)buf); - } - else - { - // Get single line. - length = notifyView->execute(SCI_GETCURLINE); - buf = new char[length + 1]; - notifyView->execute(SCI_GETCURLINE, (WPARAM)length, (LPARAM)buf); - - // Compute the position of the click (relative to the beginning of the line). - const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber()); - position_of_click = position_of_click - line_position; - } - - bufstring = buf; - delete [] buf; - } - - int leftmost_position = -1; - int rightmost_position = -1; - - if (nppGUI._rightmostDelimiter == nppGUI._leftmostDelimiter) - { - // If the delimiters are the same (e.g. they are both a quotation mark), choose the ones - // which are closest to the clicked position. - for (int i = position_of_click; i >= 0; --i) - { - if (bufstring.at(i) == nppGUI._leftmostDelimiter) - { - // Respect escaped quotation marks. - if (nppGUI._leftmostDelimiter == '"') - { - if (! (i > 0 && bufstring.at(i - 1) == '\\')) - { - leftmost_position = i; - break; - } - } - else - { - leftmost_position = i; - break; - } - } - } - - if (leftmost_position == -1) - break; - - // Scan for right delimiter. - for (unsigned int i = position_of_click; i < bufstring.length(); ++i) - { - if (bufstring.at(i) == nppGUI._rightmostDelimiter) - { - // Respect escaped quotation marks. - if (nppGUI._rightmostDelimiter == '"') - { - if (! (i > 0 && bufstring.at(i - 1) == '\\')) - { - rightmost_position = i; - break; - } - } - else - { - rightmost_position = i; - break; - } - } - } - } - else - { - // Find matching pairs of delimiters (e.g. parantheses). - // The pair where the distance from the left delimiter to position_of_click is at a minimum is the one we're looking for. - // Of course position_of_click must lie between the delimiters. - - // This logic is required to handle cases like this: - // (size_t i = function(); i < _buffers.size(); i++) - - std::stack leftmost_delimiter_positions; - - for (unsigned int i = 0; i < bufstring.length(); ++i) - { - if (bufstring.at(i) == nppGUI._leftmostDelimiter) - leftmost_delimiter_positions.push(i); - else if (bufstring.at(i) == nppGUI._rightmostDelimiter && ! leftmost_delimiter_positions.empty()) - { - unsigned int matching_leftmost = leftmost_delimiter_positions.top(); - leftmost_delimiter_positions.pop(); - - // We have either 1) chosen neither the left- or rightmost position, or 2) chosen both left- and rightmost position. - assert( (leftmost_position == -1 && rightmost_position == -1) || (leftmost_position >= 0 && rightmost_position >= 0) ); - - // Note: cast of leftmost_position to unsigned int is safe, since if leftmost_position is not -1 then it is guaranteed to be positive. - // If it was possible, leftmost_position and rightmost_position should be of type optional. - if ( matching_leftmost <= position_of_click && i >= position_of_click && (leftmost_position == -1 || matching_leftmost > (unsigned int)leftmost_position) ) - { - leftmost_position = matching_leftmost; - rightmost_position = i; - } - } - } - } - - // Set selection to the position we found (if any). - if (rightmost_position != -1 && leftmost_position != -1) - { - if (nppGUI._delimiterSelectionOnEntireDocument) - { - notifyView->execute(SCI_SETCURRENTPOS, rightmost_position); - notifyView->execute(SCI_SETANCHOR, leftmost_position + 1); - } - else - { - const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber()); - notifyView->execute(SCI_SETCURRENTPOS, line_position + rightmost_position); - notifyView->execute(SCI_SETANCHOR, line_position + leftmost_position + 1); - } - } - } - else if (_isHotspotDblClicked) - { int pos = notifyView->execute(SCI_GETCURRENTPOS); - notifyView->execute(SCI_SETCURRENTPOS, pos); - notifyView->execute(SCI_SETANCHOR, pos); - _isHotspotDblClicked = false; + int startPos = static_cast(notifyView->execute(SCI_WORDSTARTPOSITION, pos, false)); + int endPos = static_cast(notifyView->execute(SCI_WORDENDPOSITION, pos, false)); + + notifyView->execute(SCI_SETTARGETSTART, startPos); + notifyView->execute(SCI_SETTARGETEND, endPos); + + int posFound = notifyView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR); + if (posFound != -2) + { + if (posFound != -1) + { + startPos = int(notifyView->execute(SCI_GETTARGETSTART)); + endPos = int(notifyView->execute(SCI_GETTARGETEND)); + } + + // Prevent buffer overflow in getGenericText(). + if(endPos - startPos > 2*MAX_PATH) + endPos = startPos + 2*MAX_PATH; + + TCHAR currentWord[2*MAX_PATH]; + + notifyView->getGenericText(currentWord, MAX_PATH*2, startPos, endPos); + + // This treatment would fail on some valid URLs where there's actually supposed to be a comma or parenthesis at the end. + int lastCharIndex = _tcsnlen(currentWord, MAX_PATH*2) - 1; + if(lastCharIndex >= 0 && (currentWord[lastCharIndex] == ',' || currentWord[lastCharIndex] == ')' || currentWord[lastCharIndex] == '(')) + currentWord[lastCharIndex] = '\0'; + + ::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), currentWord, NULL, NULL, SW_SHOW); + _isHotspotDblClicked = true; + notifyView->execute(SCI_SETCHARSDEFAULT); + } + break; } - } - break; - case SCN_UPDATEUI: - { - NppParameters *nppParam = NppParameters::getInstance(); - - // replacement for obsolete custom SCN_SCROLLED - if (notification->updated & SC_UPDATE_V_SCROLL) + case SCN_NEEDSHOWN: { - int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; - if ((urlAction == 1) || (urlAction == 2)) - addHotSpot(); + int begin = notifyView->execute(SCI_LINEFROMPOSITION, notification->position); + int end = notifyView->execute(SCI_LINEFROMPOSITION, notification->position + notification->length); + int firstLine = begin < end ? begin : end; + int lastLine = begin > end ? begin : end; + + for (int line = firstLine; line <= lastLine; ++line) + notifyView->execute(SCI_ENSUREVISIBLE, line, 0); + break; } - // if it's searching/replacing, then do nothing - if (nppParam->_isFindReplacing) + case SCN_CALLTIPCLICK: + { + AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; + autoC->callTipClick(notification->position); + break; + } + + case RBN_HEIGHTCHANGE: + { + SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); + break; + } + + case RBN_CHEVRONPUSHED: + { + NMREBARCHEVRON * lpnm = (NMREBARCHEVRON*) notification; + ReBar * notifRebar = &_rebarTop; + if (_rebarBottom.getHSelf() == lpnm->hdr.hwndFrom) + notifRebar = &_rebarBottom; + + //If N++ ID, use proper object + if (lpnm->wID == REBAR_BAR_TOOLBAR) + { + POINT pt; + pt.x = lpnm->rc.left; + pt.y = lpnm->rc.bottom; + ClientToScreen(notifRebar->getHSelf(), &pt); + _toolBar.doPopop(pt); + return TRUE; + } + + //Else forward notification to window of rebarband + REBARBANDINFO rbBand; + ZeroMemory(&rbBand, REBARBAND_SIZE); + rbBand.cbSize = REBARBAND_SIZE; + + rbBand.fMask = RBBIM_CHILD; + ::SendMessage(notifRebar->getHSelf(), RB_GETBANDINFO, lpnm->uBand, (LPARAM)&rbBand); + ::SendMessage(rbBand.hwndChild, WM_NOTIFY, 0, (LPARAM)lpnm); + break; + } + + default: break; - if (notification->nmhdr.hwndFrom != _pEditView->getHSelf()) - break; - - braceMatch(); - - NppGUI & nppGui = (NppGUI &)nppParam->getNppGUI(); - - if (nppGui._enableTagsMatchHilite) - { - XmlMatchedTagsHighlighter xmlTagMatchHiliter(_pEditView); - xmlTagMatchHiliter.tagMatch(nppGui._enableTagAttrsHilite); - } - - if (nppGui._enableSmartHilite) - { - if (nppGui._disableSmartHiliteTmp) - nppGui._disableSmartHiliteTmp = false; - else - _smartHighlighter.highlightView(notifyView); - } - - updateStatusBar(); - AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; - autoC->update(0); - - break; } - - case TTN_GETDISPINFO: - { - try { - LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)notification; - - //Joce's fix - lpttt->hinst = NULL; - - POINT p; - ::GetCursorPos(&p); - ::ScreenToClient(_pPublicInterface->getHSelf(), &p); - HWND hWin = ::RealChildWindowFromPoint(_pPublicInterface->getHSelf(), p); - const int tipMaxLen = 1024; - static TCHAR docTip[tipMaxLen]; - docTip[0] = '\0'; - - generic_string tipTmp(TEXT("")); - int id = int(lpttt->hdr.idFrom); - - if (hWin == _rebarTop.getHSelf()) - { - getNameStrFromCmd(id, tipTmp); - if (tipTmp.length() >= 80) - return FALSE; - - lstrcpy(lpttt->szText, tipTmp.c_str()); - return TRUE; - } - else if (hWin == _mainDocTab.getHSelf()) - { - BufferID idd = _mainDocTab.getBufferByIndex(id); - Buffer * buf = MainFileManager->getBufferByID(idd); - tipTmp = buf->getFullPathName(); - - if (tipTmp.length() >= tipMaxLen) - return FALSE; - lstrcpy(docTip, tipTmp.c_str()); - lpttt->lpszText = docTip; - return TRUE; - } - else if (hWin == _subDocTab.getHSelf()) - { - BufferID idd = _subDocTab.getBufferByIndex(id); - Buffer * buf = MainFileManager->getBufferByID(idd); - tipTmp = buf->getFullPathName(); - - if (tipTmp.length() >= tipMaxLen) - return FALSE; - lstrcpy(docTip, tipTmp.c_str()); - lpttt->lpszText = docTip; - return TRUE; - } - else - { - return FALSE; - } - } catch (...) { - //printStr(TEXT("ToolTip crash is caught!")); - } - } - break; - - - case SCN_ZOOM: - break; - - case SCN_MACRORECORD: - _macro.push_back(recordedMacroStep(notification->message, notification->wParam, notification->lParam, _pEditView->execute(SCI_GETCODEPAGE))); - break; - - case SCN_PAINTED: - { - //--FLS: ViewMoveAtWrappingDisableFix: Disable wrapping messes up visible lines. Therefore save view position before in IDM_VIEW_WRAP and restore after SCN_PAINTED, as doc. says - if (_mainEditView.isWrapRestoreNeeded()) - { - _mainEditView.restoreCurrentPos(); - _mainEditView.setWrapRestoreNeeded(false); - } - - if (_subEditView.isWrapRestoreNeeded()) - { - _subEditView.restoreCurrentPos(); - _subEditView.setWrapRestoreNeeded(false); - } - notifyView->updateLineNumberWidth(); - if (_syncInfo.doSync()) - doSynScorll(HWND(notification->nmhdr.hwndFrom)); - - NppParameters *nppParam = NppParameters::getInstance(); - - // if it's searching/replacing, then do nothing - if ((_linkTriggered && !nppParam->_isFindReplacing) || notification->wParam == LINKTRIGGERED) - { - int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; - if ((urlAction == 1) || (urlAction == 2)) - addHotSpot(); - _linkTriggered = false; - } - - if (_pDocMap) - { - _pDocMap->wrapMap(); - _pDocMap->scrollMap(); - } - break; - } - - case SCN_HOTSPOTDOUBLECLICK : - { - notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.,:?&@=/%#()"); - - int pos = notifyView->execute(SCI_GETCURRENTPOS); - int startPos = static_cast(notifyView->execute(SCI_WORDSTARTPOSITION, pos, false)); - int endPos = static_cast(notifyView->execute(SCI_WORDENDPOSITION, pos, false)); - - notifyView->execute(SCI_SETTARGETSTART, startPos); - notifyView->execute(SCI_SETTARGETEND, endPos); - - int posFound = notifyView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR); - if (posFound != -2) - { - if (posFound != -1) - { - startPos = int(notifyView->execute(SCI_GETTARGETSTART)); - endPos = int(notifyView->execute(SCI_GETTARGETEND)); - } - - // Prevent buffer overflow in getGenericText(). - if(endPos - startPos > 2*MAX_PATH) - endPos = startPos + 2*MAX_PATH; - - TCHAR currentWord[2*MAX_PATH]; - - notifyView->getGenericText(currentWord, MAX_PATH*2, startPos, endPos); - - // This treatment would fail on some valid URLs where there's actually supposed to be a comma or parenthesis at the end. - int lastCharIndex = _tcsnlen(currentWord, MAX_PATH*2) - 1; - if(lastCharIndex >= 0 && (currentWord[lastCharIndex] == ',' || currentWord[lastCharIndex] == ')' || currentWord[lastCharIndex] == '(')) - currentWord[lastCharIndex] = '\0'; - - ::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), currentWord, NULL, NULL, SW_SHOW); - _isHotspotDblClicked = true; - notifyView->execute(SCI_SETCHARSDEFAULT); - } - break; - } - - case SCN_NEEDSHOWN : - { - int begin = notifyView->execute(SCI_LINEFROMPOSITION, notification->position); - int end = notifyView->execute(SCI_LINEFROMPOSITION, notification->position + notification->length); - int firstLine = begin < end ? begin : end; - int lastLine = begin > end ? begin : end; - for (int line = firstLine; line <= lastLine; ++line) - { - notifyView->execute(SCI_ENSUREVISIBLE, line, 0); - } - break; - } - - case SCN_CALLTIPCLICK: - { - AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; - autoC->callTipClick(notification->position); - break; - } - - case RBN_HEIGHTCHANGE: - { - SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); - break; - } - case RBN_CHEVRONPUSHED: - { - NMREBARCHEVRON * lpnm = (NMREBARCHEVRON*) notification; - ReBar * notifRebar = &_rebarTop; - if (_rebarBottom.getHSelf() == lpnm->hdr.hwndFrom) - notifRebar = &_rebarBottom; - //If N++ ID, use proper object - if (lpnm->wID == REBAR_BAR_TOOLBAR) - { - POINT pt; - pt.x = lpnm->rc.left; - pt.y = lpnm->rc.bottom; - ClientToScreen(notifRebar->getHSelf(), &pt); - _toolBar.doPopop(pt); - return TRUE; - } - //Else forward notification to window of rebarband - REBARBANDINFO rbBand; - ZeroMemory(&rbBand, REBARBAND_SIZE); - rbBand.cbSize = REBARBAND_SIZE; - - rbBand.fMask = RBBIM_CHILD; - ::SendMessage(notifRebar->getHSelf(), RB_GETBANDINFO, lpnm->uBand, (LPARAM)&rbBand); - ::SendMessage(rbBand.hwndChild, WM_NOTIFY, 0, (LPARAM)lpnm); - break; - } - - default : - break; - - } - return FALSE; + return FALSE; } diff --git a/PowerEditor/src/ScitillaComponent/UserDefineResource.h b/PowerEditor/src/ScitillaComponent/UserDefineResource.h index 01283a2f..2f942ed9 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineResource.h +++ b/PowerEditor/src/ScitillaComponent/UserDefineResource.h @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp index 4810b7ca..b265f184 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -24,74 +24,69 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - #include #include "ColourPicker.h" #include "ColourPopup.h" + + + void ColourPicker::init(HINSTANCE hInst, HWND parent) { Window::init(hInst, parent); _hSelf = ::CreateWindowEx( - 0, - TEXT("Button"), - TEXT("F"), - WS_CHILD | WS_VISIBLE, - 0, 0, 25, 25, - _hParent, - NULL, - _hInst, - (LPVOID)0); + 0, + TEXT("Button"), + TEXT("F"), + WS_CHILD | WS_VISIBLE, + 0, 0, 25, 25, + _hParent, NULL, _hInst, (LPVOID)0); + if (!_hSelf) - { throw std::runtime_error("ColourPicker::init : CreateWindowEx() function return null"); - } - - - ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this); - _buttonDefaultProc = reinterpret_cast(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticWinProc)); + ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this); + _buttonDefaultProc = reinterpret_cast(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticWinProc)); } + void ColourPicker::destroy() { - if (_pColourPopup) - { - delete _pColourPopup; - _pColourPopup = NULL; - } + delete _pColourPopup; + _pColourPopup = NULL; ::DestroyWindow(_hSelf); } + void ColourPicker::drawBackground(HDC hDC) { - RECT rc; + RECT rc; HBRUSH hbrush; - if(!hDC) + if (!hDC) return; - getClientRect(rc); + getClientRect(rc); hbrush = ::CreateSolidBrush(_currentColour); HGDIOBJ oldObj = ::SelectObject(hDC, hbrush); ::Rectangle(hDC, 0, 0, rc.right, rc.bottom); ::SelectObject(hDC, oldObj); //FillRect(hDC, &rc, hbrush); - ::DeleteObject(hbrush); + ::DeleteObject(hbrush); } + void ColourPicker::drawForeground(HDC hDC) { - RECT rc; + RECT rc; HBRUSH hbrush = NULL; - if(!hDC || _isEnabled) + if (!hDC || _isEnabled) return; int oldMode = ::SetBkMode(hDC, TRANSPARENT); - getClientRect(rc); + getClientRect(rc); COLORREF strikeOut = RGB(0,0,0); if ((((_currentColour ) & 0xFF) + ((_currentColour >> 8) & 0xFF) + @@ -103,17 +98,18 @@ void ColourPicker::drawForeground(HDC hDC) ::Rectangle(hDC, 0, 0, rc.right, rc.bottom); ::SelectObject(hDC, oldObj); //FillRect(hDC, &rc, hbrush); - ::DeleteObject(hbrush); + ::DeleteObject(hbrush); ::SetBkMode(hDC, oldMode); } + LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { - case WM_LBUTTONDBLCLK : - case WM_LBUTTONDOWN : - { + case WM_LBUTTONDBLCLK: + case WM_LBUTTONDOWN: + { RECT rc; POINT p; Window::getClientRect(rc); @@ -134,8 +130,9 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam) _pColourPopup->doDialog(p); _pColourPopup->display(true); } - return TRUE; - } + return TRUE; + } + case WM_RBUTTONDOWN: { _isEnabled = !_isEnabled; @@ -152,41 +149,44 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam) break; } - case WM_PAINT : - { + case WM_PAINT: + { PAINTSTRUCT ps; HDC dc = ::BeginPaint(_hSelf, &ps); - drawForeground(dc); + drawForeground(dc); ::EndPaint(_hSelf, &ps); - return TRUE; - } + return TRUE; + } - case WM_PICKUP_COLOR : - { - _currentColour = (COLORREF)wParam; - redraw(); + case WM_PICKUP_COLOR: + { + _currentColour = (COLORREF)wParam; + redraw(); _pColourPopup->display(false); ::SendMessage(_hParent, WM_COMMAND, MAKELONG(0, CPN_COLOURPICKED), (LPARAM)_hSelf); - return TRUE; - } + return TRUE; + } - case WM_ENABLE : - { - if ((BOOL)wParam == FALSE) - { - _currentColour = ::GetSysColor(COLOR_3DFACE); - redraw(); - } - return TRUE; - } + case WM_ENABLE: + { + if ((BOOL)wParam == FALSE) + { + _currentColour = ::GetSysColor(COLOR_3DFACE); + redraw(); + } + return TRUE; + } - case WM_PICKUP_CANCEL : + case WM_PICKUP_CANCEL: + { _pColourPopup->display(false); return TRUE; + } - default : + default: return ::CallWindowProc(_buttonDefaultProc, _hSelf, Message, wParam, lParam); } + return FALSE; } diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h index 6fda0992..07405d8b 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -24,62 +24,54 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - -#ifndef COLOUR_POPUP_H -#define COLOUR_POPUP_H - -#ifndef COLOUR_POPUP_RESOURCE_H +#pragma once #include "ColourPopupResource.h" -#endif //COLOUR_POPUP_RESOURCE_H - -#ifndef RESOURCE_H #include "resource.h" -#endif //RESOURCE_H - #include "Window.h" -#define WM_PICKUP_COLOR (COLOURPOPUP_USER + 1) +#define WM_PICKUP_COLOR (COLOURPOPUP_USER + 1) #define WM_PICKUP_CANCEL (COLOURPOPUP_USER + 2) + + class ColourPopup : public Window { public : - ColourPopup() : Window()/*, isColourChooserLaunched(false)*/ {}; - ColourPopup(COLORREF defaultColor) : Window(), /* isColourChooserLaunched(false), */ _colour(defaultColor) {}; - ~ColourPopup(){}; - - bool isCreated() const { + ColourPopup() = default; + explicit ColourPopup(COLORREF defaultColor) : _colour(defaultColor) {} + virtual ~ColourPopup() {} + + bool isCreated() const + { return (_hSelf != NULL); - }; - + } + void create(int dialogID); - void doDialog(POINT p) { - if (!isCreated()) - create(IDD_COLOUR_POPUP); - ::SetWindowPos(_hSelf, HWND_TOP, p.x, p.y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW); - }; + void doDialog(POINT p) + { + if (!isCreated()) + create(IDD_COLOUR_POPUP); + ::SetWindowPos(_hSelf, HWND_TOP, p.x, p.y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW); + } - virtual void destroy() { - ::DestroyWindow(_hSelf); - }; + virtual void destroy() + { + ::DestroyWindow(_hSelf); + } - void setColour(COLORREF c) { - _colour = c; - }; + void setColour(COLORREF c) + { + _colour = c; + } - COLORREF getSelColour(){return _colour;}; + COLORREF getSelColour(){return _colour;}; private : RECT _rc; - COLORREF _colour; - //bool isColourChooserLaunched; + COLORREF _colour; + //bool isColourChooserLaunched = false; static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; - -#endif //COLOUR_POPUP_H - - diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopupResource.h b/PowerEditor/src/WinControls/ColourPicker/ColourPopupResource.h index 4986ff0d..683fce24 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopupResource.h +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopupResource.h @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -24,11 +24,7 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#pragma once - -#ifndef COLOUR_POPUP_RESOURCE_H - -#define IDD_COLOUR_POPUP 2100 -#define IDC_COLOUR_LIST (IDD_COLOUR_POPUP + 1) - -#endif //COLOUR_POPUP_RESOURCE_H +#define IDD_COLOUR_POPUP 2100 +#define IDC_COLOUR_LIST (IDD_COLOUR_POPUP + 1) diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 04f77077..1f037d1e 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -37,35 +37,35 @@ using namespace std; LRESULT CALLBACK ColourStaticTextHooker::colourStaticProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) - { - case WM_PAINT: - { - RECT rect; - ::GetClientRect(hwnd, &rect); + { + case WM_PAINT: + { + RECT rect; + ::GetClientRect(hwnd, &rect); - PAINTSTRUCT ps; - HDC hdc = ::BeginPaint(hwnd, &ps); - - ::SetTextColor(hdc, _colour); + PAINTSTRUCT ps; + HDC hdc = ::BeginPaint(hwnd, &ps); - // Get the default GUI font - HFONT hf = (HFONT)::GetStockObject(DEFAULT_GUI_FONT); + ::SetTextColor(hdc, _colour); + + // Get the default GUI font + HFONT hf = (HFONT)::GetStockObject(DEFAULT_GUI_FONT); HANDLE hOld = SelectObject(hdc, hf); - // Draw the text! - TCHAR text[MAX_PATH]; - ::GetWindowText(hwnd, text, MAX_PATH); - ::DrawText(hdc, text, -1, &rect, DT_LEFT); - - ::SelectObject(hdc, hOld); + // Draw the text! + TCHAR text[MAX_PATH]; + ::GetWindowText(hwnd, text, MAX_PATH); + ::DrawText(hdc, text, -1, &rect, DT_LEFT); - ::EndPaint(hwnd, &ps); + ::SelectObject(hdc, hOld); - return TRUE; - } - } - return ::CallWindowProc(_oldProc, hwnd, Message, wParam, lParam); + ::EndPaint(hwnd, &ps); + + return TRUE; + } + } + return ::CallWindowProc(_oldProc, hwnd, Message, wParam, lParam); } void WordStyleDlg::updateGlobalOverrideCtrls() { @@ -87,8 +87,8 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l { NppParameters *nppParamInst = NppParameters::getInstance(); - _hCheckBold = ::GetDlgItem(_hSelf, IDC_BOLD_CHECK); - _hCheckItalic = ::GetDlgItem(_hSelf, IDC_ITALIC_CHECK); + _hCheckBold = ::GetDlgItem(_hSelf, IDC_BOLD_CHECK); + _hCheckItalic = ::GetDlgItem(_hSelf, IDC_ITALIC_CHECK); _hCheckUnderline = ::GetDlgItem(_hSelf, IDC_UNDERLINE_CHECK); _hFontNameCombo = ::GetDlgItem(_hSelf, IDC_FONT_COMBO); _hFontSizeCombo = ::GetDlgItem(_hSelf, IDC_FONTSIZE_COMBO); @@ -110,12 +110,12 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l { pair & themeInfo = themeSwitcher.getElementFromIndex(i); int j = ::SendMessage(_hSwitch2ThemeCombo, CB_ADDSTRING, 0, (LPARAM)themeInfo.first.c_str()); - if (! themeInfo.second.compare( nppParamInst->getNppGUI()._themeName ) ) + if (! themeInfo.second.compare( nppParamInst->getNppGUI()._themeName ) ) { _currentThemeIndex = j; _themeName.assign(themeInfo.second); } - if (! themeInfo.first.compare(TEXT("Default")) ) + if (! themeInfo.first.compare(TEXT("Default")) ) { defaultThemeIndex = j; } @@ -141,16 +141,15 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l _pFgColour->init(_hInst, _hSelf); _pBgColour->init(_hInst, _hSelf); - POINT p1, p2; + POINT p1, p2; + alignWith(_hFgColourStaticText, _pFgColour->getHSelf(), PosAlign::right, p1); + alignWith(_hBgColourStaticText, _pBgColour->getHSelf(), PosAlign::right, p2); - alignWith(_hFgColourStaticText, _pFgColour->getHSelf(), ALIGNPOS_RIGHT, p1); - alignWith(_hBgColourStaticText, _pBgColour->getHSelf(), ALIGNPOS_RIGHT, p2); + p1.x = p2.x = ((p1.x > p2.x)?p1.x:p2.x) + 10; + p1.y -= 4; p2.y -= 4; - p1.x = p2.x = ((p1.x > p2.x)?p1.x:p2.x) + 10; - p1.y -= 4; p2.y -= 4; - - ::MoveWindow((HWND)_pFgColour->getHSelf(), p1.x, p1.y, 25, 25, TRUE); - ::MoveWindow((HWND)_pBgColour->getHSelf(), p2.x, p2.y, 25, 25, TRUE); + ::MoveWindow((HWND)_pFgColour->getHSelf(), p1.x, p1.y, 25, 25, TRUE); + ::MoveWindow((HWND)_pBgColour->getHSelf(), p2.x, p2.y, 25, 25, TRUE); _pFgColour->display(); _pBgColour->display(); @@ -170,7 +169,6 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l goToCenter(); loadLangListFromNppParam(); - return TRUE; } @@ -193,10 +191,10 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l return TRUE; } - case WM_COMMAND : + case WM_COMMAND : { if (HIWORD(wParam) == EN_CHANGE) - { + { int editID = LOWORD(wParam); if (editID == IDC_USER_KEYWORDS_EDIT) { @@ -237,21 +235,21 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l if (_isDirty) { NppParameters *nppParamInst = NppParameters::getInstance(); - if (_restoreInvalid) - { + if (_restoreInvalid) + { generic_string str( nppParamInst->getNppGUI()._themeName ); nppParamInst->reloadStylers( &str[0] ); } LexerStylerArray & lsArray = nppParamInst->getLStylerArray(); StyleArray & globalStyles = nppParamInst->getGlobalStylers(); - - if (_restoreInvalid) + + if (_restoreInvalid) { _lsArray = _styles2restored = lsArray; _globalStyles = _gstyles2restored = globalStyles; } - else + else { globalStyles = _globalStyles = _gstyles2restored; lsArray = _lsArray = _styles2restored; @@ -264,7 +262,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l _isThemeDirty = false; setVisualFromStyleList(); - + //(nppParamInst->getNppGUI())._themeName ::SendMessage(_hSwitch2ThemeCombo, CB_SETCURSEL, _currentThemeIndex, 0); ::SendMessage(_hParent, WM_UPDATESCINTILLAS, 0, 0); @@ -297,7 +295,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l ::SendMessage(_hParent, WM_UPDATESCINTILLAS, 0, 0); return TRUE; } - + case IDC_SC_TRANSPARENT_CHECK : { bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_SC_TRANSPARENT_CHECK, BM_GETCHECK, 0, 0)); @@ -355,7 +353,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l apply(); return TRUE; } - + case IDC_GLOBAL_ITALIC_CHECK : { GlobalOverride & glo = (NppParameters::getInstance())->getGlobalOverrideStyle(); @@ -416,7 +414,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l return TRUE; } - case CPN_COLOURPICKED: + case CPN_COLOURPICKED: { if ((HWND)lParam == _pFgColour->getHSelf()) { @@ -467,17 +465,17 @@ void WordStyleDlg::loadLangListFromNppParam() { NppParameters *nppParamInst = NppParameters::getInstance(); _lsArray = nppParamInst->getLStylerArray(); - _globalStyles = nppParamInst->getGlobalStylers(); + _globalStyles = nppParamInst->getGlobalStylers(); // Clean up Language List ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_RESETCONTENT, 0, 0); ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_ADDSTRING, 0, (LPARAM)TEXT("Global Styles")); // All the lexers - for (int i = 0, nb = _lsArray.getNbLexer() ; i < nb ; ++i) - { + for (int i = 0, nb = _lsArray.getNbLexer() ; i < nb ; ++i) + { ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_ADDSTRING, 0, (LPARAM)_lsArray.getLexerDescFromIndex(i)); - } + } const int index2Begin = 0; ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_SETCURSEL, 0, index2Begin); @@ -491,7 +489,7 @@ void WordStyleDlg::updateThemeName(generic_string themeName) nppGUI._themeName.assign( themeName ); } -int WordStyleDlg::whichTabColourIndex() +int WordStyleDlg::whichTabColourIndex() { int i = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0); if (i == LB_ERR) @@ -582,7 +580,7 @@ void WordStyleDlg::updateUserKeywords() void WordStyleDlg::updateFontName() { - Style & style = getCurrentStyler(); + Style & style = getCurrentStyler(); int iFontSel = ::SendMessage(_hFontNameCombo, CB_GETCURSEL, 0, 0); TCHAR *fnStr = (TCHAR *)::SendMessage(_hFontNameCombo, CB_GETITEMDATA, iFontSel, 0); style._fontName = fnStr; @@ -590,7 +588,7 @@ void WordStyleDlg::updateFontName() void WordStyleDlg::updateFontStyleStatus(fontStyleType whitchStyle) { - Style & style = getCurrentStyler(); + Style & style = getCurrentStyler(); if (style._fontStyle == STYLE_NOT_USED) style._fontStyle = FONTSTYLE_NONE; @@ -624,11 +622,11 @@ void WordStyleDlg::switchToTheme() generic_string prevThemeName(_themeName); _themeName.clear(); - + NppParameters *nppParamInst = NppParameters::getInstance(); - ThemeSwitcher & themeSwitcher = nppParamInst->getThemeSwitcher(); + ThemeSwitcher & themeSwitcher = nppParamInst->getThemeSwitcher(); pair & themeInfo = themeSwitcher.getElementFromIndex(iSel); - _themeName = themeInfo.second; + _themeName = themeInfo.second; if (_isThemeDirty) { @@ -638,7 +636,7 @@ void WordStyleDlg::switchToTheme() PathRemoveExtension(themeFileName); int mb_response = ::MessageBox( _hSelf, - TEXT(" Unsaved changes are about to be discarded!\n") + TEXT(" Unsaved changes are about to be discarded!\n") TEXT(" Do you want to save your changes before switching themes?"), themeFileName, MB_ICONWARNING | MB_YESNO | MB_APPLMODAL | MB_SETFOREGROUND ); @@ -654,10 +652,10 @@ void WordStyleDlg::switchToTheme() void WordStyleDlg::setStyleListFromLexer(int index) { - _currentLexerIndex = index; + _currentLexerIndex = index; - // Fill out Styles listbox - // Before filling out, we clean it + // Fill out Styles listbox + // Before filling out, we clean it ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_RESETCONTENT, 0, 0); if (index) @@ -667,39 +665,39 @@ void WordStyleDlg::setStyleListFromLexer(int index) const TCHAR *userExt = (_lsArray.getLexerStylerByName(langName))->getLexerUserExt(); ::SendDlgItemMessage(_hSelf, IDC_DEF_EXT_EDIT, WM_SETTEXT, 0, (LPARAM)(ext)); - // WM_SETTEXT cause sending WM_COMMAND message with EN_CHANGE. - // That makes status dirty, even it shouldn't in this case. - // The walk around solution is get the current status before sending WM_SETTEXT, - // then restore the status after sending this message. - bool isDirty = _isDirty; + // WM_SETTEXT cause sending WM_COMMAND message with EN_CHANGE. + // That makes status dirty, even it shouldn't in this case. + // The walk around solution is get the current status before sending WM_SETTEXT, + // then restore the status after sending this message. + bool isDirty = _isDirty; bool isThemeDirty = _isThemeDirty; ::SendDlgItemMessage(_hSelf, IDC_USER_EXT_EDIT, WM_SETTEXT, 0, (LPARAM)(userExt)); - _isDirty = isDirty; - _isThemeDirty = isThemeDirty; - ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), isDirty || isThemeDirty); + _isDirty = isDirty; + _isThemeDirty = isThemeDirty; + ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), isDirty || isThemeDirty); } ::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_EXT_EDIT), index?SW_SHOW:SW_HIDE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_EXT_STATIC), index?SW_SHOW:SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_EXT_STATIC), index?SW_SHOW:SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_EXT_EDIT), index?SW_SHOW:SW_HIDE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_EXT_STATIC), index?SW_SHOW:SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_EXT_STATIC), index?SW_SHOW:SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_PLUSSYMBOL2_STATIC), index?SW_SHOW:SW_HIDE); StyleArray & lexerStyler = index?_lsArray.getLexerFromIndex(index-1):_globalStyles; - for (int i = 0, nb = lexerStyler.getNbStyler(); i < nb ; ++i) - { - Style & style = lexerStyler.getStyler(i); + for (int i = 0, nb = lexerStyler.getNbStyler(); i < nb ; ++i) + { + Style & style = lexerStyler.getStyler(i); ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_ADDSTRING, 0, (LPARAM)style._styleDesc); - } + } ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_SETCURSEL, 0, 0); - setVisualFromStyleList(); + setVisualFromStyleList(); } -void WordStyleDlg::setVisualFromStyleList() +void WordStyleDlg::setVisualFromStyleList() { showGlobalOverrideCtrls(false); - Style & style = getCurrentStyler(); + Style & style = getCurrentStyler(); // Global override style if (style._styleDesc && lstrcmp(style._styleDesc, TEXT("Global override")) == 0) @@ -707,14 +705,14 @@ void WordStyleDlg::setVisualFromStyleList() showGlobalOverrideCtrls(true); } - //--Warning text - //bool showWarning = ((_currentLexerIndex == 0) && (style._styleID == STYLE_DEFAULT));//?SW_SHOW:SW_HIDE; + //--Warning text + //bool showWarning = ((_currentLexerIndex == 0) && (style._styleID == STYLE_DEFAULT));//?SW_SHOW:SW_HIDE; COLORREF c = RGB(0x00, 0x00, 0xFF); TCHAR str[256]; str[0] = '\0'; - + int i = ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETCURSEL, 0, 0); if (i == LB_ERR) return; @@ -802,7 +800,7 @@ void WordStyleDlg::setVisualFromStyleList() ::SendMessage(_hCheckUnderline, BM_SETCHECK, BST_UNCHECKED, 0); } - enableFontStyle(isEnable); + enableFontStyle(isEnable); //-- Default Keywords @@ -827,6 +825,7 @@ void WordStyleDlg::setVisualFromStyleList() const TCHAR *ckwStr = (style._keywords)?style._keywords->c_str():TEXT(""); ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(ckwStr)); } + int showOption = shouldBeDisplayed?SW_SHOW:SW_HIDE; ::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_EDIT), showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_EDIT),showOption); @@ -834,9 +833,10 @@ void WordStyleDlg::setVisualFromStyleList() ::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_STATIC),showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_PLUSSYMBOL_STATIC),showOption); - redraw(); + redraw(); } + void WordStyleDlg::create(int dialogID, bool isRTL) { StaticDialog::create(dialogID, isRTL); @@ -845,7 +845,7 @@ void WordStyleDlg::create(int dialogID, bool isRTL) { ::ShowWindow(::GetDlgItem(_hSelf, IDC_SC_TRANSPARENT_CHECK), SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_SC_PERCENTAGE_SLIDER), SW_SHOW); - + ::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(20, 200)); ::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, TBM_SETPOS, TRUE, 150); if (!(BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, BM_GETCHECK, 0, 0))) @@ -853,6 +853,7 @@ void WordStyleDlg::create(int dialogID, bool isRTL) } } + void WordStyleDlg::apply() { LexerStylerArray & lsa = (NppParameters::getInstance())->getLStylerArray(); diff --git a/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp b/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp index e7bb06a5..3282957d 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp +++ b/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp @@ -24,8 +24,6 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - #include #include #include "Splitter.h" @@ -38,28 +36,24 @@ bool Splitter::_isVerticalFixedRegistered = false; #define SPLITTER_SIZE 8 -Splitter::Splitter() : Window() + + +Splitter::Splitter() { - //hInstance = GetModuleHandle(NULL); _rect.left = 0; // x axis _rect.top = 0; // y axis _rect.right = 0; // Width of the spliter. _rect.bottom = 0; // Height of the spliter - _isFixed = false; } -void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, - double iSplitRatio, DWORD dwFlags) +void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, double iSplitRatio, DWORD dwFlags) { if (hPere == NULL) - { throw std::runtime_error("Splitter::init : Parameter hPere is null"); - } + if (iSplitRatio < 0) - { throw std::runtime_error("Splitter::init : Parameter iSplitRatio shoulds be 0 < ratio < 100"); - } Window::init(hInst, hPere); _spiltterSize = splitterSize; @@ -183,61 +177,61 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, _isVerticalFixedRegistered = true; } - _hSelf = CreateWindowEx( - dwExStyle, - wcex.lpszClassName, - TEXT(""), - dwStyle, - _rect.left, - _rect.top, - _rect.right, - _rect.bottom, - _hParent, - NULL, - _hInst, - (LPVOID)this); + _hSelf = CreateWindowEx(dwExStyle, wcex.lpszClassName, + TEXT(""), + dwStyle, + _rect.left, _rect.top, _rect.right, _rect.bottom, + _hParent, NULL, _hInst, this); if (!_hSelf) - { throw std::runtime_error("Splitter::init : CreateWindowEx() function return null"); - } RECT rc; getClientRect(rc); //::GetClientRect(_hParent,&rc); - _clickZone2TL.left = rc.left; - _clickZone2TL.top = rc.top; + _clickZone2TL.left = rc.left; + _clickZone2TL.top = rc.top; - int clickZoneWidth = getClickZone(WIDTH); - int clickZoneHeight = getClickZone(HEIGHT); - _clickZone2TL.right = clickZoneWidth; + int clickZoneWidth = getClickZone(WH::width); + int clickZoneHeight = getClickZone(WH::height); + _clickZone2TL.right = clickZoneWidth; _clickZone2TL.bottom = clickZoneHeight; - _clickZone2BR.left = rc.right - clickZoneWidth; - _clickZone2BR.top = rc.bottom - clickZoneHeight; - _clickZone2BR.right = clickZoneWidth; + _clickZone2BR.left = rc.right - clickZoneWidth; + _clickZone2BR.top = rc.bottom - clickZoneHeight; + _clickZone2BR.right = clickZoneWidth; _clickZone2BR.bottom = clickZoneHeight; display(); ::SendMessage(_hParent, WM_RESIZE_CONTAINER, _rect.left, _rect.top); - } -// determinated by (_dwFlags & SV_VERTICAL) && _splitterSize + + +void Splitter::destroy() +{ + ::DestroyWindow(_hSelf); +} + + int Splitter::getClickZone(WH which) { + // determinated by (_dwFlags & SV_VERTICAL) && _splitterSize if (_spiltterSize <= 8) { - return isVertical()?(which==WIDTH?_spiltterSize:HIEGHT_MINIMAL) - :(which==WIDTH?HIEGHT_MINIMAL:_spiltterSize); + return isVertical() + ? (which == WH::width ? _spiltterSize : HIEGHT_MINIMAL) + : (which == WH::width ? HIEGHT_MINIMAL : _spiltterSize); } else // (_spiltterSize > 8) { - return isVertical()?(which==WIDTH? 8:15) - :(which==WIDTH?15:8); + return isVertical() + ? ((which == WH::width) ? 8 : 15) + : ((which == WH::width) ? 15 : 8); } } + LRESULT CALLBACK Splitter::staticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) @@ -260,24 +254,12 @@ LRESULT CALLBACK Splitter::staticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP } } + LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { -/* - case WM_LBUTTONDBLCLK: - { -::MessageBox(NULL, TEXT(""), TEXT(""), MB_OK); - } - return 0; - - case WM_RBUTTONDBLCLK: - { - - } - return 0; - */ - case WM_LBUTTONDOWN: + case WM_LBUTTONDOWN: { POINT p; p.x = LOWORD(lParam); @@ -300,14 +282,17 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara ::SetCapture(_hSelf); _isDraged = true; } + + return 0; } - return 0; - case WM_RBUTTONDOWN : - ::SendMessage(_hParent, WM_DOPOPUPMENU, wParam, lParam); - return TRUE; + case WM_RBUTTONDOWN: + { + ::SendMessage(_hParent, WM_DOPOPUPMENU, wParam, lParam); + return TRUE; + } - case WM_MOUSEMOVE: + case WM_MOUSEMOVE: { POINT p; p.x = LOWORD(lParam); @@ -378,7 +363,7 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara return 0; } - case WM_LBUTTONUP: + case WM_LBUTTONUP: { if (!_isFixed) { @@ -386,7 +371,8 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara } return 0; } - case WM_CAPTURECHANGED: + + case WM_CAPTURECHANGED: { if (_isDraged) { @@ -397,17 +383,23 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara return 0; } - case WM_PAINT : - drawSplitter(); - return 0; + case WM_PAINT: + { + drawSplitter(); + return 0; + } - case WM_CLOSE: - destroy(); - return 0; + case WM_CLOSE: + { + destroy(); + return 0; + } } + return ::DefWindowProc(_hSelf, uMsg, wParam, lParam); } + void Splitter::resizeSpliter(RECT *pRect) { RECT rect; @@ -437,10 +429,10 @@ void Splitter::resizeSpliter(RECT *pRect) //if resizeing should be done proportionately. if (_dwFlags & SV_RESIZEWTHPERCNT) - { + { _rect.left = (LONG)((rect.right * _splitPercent)/100); - } - else // soit la fenetre gauche soit la fenetre droit qui est fixee + } + else // soit la fenetre gauche soit la fenetre droit qui est fixee _rect.left = getSplitterFixPosX(); } @@ -449,8 +441,8 @@ void Splitter::resizeSpliter(RECT *pRect) RECT rc; getClientRect(rc); - _clickZone2BR.right = getClickZone(WIDTH); - _clickZone2BR.bottom = getClickZone(HEIGHT); + _clickZone2BR.right = getClickZone(WH::width); + _clickZone2BR.bottom = getClickZone(WH::height); _clickZone2BR.left = rc.right - _clickZone2BR.right; _clickZone2BR.top = rc.bottom - _clickZone2BR.bottom; @@ -460,14 +452,16 @@ void Splitter::resizeSpliter(RECT *pRect) redraw(); } + void Splitter::gotoTopLeft() { if ((_dwFlags & SV_ENABLELDBLCLK) && (!_isFixed) && (_splitPercent > 1)) { if (_dwFlags & SV_HORIZONTAL) - _rect.top = 1; + _rect.top = 1; else - _rect.left = 1; + _rect.left = 1; + _splitPercent = 1; ::SendMessage(_hParent, WM_RESIZE_CONTAINER, _rect.left, _rect.top); @@ -476,6 +470,7 @@ void Splitter::gotoTopLeft() } } + void Splitter::gotoRightBouuom() { if ((_dwFlags & SV_ENABLERDBLCLK) && (!_isFixed) && (_splitPercent < 99)) @@ -496,6 +491,7 @@ void Splitter::gotoRightBouuom() } } + void Splitter::drawSplitter() { PAINTSTRUCT ps; @@ -506,25 +502,25 @@ void Splitter::drawSplitter() if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT)) { - adjustZoneToDraw(TLrc, TOP_LEFT); - adjustZoneToDraw(BRrc, BOTTOM_RIGHT); - paintArrow(hdc, TLrc, isVertical()?ARROW_LEFT:ARROW_UP); + adjustZoneToDraw(TLrc, ZONE_TYPE::topLeft); + adjustZoneToDraw(BRrc, ZONE_TYPE::bottomRight); + paintArrow(hdc, TLrc, isVertical() ? Arrow::left : Arrow::up); } if (isVertical()) { - rcToDraw2.top = (_dwFlags & SV_RESIZEWTHPERCNT)?_clickZone2TL.bottom:0; + rcToDraw2.top = (_dwFlags & SV_RESIZEWTHPERCNT) ? _clickZone2TL.bottom : 0; rcToDraw2.bottom = rcToDraw2.top + 2; - rcToDraw1.top = rcToDraw2.top + 1; + rcToDraw1.top = rcToDraw2.top + 1; rcToDraw1.bottom = rcToDraw1.top + 2; } else { - rcToDraw2.top = 1; + rcToDraw2.top = 1; rcToDraw2.bottom = 3; - rcToDraw1.top = 2; + rcToDraw1.top = 2; rcToDraw1.bottom = 4; } @@ -538,10 +534,10 @@ void Splitter::drawSplitter() { if (isVertical()) { - rcToDraw2.left = 1; + rcToDraw2.left = 1; rcToDraw2.right = 3; - rcToDraw1.left = 2; + rcToDraw1.left = 2; rcToDraw1.right = 4; } else @@ -563,6 +559,7 @@ void Splitter::drawSplitter() rcToDraw1.left += 4; rcToDraw1.right += 4; } + rcToDraw2.top += 4; rcToDraw2.bottom += 4; rcToDraw1.top += 4; @@ -570,16 +567,18 @@ void Splitter::drawSplitter() } if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT)) - paintArrow(hdc, BRrc, isVertical()?ARROW_RIGHT:ARROW_DOWN); + paintArrow(hdc, BRrc, isVertical() ? Arrow::right : Arrow::down); ::EndPaint(_hSelf, &ps); } + void Splitter::rotate() { if (!_isFixed) { destroy(); + if (_dwFlags & SV_HORIZONTAL) { _dwFlags ^= SV_HORIZONTAL; @@ -590,82 +589,101 @@ void Splitter::rotate() _dwFlags ^= SV_VERTICAL; _dwFlags |= SV_HORIZONTAL; } + init(_hInst, _hParent, _spiltterSize, _splitPercent, _dwFlags); } } + void Splitter::paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir) { RECT rc; rc.left = rect.left; rc.top = rect.top; rc.right = rect.right; rc.bottom = rect.bottom; - if (arrowDir == ARROW_LEFT) - { - int x = rc.right; - int y = rc.top; - //::MoveToEx(hdc, x, y, NULL); - for (; (x > rc.left) && (y != rc.bottom) ; x--) + switch (arrowDir) + { + case Arrow::left: { - ::MoveToEx(hdc, x, y++, NULL); - ::LineTo(hdc, x, rc.bottom--); + int x = rc.right; + int y = rc.top; + + //::MoveToEx(hdc, x, y, NULL); + for (; (x > rc.left) && (y != rc.bottom) ; --x) + { + ::MoveToEx(hdc, x, y++, NULL); + ::LineTo(hdc, x, rc.bottom--); + } + break; } - } - else if (arrowDir == ARROW_RIGHT) - { - int x = rc.left; - int y = rc.top; - //::MoveToEx(hdc, x, y, NULL); - for (; (x < rc.right) && (y != rc.bottom) ; ++x) + case Arrow::right: { - ::MoveToEx(hdc, x, y++, NULL); - ::LineTo(hdc, x, rc.bottom--); + int x = rc.left; + int y = rc.top; + + //::MoveToEx(hdc, x, y, NULL); + for (; (x < rc.right) && (y != rc.bottom) ; ++x) + { + ::MoveToEx(hdc, x, y++, NULL); + ::LineTo(hdc, x, rc.bottom--); + } + break; } - } - else if (arrowDir == ARROW_UP) - { - int x = rc.left; - int y = rc.bottom; - //::MoveToEx(hdc, x, y, NULL); - for (; (y > rc.top) && (x != rc.right) ; y--) + case Arrow::up: { - ::MoveToEx(hdc, x++, y, NULL); - ::LineTo(hdc, rc.right--, y); + int x = rc.left; + int y = rc.bottom; + + //::MoveToEx(hdc, x, y, NULL); + for (; (y > rc.top) && (x != rc.right) ; --y) + { + ::MoveToEx(hdc, x++, y, NULL); + ::LineTo(hdc, rc.right--, y); + } + break; } - } - else if (arrowDir == ARROW_DOWN) - { - int x = rc.left; - int y = rc.top; - //::MoveToEx(hdc, x, y, NULL); - for (; (y < rc.bottom) && (x != rc.right) ; ++y) + case Arrow::down: { - ::MoveToEx(hdc, x++, y, NULL); - ::LineTo(hdc, rc.right--, y); + int x = rc.left; + int y = rc.top; + + //::MoveToEx(hdc, x, y, NULL); + for (; (y < rc.bottom) && (x != rc.right) ; ++y) + { + ::MoveToEx(hdc, x++, y, NULL); + ::LineTo(hdc, rc.right--, y); + } + break; } } } -void Splitter::adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone) + + +void Splitter::adjustZoneToDraw(RECT& rc2def, ZONE_TYPE whichZone) { - if (_spiltterSize < 4) return; + if (_spiltterSize < 4) + return; + int x0, y0, x1, y1, w, h; + if ((4 <= _spiltterSize) && (_spiltterSize <= 8)) { - w = (isVertical()?4:7); - h = (isVertical()?7:4); + w = (isVertical() ? 4 : 7); + h = (isVertical() ? 7 : 4); } else // (_spiltterSize > 8) { - w = (isVertical()?6:11); - h = (isVertical()?11:6); + w = (isVertical() ? 6 : 11); + h = (isVertical() ? 11 : 6); } if (isVertical()) - {//w=4 h=7 - if (whichZone == TOP_LEFT) + { + // w=4 h=7 + if (whichZone == ZONE_TYPE::topLeft) { x0 = 0; y0 = (_clickZone2TL.bottom - h) / 2; @@ -675,12 +693,14 @@ void Splitter::adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone) x0 = _clickZone2BR.left + _clickZone2BR.right - w; y0 = (_clickZone2BR.bottom - h) / 2 + _clickZone2BR.top; } + x1 = x0 + w; y1 = y0 + h; } else // Horizontal - {//w=7 h=4 - if (whichZone == TOP_LEFT) + { + //w=7 h=4 + if (whichZone == ZONE_TYPE::topLeft) { x0 = (_clickZone2TL.right - w) / 2; y0 = 0; @@ -690,11 +710,14 @@ void Splitter::adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone) x0 = ((_clickZone2BR.right - w) / 2) + _clickZone2BR.left; y0 = _clickZone2BR.top + _clickZone2BR.bottom - h; } + x1 = x0 + w; y1 = y0 + h; } + rc2def.left = x0; rc2def.top = y0; rc2def.right = x1; rc2def.bottom = y1; } + diff --git a/PowerEditor/src/WinControls/SplitterContainer/Splitter.h b/PowerEditor/src/WinControls/SplitterContainer/Splitter.h index 7f4cbe14..b63f91fc 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/Splitter.h +++ b/PowerEditor/src/WinControls/SplitterContainer/Splitter.h @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -24,16 +24,11 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - -#ifndef SPLITTER_H -#define SPLITTER_H - -#ifndef RESOURCE_H +#pragma once #include "resource.h" -#endif //RESOURCE_H - #include "Window.h" +#include "Common.h" + #define SV_HORIZONTAL 0x00000001 #define SV_VERTICAL 0x00000002 @@ -50,81 +45,90 @@ const int HIEGHT_MINIMAL = 15; -enum Arrow {ARROW_LEFT, ARROW_UP, ARROW_RIGHT, ARROW_DOWN}; -typedef bool WH; -const bool WIDTH = true; -const bool HEIGHT = false; +enum class Arrow { left, up, right, down }; -typedef bool ZONE_TYPE; -const bool TOP_LEFT = true; -const bool BOTTOM_RIGHT = false; +enum class WH { height, width }; -enum SplitterMode { +enum class ZONE_TYPE { bottomRight, topLeft }; + +enum class SplitterMode: std::uint8_t +{ DYNAMIC, LEFT_FIX, RIGHT_FIX }; + + + + class Splitter : public Window { -public: +public: Splitter(); - ~Splitter(){}; - void destroy() { - ::DestroyWindow(_hSelf); - }; + virtual ~Splitter() = default; + + virtual void destroy() override; + void resizeSpliter(RECT *pRect = NULL); - void init(HINSTANCE hInst, HWND hPere, int splitterSize, - double iSplitRatio, DWORD dwFlags); + void init(HINSTANCE hInst, HWND hPere, int splitterSize, double iSplitRatio, DWORD dwFlags); void rotate(); - int getPhisicalSize() const { + + int getPhisicalSize() const + { return _spiltterSize; - }; + } + private: RECT _rect; - double _splitPercent; - int _spiltterSize; - bool _isDraged; - DWORD _dwFlags; - bool _isFixed; + double _splitPercent = 0.; + int _spiltterSize = 0; + bool _isDraged = false; + DWORD _dwFlags = 0; + bool _isFixed = false; static bool _isHorizontalRegistered; static bool _isVerticalRegistered; - static bool _isHorizontalFixedRegistered; - static bool _isVerticalFixedRegistered; + static bool _isHorizontalFixedRegistered; + static bool _isVerticalFixedRegistered; RECT _clickZone2TL, _clickZone2BR; static LRESULT CALLBACK staticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lParam); - int getClickZone(WH which); - void adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone); + int getClickZone(WH which); + void adjustZoneToDraw(RECT & rc2def, ZONE_TYPE whichZone); void drawSplitter(); bool isVertical() const {return (_dwFlags & SV_VERTICAL) != 0;}; void paintArrow(HDC hdc, const RECT &rect, Arrow arrowDir); void gotoTopLeft(); void gotoRightBouuom(); - bool isInLeftTopZone(const POINT &p) const { - return (((p.x >= _clickZone2TL.left) && (p.x <= _clickZone2TL.left + _clickZone2TL.right)) && - (p.y >= _clickZone2TL.top) && (p.y <= _clickZone2TL.top + _clickZone2TL.bottom)); - }; + bool isInLeftTopZone(const POINT& p) const + { + return ((p.x >= _clickZone2TL.left) + and (p.x <= _clickZone2TL.left + _clickZone2TL.right) + and (p.y >= _clickZone2TL.top) + and (p.y <= _clickZone2TL.top + _clickZone2TL.bottom)); + } - bool isInRightBottomZone(const POINT &p) const { - return (((p.x >= _clickZone2BR.left) && - (p.x <= _clickZone2BR.left + _clickZone2BR.right)) && - (p.y >= _clickZone2BR.top) && - (p.y <= _clickZone2BR.top + _clickZone2BR.bottom)); - }; - - int getSplitterFixPosX() { + bool isInRightBottomZone(const POINT& p) const + { + return ((p.x >= _clickZone2BR.left) + and (p.x <= _clickZone2BR.left + _clickZone2BR.right) + and (p.y >= _clickZone2BR.top) + and (p.y <= _clickZone2BR.top + _clickZone2BR.bottom)); + } + + int getSplitterFixPosX() const + { long result = long(::SendMessage(_hParent, WM_GETSPLITTER_X, 0, 0)); - return (LOWORD(result) - ((HIWORD(result) == RIGHT_FIX) ? _spiltterSize : 0)); - }; + return (LOWORD(result) - ((HIWORD(result) == static_cast(SplitterMode::RIGHT_FIX)) ? _spiltterSize : 0)); + } - int getSplitterFixPosY() { + int getSplitterFixPosY() const + { long result = long(::SendMessage(_hParent, WM_GETSPLITTER_Y, 0, 0)); - return (LOWORD(result) - ((HIWORD(result) == RIGHT_FIX) ? _spiltterSize : 0)); - }; + return (LOWORD(result) - ((HIWORD(result) == static_cast(SplitterMode::RIGHT_FIX)) ? _spiltterSize : 0)); + } }; -#endif //SPLITTER_H diff --git a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp index 1875f162..f09beb71 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp +++ b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp @@ -24,16 +24,18 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - #include #include #include "SplitterContainer.h" +#include + + bool SplitterContainer::_isRegistered = false; -void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize, - SplitterMode mode, int ratio, bool isVertical) + + +void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize, SplitterMode mode, int ratio, bool isVertical) { //Window::init(hInst, parent); _pWin0 = pWin0; @@ -42,9 +44,10 @@ void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize, _splitterMode = mode; _ratio = ratio; _dwSplitterStyle |= isVertical?SV_VERTICAL:SV_HORIZONTAL; - if (_splitterMode != DYNAMIC) + + if (_splitterMode != SplitterMode::DYNAMIC) { - _dwSplitterStyle |= SV_FIXED; + _dwSplitterStyle |= SV_FIXED; _dwSplitterStyle &= ~SV_RESIZEWTHPERCNT; } if (!_isRegistered) @@ -66,30 +69,63 @@ void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize, splitterContainerClass.lpszClassName = SPC_CLASS_NAME; if (!::RegisterClass(&splitterContainerClass)) - { throw std::runtime_error(" SplitterContainer::create : RegisterClass() function failed"); - } + _isRegistered = true; } _hSelf = ::CreateWindowEx( - 0, - SPC_CLASS_NAME, - TEXT("a koi sert?"), - WS_CHILD | WS_CLIPCHILDREN, - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - _hParent, - NULL, - _hInst, - (LPVOID)this); + 0, SPC_CLASS_NAME, TEXT("a koi sert?"), + WS_CHILD | WS_CLIPCHILDREN, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + _hParent, NULL, _hInst, this); if (!_hSelf) - { throw std::runtime_error(" SplitterContainer::create : CreateWindowEx() function return null"); - } } + +void SplitterContainer::destroy() +{ + if (_hPopupMenu) + ::DestroyMenu(_hPopupMenu); + + _splitter.destroy(); + ::DestroyWindow(_hSelf); +} + + +void SplitterContainer::reSizeTo(RECT & rc) +{ + _x = rc.left; + _y = rc.top; + ::MoveWindow(_hSelf, _x, _y, rc.right, rc.bottom, FALSE); + _splitter.resizeSpliter(); +} + + +void SplitterContainer::display(bool toShow) const +{ + Window::display(toShow); + + assert(_pWin0 != nullptr); + assert(_pWin1 != nullptr); + _pWin0->display(toShow); + _pWin1->display(toShow); + + _splitter.display(toShow); +} + + +void SplitterContainer::redraw() const +{ + assert(_pWin0 != nullptr); + assert(_pWin1 != nullptr); + _pWin0->redraw(true); + _pWin1->redraw(true); +} + + void SplitterContainer::rotateTo(DIRECTION direction) { bool doSwitchWindow = false; @@ -97,13 +133,13 @@ void SplitterContainer::rotateTo(DIRECTION direction) { _dwSplitterStyle ^= SV_VERTICAL; _dwSplitterStyle |= SV_HORIZONTAL; - doSwitchWindow = (direction == LEFT); + doSwitchWindow = (direction == DIRECTION::LEFT); } else { _dwSplitterStyle ^= SV_HORIZONTAL; _dwSplitterStyle |= SV_VERTICAL; - doSwitchWindow = (direction == RIGHT); + doSwitchWindow = (direction == DIRECTION::RIGHT); } if (doSwitchWindow) { @@ -120,42 +156,54 @@ LRESULT CALLBACK SplitterContainer::staticWinProc(HWND hwnd, UINT message, WPARA SplitterContainer *pSplitterContainer = NULL; switch (message) { - case WM_NCCREATE : + case WM_NCCREATE: + { pSplitterContainer = (SplitterContainer *)(((LPCREATESTRUCT)lParam)->lpCreateParams); pSplitterContainer->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pSplitterContainer); return TRUE; + } - default : + default: + { pSplitterContainer = (SplitterContainer *)::GetWindowLongPtr(hwnd, GWLP_USERDATA); if (!pSplitterContainer) return ::DefWindowProc(hwnd, message, wParam, lParam); return pSplitterContainer->runProc(message, wParam, lParam); + } } } + LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { - case WM_CREATE : + case WM_CREATE: + { _splitter.init(_hInst, _hSelf, _splitterSize, _ratio, _dwSplitterStyle); return TRUE; + } - case WM_COMMAND : + case WM_COMMAND: { switch (LOWORD(wParam)) { case ROTATION_A_GAUCHE: - rotateTo(LEFT); - return TRUE; + { + rotateTo(DIRECTION::LEFT); + break; + } case ROTATION_A_DROITE: - rotateTo(RIGHT); - return TRUE; + { + rotateTo(DIRECTION::RIGHT); + break; + } } return TRUE; } - case WM_RESIZE_CONTAINER : + + case WM_RESIZE_CONTAINER: { RECT rc0, rc1; getClientRect(rc0); @@ -192,9 +240,9 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam) return TRUE; } - case WM_DOPOPUPMENU : + case WM_DOPOPUPMENU: { - if ((_splitterMode != LEFT_FIX) && (_splitterMode != RIGHT_FIX) ) + if ((_splitterMode != SplitterMode::LEFT_FIX) && (_splitterMode != SplitterMode::RIGHT_FIX) ) { POINT p; ::GetCursorPos(&p); @@ -213,36 +261,48 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam) return TRUE; } - case WM_GETSPLITTER_X : - { - if (_splitterMode == LEFT_FIX) - return MAKELONG(_pWin0->getWidth(), LEFT_FIX); - else if (_splitterMode == RIGHT_FIX) - { - int x = getWidth()-_pWin1->getWidth(); - if (x < 0) - x = 0; - return MAKELONG(x, RIGHT_FIX); - } - else - return MAKELONG(0, DYNAMIC); + case WM_GETSPLITTER_X: + { + switch (_splitterMode) + { + case SplitterMode::LEFT_FIX: + { + return MAKELONG(_pWin0->getWidth(), static_cast(SplitterMode::LEFT_FIX)); + } - } + case SplitterMode::RIGHT_FIX: + { + int x = getWidth()-_pWin1->getWidth(); + if (x < 0) + x = 0; + return MAKELONG(x, static_cast(SplitterMode::RIGHT_FIX)); + } + default: + break; + } + return MAKELONG(0, static_cast(SplitterMode::DYNAMIC)); + } - case WM_GETSPLITTER_Y : - { - if (_splitterMode == LEFT_FIX) - return MAKELONG(_pWin0->getHeight(), LEFT_FIX); - else if (_splitterMode == RIGHT_FIX) - { - int y = getHeight()-_pWin1->getHeight(); - if (y < 0) - y = 0; - return MAKELONG(y, RIGHT_FIX); - } - else - return MAKELONG(0, DYNAMIC); - } + case WM_GETSPLITTER_Y: + { + switch (_splitterMode) + { + case SplitterMode::LEFT_FIX: + { + return MAKELONG(_pWin0->getHeight(), static_cast(SplitterMode::LEFT_FIX)); + } + case SplitterMode::RIGHT_FIX: + { + int y = getHeight()-_pWin1->getHeight(); + if (y < 0) + y = 0; + return MAKELONG(y, static_cast(SplitterMode::RIGHT_FIX)); + } + default: + break; + } + return MAKELONG(0, static_cast(SplitterMode::DYNAMIC)); + } case WM_LBUTTONDBLCLK: { @@ -250,21 +310,18 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam) ::GetCursorPos(&pt); ::ScreenToClient(_splitter.getHSelf(), &pt); - Window* targetWindow; - - if(this->isVertical()) - targetWindow = pt.x < 0?_pWin0:_pWin1; - else - targetWindow = pt.y < 0?_pWin0:_pWin1; - HWND parent = ::GetParent(getHSelf()); + Window* targetWindow = (this->isVertical()) + ? (pt.x < 0 ? _pWin0 : _pWin1) + : (pt.y < 0 ? _pWin0 : _pWin1); + ::SendMessage(parent, NPPM_INTERNAL_SWITCHVIEWFROMHWND, 0, (LPARAM)targetWindow->getHSelf()); ::SendMessage(parent, WM_COMMAND, IDM_FILE_NEW, 0); return TRUE; } - default : + default: return ::DefWindowProc(_hSelf, message, wParam, lParam); } } diff --git a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.h b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.h index 9afb49f3..9675b2bd 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.h +++ b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.h @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -24,94 +24,74 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - -#ifndef SPLITTER_CONTAINER_H -#define SPLITTER_CONTAINER_H - -#ifndef SPLITTER_H +#pragma once #include "Splitter.h" -#endif //SPLITTER_H - -#ifndef MENUCMDID_H #include "menuCmdID.h" -#endif //MENUCMDID_H + #define SPC_CLASS_NAME TEXT("splitterContainer") #define ROTATION_A_GAUCHE 2000 #define ROTATION_A_DROITE 2001 -typedef bool DIRECTION; -const bool LEFT = true; -const bool RIGHT = false; + +enum class DIRECTION +{ + RIGHT, + LEFT +}; + class SplitterContainer : public Window { public : - SplitterContainer(): Window(), _x(0), _y(0), _hPopupMenu(NULL), - _dwSplitterStyle(SV_ENABLERDBLCLK | SV_ENABLELDBLCLK | SV_RESIZEWTHPERCNT){ - }; - ~SplitterContainer(){}; + virtual ~SplitterContainer() = default; + void create(Window *pWin0, Window *pWin1, int splitterSize = 4, - SplitterMode mode = DYNAMIC, int ratio = 50, bool _isVertical = true); + SplitterMode mode = SplitterMode::DYNAMIC, int ratio = 50, bool _isVertical = true); - void destroy() { - if (_hPopupMenu) - ::DestroyMenu(_hPopupMenu); - _splitter.destroy(); - ::DestroyWindow(_hSelf); - }; - void reSizeTo(RECT & rc) { - _x = rc.left; - _y = rc.top; - ::MoveWindow(_hSelf, _x, _y, rc.right, rc.bottom, FALSE); - _splitter.resizeSpliter(); - }; - virtual void display(bool toShow = true) const { - Window::display(toShow); - - _pWin0->display(toShow); - _pWin1->display(toShow); - _splitter.display(toShow); - }; - virtual void redraw() const { - _pWin0->redraw(true); - _pWin1->redraw(true); - }; + void destroy(); - void setWin0(Window *pWin) { - _pWin0 = pWin; + void reSizeTo(RECT & rc); - }; + virtual void display(bool toShow = true) const; - void setWin1(Window *pWin) { - _pWin1 = pWin; - }; + virtual void redraw() const; - bool isVertical() const { + void setWin0(Window* pWin) + { + _pWin0 = pWin; + } + + void setWin1(Window* pWin) + { + _pWin1 = pWin; + } + + bool isVertical() const + { return ((_dwSplitterStyle & SV_VERTICAL) != 0); - }; + } + + private : - Window *_pWin0; // left or top window - Window *_pWin1; // right or bottom window + Window* _pWin0 = nullptr; // left or top window + Window* _pWin1 = nullptr; // right or bottom window Splitter _splitter; - int _splitterSize; - int _ratio; - int _x, _y; - HMENU _hPopupMenu; - DWORD _dwSplitterStyle; + int _splitterSize = 0; + int _ratio = 0; + int _x = 0; + int _y = 0; + HMENU _hPopupMenu = NULL; + DWORD _dwSplitterStyle = (SV_ENABLERDBLCLK | SV_ENABLELDBLCLK | SV_RESIZEWTHPERCNT); - SplitterMode _splitterMode; + SplitterMode _splitterMode = SplitterMode::DYNAMIC; static bool _isRegistered; static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); LRESULT runProc(UINT Message, WPARAM wParam, LPARAM lParam); void rotateTo(DIRECTION direction); - }; - -#endif //SPLITTER_CONTAINER_H diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index fc359adc..281d7c92 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp @@ -29,14 +29,51 @@ #include #include "StaticDialog.h" + + +StaticDialog::~StaticDialog() +{ + if (isCreated()) + { + // Prevent run_dlgProc from doing anything, since its virtual + ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR) NULL); + destroy(); + } +} + + +void StaticDialog::destroy() +{ + ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_hSelf); + ::DestroyWindow(_hSelf); +} + + +POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const +{ + RECT rc; + ::GetWindowRect(hwnd, &rc); + + POINT p; + if (isLeft) + p.x = rc.left; + else + p.x = rc.right; + + p.y = rc.top; + ::ScreenToClient(_hSelf, &p); + return p; +} + + void StaticDialog::goToCenter() { - RECT rc; - ::GetClientRect(_hParent, &rc); - POINT center; - center.x = rc.left + (rc.right - rc.left)/2; - center.y = rc.top + (rc.bottom - rc.top)/2; - ::ClientToScreen(_hParent, ¢er); + RECT rc; + ::GetClientRect(_hParent, &rc); + POINT center; + center.x = rc.left + (rc.right - rc.left)/2; + center.y = rc.top + (rc.bottom - rc.top)/2; + ::ClientToScreen(_hParent, ¢er); int x = center.x - (_rc.right - _rc.left)/2; int y = center.y - (_rc.bottom - _rc.top)/2; @@ -47,7 +84,8 @@ void StaticDialog::goToCenter() void StaticDialog::display(bool toShow) const { - if (toShow) { + if (toShow) + { // If the user has switched from a dual monitor to a single monitor since we last // displayed the dialog, then ensure that it's still visible on the single monitor. RECT workAreaRect = {0}; @@ -57,6 +95,7 @@ void StaticDialog::display(bool toShow) const int newLeft = rc.left; int newTop = rc.top; int margin = ::GetSystemMetrics(SM_CYSMCAPTION); + if (newLeft > ::GetSystemMetrics(SM_CXVIRTUALSCREEN)-margin) newLeft -= rc.right - workAreaRect.right; if (newLeft + (rc.right - rc.left) < ::GetSystemMetrics(SM_XVIRTUALSCREEN)+margin) @@ -131,22 +170,23 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent) ::SendMessage(msgDestParent?_hParent:(::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (WPARAM)_hSelf); } + INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { - case WM_INITDIALOG : + case WM_INITDIALOG: { StaticDialog *pStaticDlg = (StaticDialog *)(lParam); pStaticDlg->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); ::GetWindowRect(hwnd, &(pStaticDlg->_rc)); - pStaticDlg->run_dlgProc(message, wParam, lParam); + pStaticDlg->run_dlgProc(message, wParam, lParam); return TRUE; } - default : + default: { StaticDialog *pStaticDlg = reinterpret_cast(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); if (!pStaticDlg) @@ -158,34 +198,39 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point) { - RECT rc, rc2; - ::GetWindowRect(handle, &rc); + RECT rc, rc2; + ::GetWindowRect(handle, &rc); - point.x = rc.left; - point.y = rc.top; + point.x = rc.left; + point.y = rc.top; - switch (pos) - { - case ALIGNPOS_LEFT : - ::GetWindowRect(handle2Align, &rc2); - point.x -= rc2.right - rc2.left; - break; + switch (pos) + { + case PosAlign::left: + { + ::GetWindowRect(handle2Align, &rc2); + point.x -= rc2.right - rc2.left; + break; + } + case PosAlign::right: + { + ::GetWindowRect(handle, &rc2); + point.x += rc2.right - rc2.left; + break; + } + case PosAlign::top: + { + ::GetWindowRect(handle2Align, &rc2); + point.y -= rc2.bottom - rc2.top; + break; + } + case PosAlign::bottom: + { + ::GetWindowRect(handle, &rc2); + point.y += rc2.bottom - rc2.top; + break; + } + } - case ALIGNPOS_RIGHT : - ::GetWindowRect(handle, &rc2); - point.x += rc2.right - rc2.left; - break; - - case ALIGNPOS_TOP : - ::GetWindowRect(handle2Align, &rc2); - point.y -= rc2.bottom - rc2.top; - break; - - default : //ALIGNPOS_BOTTOM - ::GetWindowRect(handle, &rc2); - point.y += rc2.bottom - rc2.top; - break; - } - - ::ScreenToClient(_hSelf, &point); + ::ScreenToClient(_hSelf, &point); } diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h index 2bf054ae..90982c9f 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -24,81 +24,64 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - -#ifndef STATIC_DIALOG_H -#define STATIC_DIALOG_H - +#pragma once #include "Notepad_plus_msgs.h" #include "Window.h" + typedef HRESULT (WINAPI * ETDTProc) (HWND, DWORD); -enum PosAlign{ALIGNPOS_LEFT, ALIGNPOS_RIGHT, ALIGNPOS_TOP, ALIGNPOS_BOTTOM}; +enum class PosAlign { left, right, top, bottom }; -struct DLGTEMPLATEEX { + +struct DLGTEMPLATEEX +{ WORD dlgVer; WORD signature; DWORD helpID; DWORD exStyle; - DWORD style; + DWORD style; WORD cDlgItems; short x; - short y; + short y; short cx; short cy; // The structure has more fields but are variable length -} ; +}; + + class StaticDialog : public Window { public : - StaticDialog() : Window() {}; - ~StaticDialog(){ - if (isCreated()) { - ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)NULL); //Prevent run_dlgProc from doing anything, since its virtual - destroy(); - } - }; + virtual ~StaticDialog(); + virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true); - virtual bool isCreated() const { + virtual bool isCreated() const + { return (_hSelf != NULL); - }; + } void goToCenter(); void display(bool toShow = true) const; - POINT getTopPoint(HWND hwnd, bool isLeft = true) const { - RECT rc; - ::GetWindowRect(hwnd, &rc); - POINT p; - if (isLeft) - p.x = rc.left; - else - p.x = rc.right; - p.y = rc.top; - ::ScreenToClient(_hSelf, &p); - return p; - }; + POINT getTopPoint(HWND hwnd, bool isLeft = true) const; - bool isCheckedOrNot(int checkControlID) const { + bool isCheckedOrNot(int checkControlID) const + { return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0)); - }; + } - void destroy() { - ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_hSelf); - ::DestroyWindow(_hSelf); - }; + virtual void destroy() override; -protected : + +protected: RECT _rc; static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0; void alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point); HGLOBAL makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate); -}; - -#endif //STATIC_DIALOG_H +}; \ No newline at end of file diff --git a/PowerEditor/src/WinControls/Window.h b/PowerEditor/src/WinControls/Window.h index 42b8dae6..17f5b0ff 100644 --- a/PowerEditor/src/WinControls/Window.h +++ b/PowerEditor/src/WinControls/Window.h @@ -33,7 +33,13 @@ class Window { public: + //! \name Constructors & Destructor + //@{ + Window() = default; + Window(const Window&) = delete; virtual ~Window() = default; + //@} + virtual void init(HINSTANCE hInst, HWND parent) { @@ -123,6 +129,9 @@ public: } + Window& operator = (const Window&) = delete; + + protected: HINSTANCE _hInst = NULL; HWND _hParent = NULL; diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 1f74f3f0..18371c9f 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -7,10 +7,10 @@ // version 2 of the License, or (at your option) any later version. // // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a +// it does not provide a detailed definition of that term. To avoid +// misunderstandings, we consider an application to constitute a // "derivative work" for the purpose of this license if it does any of the -// following: +// following: // 1. Integrates source code from Notepad++. // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // installer, such as those produced by InstallShield. @@ -24,178 +24,176 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - -#ifndef RESOURCE_H -#define RESOURCE_H +#pragma once #define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v6.8.1") -// should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71 + +// should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71 // ex : #define VERSION_VALUE TEXT("5.63\0") #define VERSION_VALUE TEXT("6.8.1\0") #define VERSION_DIGITALVALUE 6, 8, 1, 0 #ifndef IDC_STATIC -#define IDC_STATIC -1 +#define IDC_STATIC -1 #endif -#define IDI_M30ICON 100 -#define IDI_CHAMELEON 101 -//#define IDI_JESUISCHARLIE 102 +#define IDI_M30ICON 100 +#define IDI_CHAMELEON 101 +//#define IDI_JESUISCHARLIE 102 #define IDR_RT_MANIFEST 103 -#define IDI_NEW_OFF_ICON 201 -#define IDI_OPEN_OFF_ICON 202 -#define IDI_CLOSE_OFF_ICON 203 -#define IDI_CLOSEALL_OFF_ICON 204 -#define IDI_SAVE_OFF_ICON 205 -#define IDI_SAVEALL_OFF_ICON 206 -#define IDI_CUT_OFF_ICON 207 -#define IDI_COPY_OFF_ICON 208 -#define IDI_PASTE_OFF_ICON 209 -#define IDI_UNDO_OFF_ICON 210 -#define IDI_REDO_OFF_ICON 211 -#define IDI_FIND_OFF_ICON 212 -#define IDI_REPLACE_OFF_ICON 213 -#define IDI_ZOOMIN_OFF_ICON 214 -#define IDI_ZOOMOUT_OFF_ICON 215 -#define IDI_VIEW_UD_DLG_OFF_ICON 216 -#define IDI_PRINT_OFF_ICON 217 -#define IDI_VIEW_ALL_CHAR_ON_ICON 218 -#define IDI_VIEW_INDENT_ON_ICON 219 -#define IDI_VIEW_WRAP_ON_ICON 220 +#define IDI_NEW_OFF_ICON 201 +#define IDI_OPEN_OFF_ICON 202 +#define IDI_CLOSE_OFF_ICON 203 +#define IDI_CLOSEALL_OFF_ICON 204 +#define IDI_SAVE_OFF_ICON 205 +#define IDI_SAVEALL_OFF_ICON 206 +#define IDI_CUT_OFF_ICON 207 +#define IDI_COPY_OFF_ICON 208 +#define IDI_PASTE_OFF_ICON 209 +#define IDI_UNDO_OFF_ICON 210 +#define IDI_REDO_OFF_ICON 211 +#define IDI_FIND_OFF_ICON 212 +#define IDI_REPLACE_OFF_ICON 213 +#define IDI_ZOOMIN_OFF_ICON 214 +#define IDI_ZOOMOUT_OFF_ICON 215 +#define IDI_VIEW_UD_DLG_OFF_ICON 216 +#define IDI_PRINT_OFF_ICON 217 +#define IDI_VIEW_ALL_CHAR_ON_ICON 218 +#define IDI_VIEW_INDENT_ON_ICON 219 +#define IDI_VIEW_WRAP_ON_ICON 220 -#define IDI_STARTRECORD_OFF_ICON 221 -#define IDI_STARTRECORD_ON_ICON 222 -#define IDI_STARTRECORD_DISABLE_ICON 223 -#define IDI_STOPRECORD_OFF_ICON 224 -#define IDI_STOPRECORD_ON_ICON 225 -#define IDI_STOPRECORD_DISABLE_ICON 226 -#define IDI_PLAYRECORD_OFF_ICON 227 -#define IDI_PLAYRECORD_ON_ICON 228 -#define IDI_PLAYRECORD_DISABLE_ICON 229 -#define IDI_SAVERECORD_OFF_ICON 230 -#define IDI_SAVERECORD_ON_ICON 231 -#define IDI_SAVERECORD_DISABLE_ICON 232 +#define IDI_STARTRECORD_OFF_ICON 221 +#define IDI_STARTRECORD_ON_ICON 222 +#define IDI_STARTRECORD_DISABLE_ICON 223 +#define IDI_STOPRECORD_OFF_ICON 224 +#define IDI_STOPRECORD_ON_ICON 225 +#define IDI_STOPRECORD_DISABLE_ICON 226 +#define IDI_PLAYRECORD_OFF_ICON 227 +#define IDI_PLAYRECORD_ON_ICON 228 +#define IDI_PLAYRECORD_DISABLE_ICON 229 +#define IDI_SAVERECORD_OFF_ICON 230 +#define IDI_SAVERECORD_ON_ICON 231 +#define IDI_SAVERECORD_DISABLE_ICON 232 // multi run macro -#define IDI_MMPLAY_DIS_ICON 233 -#define IDI_MMPLAY_OFF_ICON 234 -#define IDI_MMPLAY_ON_ICON 235 +#define IDI_MMPLAY_DIS_ICON 233 +#define IDI_MMPLAY_OFF_ICON 234 +#define IDI_MMPLAY_ON_ICON 235 -#define IDI_NEW_ON_ICON 301 -#define IDI_OPEN_ON_ICON 302 -#define IDI_CLOSE_ON_ICON 303 -#define IDI_CLOSEALL_ON_ICON 304 -#define IDI_SAVE_ON_ICON 305 -#define IDI_SAVEALL_ON_ICON 306 -#define IDI_CUT_ON_ICON 307 -#define IDI_COPY_ON_ICON 308 -#define IDI_PASTE_ON_ICON 309 -#define IDI_UNDO_ON_ICON 310 -#define IDI_REDO_ON_ICON 311 -#define IDI_FIND_ON_ICON 312 -#define IDI_REPLACE_ON_ICON 313 -#define IDI_ZOOMIN_ON_ICON 314 -#define IDI_ZOOMOUT_ON_ICON 315 -#define IDI_VIEW_UD_DLG_ON_ICON 316 -#define IDI_PRINT_ON_ICON 317 -#define IDI_VIEW_ALL_CHAR_OFF_ICON 318 -#define IDI_VIEW_INDENT_OFF_ICON 319 -#define IDI_VIEW_WRAP_OFF_ICON 320 +#define IDI_NEW_ON_ICON 301 +#define IDI_OPEN_ON_ICON 302 +#define IDI_CLOSE_ON_ICON 303 +#define IDI_CLOSEALL_ON_ICON 304 +#define IDI_SAVE_ON_ICON 305 +#define IDI_SAVEALL_ON_ICON 306 +#define IDI_CUT_ON_ICON 307 +#define IDI_COPY_ON_ICON 308 +#define IDI_PASTE_ON_ICON 309 +#define IDI_UNDO_ON_ICON 310 +#define IDI_REDO_ON_ICON 311 +#define IDI_FIND_ON_ICON 312 +#define IDI_REPLACE_ON_ICON 313 +#define IDI_ZOOMIN_ON_ICON 314 +#define IDI_ZOOMOUT_ON_ICON 315 +#define IDI_VIEW_UD_DLG_ON_ICON 316 +#define IDI_PRINT_ON_ICON 317 +#define IDI_VIEW_ALL_CHAR_OFF_ICON 318 +#define IDI_VIEW_INDENT_OFF_ICON 319 +#define IDI_VIEW_WRAP_OFF_ICON 320 -//#define IDI_NEW_DISABLE_ICON 401 -//#define IDI_OPEN_ON_ICON 402 -#define IDI_SAVE_DISABLE_ICON 403 -#define IDI_SAVEALL_DISABLE_ICON 404 -//#define IDI_CLOSE_ON_ICON 405 -//#define IDI_CLOSEALL_ON_ICON 406 -#define IDI_CUT_DISABLE_ICON 407 -#define IDI_COPY_DISABLE_ICON 408 -#define IDI_PASTE_DISABLE_ICON 409 -#define IDI_UNDO_DISABLE_ICON 410 -#define IDI_REDO_DISABLE_ICON 411 -#define IDI_DELETE_ICON 412 +//#define IDI_NEW_DISABLE_ICON 401 +//#define IDI_OPEN_ON_ICON 402 +#define IDI_SAVE_DISABLE_ICON 403 +#define IDI_SAVEALL_DISABLE_ICON 404 +//#define IDI_CLOSE_ON_ICON 405 +//#define IDI_CLOSEALL_ON_ICON 406 +#define IDI_CUT_DISABLE_ICON 407 +#define IDI_COPY_DISABLE_ICON 408 +#define IDI_PASTE_DISABLE_ICON 409 +#define IDI_UNDO_DISABLE_ICON 410 +#define IDI_REDO_DISABLE_ICON 411 +#define IDI_DELETE_ICON 412 -#define IDI_SYNCV_OFF_ICON 413 -#define IDI_SYNCV_ON_ICON 414 -#define IDI_SYNCV_DISABLE_ICON 415 +#define IDI_SYNCV_OFF_ICON 413 +#define IDI_SYNCV_ON_ICON 414 +#define IDI_SYNCV_DISABLE_ICON 415 -#define IDI_SYNCH_OFF_ICON 416 -#define IDI_SYNCH_ON_ICON 417 -#define IDI_SYNCH_DISABLE_ICON 418 +#define IDI_SYNCH_OFF_ICON 416 +#define IDI_SYNCH_ON_ICON 417 +#define IDI_SYNCH_DISABLE_ICON 418 -#define IDI_SAVED_ICON 501 -#define IDI_UNSAVED_ICON 502 -#define IDI_READONLY_ICON 503 -#define IDI_FIND_RESULT_ICON 504 +#define IDI_SAVED_ICON 501 +#define IDI_UNSAVED_ICON 502 +#define IDI_READONLY_ICON 503 +#define IDI_FIND_RESULT_ICON 504 -#define IDI_PROJECT_WORKSPACE 601 -#define IDI_PROJECT_WORKSPACEDIRTY 602 -#define IDI_PROJECT_PROJECT 603 -#define IDI_PROJECT_FOLDEROPEN 604 -#define IDI_PROJECT_FOLDERCLOSE 605 -#define IDI_PROJECT_FILE 606 -#define IDI_PROJECT_FILEINVALID 607 +#define IDI_PROJECT_WORKSPACE 601 +#define IDI_PROJECT_WORKSPACEDIRTY 602 +#define IDI_PROJECT_PROJECT 603 +#define IDI_PROJECT_FOLDEROPEN 604 +#define IDI_PROJECT_FOLDERCLOSE 605 +#define IDI_PROJECT_FILE 606 +#define IDI_PROJECT_FILEINVALID 607 -#define IDI_FUNCLIST_ROOT 620 -#define IDI_FUNCLIST_NODE 621 -#define IDI_FUNCLIST_LEAF 622 +#define IDI_FUNCLIST_ROOT 620 +#define IDI_FUNCLIST_NODE 621 +#define IDI_FUNCLIST_LEAF 622 -#define IDI_FUNCLIST_SORTBUTTON 631 -#define IDI_FUNCLIST_RELOADBUTTON 632 +#define IDI_FUNCLIST_SORTBUTTON 631 +#define IDI_FUNCLIST_RELOADBUTTON 632 -#define IDC_MY_CUR 1402 -#define IDC_UP_ARROW 1403 -#define IDC_DRAG_TAB 1404 -#define IDC_DRAG_INTERDIT_TAB 1405 -#define IDC_DRAG_PLUS_TAB 1406 -#define IDC_DRAG_OUT_TAB 1407 +#define IDC_MY_CUR 1402 +#define IDC_UP_ARROW 1403 +#define IDC_DRAG_TAB 1404 +#define IDC_DRAG_INTERDIT_TAB 1405 +#define IDC_DRAG_PLUS_TAB 1406 +#define IDC_DRAG_OUT_TAB 1407 -#define IDC_MACRO_RECORDING 1408 +#define IDC_MACRO_RECORDING 1408 -#define IDR_SAVEALL 1500 -#define IDR_CLOSEFILE 1501 -#define IDR_CLOSEALL 1502 -#define IDR_FIND 1503 -#define IDR_REPLACE 1504 -#define IDR_ZOOMIN 1505 -#define IDR_ZOOMOUT 1506 -#define IDR_WRAP 1507 -#define IDR_INVISIBLECHAR 1508 -#define IDR_INDENTGUIDE 1509 -#define IDR_SHOWPANNEL 1510 -#define IDR_STARTRECORD 1511 -#define IDR_STOPRECORD 1512 -#define IDR_PLAYRECORD 1513 -#define IDR_SAVERECORD 1514 -#define IDR_SYNCV 1515 -#define IDR_SYNCH 1516 -#define IDR_FILENEW 1517 -#define IDR_FILEOPEN 1518 -#define IDR_FILESAVE 1519 -#define IDR_PRINT 1520 -#define IDR_CUT 1521 -#define IDR_COPY 1522 -#define IDR_PASTE 1523 -#define IDR_UNDO 1524 -#define IDR_REDO 1525 -#define IDR_M_PLAYRECORD 1526 -#define IDR_DOCMAP 1527 -#define IDR_FUNC_LIST 1528 -#define IDR_CLOSETAB 1530 -#define IDR_CLOSETAB_INACT 1531 -#define IDR_CLOSETAB_HOVER 1532 -#define IDR_CLOSETAB_PUSH 1533 +#define IDR_SAVEALL 1500 +#define IDR_CLOSEFILE 1501 +#define IDR_CLOSEALL 1502 +#define IDR_FIND 1503 +#define IDR_REPLACE 1504 +#define IDR_ZOOMIN 1505 +#define IDR_ZOOMOUT 1506 +#define IDR_WRAP 1507 +#define IDR_INVISIBLECHAR 1508 +#define IDR_INDENTGUIDE 1509 +#define IDR_SHOWPANNEL 1510 +#define IDR_STARTRECORD 1511 +#define IDR_STOPRECORD 1512 +#define IDR_PLAYRECORD 1513 +#define IDR_SAVERECORD 1514 +#define IDR_SYNCV 1515 +#define IDR_SYNCH 1516 +#define IDR_FILENEW 1517 +#define IDR_FILEOPEN 1518 +#define IDR_FILESAVE 1519 +#define IDR_PRINT 1520 +#define IDR_CUT 1521 +#define IDR_COPY 1522 +#define IDR_PASTE 1523 +#define IDR_UNDO 1524 +#define IDR_REDO 1525 +#define IDR_M_PLAYRECORD 1526 +#define IDR_DOCMAP 1527 +#define IDR_FUNC_LIST 1528 +#define IDR_CLOSETAB 1530 +#define IDR_CLOSETAB_INACT 1531 +#define IDR_CLOSETAB_HOVER 1532 +#define IDR_CLOSETAB_PUSH 1533 -#define IDR_FUNC_LIST_ICO 1534 -#define IDR_DOCMAP_ICO 1535 -#define IDR_PROJECTPANEL_ICO 1536 -#define IDR_CLIPBOARDPANEL_ICO 1537 -#define IDR_ASCIIPANEL_ICO 1538 -#define IDR_DOCSWITCHER_ICO 1539 +#define IDR_FUNC_LIST_ICO 1534 +#define IDR_DOCMAP_ICO 1535 +#define IDR_PROJECTPANEL_ICO 1536 +#define IDR_CLIPBOARDPANEL_ICO 1537 +#define IDR_ASCIIPANEL_ICO 1538 +#define IDR_DOCSWITCHER_ICO 1539 #define ID_MACRO 20000 #define ID_MACRO_LIMIT 20200 @@ -207,7 +205,7 @@ #define ID_PLUGINS_CMD_LIMIT 22500 #define ID_PLUGINS_CMD_DYNAMIC 23000 -#define ID_PLUGINS_CMD_DYNAMIC_LIMIT 24999 +#define ID_PLUGINS_CMD_DYNAMIC_LIMIT 24999 #define MARKER_PLUGINS 3 #define MARKER_PLUGINS_LIMIT 19 @@ -220,136 +218,136 @@ //#define IDM 40000 #define IDCMD 50000 - //#define IDM_EDIT_AUTOCOMPLETE (IDCMD+0) - //#define IDM_EDIT_AUTOCOMPLETE_CURRENTFILE (IDCMD+1) - - #define IDC_PREV_DOC (IDCMD+3) - #define IDC_NEXT_DOC (IDCMD+4) - #define IDC_EDIT_TOGGLEMACRORECORDING (IDCMD+5) - //#define IDC_KEY_HOME (IDCMD+6) - //#define IDC_KEY_END (IDCMD+7) - //#define IDC_KEY_SELECT_2_HOME (IDCMD+8) - //#define IDC_KEY_SELECT_2_END (IDCMD+9) - -#define IDCMD_LIMIT (IDCMD+20) + //#define IDM_EDIT_AUTOCOMPLETE (IDCMD+0) + //#define IDM_EDIT_AUTOCOMPLETE_CURRENTFILE (IDCMD+1) -#define IDSCINTILLA 60000 - #define IDSCINTILLA_KEY_HOME (IDSCINTILLA+0) - #define IDSCINTILLA_KEY_HOME_WRAP (IDSCINTILLA+1) - #define IDSCINTILLA_KEY_END (IDSCINTILLA+2) - #define IDSCINTILLA_KEY_END_WRAP (IDSCINTILLA+3) - #define IDSCINTILLA_KEY_LINE_DUP (IDSCINTILLA+4) - #define IDSCINTILLA_KEY_LINE_CUT (IDSCINTILLA+5) - #define IDSCINTILLA_KEY_LINE_DEL (IDSCINTILLA+6) - #define IDSCINTILLA_KEY_LINE_TRANS (IDSCINTILLA+7) - #define IDSCINTILLA_KEY_LINE_COPY (IDSCINTILLA+8) - #define IDSCINTILLA_KEY_CUT (IDSCINTILLA+9) - #define IDSCINTILLA_KEY_COPY (IDSCINTILLA+10) - #define IDSCINTILLA_KEY_PASTE (IDSCINTILLA+11) - #define IDSCINTILLA_KEY_DEL (IDSCINTILLA+12) - #define IDSCINTILLA_KEY_SELECTALL (IDSCINTILLA+13) - #define IDSCINTILLA_KEY_OUTDENT (IDSCINTILLA+14) - #define IDSCINTILLA_KEY_UNDO (IDSCINTILLA+15) - #define IDSCINTILLA_KEY_REDO (IDSCINTILLA+16) -#define IDSCINTILLA_LIMIT (IDSCINTILLA+30) + #define IDC_PREV_DOC (IDCMD+3) + #define IDC_NEXT_DOC (IDCMD+4) + #define IDC_EDIT_TOGGLEMACRORECORDING (IDCMD+5) + //#define IDC_KEY_HOME (IDCMD+6) + //#define IDC_KEY_END (IDCMD+7) + //#define IDC_KEY_SELECT_2_HOME (IDCMD+8) + //#define IDC_KEY_SELECT_2_END (IDCMD+9) -#define IDD_FILEVIEW_DIALOG 1000 +#define IDCMD_LIMIT (IDCMD+20) -#define IDC_MINIMIZED_TRAY 67001 +#define IDSCINTILLA 60000 + #define IDSCINTILLA_KEY_HOME (IDSCINTILLA+0) + #define IDSCINTILLA_KEY_HOME_WRAP (IDSCINTILLA+1) + #define IDSCINTILLA_KEY_END (IDSCINTILLA+2) + #define IDSCINTILLA_KEY_END_WRAP (IDSCINTILLA+3) + #define IDSCINTILLA_KEY_LINE_DUP (IDSCINTILLA+4) + #define IDSCINTILLA_KEY_LINE_CUT (IDSCINTILLA+5) + #define IDSCINTILLA_KEY_LINE_DEL (IDSCINTILLA+6) + #define IDSCINTILLA_KEY_LINE_TRANS (IDSCINTILLA+7) + #define IDSCINTILLA_KEY_LINE_COPY (IDSCINTILLA+8) + #define IDSCINTILLA_KEY_CUT (IDSCINTILLA+9) + #define IDSCINTILLA_KEY_COPY (IDSCINTILLA+10) + #define IDSCINTILLA_KEY_PASTE (IDSCINTILLA+11) + #define IDSCINTILLA_KEY_DEL (IDSCINTILLA+12) + #define IDSCINTILLA_KEY_SELECTALL (IDSCINTILLA+13) + #define IDSCINTILLA_KEY_OUTDENT (IDSCINTILLA+14) + #define IDSCINTILLA_KEY_UNDO (IDSCINTILLA+15) + #define IDSCINTILLA_KEY_REDO (IDSCINTILLA+16) +#define IDSCINTILLA_LIMIT (IDSCINTILLA+30) -#define IDD_CREATE_DIRECTORY 1100 +#define IDD_FILEVIEW_DIALOG 1000 + +#define IDC_MINIMIZED_TRAY 67001 + +#define IDD_CREATE_DIRECTORY 1100 #define IDC_STATIC_CURRENT_FOLDER 1101 #define IDC_EDIT_NEW_FOLDER 1102 -#define IDD_INSERT_INPUT_TEXT 1200 -#define IDC_EDIT_INPUT_VALUE 1201 -#define IDC_STATIC_INPUT_TITLE 1202 -#define IDC_ICON_INPUT_ICON 1203 +#define IDD_INSERT_INPUT_TEXT 1200 +#define IDC_EDIT_INPUT_VALUE 1201 +#define IDC_STATIC_INPUT_TITLE 1202 +#define IDC_ICON_INPUT_ICON 1203 -#define IDR_M30_MENU 1500 +#define IDR_M30_MENU 1500 -#define IDR_SYSTRAYPOPUP_MENU 1501 +#define IDR_SYSTRAYPOPUP_MENU 1501 -// #define IDD_FIND_REPLACE_DLG 1600 +// #define IDD_FIND_REPLACE_DLG 1600 -#define IDD_ABOUTBOX 1700 -#define IDC_LICENCE_EDIT 1701 -#define IDC_HOME_ADDR 1702 -#define IDC_EMAIL_ADDR 1703 -#define IDC_ONLINEHELP_ADDR 1704 -#define IDC_AUTHOR_NAME 1705 -#define IDC_BUILD_DATETIME 1706 //LS: CompileDateInAboutDialog: Automatically insert compile date as additional version info in About-dialog! -//#define IDD_USER_DEFINE_BOX 1800 +#define IDD_ABOUTBOX 1700 +#define IDC_LICENCE_EDIT 1701 +#define IDC_HOME_ADDR 1702 +#define IDC_EMAIL_ADDR 1703 +#define IDC_ONLINEHELP_ADDR 1704 +#define IDC_AUTHOR_NAME 1705 +#define IDC_BUILD_DATETIME 1706 //LS: CompileDateInAboutDialog: Automatically insert compile date as additional version info in About-dialog! +//#define IDD_USER_DEFINE_BOX 1800 -//#define IDD_RUN_DLG 1900 +//#define IDD_RUN_DLG 1900 -#define IDD_GOLINE 2000 -#define ID_GOLINE_EDIT (IDD_GOLINE + 1) -#define ID_CURRLINE (IDD_GOLINE + 2) -#define ID_LASTLINE (IDD_GOLINE + 3) -#define ID_URHERE_STATIC (IDD_GOLINE + 4) -#define ID_UGO_STATIC (IDD_GOLINE + 5) -#define ID_NOMORETHAN_STATIC (IDD_GOLINE + 6) -#define IDC_RADIO_GOTOLINE (IDD_GOLINE + 7) -#define IDC_RADIO_GOTOOFFSET (IDD_GOLINE + 8) +#define IDD_GOLINE 2000 +#define ID_GOLINE_EDIT (IDD_GOLINE + 1) +#define ID_CURRLINE (IDD_GOLINE + 2) +#define ID_LASTLINE (IDD_GOLINE + 3) +#define ID_URHERE_STATIC (IDD_GOLINE + 4) +#define ID_UGO_STATIC (IDD_GOLINE + 5) +#define ID_NOMORETHAN_STATIC (IDD_GOLINE + 6) +#define IDC_RADIO_GOTOLINE (IDD_GOLINE + 7) +#define IDC_RADIO_GOTOOFFSET (IDD_GOLINE + 8) // voir columnEditor_rc.h -//#define IDD_COLUMNEDIT 2020 +//#define IDD_COLUMNEDIT 2020 -//#define IDD_COLOUR_POPUP 2100 +//#define IDD_COLOUR_POPUP 2100 // See WordStyleDlgRes.h -//#define IDD_STYLER_DLG 2200 -//#define IDD_GLOBAL_STYLER_DLG 2300 +//#define IDD_STYLER_DLG 2200 +//#define IDD_GLOBAL_STYLER_DLG 2300 -#define IDD_VALUE_DLG 2400 -#define IDC_VALUE_STATIC 2401 -#define IDC_VALUE_EDIT 2402 +#define IDD_VALUE_DLG 2400 +#define IDC_VALUE_STATIC 2401 +#define IDC_VALUE_EDIT 2402 -#define IDD_BUTTON_DLG 2410 -#define IDC_RESTORE_BUTTON 2411 +#define IDD_BUTTON_DLG 2410 +#define IDC_RESTORE_BUTTON 2411 // see TaskListDlg_rc.h -//#define IDD_TASKLIST_DLG 2450 -#define IDD_SETTING_DLG 2500 +//#define IDD_TASKLIST_DLG 2450 +#define IDD_SETTING_DLG 2500 //See ShortcutMapper_rc.h -//#define IDD_SHORTCUTMAPPER_DLG 2600 +//#define IDD_SHORTCUTMAPPER_DLG 2600 //See ansiCharPanel_rc.h -//#define IDD_ANSIASCII_PANEL 2700 +//#define IDD_ANSIASCII_PANEL 2700 //See clipboardHistoryPanel_rc.h -//#define IDD_CLIPBOARDHISTORY_PANEL 2800 +//#define IDD_CLIPBOARDHISTORY_PANEL 2800 //See findCharsInRange_rc.h -//#define IDD_FINDCHARACTERS 2900 +//#define IDD_FINDCHARACTERS 2900 //See VerticalFileSwitcher_rc.h -//#define IDD_FILESWITCHER_PANEL 3000 +//#define IDD_FILESWITCHER_PANEL 3000 //See ProjectPanel_rc.h -//#define IDD_PROJECTPANEL 3100 -//#define IDD_FILERELOCALIZER_DIALOG 3200 +//#define IDD_PROJECTPANEL 3100 +//#define IDD_FILERELOCALIZER_DIALOG 3200 //See documentMap_rc.h -//#define IDD_DOCUMENTMAP 3300 +//#define IDD_DOCUMENTMAP 3300 //See functionListPanel_rc.h -//#define IDD_FUNCLIST_PANEL 3400 +//#define IDD_FUNCLIST_PANEL 3400 // See regExtDlg.h -//#define IDD_REGEXT 4000 +//#define IDD_REGEXT 4000 // See shortcutRc.h -//#define IDD_SHORTCUT_DLG 5000 +//#define IDD_SHORTCUT_DLG 5000 // See preference.rc -//#define IDD_PREFERENCE_BOX 6000 +//#define IDD_PREFERENCE_BOX 6000 #define NOTEPADPLUS_USER_INTERNAL (WM_USER + 0000) #define NPPM_INTERNAL_USERCMDLIST_MODIFIED (NOTEPADPLUS_USER_INTERNAL + 1) @@ -357,94 +355,94 @@ #define NPPM_INTERNAL_MACROLIST_MODIFIED (NOTEPADPLUS_USER_INTERNAL + 3) #define NPPM_INTERNAL_PLUGINCMDLIST_MODIFIED (NOTEPADPLUS_USER_INTERNAL + 4) #define NPPM_INTERNAL_CLEARSCINTILLAKEY (NOTEPADPLUS_USER_INTERNAL + 5) - #define NPPM_INTERNAL_BINDSCINTILLAKEY (NOTEPADPLUS_USER_INTERNAL + 6) + #define NPPM_INTERNAL_BINDSCINTILLAKEY (NOTEPADPLUS_USER_INTERNAL + 6) #define NPPM_INTERNAL_SCINTILLAKEYMODIFIED (NOTEPADPLUS_USER_INTERNAL + 7) #define NPPM_INTERNAL_SCINTILLAFINFERCOLLAPSE (NOTEPADPLUS_USER_INTERNAL + 8) #define NPPM_INTERNAL_SCINTILLAFINFERUNCOLLAPSE (NOTEPADPLUS_USER_INTERNAL + 9) - #define NPPM_INTERNAL_DISABLEAUTOUPDATE (NOTEPADPLUS_USER_INTERNAL + 10) - #define NPPM_INTERNAL_SETTING_HISTORY_SIZE (NOTEPADPLUS_USER_INTERNAL + 11) - #define NPPM_INTERNAL_ISTABBARREDUCED (NOTEPADPLUS_USER_INTERNAL + 12) - #define NPPM_INTERNAL_ISFOCUSEDTAB (NOTEPADPLUS_USER_INTERNAL + 13) - #define NPPM_INTERNAL_GETMENU (NOTEPADPLUS_USER_INTERNAL + 14) - #define NPPM_INTERNAL_CLEARINDICATOR (NOTEPADPLUS_USER_INTERNAL + 15) + #define NPPM_INTERNAL_DISABLEAUTOUPDATE (NOTEPADPLUS_USER_INTERNAL + 10) + #define NPPM_INTERNAL_SETTING_HISTORY_SIZE (NOTEPADPLUS_USER_INTERNAL + 11) + #define NPPM_INTERNAL_ISTABBARREDUCED (NOTEPADPLUS_USER_INTERNAL + 12) + #define NPPM_INTERNAL_ISFOCUSEDTAB (NOTEPADPLUS_USER_INTERNAL + 13) + #define NPPM_INTERNAL_GETMENU (NOTEPADPLUS_USER_INTERNAL + 14) + #define NPPM_INTERNAL_CLEARINDICATOR (NOTEPADPLUS_USER_INTERNAL + 15) #define NPPM_INTERNAL_SCINTILLAFINFERCOPY (NOTEPADPLUS_USER_INTERNAL + 16) #define NPPM_INTERNAL_SCINTILLAFINFERSELECTALL (NOTEPADPLUS_USER_INTERNAL + 17) #define NPPM_INTERNAL_SETCARETWIDTH (NOTEPADPLUS_USER_INTERNAL + 18) #define NPPM_INTERNAL_SETCARETBLINKRATE (NOTEPADPLUS_USER_INTERNAL + 19) - #define NPPM_INTERNAL_CLEARINDICATORTAGMATCH (NOTEPADPLUS_USER_INTERNAL + 20) - #define NPPM_INTERNAL_CLEARINDICATORTAGATTR (NOTEPADPLUS_USER_INTERNAL + 21) - #define NPPM_INTERNAL_SWITCHVIEWFROMHWND (NOTEPADPLUS_USER_INTERNAL + 22) - #define NPPM_INTERNAL_UPDATETITLEBAR (NOTEPADPLUS_USER_INTERNAL + 23) - #define NPPM_INTERNAL_CANCEL_FIND_IN_FILES (NOTEPADPLUS_USER_INTERNAL + 24) - #define NPPM_INTERNAL_RELOADNATIVELANG (NOTEPADPLUS_USER_INTERNAL + 25) - #define NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED (NOTEPADPLUS_USER_INTERNAL + 26) - #define NPPM_INTERNAL_SCINTILLAFINFERCLEARALL (NOTEPADPLUS_USER_INTERNAL + 27) - #define NPPM_INTERNAL_SETTING_EDGE_SIZE (NOTEPADPLUS_USER_INTERNAL + 28) - #define NPPM_INTERNAL_SETTING_TAB_REPLCESPACE (NOTEPADPLUS_USER_INTERNAL + 29) - #define NPPM_INTERNAL_SETTING_TAB_SIZE (NOTEPADPLUS_USER_INTERNAL + 30) - #define NPPM_INTERNAL_RELOADSTYLERS (NOTEPADPLUS_USER_INTERNAL + 31) - #define NPPM_INTERNAL_DOCORDERCHANGED (NOTEPADPLUS_USER_INTERNAL + 32) + #define NPPM_INTERNAL_CLEARINDICATORTAGMATCH (NOTEPADPLUS_USER_INTERNAL + 20) + #define NPPM_INTERNAL_CLEARINDICATORTAGATTR (NOTEPADPLUS_USER_INTERNAL + 21) + #define NPPM_INTERNAL_SWITCHVIEWFROMHWND (NOTEPADPLUS_USER_INTERNAL + 22) + #define NPPM_INTERNAL_UPDATETITLEBAR (NOTEPADPLUS_USER_INTERNAL + 23) + #define NPPM_INTERNAL_CANCEL_FIND_IN_FILES (NOTEPADPLUS_USER_INTERNAL + 24) + #define NPPM_INTERNAL_RELOADNATIVELANG (NOTEPADPLUS_USER_INTERNAL + 25) + #define NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED (NOTEPADPLUS_USER_INTERNAL + 26) + #define NPPM_INTERNAL_SCINTILLAFINFERCLEARALL (NOTEPADPLUS_USER_INTERNAL + 27) + #define NPPM_INTERNAL_SETTING_EDGE_SIZE (NOTEPADPLUS_USER_INTERNAL + 28) + #define NPPM_INTERNAL_SETTING_TAB_REPLCESPACE (NOTEPADPLUS_USER_INTERNAL + 29) + #define NPPM_INTERNAL_SETTING_TAB_SIZE (NOTEPADPLUS_USER_INTERNAL + 30) + #define NPPM_INTERNAL_RELOADSTYLERS (NOTEPADPLUS_USER_INTERNAL + 31) + #define NPPM_INTERNAL_DOCORDERCHANGED (NOTEPADPLUS_USER_INTERNAL + 32) #define NPPM_INTERNAL_SETMULTISELCTION (NOTEPADPLUS_USER_INTERNAL + 33) - #define NPPM_INTERNAL_SCINTILLAFINFEROPENALL (NOTEPADPLUS_USER_INTERNAL + 34) - #define NPPM_INTERNAL_RECENTFILELIST_UPDATE (NOTEPADPLUS_USER_INTERNAL + 35) - #define NPPM_INTERNAL_RECENTFILELIST_SWITCH (NOTEPADPLUS_USER_INTERNAL + 36) - #define NPPM_INTERNAL_GETSCINTEDTVIEW (NOTEPADPLUS_USER_INTERNAL + 37) - #define NPPM_INTERNAL_ENABLESNAPSHOT (NOTEPADPLUS_USER_INTERNAL + 38) - #define NPPM_INTERNAL_SAVECURRENTSESSION (NOTEPADPLUS_USER_INTERNAL + 39) + #define NPPM_INTERNAL_SCINTILLAFINFEROPENALL (NOTEPADPLUS_USER_INTERNAL + 34) + #define NPPM_INTERNAL_RECENTFILELIST_UPDATE (NOTEPADPLUS_USER_INTERNAL + 35) + #define NPPM_INTERNAL_RECENTFILELIST_SWITCH (NOTEPADPLUS_USER_INTERNAL + 36) + #define NPPM_INTERNAL_GETSCINTEDTVIEW (NOTEPADPLUS_USER_INTERNAL + 37) + #define NPPM_INTERNAL_ENABLESNAPSHOT (NOTEPADPLUS_USER_INTERNAL + 38) + #define NPPM_INTERNAL_SAVECURRENTSESSION (NOTEPADPLUS_USER_INTERNAL + 39) - //wParam: 0 - //lParam: document new index + //wParam: 0 + //lParam: document new index // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000) - // - // Used by Doc Monitor plugin - // + // + // Used by Doc Monitor plugin + // #define NPPM_INTERNAL_CHECKDOCSTATUS (NPPMSG + 53) - // VOID NPPM_CHECKDOCSTATUS(BOOL, 0) - // check all opened documents status. - // If files are modified, then reloaod (with or without prompt, it depends on settings). - // if files are deleted, then prompt user to close the documents + // VOID NPPM_CHECKDOCSTATUS(BOOL, 0) + // check all opened documents status. + // If files are modified, then reloaod (with or without prompt, it depends on settings). + // if files are deleted, then prompt user to close the documents #define NPPM_INTERNAL_ENABLECHECKDOCOPT (NPPMSG + 54) - // VOID NPPM_ENABLECHECKDOCOPT(OPT, 0) - // where OPT is : - #define CHECKDOCOPT_NONE 0 - #define CHECKDOCOPT_UPDATESILENTLY 1 - #define CHECKDOCOPT_UPDATEGO2END 2 + // VOID NPPM_ENABLECHECKDOCOPT(OPT, 0) + // where OPT is : + #define CHECKDOCOPT_NONE 0 + #define CHECKDOCOPT_UPDATESILENTLY 1 + #define CHECKDOCOPT_UPDATEGO2END 2 #define NPPM_INTERNAL_GETCHECKDOCOPT (NPPMSG + 55) - // INT NPPM_GETCHECKDOCOPT(0, 0) + // INT NPPM_GETCHECKDOCOPT(0, 0) #define NPPM_INTERNAL_SETCHECKDOCOPT (NPPMSG + 56) - // INT NPPM_SETCHECKDOCOPT(OPT, 0) + // INT NPPM_SETCHECKDOCOPT(OPT, 0) - // - // Used by netnote plugin - // + // + // Used by netnote plugin + // #define NPPM_INTERNAL_SETFILENAME (NPPMSG + 63) - //wParam: BufferID to rename - //lParam: name to set (TCHAR*) - //Buffer must have been previously unnamed (eg "new 1" document types) + //wParam: BufferID to rename + //lParam: name to set (TCHAR*) + //Buffer must have been previously unnamed (eg "new 1" document types) #define SCINTILLA_USER (WM_USER + 2000) -#define MACRO_USER (WM_USER + 4000) +#define MACRO_USER (WM_USER + 4000) #define WM_GETCURRENTMACROSTATUS (MACRO_USER + 01) #define WM_MACRODLGRUNMACRO (MACRO_USER + 02) // See Notepad_plus_msgs.h -//#define RUNCOMMAND_USER (WM_USER + 3000) +//#define RUNCOMMAND_USER (WM_USER + 3000) #define SPLITTER_USER (WM_USER + 4000) #define WORDSTYLE_USER (WM_USER + 5000) #define COLOURPOPUP_USER (WM_USER + 6000) #define BABYGRID_USER (WM_USER + 7000) -//#define IDD_DOCKING_MNG (IDM + 7000) +//#define IDD_DOCKING_MNG (IDM + 7000) #define MENUINDEX_FILE 0 #define MENUINDEX_EDIT 1 @@ -455,8 +453,4 @@ #define MENUINDEX_SETTINGS 6 #define MENUINDEX_MACRO 7 #define MENUINDEX_RUN 8 -#define MENUINDEX_PLUGINS 9 - -#endif // RESOURCE_H - - +#define MENUINDEX_PLUGINS 9