diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index d9d313ce8..d895ca01d 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -339,8 +339,7 @@ LRESULT Notepad_plus::init(HWND hwnd) _mainEditView.execute(SCI_SETZOOM, svp._zoom); _subEditView.execute(SCI_SETZOOM, svp._zoom2); - _mainEditView.execute(SCI_SETMULTIPLESELECTION, true); - _subEditView.execute(SCI_SETMULTIPLESELECTION, true); + ::SendMessage(hwnd, NPPM_INTERNAL_SETMULTISELCTION, 0, 0); // Make backspace or delete work with multiple selections _mainEditView.execute(SCI_SETADDITIONALSELECTIONTYPING, true); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index bdf2651da..70bfda5e7 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1904,6 +1904,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } + case NPPM_INTERNAL_SETMULTISELCTION: + { + ScintillaViewParams& svp = const_cast(nppParam.getSVP()); + _mainEditView.execute(SCI_SETMULTIPLESELECTION, svp._multiSelection); + _subEditView.execute(SCI_SETMULTIPLESELECTION, svp._multiSelection); + return TRUE; + } + case NPPM_INTERNAL_SETCARETBLINKRATE: { const NppGUI & nppGUI = nppParam.getNppGUI(); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index e599698a1..7751a6806 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -1652,21 +1652,6 @@ bool NppParameters::load() _isRegForOSAppRestartDisabled = (::PathFileExists(filePath.c_str()) == TRUE); } - - //-------------------------------------------------------------// - // noColumnToMultiSelect.xml // - // This empty xml file is optional - user adds this empty file // - // manually in order to prevent Notepad++ transform column // - // selection into multi-select. // - //-------------------------------------------------------------// - std::wstring disableColumn2MultiSelectPath = _userPath; - pathAppend(disableColumn2MultiSelectPath, TEXT("noColumnToMultiSelect.xml")); - - if (PathFileExists(disableColumn2MultiSelectPath.c_str())) - { - _column2MultiSelect = false; - } - return isAllLaoded; } @@ -6634,6 +6619,24 @@ void NppParameters::feedScintillaParam(TiXmlNode *node) else if (!lstrcmp(nm, TEXT("no"))) _svp._lineCopyCutWithoutSelection = false; } + + nm = element->Attribute(TEXT("multiSelection")); + if (nm) + { + if (!lstrcmp(nm, TEXT("yes"))) + _svp._multiSelection = true; + else if (!lstrcmp(nm, TEXT("no"))) + _svp._multiSelection = false; + } + + nm = element->Attribute(TEXT("columnSel2MultiEdit")); + if (nm) + { + if (!lstrcmp(nm, TEXT("yes")) && _svp._multiSelection) + _svp._columnSel2MultiEdit = true; + else if (!lstrcmp(nm, TEXT("no"))) + _svp._columnSel2MultiEdit = false; + } } @@ -6909,6 +6912,11 @@ bool NppParameters::writeScintillaParams() (scintNode->ToElement())->SetAttribute(TEXT("paddingRight"), _svp._paddingRight); (scintNode->ToElement())->SetAttribute(TEXT("distractionFreeDivPart"), _svp._distractionFreeDivPart); (scintNode->ToElement())->SetAttribute(TEXT("lineCopyCutWithoutSelection"), _svp._lineCopyCutWithoutSelection ? TEXT("yes") : TEXT("no")); + + (scintNode->ToElement())->SetAttribute(TEXT("multiSelection"), _svp._multiSelection ? TEXT("yes") : TEXT("no")); + bool canEnableColumnSel2MultiEdit = _svp._multiSelection && _svp._columnSel2MultiEdit; + (scintNode->ToElement())->SetAttribute(TEXT("columnSel2MultiEdit"), canEnableColumnSel2MultiEdit ? TEXT("yes") : TEXT("no")); + return true; } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index f2b4bd2a6..4d4c34f12 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -993,6 +993,9 @@ struct ScintillaViewParams }; bool _lineCopyCutWithoutSelection = true; + + bool _multiSelection = true; // if _multiSelection is false + bool _columnSel2MultiEdit = true; // _columnSel2MultiEdit must be false }; const int NB_LIST = 20; @@ -1888,7 +1891,6 @@ public: bool regexBackward4PowerUser() const { return _findHistory._regexBackward4PowerUser; } bool isSelectFgColorEnabled() const { return _isSelectFgColorEnabled; }; bool isRegForOSAppRestartDisabled() const { return _isRegForOSAppRestartDisabled; }; - bool doColumn2MultiSelect() const { return _column2MultiSelect; }; private: bool _isAnyShortcutModified = false; @@ -1956,7 +1958,6 @@ private: bool _isSelectFgColorEnabled = false; bool _isRegForOSAppRestartDisabled = false; - bool _column2MultiSelect = true; bool _doNppLogNetworkDriveIssue = false; bool _doNppLogNulContentCorruptionIssue = false; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 4cd8df9e2..106d2cbe9 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -528,7 +528,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa SHORT alt = GetKeyState(VK_MENU); SHORT shift = GetKeyState(VK_SHIFT); bool isColumnSelection = (execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN); - bool column2MultSelect = (NppParameters::getInstance()).doColumn2MultiSelect(); + bool column2MultSelect = (NppParameters::getInstance()).getSVP()._columnSel2MultiEdit; if (wParam == VK_DELETE) { diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index a0dd61dfe..b462ffeaf 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -120,6 +120,16 @@ BEGIN END +IDD_PREFERENCE_SUB_EDITING2 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-Editing",IDC_GB_STATIC_MULTIEDITING,80,25,290,50,BS_CENTER + CONTROL "Enable Multi-Editing (Ctrl+Mouse click/selection)",IDC_CHECK_MULTISELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,40,270,10 + CONTROL "Enable Column Selection to Multi-Editing",IDC_CHECK_COLUMN2MULTIEDITING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,97,55,270,10 +END + + IDD_PREFERENCE_SUB_DARKMODE DIALOGEX 115, 10, 460, 205 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index de67148f2..6a166de83 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -127,6 +127,9 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM _editingSubDlg.init(_hInst, _hSelf); _editingSubDlg.create(IDD_PREFERENCE_SUB_EDITING, false, false); + _editing2SubDlg.init(_hInst, _hSelf); + _editing2SubDlg.create(IDD_PREFERENCE_SUB_EDITING2, false, false); + _darkModeSubDlg.init(_hInst, _hSelf); _darkModeSubDlg.create(IDD_PREFERENCE_SUB_DARKMODE, false, false); @@ -182,7 +185,8 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM _searchEngineSubDlg.create(IDD_PREFERENCE_SUB_SEARCHENGINE, false, false); _wVector.push_back(DlgInfo(&_generalSubDlg, TEXT("General"), TEXT("Global"))); - _wVector.push_back(DlgInfo(&_editingSubDlg, TEXT("Editing"), TEXT("Scintillas"))); + _wVector.push_back(DlgInfo(&_editingSubDlg, TEXT("Editing 1"), TEXT("Scintillas"))); + _wVector.push_back(DlgInfo(&_editing2SubDlg, TEXT("Editing 2"), TEXT("Scintillas2"))); _wVector.push_back(DlgInfo(&_darkModeSubDlg, TEXT("Dark Mode"), TEXT("DarkMode"))); _wVector.push_back(DlgInfo(&_marginsBorderEdgeSubDlg, TEXT("Margins/Border/Edge"), TEXT("MarginsBorderEdge"))); _wVector.push_back(DlgInfo(&_newDocumentSubDlg, TEXT("New Document"), TEXT("NewDoc"))); @@ -487,6 +491,7 @@ void PreferenceDlg::destroy() { _generalSubDlg.destroy(); _editingSubDlg.destroy(); + _editing2SubDlg.destroy(); _darkModeSubDlg.destroy(); _marginsBorderEdgeSubDlg.destroy(); _miscSubDlg.destroy(); @@ -1304,6 +1309,52 @@ intptr_t CALLBACK EditingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM return FALSE; } +intptr_t CALLBACK Editing2SubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/) +{ + switch (message) + { + case WM_INITDIALOG: + { + NppParameters& nppParam = NppParameters::getInstance(); + ScintillaViewParams& svp = const_cast(nppParam.getSVP()); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_MULTISELECTION, BM_SETCHECK, svp._multiSelection, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_COLUMN2MULTIEDITING, BM_SETCHECK, svp._columnSel2MultiEdit, 0); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_COLUMN2MULTIEDITING), svp._multiSelection); + } + return TRUE; + + case WM_COMMAND: + { + NppParameters& nppParam = NppParameters::getInstance(); + ScintillaViewParams& svp = const_cast(nppParam.getSVP()); + switch (wParam) + { + case IDC_CHECK_MULTISELECTION: + { + svp._multiSelection = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_MULTISELECTION, BM_GETCHECK, 0, 0)); + if (!svp._multiSelection) + { + ::SendDlgItemMessage(_hSelf, IDC_CHECK_COLUMN2MULTIEDITING, BM_SETCHECK, FALSE, 0); + svp._columnSel2MultiEdit = false; + } + + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_COLUMN2MULTIEDITING), svp._multiSelection); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETMULTISELCTION, 0, 0); + } + return TRUE; + + case IDC_CHECK_COLUMN2MULTIEDITING: + { + svp._columnSel2MultiEdit = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_COLUMN2MULTIEDITING, BM_GETCHECK, 0, 0)); + } + return TRUE; + } + } + return TRUE; + } + return FALSE; +} + void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable) { diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 917cfdc64..7ef31a71a 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -79,6 +79,17 @@ private : void changeLineHiliteMode(bool enableSlider); }; +class Editing2SubDlg : public StaticDialog +{ +friend class PreferenceDlg; +public : + Editing2SubDlg() = default; + ~Editing2SubDlg() = default; + +private: + intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; +}; + class DarkModeSubDlg : public StaticDialog { public: @@ -327,6 +338,7 @@ private : WindowVector _wVector; GeneralSubDlg _generalSubDlg; EditingSubDlg _editingSubDlg; + Editing2SubDlg _editing2SubDlg; DarkModeSubDlg _darkModeSubDlg; MarginsBorderEdgeSubDlg _marginsBorderEdgeSubDlg; MiscSubDlg _miscSubDlg; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 97a0a0119..1a0202e94 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -317,7 +317,12 @@ //#define IDC_TABSIZEVAL_DISABLE_STATIC (IDD_PREFERENCE_SUB_LANGUAGE + 12) #define IDC_EDIT_TABSIZEVAL (IDD_PREFERENCE_SUB_LANGUAGE + 13) -#define IDD_PREFERENCE_SUB_HIGHLIGHTING 6550 //(IDD_PREFERENCE_BOX + 500) +#define IDD_PREFERENCE_SUB_EDITING2 6520 //(IDD_PREFERENCE_BOX + 520) + #define IDC_GB_STATIC_MULTIEDITING (IDD_PREFERENCE_SUB_EDITING2 + 1) + #define IDC_CHECK_MULTISELECTION (IDD_PREFERENCE_SUB_EDITING2 + 2) + #define IDC_CHECK_COLUMN2MULTIEDITING (IDD_PREFERENCE_SUB_EDITING2 + 3) + +#define IDD_PREFERENCE_SUB_HIGHLIGHTING 6550 //(IDD_PREFERENCE_BOX + 550) #define IDD_PREFERENCE_SUB_PRINT 6600 //(IDD_PREFERENCE_BOX + 600) #define IDC_CHECK_PRINTLINENUM (IDD_PREFERENCE_SUB_PRINT + 1) diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index e6d77afa9..16f71a91c 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -611,7 +611,7 @@ #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_SETMULTISELCTION (NOTEPADPLUS_USER_INTERNAL + 33) #define NPPM_INTERNAL_SCINTILLAFINDEROPENALL (NOTEPADPLUS_USER_INTERNAL + 34) #define NPPM_INTERNAL_RECENTFILELIST_UPDATE (NOTEPADPLUS_USER_INTERNAL + 35) #define NPPM_INTERNAL_RECENTFILELIST_SWITCH (NOTEPADPLUS_USER_INTERNAL + 36)