From 58716efa78bfa473d356de18a5ba41df44b2e0b8 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 17 Jul 2013 22:35:34 +0000 Subject: [PATCH] [NEW_FEATURE] Add open session in the new instance and customizable multi-instance feature. [NEW_FEATURE] Add new command line argument "-openSession" for opening a session file. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1079 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 16 +- PowerEditor/src/Notepad_plus_Window.cpp | 1 - PowerEditor/src/NppIO.cpp | 31 +- PowerEditor/src/Parameters.cpp | 36 ++- PowerEditor/src/Parameters.h | 5 +- .../src/WinControls/Preference/preference.rc | 10 + .../WinControls/Preference/preferenceDlg.cpp | 282 +++++------------- .../WinControls/Preference/preferenceDlg.h | 62 ++-- .../WinControls/Preference/preference_rc.h | 6 + PowerEditor/src/config.model.xml | 1 + PowerEditor/src/langs.model.xml | 2 +- PowerEditor/src/localization.cpp | 7 +- PowerEditor/src/winmain.cpp | 18 +- 13 files changed, 206 insertions(+), 271 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 67a7e60d..5d01fd03 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -4615,10 +4615,22 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam if (!commandLine || ! pCmdParams) return; + NppParameters *nppParams = NppParameters::getInstance(); FileNameStringSplitter fnss(commandLine); const TCHAR *pFn = NULL; - LangType lt = pCmdParams->_langType;//LangType(pCopyData->dwData & LASTBYTEMASK); + // loading file as session file is allowed only when there is only one file + if (pCmdParams->_isSessionFile && fnss.size() == 1) + { + Session session2Load; + if ((NppParameters::getInstance())->loadSession(session2Load, fnss.getFileName(0))) + { + loadSession(session2Load); + } + return; + } + + LangType lt = pCmdParams->_langType; int ln = pCmdParams->_line2go; int cn = pCmdParams->_column2go; @@ -4634,7 +4646,7 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam lastOpened = bufID; - if (lt != L_EXTERNAL && lt < NppParameters::getInstance()->L_END) + if (lt != L_EXTERNAL && lt < nppParams->L_END) { Buffer * pBuf = MainFileManager->getBufferByID(bufID); pBuf->setLangType(lt); diff --git a/PowerEditor/src/Notepad_plus_Window.cpp b/PowerEditor/src/Notepad_plus_Window.cpp index e5289924..889a0647 100644 --- a/PowerEditor/src/Notepad_plus_Window.cpp +++ b/PowerEditor/src/Notepad_plus_Window.cpp @@ -94,7 +94,6 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin if (cmdLineParams->isPointValid()) ::MoveWindow(_hSelf, cmdLineParams->_point.x, cmdLineParams->_point.y, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE); else - //::MoveWindow(_hSelf, newUpperLeft.x, newUpperLeft.y, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE); { WINDOWPLACEMENT posInfo; diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index a98ac20b..be0f096b 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -61,7 +61,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi if (test != BUFFER_INVALID) { //switchToFile(test); - //Dont switch, not responsibility of doOpen, but of caller + //Don't switch, not responsibility of doOpen, but of caller if (_pTrayIco) { if (_pTrayIco->isInTray()) @@ -1228,18 +1228,31 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn) sessionFileName = fn; } + NppParameters *pNppParam = NppParameters::getInstance(); + const NppGUI & nppGUI = pNppParam->getNppGUI(); if (sessionFileName) { - bool isAllSuccessful = true; - Session session2Load; - - if ((NppParameters::getInstance())->loadSession(session2Load, sessionFileName)) + if ((nppGUI._multiInstSetting == multiInstOnSession || nppGUI._multiInstSetting == multiInst)) { - isAllSuccessful = loadSession(session2Load); - result = true; + TCHAR nppFullPath[MAX_PATH]; + ::GetModuleFileName(NULL, nppFullPath, MAX_PATH); + generic_string args = TEXT("-multiInst -nosession -openSession "); + args += sessionFileName; + ::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), nppFullPath, args.c_str(), TEXT("."), SW_SHOW); + } + else + { + bool isAllSuccessful = true; + Session session2Load; + + if ((NppParameters::getInstance())->loadSession(session2Load, sessionFileName)) + { + isAllSuccessful = loadSession(session2Load); + result = true; + } + if (!isAllSuccessful) + (NppParameters::getInstance())->writeSession(session2Load, sessionFileName); } - if (!isAllSuccessful) - (NppParameters::getInstance())->writeSession(session2Load, sessionFileName); } return result; } diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 3e3c8dbb..015e8c63 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -623,14 +623,14 @@ winVer getWindowsVersion() NppParameters * NppParameters::_pSelf = new NppParameters; int FileDialog::_dialogFileBoxId = (NppParameters::getInstance())->getWinVersion() < WV_W2K?edt1:cmb13; -NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserStylerDoc(NULL),\ - _pXmlUserLangDoc(NULL), _pXmlNativeLangDocA(NULL),\ - _nbLang(0), _pXmlToolIconsDoc(NULL),\ - _nbRecentFile(0), _nbMaxRecentFile(10), _recentFileCustomLength(RECENTFILES_SHOWFULLPATH),_putRecentFileInSubMenu(false), - _pXmlShortcutDoc(NULL), _pXmlContextMenuDocA(NULL), _pXmlSessionDoc(NULL), _pXmlBlacklistDoc(NULL),\ - _nbUserLang(0), _nbExternalLang(0), _hUser32(NULL), _hUXTheme(NULL),\ - _transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL), _pNativeLangSpeaker(NULL),\ - _isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false), _isFindReplacing(false) +NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserStylerDoc(NULL),_pXmlUserLangDoc(NULL),\ + _pXmlNativeLangDocA(NULL), _nbLang(0), _pXmlToolIconsDoc(NULL), _nbRecentFile(0),\ + _nbMaxRecentFile(10), _recentFileCustomLength(RECENTFILES_SHOWFULLPATH),\ + _putRecentFileInSubMenu(false), _pXmlShortcutDoc(NULL), _pXmlContextMenuDocA(NULL),\ + _pXmlSessionDoc(NULL), _pXmlBlacklistDoc(NULL), _nbUserLang(0), _nbExternalLang(0),\ + _hUser32(NULL), _hUXTheme(NULL), _transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\ + _pNativeLangSpeaker(NULL), _isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1),\ + _asNotepadStyle(false), _isFindReplacing(false)/*, _forceLoadingSession(false)*/ { // init import UDL array _nbImportedULD = 0; @@ -3901,6 +3901,14 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) else _nppGUI._delimiterSelectionOnEntireDocument = false; } + else if (!lstrcmp(nm, TEXT("multiInst"))) + { + int val = 0; + element->Attribute(TEXT("setting"), &val); + if (val < 0 || val > 2) + val = 0; + _nppGUI._multiInstSetting = (MultiInstSetting)val; + } } } @@ -4236,6 +4244,7 @@ bool NppParameters::writeGUIParams() bool titleBarExist = false; bool stylerThemeExist = false; bool delimiterSelectionExist = false; + bool multiInstExist = false; TiXmlNode *dockingParamNode = NULL; @@ -4610,6 +4619,11 @@ bool NppParameters::writeGUIParams() element->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), TEXT("no")); delimiterSelectionExist = true; } + else if (!lstrcmp(nm, TEXT("multiInst"))) + { + multiInstExist = true; + element->SetAttribute(TEXT("setting"), _nppGUI._multiInstSetting); + } } if (!noUpdateExist) @@ -4817,6 +4831,12 @@ bool NppParameters::writeGUIParams() GUIConfigElement->SetAttribute(TEXT("rightmostDelimiter"), _nppGUI._rightmostDelimiter); GUIConfigElement->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), _nppGUI._delimiterSelectionOnEntireDocument); } + if (!multiInstExist) + { + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("multiInst")); + GUIConfigElement->SetAttribute(TEXT("setting"), _nppGUI._multiInstSetting); + } insertDockingParamNode(GUIRoot); return true; diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 69cbcd23..315762af 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -97,6 +97,7 @@ enum UniMode {uni8Bit=0, uniUTF8=1, uni16BE=2, uni16LE=3, uniCookie=4, uni7Bit=5 enum ChangeDetect {cdDisabled=0, cdEnabled=1, cdAutoUpdate=2, cdGo2end=3, cdAutoUpdateGo2end=4}; enum BackupFeature {bak_none = 0, bak_simple = 1, bak_verbose = 2}; enum OpenSaveDirSetting {dir_followCurrent = 0, dir_last = 1, dir_userDef = 2}; +enum MultiInstSetting {monoInst = 0, multiInstOnSession = 1, multiInst = 2}; const int LANG_INDEX_INSTR = 0; const int LANG_INDEX_INSTR2 = 1; @@ -181,6 +182,7 @@ struct CmdLineParams { bool isPointValid() { return _isPointXValid && _isPointYValid; }; + bool _isSessionFile; LangType _langType; CmdLineParams() : _isNoPlugin(false), _isReadOnly(false), _isNoSession(false), _isNoTab(false),_showLoadingTime(false),\ @@ -682,7 +684,7 @@ struct NppGUI _doTaskList(true), _maitainIndent(true), _openSaveDir(dir_followCurrent), _styleMRU(true), _styleURL(0),\ _autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")),\ _doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _enableMultiSelection(false), _shortTitlebar(false), _themeName(TEXT("")), _isLangMenuCompact(false), - _smartHiliteCaseSensitive(false), _leftmostDelimiter('('), _rightmostDelimiter(')'), _delimiterSelectionOnEntireDocument(false) { + _smartHiliteCaseSensitive(false), _leftmostDelimiter('('), _rightmostDelimiter(')'), _delimiterSelectionOnEntireDocument(false), _multiInstSetting(monoInst) { _appPos.left = 0; _appPos.top = 0; _appPos.right = 700; @@ -778,6 +780,7 @@ struct NppGUI TCHAR _defaultDir[MAX_PATH]; TCHAR _defaultDirExp[MAX_PATH]; //expanded environment variables generic_string _themeName; + MultiInstSetting _multiInstSetting; }; struct ScintillaViewParams diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index ff0e38a3..ad015bd8 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -317,3 +317,13 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,91,103,160,10 END +IDD_PREFERENCE_MULTIINSTANCE_BOX DIALOGEX 0, 0, 455, 185 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Multi-instance settings",IDC_MULTIINST_GB_STATIC,89,44,268,89,BS_CENTER + CONTROL "Open session in a new instance of Notepad++",IDC_SESSIONININST_RADIO, + "Button",BS_AUTORADIOBUTTON,123,68,226,10 + CONTROL "Always in multi-instance mode",IDC_MULTIINST_RADIO,"Button",BS_AUTORADIOBUTTON,123,87,218,10 + CONTROL "Default (mono-instance)",IDC_MONOINST_RADIO,"Button",BS_AUTORADIOBUTTON,123,106,196,10 +END diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 55cd62d6..6f5f7cb4 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -96,9 +96,6 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa { case WM_INITDIALOG : { - //_ctrlTab.init(_hInst, _hSelf, false, true, true); - //_ctrlTab.setFont(TEXT("Tahoma"), 13); - _barsDlg.init(_hInst, _hSelf); _barsDlg.create(IDD_PREFERENCE_BAR_BOX, false, false); _barsDlg.display(); @@ -136,6 +133,9 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa _autoCompletionDlg.init(_hInst, _hSelf); _autoCompletionDlg.create(IDD_PREFERENCE_AUTOCOMPLETION_BOX, false, false); + _multiInstDlg.init(_hInst, _hSelf); + _multiInstDlg.create(IDD_PREFERENCE_MULTIINSTANCE_BOX, false, false); + _wVector.push_back(DlgInfo(&_barsDlg, TEXT("General"), TEXT("Global"))); _wVector.push_back(DlgInfo(&_marginsDlg, TEXT("Editing"), TEXT("Scintillas"))); _wVector.push_back(DlgInfo(&_defaultNewDocDlg, TEXT("New Document"), TEXT("NewDoc"))); @@ -147,14 +147,13 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa _wVector.push_back(DlgInfo(&_printSettingsDlg, TEXT("Print"), TEXT("Print"))); _wVector.push_back(DlgInfo(&_backupDlg, TEXT("Backup"), TEXT("Backup"))); _wVector.push_back(DlgInfo(&_autoCompletionDlg, TEXT("Auto-Completion"), TEXT("AutoCompletion"))); + _wVector.push_back(DlgInfo(&_multiInstDlg, TEXT("Multi-Instance"), TEXT("MultiInstance"))); _wVector.push_back(DlgInfo(&_settingsDlg, TEXT("MISC."), TEXT("MISC"))); - //_ctrlTab.createTabs(_wVector); - //_ctrlTab.display(); + makeCategoryList(); RECT rc; getClientRect(rc); - //_ctrlTab.reSizeTo(rc); rc.top += 10; rc.bottom -= 50; rc.left += 150; @@ -171,29 +170,17 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa _printSettingsDlg.reSizeTo(rc); _backupDlg.reSizeTo(rc); _autoCompletionDlg.reSizeTo(rc); + _multiInstDlg.reSizeTo(rc); NppParameters *pNppParam = NppParameters::getInstance(); ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture(); if (enableDlgTheme) enableDlgTheme(_hSelf, ETDT_ENABLETAB); + return TRUE; } -/* - case WM_NOTIFY : - { - NMHDR *nmhdr = (NMHDR *)lParam; - if (nmhdr->code == TCN_SELCHANGE) - { - if (nmhdr->hwndFrom == _ctrlTab.getHSelf()) - { - _ctrlTab.clickedUpdate(); - return TRUE; - } - } - break; - } -*/ - case WM_COMMAND : + + case WM_COMMAND : { if (LOWORD(wParam) == IDC_LIST_DLGTITLE) { @@ -202,7 +189,6 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_GETCURSEL, 0, 0); if (i != LB_ERR) { - //printInt(i); showDialogByIndex(i); } } @@ -232,8 +218,15 @@ void PreferenceDlg::makeCategoryList() { ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_ADDSTRING, 0, (LPARAM)_wVector[i]._name.c_str()); } + setListSelection(0); +} - ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_SETSEL, (WPARAM)TRUE, 0); +void PreferenceDlg::setListSelection(size_t currentSel) const +{ + // Stupid LB API doesn't allow LB_SETSEL to be used on single select listbox, so we do it in a hard way + TCHAR selStr[256]; + ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_GETTEXT, currentSel, (LPARAM)selStr); + ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_SELECTSTRING, currentSel, (LPARAM)selStr); } bool PreferenceDlg::renameDialogTitle(const TCHAR *internalName, const TCHAR *newName) @@ -279,6 +272,23 @@ void PreferenceDlg::showDialogByIndex(int index) _wVector[index]._dlg->display(true); } +void PreferenceDlg::destroy() +{ + _barsDlg.destroy(); + _marginsDlg.destroy(); + _settingsDlg.destroy(); + _fileAssocDlg.destroy(); + _langMenuDlg.destroy(); + _tabSettings.destroy(); + _printSettingsDlg.destroy(); + _defaultNewDocDlg.destroy(); + _defaultDirectoryDlg.destroy(); + _recentFilesHistoryDlg.destroy(); + _backupDlg.destroy(); + _autoCompletionDlg.destroy(); + _multiInstDlg.destroy(); +} + BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); @@ -937,7 +947,6 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) return TRUE; case IDC_CHECK_REMEMBERSESSION: - //::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_REMEMBER_LAST_SESSION, 0); nppGUI._rememberLastSession = isCheckedOrNot(wParam); return TRUE; @@ -1463,27 +1472,12 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara { case WM_INITDIALOG : { - /* - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE); - - _tabSizeVal.init(_hInst, _hSelf); - _tabSizeVal.create(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), IDC_TABSIZEVAL_STATIC); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_REPLACEBYSPACE, BM_SETCHECK, nppGUI._tabReplacedBySpace, 0); - */ int nbLang = pNppParam->getNbLang(); - //::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_ADDSTRING, 0, (LPARAM)TEXT("[Default]")); for (int i = 0 ; i < nbLang ; ++i) { ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_ADDSTRING, 0, (LPARAM)pNppParam->getLangFromIndex(i)->_langName.c_str()); } - /* - const int index2Begin = 0; - ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_SETCURSEL, 0, index2Begin); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), SW_HIDE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), SW_HIDE); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), FALSE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE); - */ + for (int i = L_TEXT ; i < pNppParam->L_END ; ++i) { generic_string str; @@ -1521,54 +1515,6 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara { if (HIWORD(wParam) == LBN_SELCHANGE) { - /* - if (LOWORD(wParam) == IDC_LIST_TABSETTNG) - { - int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); - if (index == LB_ERR) - return FALSE; - ::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), index?SW_SHOW:SW_HIDE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), index?SW_SHOW:SW_HIDE); - - if (index) - { - Lang *lang = pNppParam->getLangFromIndex(index - 1); - if (!lang) return FALSE; - bool useDefaultTab = (lang->_tabSize == -1 || lang->_tabSize == 0); - - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab); - - int size = useDefaultTab?nppGUI._tabSize:lang->_tabSize; - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE); - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE); - - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab?nppGUI._tabReplacedBySpace:lang->_isTabReplacedBySpace, 0); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab); - - if (!useDefaultTab) - { - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, lang->_tabSize, FALSE); - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, lang->_isTabReplacedBySpace, 0); - } - } - else - { - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), TRUE); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), TRUE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), SW_SHOW); - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE); - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, nppGUI._tabReplacedBySpace, 0); - } - - return TRUE; - } - */ if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG) { HWND hEnableList = ::GetDlgItem(_hSelf, IDC_LIST_ENABLEDLANG); @@ -1610,95 +1556,6 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara switch (wParam) { - /* - case IDC_TABSIZEVAL_STATIC: - { - ValueDlg tabSizeDlg; - tabSizeDlg.init(_hInst, _hParent, nppGUI._tabSize, TEXT("Tab Size : ")); - POINT p; - ::GetCursorPos(&p); - int size = tabSizeDlg.doDialog(p); - if (size == -1) return FALSE; - - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE); - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE); - - int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); - if (index == LB_ERR) return FALSE; - - if (index != 0) - { - Lang *lang = pNppParam->getLangFromIndex(index - 1); - if (!lang) return FALSE; - lang->_tabSize = size; - - // write in langs.xml - pNppParam->insertTabInfo(lang->getLangName(), lang->getTabInfo()); - } - else - { - nppGUI._tabSize = size; - } - - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_TAB_SIZE, 0, 0); - return TRUE; - } - - case IDC_CHECK_REPLACEBYSPACE: - { - bool isTabReplacedBySpace = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_GETCHECK, 0, 0); - int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); - if (index == LB_ERR) return FALSE; - if (index != 0) - { - Lang *lang = pNppParam->getLangFromIndex(index - 1); - if (!lang) return FALSE; - if (!lang->_tabSize || lang->_tabSize == -1) - lang->_tabSize = nppGUI._tabSize; - lang->_isTabReplacedBySpace = isTabReplacedBySpace; - - // write in langs.xml - pNppParam->insertTabInfo(lang->getLangName(), lang->getTabInfo()); - } - else - { - nppGUI._tabReplacedBySpace = isTabReplacedBySpace; - } - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_TAB_REPLCESPACE, 0, 0); - return TRUE; - } - - case IDC_CHECK_DEFAULTTABVALUE: - { - bool useDefaultTab = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_GETCHECK, 0, 0); - int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); - if (index == LB_ERR || index == 0) // index == 0 shouldn't happen - return FALSE; - - Lang *lang = pNppParam->getLangFromIndex(index - 1); - if (!lang) - return FALSE; - - //- Set tab setting in choosed language - lang->_tabSize = useDefaultTab?0:nppGUI._tabSize; - lang->_isTabReplacedBySpace = useDefaultTab?false:nppGUI._tabReplacedBySpace; - - //- set visual effect - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab); - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, useDefaultTab?nppGUI._tabSize:lang->_tabSize, FALSE); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab?nppGUI._tabReplacedBySpace:lang->_isTabReplacedBySpace, 0); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab); - - // write in langs.xml - if (useDefaultTab) - pNppParam->insertTabInfo(lang->getLangName(), -1); - - return TRUE; - } - */ case IDC_CHECK_LANGMENUCOMPACT : { nppGUI._isLangMenuCompact = (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_LANGMENUCOMPACT), BM_GETCHECK, 0, 0)); @@ -2300,11 +2157,6 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { case WM_INITDIALOG : { - /* - ::SetDlgItemInt(_hSelf, IDD_AUTOC_STATIC_N, nppGUI._autocFromLen, FALSE); - _nbCharVal.init(_hInst, _hSelf); - _nbCharVal.create(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), IDD_AUTOC_STATIC_N); - */ int ID2Check = 0; switch (nppGUI._backup) @@ -2325,23 +2177,7 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_CHECK, BM_SETCHECK, BST_CHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_EDIT, WM_SETTEXT, 0, (LPARAM)nppGUI._backupDir.c_str()); - /* - bool isEnableAutoC = nppGUI._autocStatus != nppGUI.autoc_none; - ::SendDlgItemMessage(_hSelf, IDD_AUTOC_ENABLECHECK, BM_SETCHECK, isEnableAutoC?BST_CHECKED:BST_UNCHECKED, 0); - ::SendDlgItemMessage(_hSelf, IDD_AUTOC_FUNCRADIO, BM_SETCHECK, nppGUI._autocStatus == nppGUI.autoc_func?BST_CHECKED:BST_UNCHECKED, 0); - ::SendDlgItemMessage(_hSelf, IDD_AUTOC_WORDRADIO, BM_SETCHECK, nppGUI._autocStatus == nppGUI.autoc_word?BST_CHECKED:BST_UNCHECKED, 0); - ::SendDlgItemMessage(_hSelf, IDD_FUNC_CHECK, BM_SETCHECK, nppGUI._funcParams?BST_CHECKED:BST_UNCHECKED, 0); - if (!isEnableAutoC) - { - ::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_FUNCRADIO), FALSE); - ::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_WORDRADIO), FALSE); - ::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_FROM), FALSE); - ::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), FALSE); - ::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_CHAR), FALSE); - ::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_NOTE), FALSE); - } - */ updateBackupGUI(); return TRUE; } @@ -2549,4 +2385,50 @@ BOOL CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM } } return FALSE; -} \ No newline at end of file +} + + +BOOL CALLBACK MultiInstDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +{ + NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); + switch (Message) + { + case WM_INITDIALOG : + { + MultiInstSetting multiInstSetting = nppGUI._multiInstSetting; + + ::SendDlgItemMessage(_hSelf, IDC_SESSIONININST_RADIO, BM_SETCHECK, multiInstSetting == multiInstOnSession?BST_CHECKED:BST_UNCHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_MULTIINST_RADIO, BM_SETCHECK, multiInstSetting == multiInst?BST_CHECKED:BST_UNCHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_MONOINST_RADIO, BM_SETCHECK, multiInstSetting == monoInst?BST_CHECKED:BST_UNCHECKED, 0); + } + break; + case WM_COMMAND : + { + switch (wParam) + { + case IDC_SESSIONININST_RADIO : + { + nppGUI._multiInstSetting = multiInstOnSession; + } + break; + + case IDC_MULTIINST_RADIO : + { + nppGUI._multiInstSetting = multiInst; + } + break; + + case IDC_MONOINST_RADIO : + { + nppGUI._multiInstSetting = monoInst; + } + break; + default : + return FALSE; + } + } + break; + } + + return FALSE; +} diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 92ea33ed..417fb98a 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -95,22 +95,14 @@ class DefaultNewDocDlg : public StaticDialog { public : DefaultNewDocDlg() {}; - /* - virtual void destroy() { - _nbHistoryVal.destroy(); - _customLenVal.destroy(); - }; - */ + private : - //URLCtrl _nbHistoryVal; - //URLCtrl _customLenVal; std::vector _langList; void makeOpenAnsiAsUtf8(bool doIt){ if (!doIt) ::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, BST_UNCHECKED, 0); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), doIt); }; - //void setCustomLen(int val); BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); }; @@ -118,24 +110,8 @@ class DefaultDirectoryDlg : public StaticDialog { public : DefaultDirectoryDlg() {}; - /* - virtual void destroy() { - _nbHistoryVal.destroy(); - _customLenVal.destroy(); - }; - */ + private : - //URLCtrl _nbHistoryVal; - //URLCtrl _customLenVal; - //std::vector _langList; - /* - void makeOpenAnsiAsUtf8(bool doIt){ - if (!doIt) - ::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, BST_UNCHECKED, 0); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), doIt); - }; - */ - //void setCustomLen(int val); BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); }; @@ -159,14 +135,8 @@ class LangMenuDlg : public StaticDialog { public : LangMenuDlg() {}; - /* - virtual void destroy() { - _tabSizeVal.destroy(); - }; - */ private : - //URLCtrl _tabSizeVal; LexerStylerArray _lsArray; BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); vector _langList; @@ -209,7 +179,6 @@ class BackupDlg : public StaticDialog public : BackupDlg() {}; private : - //URLCtrl _nbCharVal; void updateBackupGUI(); BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); }; @@ -221,10 +190,17 @@ public : AutoCompletionDlg() {}; private : URLCtrl _nbCharVal; - //void updateAutoCompletionGUI(); BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); }; +class MultiInstDlg : public StaticDialog +{ +public : + MultiInstDlg() {}; + +private : + BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); +}; class PreferenceDlg : public StaticDialog { @@ -246,17 +222,14 @@ public : display(); }; bool renameDialogTitle(const TCHAR *internalName, const TCHAR *newName); - - virtual void destroy() { - //_ctrlTab.destroy(); - _barsDlg.destroy(); - _marginsDlg.destroy(); - _settingsDlg.destroy(); - _fileAssocDlg.destroy(); - _langMenuDlg.destroy(); - _printSettingsDlg.destroy(); - _defaultNewDocDlg.destroy(); + + int getListSelectedIndex() const { + return ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_GETCURSEL, 0, 0); }; + void setListSelection(size_t currentSel) const; + + virtual void destroy(); + private : BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); void makeCategoryList(); @@ -275,6 +248,7 @@ private : RecentFilesHistoryDlg _recentFilesHistoryDlg; BackupDlg _backupDlg; AutoCompletionDlg _autoCompletionDlg; + MultiInstDlg _multiInstDlg; }; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 252f8187..1196db44 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -62,6 +62,12 @@ #define IDC_DOCSWITCH_GB_STATIC (IDD_PREFERENCE_BAR_BOX + 25) #define IDC_CHECK_DOCSWITCH (IDD_PREFERENCE_BAR_BOX + 26) +#define IDD_PREFERENCE_MULTIINSTANCE_BOX 6150 //(IDD_PREFERENCE_BOX + 150) + #define IDC_MULTIINST_GB_STATIC (IDD_PREFERENCE_MULTIINSTANCE_BOX + 1) + #define IDC_SESSIONININST_RADIO (IDD_PREFERENCE_MULTIINSTANCE_BOX + 2) + #define IDC_MULTIINST_RADIO (IDD_PREFERENCE_MULTIINSTANCE_BOX + 3) + #define IDC_MONOINST_RADIO (IDD_PREFERENCE_MULTIINSTANCE_BOX + 4) + #define IDD_PREFERENCE_MARGEIN_BOX 6200 //(IDD_PREFERENCE_BOX + 200) #define IDC_FMS_GB_STATIC (IDD_PREFERENCE_MARGEIN_BOX + 1) #define IDC_RADIO_SIMPLE (IDD_PREFERENCE_MARGEIN_BOX + 2) diff --git a/PowerEditor/src/config.model.xml b/PowerEditor/src/config.model.xml index e2ef2854..b92c8e2e 100644 --- a/PowerEditor/src/config.model.xml +++ b/PowerEditor/src/config.model.xml @@ -74,6 +74,7 @@ 2 + diff --git a/PowerEditor/src/langs.model.xml b/PowerEditor/src/langs.model.xml index 95accc31..3e9eb967 100644 --- a/PowerEditor/src/langs.model.xml +++ b/PowerEditor/src/langs.model.xml @@ -214,7 +214,7 @@ std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives vital_timing boolean bit character severity_level integer real time delay_length natural positive string bit_vector file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic std_logic_vector X01 X01Z UX01 UX01Z unsigned signed - + diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 8848c8e5..bcd60075 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -860,12 +860,11 @@ void NativeLangSpeaker::changeFindReplaceDlgLang(FindReplaceDlg & findReplaceDlg void NativeLangSpeaker::changePrefereceDlgLang(PreferenceDlg & preference) { + int currentSel = preference.getListSelectedIndex(); changeDlgLang(preference.getHSelf(), "Preference"); - char titre[128]; - WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); - + char titre[128]; changeDlgLang(preference._barsDlg.getHSelf(), "Global", titre); if (titre[0] != '\0') { @@ -946,6 +945,8 @@ void NativeLangSpeaker::changePrefereceDlgLang(PreferenceDlg & preference) const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding); preference.renameDialogTitle(TEXT("AutoCompletion"), nameW); } + + preference.setListSelection(currentSel); } void NativeLangSpeaker::changeShortcutLang() diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index fe112629..969ff714 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -178,6 +178,7 @@ const TCHAR FLAG_SYSTRAY[] = TEXT("-systemtray"); const TCHAR FLAG_LOADINGTIME[] = TEXT("-loadingTime"); const TCHAR FLAG_HELP[] = TEXT("--help"); const TCHAR FLAG_ALWAYS_ON_TOP[] = TEXT("-alwaysOnTop"); +const TCHAR FLAG_OPENSESSIONFILE[] = TEXT("-openSession"); const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\ \r\ @@ -197,6 +198,7 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-nLineNumber] [-cColum -systemtray : Launch Notepad++ directly in system tray\r\ -loadingTime : Display Notepad++ loading time\r\ -alwaysOnTop : Make Notepad++ always on top\r\ + -openSession : Open a specific session. fullFilePathName must be a session file\r\ fullFilePathName : file name to open (absolute or relative path name)\r\ "); @@ -228,18 +230,21 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) cmdLineParams._isPreLaunch = isInList(FLAG_SYSTRAY, params); cmdLineParams._alwaysOnTop = isInList(FLAG_ALWAYS_ON_TOP, params); cmdLineParams._showLoadingTime = isInList(FLAG_LOADINGTIME, params); + cmdLineParams._isSessionFile = isInList(FLAG_OPENSESSIONFILE, params); cmdLineParams._langType = getLangTypeFromParam(params); cmdLineParams._line2go = getNumberFromParam('n', params, isParamePresent); cmdLineParams._column2go = getNumberFromParam('c', params, isParamePresent); cmdLineParams._point.x = getNumberFromParam('x', params, cmdLineParams._isPointXValid); cmdLineParams._point.y = getNumberFromParam('y', params, cmdLineParams._isPointYValid); - + if (showHelp) { ::MessageBox(NULL, COMMAND_ARG_HELP, TEXT("Notepad++ Command Argument Help"), MB_OK); } NppParameters *pNppParameters = NppParameters::getInstance(); + pNppParameters->load(); + // override the settings if notepad style is present if (pNppParameters->asNotepadStyle()) { @@ -248,6 +253,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) cmdLineParams._isNoSession = true; } + // override the settings if multiInst is choosen by user in the preference dialog + const NppGUI & nppGUI = pNppParameters->getNppGUI(); + if (nppGUI._multiInstSetting == multiInst) + { + isMultiInst = true; + // Only the first launch remembers the session + if (!TheFirstOne) + cmdLineParams._isNoSession = true; + } + generic_string quotFileName = TEXT(""); // tell the running instance the FULL path to the new files to load size_t nrFilesToOpen = params.size(); @@ -331,7 +346,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) } } - pNppParameters->load(); Notepad_plus_Window notepad_plus_plus; NppGUI & nppGui = (NppGUI &)pNppParameters->getNppGUI();