From 307fd2fcd2d4dd7a626092e6e1dc1a0467b596f5 Mon Sep 17 00:00:00 2001 From: ozone10 Date: Sat, 24 Dec 2022 19:13:13 +0100 Subject: [PATCH] Add setting for panels to ignore '-nosession' Fix #9710, close #12699 --- PowerEditor/installer/nativeLang/english.xml | 12 +++- PowerEditor/src/Notepad_plus.cpp | 31 +++++++++- PowerEditor/src/Parameters.cpp | 35 +++++++++++ PowerEditor/src/Parameters.h | 8 +++ .../src/WinControls/Preference/preference.rc | 38 ++++++++---- .../WinControls/Preference/preferenceDlg.cpp | 62 +++++++++++++++++++ .../WinControls/Preference/preference_rc.h | 11 ++++ 7 files changed, 180 insertions(+), 17 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 7f04a2627..93b9e4dae 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1137,7 +1137,7 @@ You can define several column markers by using white space to separate the diffe - + @@ -1145,6 +1145,16 @@ You can define several column markers by using white space to separate the diffe + + + + + + + + + + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 44e6f916f..50423a1ff 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -766,14 +766,39 @@ LRESULT Notepad_plus::init(HWND hwnd) _dockingManager.setDockedContSize(CONT_TOP, nppGUI._dockingData._topHeight); _dockingManager.setDockedContSize(CONT_BOTTOM, nppGUI._dockingData._bottomHight); - if (!nppGUI._isCmdlineNosessionActivated) { for (size_t i = 0, len = dmd._pluginDockInfo.size(); i < len; ++i) { PluginDlgDockingInfo& pdi = dmd._pluginDockInfo[i]; - if (pdi._isVisible) + const bool isInternalFunc = pdi._name == NPP_INTERNAL_FUCTION_STR; + + bool showPanel = true; + if (nppGUI._isCmdlineNosessionActivated) { - if (pdi._name == NPP_INTERNAL_FUCTION_STR) + const bool showProjectPanel = isInternalFunc + && nppGUI._projectPanelKeepState + && (pdi._internalID != IDM_EDIT_CLIPBOARDHISTORY_PANEL + && pdi._internalID != IDM_VIEW_DOCLIST + && pdi._internalID != IDM_EDIT_CHAR_PANEL + && pdi._internalID != IDM_VIEW_FILEBROWSER + && pdi._internalID != IDM_VIEW_DOC_MAP + && pdi._internalID != IDM_VIEW_FUNC_LIST); + + const bool showInternalPanel = isInternalFunc + && ((pdi._internalID == IDM_EDIT_CLIPBOARDHISTORY_PANEL && nppGUI._clipboardHistoryPanelKeepState) + || (pdi._internalID == IDM_VIEW_DOCLIST && nppGUI._docListKeepState) + || (pdi._internalID == IDM_EDIT_CHAR_PANEL && nppGUI._charPanelKeepState) + || (pdi._internalID == IDM_VIEW_FILEBROWSER && nppGUI._fileBrowserKeepState) + || (showProjectPanel) + || (pdi._internalID == IDM_VIEW_DOC_MAP && nppGUI._docMapKeepState) + || (pdi._internalID == IDM_VIEW_FUNC_LIST && nppGUI._funcListKeepState)); + + showPanel = ((!isInternalFunc && nppGUI._pluginPanelKeepState) || showInternalPanel); + } + + if (pdi._isVisible && showPanel) + { + if (isInternalFunc) _internalFuncIDs.push_back(pdi._internalID); else _pluginsManager.runPluginCommand(pdi._name.c_str(), pdi._internalID); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 8dad0e3da..b887810a0 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5686,6 +5686,27 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (val < 0 || val > 2) val = 0; _nppGUI._multiInstSetting = (MultiInstSetting)val; + + auto parseYesNoBoolAttribute = [&element](const TCHAR* name, bool defaultValue = false) -> bool { + const TCHAR* val = element->Attribute(name); + if (val != nullptr) + { + if (!lstrcmp(val, TEXT("yes"))) + return true; + else if (!lstrcmp(val, TEXT("no"))) + return false; + } + return defaultValue; + }; + + _nppGUI._clipboardHistoryPanelKeepState = parseYesNoBoolAttribute(TEXT("clipboardHistory")); + _nppGUI._docListKeepState = parseYesNoBoolAttribute(TEXT("documentList")); + _nppGUI._charPanelKeepState = parseYesNoBoolAttribute(TEXT("characterPanel")); + _nppGUI._fileBrowserKeepState = parseYesNoBoolAttribute(TEXT("folderAsWorkspace")); + _nppGUI._projectPanelKeepState = parseYesNoBoolAttribute(TEXT("projectPanels")); + _nppGUI._docMapKeepState = parseYesNoBoolAttribute(TEXT("documentMap")); + _nppGUI._funcListKeepState = parseYesNoBoolAttribute(TEXT("fuctionList")); + _nppGUI._pluginPanelKeepState = parseYesNoBoolAttribute(TEXT("pluginPanels")); } else if (!lstrcmp(nm, TEXT("searchEngine"))) { @@ -6995,6 +7016,20 @@ void NppParameters::createXmlTreeFromGUIParams() TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("multiInst")); GUIConfigElement->SetAttribute(TEXT("setting"), _nppGUI._multiInstSetting); + + auto setYesNoBoolAttribute = [&GUIConfigElement](const TCHAR* name, bool value) -> void { + const TCHAR* pStr = value ? TEXT("yes") : TEXT("no"); + GUIConfigElement->SetAttribute(name, pStr); + }; + + setYesNoBoolAttribute(TEXT("clipboardHistory"), _nppGUI._clipboardHistoryPanelKeepState); + setYesNoBoolAttribute(TEXT("documentList"), _nppGUI._docListKeepState); + setYesNoBoolAttribute(TEXT("characterPanel"), _nppGUI._charPanelKeepState); + setYesNoBoolAttribute(TEXT("folderAsWorkspace"), _nppGUI._fileBrowserKeepState); + setYesNoBoolAttribute(TEXT("projectPanels"), _nppGUI._projectPanelKeepState); + setYesNoBoolAttribute(TEXT("documentMap"), _nppGUI._docMapKeepState); + setYesNoBoolAttribute(TEXT("fuctionList"), _nppGUI._funcListKeepState); + setYesNoBoolAttribute(TEXT("pluginPanels"), _nppGUI._pluginPanelKeepState); } // diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index e6bd6f17a..15c101757 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -883,6 +883,14 @@ struct NppGUI final TCHAR _defaultDirExp[MAX_PATH]; //expanded environment variables generic_string _themeName; MultiInstSetting _multiInstSetting = monoInst; + bool _clipboardHistoryPanelKeepState = false; + bool _docListKeepState = false; + bool _charPanelKeepState = false; + bool _fileBrowserKeepState = false; + bool _projectPanelKeepState = false; + bool _docMapKeepState = false; + bool _funcListKeepState = false; + bool _pluginPanelKeepState = false; bool _fileSwitcherWithoutExtColumn = true; int _fileSwitcherExtWidth = 50; bool _fileSwitcherWithoutPathColumn = true; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 2787de31e..95bafc8f3 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -400,23 +400,35 @@ BEGIN END -IDD_PREFERENCE_SUB_MULTIINSTANCE DIALOGEX 0, 0, 455, 210 +IDD_PREFERENCE_SUB_MULTIINSTANCE DIALOGEX 115, 10, 460, 205 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,3,268,92,BS_CENTER - CONTROL "Open session in a new instance (and save session automatically on exit)",IDC_SESSIONININST_RADIO,"Button",BS_AUTORADIOBUTTON|BS_MULTILINE,122,14,226,20 - CONTROL "Always in multi-instance mode",IDC_MULTIINST_RADIO,"Button",BS_AUTORADIOBUTTON,122,38,218,10 - CONTROL "Default (mono-instance)",IDC_MONOINST_RADIO,"Button",BS_AUTORADIOBUTTON,122,55,196,10 - LTEXT "* The modification of this setting needs to restart Notepad++",IDD_STATIC_RESTARTNOTE,110,74,239,20 - GROUPBOX "Customize insert Date Time",IDC_DATETIMEFORMAT_GB_STATIC,90,100,268,102,BS_CENTER - CONTROL "Reverse default date time order (short && long formats)",IDD_DATETIMEFORMAT_REVERSEORDER_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,103,116,241,10 - RTEXT "yyyy-MM-dd HH:mm:ss\nH:m d/M/yyyy\nMMM d, yyyy tt h:m",IDC_STATIC,134,142,77,25 - LTEXT "1985-10-26 16:24:42\n16:24 26/10/1985\nOct 26, 1985 PM 4:24",IDC_STATIC,234,142,94,25 - RTEXT "Custom format:",IDD_DATETIMEFORMAT_STATIC,92,172,77,8 - EDITTEXT IDC_DATETIMEFORMAT_EDIT,170,170,182,14,ES_AUTOHSCROLL - LTEXT "",IDD_DATETIMEFORMAT_RESULT_STATIC,172,187,180,8 + GROUPBOX "Multi-instance settings *",IDC_MULTIINST_GB_STATIC,11,3,268,71,BS_CENTER + CONTROL "Default (mono-instance)",IDC_MONOINST_RADIO,"Button",BS_AUTORADIOBUTTON,17,16,256,10 + CONTROL "Always in multi-instance mode",IDC_MULTIINST_RADIO,"Button",BS_AUTORADIOBUTTON,17,31,256,10 + CONTROL "Open session in a new instance (and save session automatically on exit)",IDC_SESSIONININST_RADIO,"Button",BS_AUTORADIOBUTTON | BS_MULTILINE | BS_TOP,17,46,256,20 + GROUPBOX "Customize insert Date Time",IDC_DATETIMEFORMAT_GB_STATIC,11,80,268,98,BS_CENTER + CONTROL "Reverse default date time order (short && long formats)",IDD_DATETIMEFORMAT_REVERSEORDER_CHECK,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | BS_TOP | WS_TABSTOP,17,93,256,20 + RTEXT "yyyy-MM-dd HH:mm:ss\nH:m d/M/yyyy\nMMM d, yyyy tt h:m",IDC_STATIC,36,118,77,25 + LTEXT "1985-10-26 16:24:42\n16:24 26/10/1985\nOct 26, 1985 PM 4:24",IDC_STATIC,136,118,94,25 + RTEXT "Custom format :",IDD_DATETIMEFORMAT_STATIC,14,148,77,8 + EDITTEXT IDC_DATETIMEFORMAT_EDIT,92,146,175,14,ES_AUTOHSCROLL + LTEXT "",IDD_DATETIMEFORMAT_RESULT_STATIC,94,163,180,8 + + GROUPBOX "Panel State and [-nosession] *",IDC_PANEL_IGNORESESSION_GB_STATIC,288,3,160,175,BS_CENTER + LTEXT "Remember panel state (panel is open) in other instances (multi-instance mode) or when using command line parameter [-nosession]",IDD_STATIC_PANELSTATE_DESCRIPTION,294,14,150,40 + CONTROL "Clipboard History",IDC_CHECK_CLIPBOARDHISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,294,55,134,10 + CONTROL "Document List",IDC_CHECK_DOCLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,294,70,134,10 + CONTROL "Character Panel",IDC_CHECK_CHARPANEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,294,85,134,10 + CONTROL "Folder as Workspace",IDC_CHECK_FILEBROWSER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,294,100,134,10 + CONTROL "Project Panels",IDC_CHECK_PROJECTPANEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,294,115,134,10 + CONTROL "Document Map",IDC_CHECK_DOCMAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,294,130,134,10 + CONTROL "Function List",IDC_CHECK_FUNCLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,294,145,134,10 + CONTROL "Plugin Panels",IDC_CHECK_PLUGINPANEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,294,160,134,10 + + LTEXT "* The modification of this setting needs to restart Notepad++",IDD_STATIC_RESTARTNOTE,15,187,239,20 END diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 6a21a58ef..b3d8395d6 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -4297,6 +4297,20 @@ intptr_t CALLBACK MultiInstanceSubDlg::run_dlgProc(UINT message, WPARAM wParam, { case WM_INITDIALOG : { + auto checkOrUncheckBtn = [this](int id, bool check) -> void + { + ::SendDlgItemMessage(_hSelf, id, BM_SETCHECK, check ? BST_CHECKED : BST_UNCHECKED, 0); + }; + + checkOrUncheckBtn(IDC_CHECK_CLIPBOARDHISTORY, nppGUI._clipboardHistoryPanelKeepState); + checkOrUncheckBtn(IDC_CHECK_DOCLIST, nppGUI._docListKeepState); + checkOrUncheckBtn(IDC_CHECK_CHARPANEL, nppGUI._charPanelKeepState); + checkOrUncheckBtn(IDC_CHECK_FILEBROWSER, nppGUI._fileBrowserKeepState); + checkOrUncheckBtn(IDC_CHECK_PROJECTPANEL, nppGUI._projectPanelKeepState); + checkOrUncheckBtn(IDC_CHECK_DOCMAP, nppGUI._docMapKeepState); + checkOrUncheckBtn(IDC_CHECK_FUNCLIST, nppGUI._funcListKeepState); + checkOrUncheckBtn(IDC_CHECK_PLUGINPANEL, nppGUI._pluginPanelKeepState); + MultiInstSetting multiInstSetting = nppGUI._multiInstSetting; ::SendDlgItemMessage(_hSelf, IDC_SESSIONININST_RADIO, BM_SETCHECK, multiInstSetting == multiInstOnSession?BST_CHECKED:BST_UNCHECKED, 0); @@ -4379,6 +4393,54 @@ intptr_t CALLBACK MultiInstanceSubDlg::run_dlgProc(UINT message, WPARAM wParam, } break; + case IDC_CHECK_CLIPBOARDHISTORY: + { + nppGUI._clipboardHistoryPanelKeepState = isCheckedOrNot(IDC_CHECK_CLIPBOARDHISTORY); + } + break; + + case IDC_CHECK_DOCLIST: + { + nppGUI._docListKeepState = isCheckedOrNot(IDC_CHECK_DOCLIST); + } + break; + + case IDC_CHECK_CHARPANEL: + { + nppGUI._charPanelKeepState = isCheckedOrNot(IDC_CHECK_CHARPANEL); + } + break; + + case IDC_CHECK_FILEBROWSER: + { + nppGUI._fileBrowserKeepState = isCheckedOrNot(IDC_CHECK_FILEBROWSER); + } + break; + + case IDC_CHECK_PROJECTPANEL: + { + nppGUI._projectPanelKeepState = isCheckedOrNot(IDC_CHECK_PROJECTPANEL); + } + break; + + case IDC_CHECK_DOCMAP: + { + nppGUI._docMapKeepState = isCheckedOrNot(IDC_CHECK_DOCMAP); + } + break; + + case IDC_CHECK_FUNCLIST: + { + nppGUI._funcListKeepState = isCheckedOrNot(IDC_CHECK_FUNCLIST); + } + break; + + case IDC_CHECK_PLUGINPANEL: + { + nppGUI._pluginPanelKeepState = isCheckedOrNot(IDC_CHECK_PLUGINPANEL); + } + break; + default : return FALSE; } diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 9a30a6a3d..6322c0915 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -81,6 +81,17 @@ #define IDD_DATETIMEFORMAT_RESULT_STATIC (IDD_PREFERENCE_SUB_DATETIMEFORMAT + 4) #define IDD_DATETIMEFORMAT_REVERSEORDER_CHECK (IDD_PREFERENCE_SUB_DATETIMEFORMAT + 5) +#define IDD_PREFERENCE_SUB_PANELIGNORESESSION 6180 //(IDD_PREFERENCE_BOX + 180) + #define IDC_PANEL_IGNORESESSION_GB_STATIC (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 1) + #define IDD_STATIC_PANELSTATE_DESCRIPTION (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 2) + #define IDC_CHECK_CLIPBOARDHISTORY (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 3) + #define IDC_CHECK_DOCLIST (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 4) + #define IDC_CHECK_CHARPANEL (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 5) + #define IDC_CHECK_FILEBROWSER (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 6) + #define IDC_CHECK_PROJECTPANEL (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 7) + #define IDC_CHECK_DOCMAP (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 8) + #define IDC_CHECK_FUNCLIST (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 9) + #define IDC_CHECK_PLUGINPANEL (IDD_PREFERENCE_SUB_PANELIGNORESESSION + 10) #define IDD_PREFERENCE_SUB_EDITING 6200 //(IDD_PREFERENCE_BOX + 200) #define IDC_FMS_GB_STATIC (IDD_PREFERENCE_SUB_EDITING + 1)