diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 4130c76ee..72f3dd7ad 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -23,6 +23,9 @@ Remove this plugin from plugins directory if you don't want to see this message bool PluginsManager::loadPlugins(const char *dir) { + if (_isDisabled) + return false; + vector dllNames; const char *pNppPath = (NppParameters::getInstance())->getNppPath(); diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index fe6116f27..0c72e3aac 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -59,7 +59,7 @@ struct PluginInfo { class PluginsManager { public: - PluginsManager() : _hPluginsMenu(NULL) {}; + PluginsManager() : _hPluginsMenu(NULL), _isDisabled(false) {}; ~PluginsManager() { for (size_t i = 0 ; i < _pluginInfos.size() ; i++) @@ -143,6 +143,7 @@ public: } } }; + void disable() {_isDisabled = true;}; private: NppData _nppData; @@ -151,6 +152,8 @@ private: vector _pluginInfos; vector _pluginsCommands; + bool _isDisabled; + bool hasPlugins(){return (_pluginInfos.size()!= 0);}; }; diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 3f1820976..acbb4ecee 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -154,7 +154,7 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p } -void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine) +void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLineParams *cmdLineParams) { Window::init(hInst, parent); @@ -184,6 +184,9 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine) const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI(); + if (cmdLineParams->_isNoPlugin) + _pluginsManager.disable(); + _hSelf = ::CreateWindowEx( WS_EX_ACCEPTFILES | (_isRTL?WS_EX_LAYOUTRTL:0),\ _className,\ @@ -210,7 +213,7 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine) ::MoveWindow(_hSelf, nppGUI._appPos.left + workAreaRect.left, nppGUI._appPos.top + workAreaRect.top, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE); //::ShowWindow(_hSelf, nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW); - if (nppGUI._rememberLastSession) + if (nppGUI._rememberLastSession && !cmdLineParams->_isNoSession) { //--LS: Session SubView restore: Code replaced to load session.xml with new loadSessionToEditView() function!! bool shouldBeResaved = loadSessionToEditView((NppParameters::getInstance())->getSession()); @@ -218,12 +221,12 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine) if (cmdLine) { - LangType lt = (NppParameters::getInstance())->getDefLang(); - int ln = (NppParameters::getInstance())->getLineNumber2go(); + LangType lt = cmdLineParams->_langType; + int ln = cmdLineParams->_line2go; if (PathFileExists(cmdLine)) { - doOpen(cmdLine); + doOpen(cmdLine, cmdLineParams->_isReadOnly); if (lt != L_TXT) _pEditView->setCurrentDocType(lt); @@ -238,7 +241,7 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine) for (int i = 0 ; i < fnss.size() ; i++) { pFn = (char *)fnss.getFileName(i); - doOpen((const char *)pFn); + doOpen((const char *)pFn, cmdLineParams->_isReadOnly); if (lt != L_TXT) _pEditView->setCurrentDocType(lt); @@ -247,7 +250,7 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine) } } // restore the doc type to L_TXT - (NppParameters::getInstance())->setDefLang(L_TXT); + //(NppParameters::getInstance())->setDefLang(L_TXT); } @@ -5660,8 +5663,8 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _pluginsManager.init(nppData); - if (!pNppParam->isNoPlugin()) - _pluginsManager.loadPlugins(); + //if (!pNppParam->isNoPlugin()) + _pluginsManager.loadPlugins(); const char *appDataNpp = pNppParam->getAppDataNppDir(); if (appDataNpp[0]) @@ -5962,26 +5965,42 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_COPYDATA : { - const DWORD LASTBYTEMASK = 0x000000FF; + //const DWORD LASTBYTEMASK = 0x000000FF; COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT *)lParam; - LangType lt = LangType(pCopyData->dwData & LASTBYTEMASK); - int ln = pCopyData->dwData >> 8; -//::MessageBox(NULL, (const char *)pCopyData->lpData, "WM_COPYDATA", MB_OK); - FileNameStringSplitter fnss((const char *)pCopyData->lpData); - char *pFn = NULL; - for (int i = 0 ; i < fnss.size() ; i++) - { - pFn = (char *)fnss.getFileName(i); - doOpen((const char *)pFn); - if (lt != L_TXT) + + switch (pCopyData->dwData) + { + case COPYDATA_PARAMS : { - _pEditView->setCurrentDocType(lt); - setLangStatus(lt); - checkLangsMenu(-1); + pNppParam->setCmdlineParam(*((CmdLineParams *)pCopyData->lpData)); + break; } - _pEditView->execute(SCI_GOTOLINE, ln-1); - } - //setLangStatus(_pEditView->getCurrentDocType()); + + case COPYDATA_FILENAMES : + { + CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); + LangType lt = cmdLineParams._langType;//LangType(pCopyData->dwData & LASTBYTEMASK); + int ln = cmdLineParams._line2go; + + FileNameStringSplitter fnss((char *)pCopyData->lpData); + char *pFn = NULL; + for (int i = 0 ; i < fnss.size() ; i++) + { + pFn = (char *)fnss.getFileName(i); + doOpen((const char *)pFn, cmdLineParams._isReadOnly); + if (lt != L_TXT) + { + _pEditView->setCurrentDocType(lt); + setLangStatus(lt); + checkLangsMenu(-1); + } + _pEditView->execute(SCI_GOTOLINE, ln-1); + } + //setLangStatus(_pEditView->getCurrentDocType()); + break; + } + } + return TRUE; } diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 221d9dfcc..ad9b629f3 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -80,7 +80,7 @@ class Notepad_plus : public Window { public: Notepad_plus(); - void init(HINSTANCE, HWND, const char *cmdLine); + void init(HINSTANCE, HWND, const char *cmdLine, CmdLineParams *cmdLineParams); // ATTENTION : the order of the destruction is very important // because if the parent's window hadle is destroyed before diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 71764316e..3637b2ede 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -21,9 +21,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "resource.h" #include "menuCmdID.h" -#define NOTEPAD_PLUS_VERSION "Notepad++ v4.4" -#define VERSION_VALUE "4.4\0" -#define VERSION_DIGITALVALUE 4, 4, 0, 0 +#define NOTEPAD_PLUS_VERSION "Notepad++ v4.4.1" +#define VERSION_VALUE "4.4.1\0" +#define VERSION_DIGITALVALUE 4, 4, 1, 0 VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_DIGITALVALUE diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 6dfbfc641..3f5335486 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -66,6 +66,9 @@ const int LANG_INDEX_TYPE3 = 4; const int LANG_INDEX_TYPE4 = 5; const int LANG_INDEX_TYPE5 = 6; +const int COPYDATA_PARAMS = 0; +const int COPYDATA_FILENAMES = 1; + const bool SCIV_PRIMARY = false; const bool SCIV_SECOND = true; @@ -120,6 +123,15 @@ struct Session { vector _files; }; +struct CmdLineParams { + bool _isNoPlugin; + bool _isReadOnly; + bool _isNoSession; + + int _line2go; + LangType _langType; +}; + struct FloatingWindowInfo { int _cont; RECT _pos; @@ -886,14 +898,16 @@ public: ::SetWindowLong(hwnd, GWL_EXSTYLE, ::GetWindowLong(hwnd, GWL_EXSTYLE) & ~/*WS_EX_LAYERED*/0x00080000); }; - void setDefLang(LangType langType) {_defLangType = langType;}; - LangType getDefLang() const {return _defLangType;}; + //void setDefLang(LangType langType) {_defLangType = langType;}; + //LangType getDefLang() const {return _defLangType;}; - void setLineNumber2go(int ln) {_lineNumber2Go = ln;}; - int getLineNumber2go() const {return _lineNumber2Go;}; + //void setLineNumber2go(int ln) {_lineNumber2Go = ln;}; + //int getLineNumber2go() const {return _lineNumber2Go;}; - void setIsNoPlugin(bool noPlugin) {_noPlugin = noPlugin;}; - bool isNoPlugin() const {return _noPlugin;}; + void setCmdlineParam(const CmdLineParams & cmdLineParams) {_cmdLineParams = cmdLineParams; + //::MessageBox(NULL, "", _cmdLineParams._isReadOnly?"Param:RO":"Param:RW", MB_OK); + }; + CmdLineParams & getCmdLineParams() {return _cmdLineParams;}; void setFileSaveDlgFilterIndex(int ln) {_fileSaveDlgFilterIndex = ln;}; int getFileSaveDlgFilterIndex() const {return _fileSaveDlgFilterIndex;}; @@ -1003,9 +1017,7 @@ private: int _nbUserLang; char _userDefineLangPath[MAX_PATH]; - LangType _defLangType; - int _lineNumber2Go; - bool _noPlugin; + CmdLineParams _cmdLineParams; int _fileSaveDlgFilterIndex; diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index d0dcf4e0c..6508d145b 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -120,7 +120,7 @@ static LangType getLangTypeFromParam(char *list2Clean) { } } return L_TXT; -}; +}; static int getLn2GoFromParam(char *list2Clean) { char word[16]; @@ -183,6 +183,8 @@ static int getLn2GoFromParam(char *list2Clean) { const char FLAG_MULTI_INSTANCE[] = "-multiInst"; const char FLAG_NO_PLUGIN[] = "-noPlugin"; +const char FLAG_READONLY[] = "-ro"; +const char FLAG_NOSESSION[] = "-nosession"; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdShow) { @@ -193,14 +195,18 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh if (::GetLastError() == ERROR_ALREADY_EXISTS) TheFirstOne = false; - bool multiInstance = isInList(FLAG_MULTI_INSTANCE, lpszCmdLine); - bool noPlugin = isInList(FLAG_NO_PLUGIN, lpszCmdLine); - LangType langType = getLangTypeFromParam(lpszCmdLine); - int lineNumber = getLn2GoFromParam(lpszCmdLine); + CmdLineParams cmdLineParams; + bool isMultiInst = isInList(FLAG_MULTI_INSTANCE, lpszCmdLine); + cmdLineParams._isNoPlugin = isInList(FLAG_NO_PLUGIN, lpszCmdLine); + cmdLineParams._isReadOnly = isInList(FLAG_READONLY, lpszCmdLine); + cmdLineParams._isNoSession = isInList(FLAG_NOSESSION, lpszCmdLine); + //printStr(cmdLineParams._isReadOnly?"RO":"RW"); + cmdLineParams._langType = getLangTypeFromParam(lpszCmdLine); + cmdLineParams._line2go = getLn2GoFromParam(lpszCmdLine); NppParameters *pNppParameters = NppParameters::getInstance(); - if ((!multiInstance) && (!TheFirstOne)) + if ((!isMultiInst) && (!TheFirstOne)) { HWND hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL); for (;!(hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL));) @@ -225,18 +231,18 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh if (lpszCmdLine[0]) { - COPYDATASTRUCT copyData; - DWORD ln = 0; - if (lineNumber != -1) - ln = lineNumber; - copyData.dwData = (ln << 8) | DWORD(langType); + COPYDATASTRUCT paramData; + paramData.dwData = COPYDATA_PARAMS; + COPYDATASTRUCT fileNamesData; + fileNamesData.dwData = COPYDATA_FILENAMES; + //pNppParameters->setCmdlineParam(cmdLineParams); string quotFileName = "\""; // tell the other running instance the FULL path to the new file to load if (lpszCmdLine[0] == '"') { - copyData.cbData = long(strlen(lpszCmdLine) + 1); - copyData.lpData = lpszCmdLine; + fileNamesData.lpData = (void *)lpszCmdLine; + fileNamesData.cbData = long(strlen(lpszCmdLine) + 1); } else { @@ -244,11 +250,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh ::GetFullPathName(lpszCmdLine, MAX_PATH, longFileName, NULL); quotFileName += longFileName; quotFileName += "\""; - copyData.cbData = long(quotFileName.length() + 1); - copyData.lpData = (void *)quotFileName.c_str(); - } - ::SendMessage(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)©Data); + fileNamesData.lpData = (void *)quotFileName.c_str(); + fileNamesData.cbData = long(quotFileName.length() + 1); + } + paramData.lpData = &cmdLineParams; + paramData.cbData = sizeof(cmdLineParams); + //printStr(((CmdLineParams *)copyData.dwData)->_isReadOnly?"DEBUT:RO":"DEBUT:RW"); + ::SendMessage(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)¶mData); + ::SendMessage(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)&fileNamesData); + //printStr(((CmdLineParams *)copyData.dwData)->_isReadOnly?"FIN:RO":"FIN:RW"); } return 0; } @@ -257,18 +268,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh Notepad_plus notepad_plus_plus; MSG msg; msg.wParam = 0; - try { char *pPathNames = NULL; if (lpszCmdLine[0]) { pPathNames = lpszCmdLine; } - pNppParameters->setDefLang(langType); - pNppParameters->setLineNumber2go(lineNumber); - pNppParameters->setIsNoPlugin(noPlugin); - - notepad_plus_plus.init(hInstance, NULL, pPathNames); + notepad_plus_plus.init(hInstance, NULL, pPathNames, &cmdLineParams); while (::GetMessage(&msg, NULL, 0, 0)) { @@ -288,7 +294,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh } } } - } catch(int i) { if (i == 106901) ::MessageBox(NULL, "Scintilla.init is failed!", "106901", MB_OK); @@ -299,14 +304,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh ::MessageBox(NULL, strcat(str, code), "int exception", MB_OK); } } -/* - catch(std::exception ex) { - ::MessageBox(NULL, ex.what(), "Exception", MB_OK); - } - catch(...) { - systemMessage("System Err"); - } -*/ return (UINT)msg.wParam; }