From cc2c9b7740cfcfa8f138d2505e96a77b56b3554b Mon Sep 17 00:00:00 2001 From: Don HO Date: Sat, 4 Apr 2020 04:55:45 +0200 Subject: [PATCH] Implement multi-line edge feature Close #3128 --- PowerEditor/src/MISC/Common/Common.cpp | 33 +++++ PowerEditor/src/MISC/Common/Common.h | 1 + PowerEditor/src/Notepad_plus.cpp | 1 + PowerEditor/src/NppBigSwitch.cpp | 64 +++++++++- PowerEditor/src/NppCommands.cpp | 25 ---- PowerEditor/src/Parameters.cpp | 28 ++++- PowerEditor/src/Parameters.h | 1 + .../ScitillaComponent/ScintillaEditView.cpp | 1 + .../src/WinControls/Preference/preference.rc | 21 ++-- .../WinControls/Preference/preferenceDlg.cpp | 113 ++++++++++++++---- .../WinControls/Preference/preferenceDlg.h | 3 + .../WinControls/Preference/preference_rc.h | 3 + PowerEditor/src/menuCmdID.h | 4 +- PowerEditor/src/resource.h | 9 +- 14 files changed, 239 insertions(+), 68 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 7eb6be0d..7bc5d6ee 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -816,6 +816,39 @@ std::vector stringSplit(const generic_string& input, const gener } +bool str2numberVector(generic_string str2convert, std::vector& numVect) +{ + numVect.clear(); + + for (auto i : str2convert) + { + switch (i) + { + case ' ': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + { + // correct. do nothing + } + break; + + default: + return false; + } + } + + std::vector v = stringSplit(str2convert, TEXT(" ")); + for (auto i : v) + { + // Don't treat empty string and the number greater than 9999 + if (!i.empty() && i.length() < 5) + { + numVect.push_back(std::stoi(i)); + } + } + return true; +} + generic_string stringJoin(const std::vector& strings, const generic_string& separator) { generic_string joined; diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index e10fc09f..004101cb 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -179,6 +179,7 @@ generic_string stringToUpper(generic_string strToConvert); generic_string stringToLower(generic_string strToConvert); generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace); std::vector stringSplit(const generic_string& input, const generic_string& delimiter); +bool str2numberVector(generic_string str2convert, std::vector& numVect); generic_string stringJoin(const std::vector& strings, const generic_string& separator); generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable); double stodLocale(const generic_string& str, _locale_t loc, size_t* idx = NULL); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 97034022..93673d85 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -295,6 +295,7 @@ LRESULT Notepad_plus::init(HWND hwnd) _mainEditView.execute(SCI_SETEDGEMODE, svp1._edgeMode); _subEditView.execute(SCI_SETEDGECOLUMN, svp1._edgeNbColumn); _subEditView.execute(SCI_SETEDGEMODE, svp1._edgeMode); + ::SendMessage(hwnd, NPPM_INTERNAL_EDGEMULTISETSIZE, 0, 0); _mainEditView.showEOL(svp1._eolShow); _subEditView.showEOL(svp1._eolShow); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index ee39285a..5ba58170 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -2337,7 +2337,69 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa break; } - case NPPM_INTERNAL_SETTING_EDGE_SIZE: + case NPPM_INTERNAL_EDGEBACKGROUND: + case NPPM_INTERNAL_EDGELINE: + case NPPM_INTERNAL_EDGENONE: + { + int mode; + switch (message) + { + case NPPM_INTERNAL_EDGELINE: + { + mode = EDGE_LINE; + break; + } + case NPPM_INTERNAL_EDGEBACKGROUND: + { + mode = EDGE_BACKGROUND; + break; + } + default: + mode = EDGE_NONE; + } + _mainEditView.execute(SCI_SETEDGEMODE, mode); + _subEditView.execute(SCI_SETEDGEMODE, mode); + } + break; + + case NPPM_INTERNAL_EDGEMULTILINE: + { + _mainEditView.execute(SCI_SETEDGEMODE, EDGE_MULTILINE); + _subEditView.execute(SCI_SETEDGEMODE, EDGE_MULTILINE); + } + break; + + case NPPM_INTERNAL_EDGEMULTISETSIZE: + { + _mainEditView.execute(SCI_MULTIEDGECLEARALL); + _subEditView.execute(SCI_MULTIEDGECLEARALL); + + ScintillaViewParams & svp = (ScintillaViewParams &)nppParam.getSVP(); + + StyleArray & stylers = NppParameters::getInstance().getMiscStylerArray(); + COLORREF multiEdgeColor = liteGrey; + int i = stylers.getStylerIndexByName(TEXT("Edge colour")); + if (i != -1) + { + Style & style = stylers.getStyler(i); + multiEdgeColor = style._fgColor; + } + + const size_t twoPower13 = 8192; + for (auto i : svp._edgeMultiColumnPos) + { + // it's absurd to set columns beyon 8000, even it's a long line. + // So let's ignore all the number greater than 2^13 + if (i > twoPower13) + continue; + + _mainEditView.execute(SCI_MULTIEDGEADDLINE, i, multiEdgeColor); + _subEditView.execute(SCI_MULTIEDGEADDLINE, i, multiEdgeColor); + } + } + break; + + case NPPM_INTERNAL_EDGESETSIZE: { ScintillaViewParams & svp = (ScintillaViewParams &)(NppParameters::getInstance()).getSVP(); _mainEditView.execute(SCI_SETEDGECOLUMN, svp._edgeNbColumn); diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 092bd93e..7bdc98a2 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -3269,31 +3269,6 @@ void Notepad_plus::command(int id) } break; - case IDM_VIEW_EDGEBACKGROUND: - case IDM_VIEW_EDGELINE: - case IDM_VIEW_EDGENONE: - { - int mode; - switch (id) - { - case IDM_VIEW_EDGELINE: - { - mode = EDGE_LINE; - break; - } - case IDM_VIEW_EDGEBACKGROUND: - { - mode = EDGE_BACKGROUND; - break; - } - default: - mode = EDGE_NONE; - } - _mainEditView.execute(SCI_SETEDGEMODE, mode); - _subEditView.execute(SCI_SETEDGEMODE, mode); - } - break; - case IDM_VIEW_LWDEF: case IDM_VIEW_LWALIGN: case IDM_VIEW_LWINDENT: diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index f7879816..87b9dfc8 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5273,6 +5273,8 @@ void NppParameters::feedScintillaParam(TiXmlNode *node) _svp._edgeMode = EDGE_BACKGROUND; else if (!lstrcmp(nm, TEXT("line"))) _svp._edgeMode = EDGE_LINE; + else if (!lstrcmp(nm, TEXT("multiColumn"))) + _svp._edgeMode = EDGE_MULTILINE; else _svp._edgeMode = EDGE_NONE; } @@ -5294,6 +5296,13 @@ void NppParameters::feedScintillaParam(TiXmlNode *node) _svp._edgeNbColumn = val; } + nm = element->Attribute(TEXT("edgeMultiColumnPos")); + if (nm) + { + str2numberVector(nm, _svp._edgeMultiColumnPos); + } + + nm = element->Attribute(TEXT("zoom"), &val); if (nm) { @@ -5474,14 +5483,25 @@ bool NppParameters::writeScintillaParams() (scintNode->ToElement())->SetAttribute(TEXT("borderEdge"), _svp._showBorderEdge ? TEXT("yes") : TEXT("no")); const TCHAR *edgeStr; - if (_svp._edgeMode == EDGE_NONE) - edgeStr = TEXT("no"); - else if (_svp._edgeMode == EDGE_LINE) + if (_svp._edgeMode == EDGE_LINE) edgeStr = TEXT("line"); - else + else if (_svp._edgeMode == EDGE_BACKGROUND) edgeStr = TEXT("background"); + else if (_svp._edgeMode == EDGE_MULTILINE) + edgeStr = TEXT("multiColumn"); + else + edgeStr = TEXT("no"); + + generic_string edgeColumnPosStr; + for (auto i : _svp._edgeMultiColumnPos) + { + std::string s = std::to_string(i); + edgeColumnPosStr += generic_string(s.begin(), s.end()); + edgeColumnPosStr += TEXT(" "); + } (scintNode->ToElement())->SetAttribute(TEXT("edge"), edgeStr); (scintNode->ToElement())->SetAttribute(TEXT("edgeNbColumn"), _svp._edgeNbColumn); + (scintNode->ToElement())->SetAttribute(TEXT("edgeMultiColumnPos"), edgeColumnPosStr); (scintNode->ToElement())->SetAttribute(TEXT("zoom"), _svp._zoom); (scintNode->ToElement())->SetAttribute(TEXT("zoom2"), _svp._zoom2); (scintNode->ToElement())->SetAttribute(TEXT("whiteSpaceShow"), _svp._whiteSpaceShow?TEXT("show"):TEXT("hide")); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 4d3707dc..22b75818 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -922,6 +922,7 @@ struct ScintillaViewParams bool _doWrap = false; int _edgeMode = EDGE_NONE; int _edgeNbColumn = 80; + std::vector _edgeMultiColumnPos; int _zoom = 0; int _zoom2 = 0; bool _whiteSpaceShow = false; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 98b39208..c26ef8b2 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -2596,6 +2596,7 @@ void ScintillaEditView::performGlobalStyles() edgeColor = style._fgColor; } execute(SCI_SETEDGECOLOUR, edgeColor); + ::SendMessage(_hParent, NPPM_INTERNAL_EDGEMULTISETSIZE, 0, 0); COLORREF foldMarginColor = grey; COLORREF foldMarginHiColor = white; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 7e0eff92..3fbd6bf4 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -83,11 +83,13 @@ BEGIN CONTROL "None",IDC_RADIO_FOLDMARGENONE,"Button",BS_AUTORADIOBUTTON,55,115,61,10 CONTROL "Box tree",IDC_RADIO_BOX,"Button",BS_AUTORADIOBUTTON,55,100,61,10 CONTROL "Show vertical edge",IDC_CHECK_SHOWVERTICALEDGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,153,56,122,10 - RTEXT "Number of columns :",IDC_NBCOLONE_STATIC,148,104,83,8 LTEXT "0",IDC_COLONENUMBER_STATIC,238,103,18,8,WS_TABSTOP - GROUPBOX "Vertical Edge Settings",IDC_VES_GB_STATIC,142,44,148,77,BS_CENTER + GROUPBOX "Vertical Edge Settings",IDC_VES_GB_STATIC,142,44,148,135,BS_CENTER CONTROL "Line mode",IDC_RADIO_LNMODE,"Button",BS_AUTORADIOBUTTON,156,72,91,10 CONTROL "Background mode",IDC_RADIO_BGMODE,"Button",BS_AUTORADIOBUTTON,156,86,91,10 + CONTROL "Multi-line mode",IDC_RADIO_MULTILNMODE,"Button",BS_AUTORADIOBUTTON,156,121,122,10 + RTEXT "Number of columns :",IDC_NBCOLONE_STATIC,148,104,83,8 + EDITTEXT IDC_COLUMNPOS_EDIT,165,137,110,36,ES_MULTILINE GROUPBOX "Caret Settings",IDC_CARETSETTING_STATIC,46,1,199,40,BS_CENTER LTEXT "Width :",IDC_WIDTH_STATIC,50,20,37,8,0,WS_EX_RIGHT COMBOBOX IDC_WIDTH_COMBO,89,18,40,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -96,22 +98,21 @@ BEGIN LTEXT "S",IDC_CARETBLINKRATE_S_STATIC,225,25,12,8 LTEXT "F",IDC_CARETBLINKRATE_F_STATIC,144,25,12,8,0,WS_EX_RIGHT GROUPBOX "Multi-Editing Settings",IDC_MULTISELECTION_GB_STATIC,253,1,140,40,BS_CENTER - CONTROL "Enable (Ctrl+Mouse click/selection)",IDC_CHECK_MULTISELECTION, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,261,18,130,10 + CONTROL "Enable (Ctrl+Mouse click/selection)",IDC_CHECK_MULTISELECTION, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,261,18,130,10 GROUPBOX "Line Wrap",IDC_LW_GB_STATIC,301,44,92,56,BS_CENTER CONTROL "Default",IDC_RADIO_LWDEF,"Button",BS_AUTORADIOBUTTON | WS_GROUP,311,57,59,10 CONTROL "Aligned",IDC_RADIO_LWALIGN,"Button",BS_AUTORADIOBUTTON,311,71,60,10 CONTROL "Indent",IDC_RADIO_LWINDENT,"Button",BS_AUTORADIOBUTTON,311,85,62,10 - GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,142,122,148,30,BS_CENTER - CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,145,135,67,13 - LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,213,135,12,8 - CONTROL "No edge",IDC_CHECK_NOEDGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,228,135,60,10 + GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,45,135,85,45,BS_CENTER + CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,48,148,67,13 + LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,116,148,12,8 + CONTROL "No edge",IDC_CHECK_NOEDGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,165,60,10 CONTROL "Display line number",IDC_CHECK_LINENUMBERMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,298,107,141,10 CONTROL "Display bookmark",IDC_CHECK_BOOKMARKMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,298,120,150,10 - CONTROL "Enable current line highlighting",IDC_CHECK_CURRENTLINEHILITE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,298,133,129,10 + CONTROL "Enable current line highlighting",IDC_CHECK_CURRENTLINEHILITE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,298,133,129,10 CONTROL "Enable smooth font",IDC_CHECK_SMOOTHFONT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,298,146,129,10 CONTROL "Enable scrolling beyond last line",IDC_CHECK_SCROLLBEYONDLASTLINE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,298,159,139,10 - CONTROL "Disable advanced scrolling feature\r(if you have touchpad problem)",IDC_CHECK_DISABLEADVANCEDSCROLL, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,298,172,139,18 + CONTROL "Disable advanced scrolling feature\r(if you have touchpad problem)",IDC_CHECK_DISABLEADVANCEDSCROLL,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,298,172,139,18 END IDD_PREFERENCE_SETTING_BOX DIALOGEX 0, 0, 455, 185 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 86ace5ec..9b816321 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -572,6 +572,22 @@ INT_PTR CALLBACK BarsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) return FALSE; } +static WNDPROC oldFunclstToolbarProc = NULL; +static LRESULT CALLBACK editNumSpaceProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_CHAR: + { + // All non decimal numbers and non white space and non backspace are ignored + if ((wParam != 8 && wParam != 32 && wParam < 48) || wParam > 57) + { + return TRUE; + } + } + } + return oldFunclstToolbarProc(hwnd, message, wParam, lParam); +} void MarginsDlg::initScintParam() { @@ -630,16 +646,33 @@ void MarginsDlg::initScintParam() ::SendDlgItemMessage(_hSelf, IDC_CHECK_SHOWVERTICALEDGE, BM_SETCHECK, isEnable, 0); ::SendDlgItemMessage(_hSelf, IDC_RADIO_LNMODE, BM_SETCHECK, (svp._edgeMode == EDGE_LINE), 0); ::SendDlgItemMessage(_hSelf, IDC_RADIO_BGMODE, BM_SETCHECK, (svp._edgeMode == EDGE_BACKGROUND), 0); + ::SendDlgItemMessage(_hSelf, IDC_RADIO_MULTILNMODE, BM_SETCHECK, (svp._edgeMode == EDGE_MULTILINE), 0); + + generic_string edgeColumnPosStr; + for (auto i : svp._edgeMultiColumnPos) + { + std::string s = std::to_string(i); + edgeColumnPosStr += generic_string(s.begin(), s.end()); + edgeColumnPosStr += TEXT(" "); + } + ::SendDlgItemMessage(_hSelf, IDC_COLUMNPOS_EDIT, WM_SETTEXT, 0, reinterpret_cast(edgeColumnPosStr.c_str())); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_LNMODE), isEnable); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_BGMODE), isEnable); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), isEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_MULTILNMODE), isEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), isEnable && !isCheckedOrNot(IDC_RADIO_MULTILNMODE)); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_COLUMNPOS_EDIT), isEnable && isCheckedOrNot(IDC_RADIO_MULTILNMODE)); + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + generic_string radioboxTip = pNativeSpeaker->getLocalizedStrFromID("multi-edge-radio-tip", TEXT("Add your column marker by indicating its position with a decimal number.\nYou can define several column markers by using white space to seperate the different positions.")); + _multiEdgeTip = CreateToolTip(IDC_RADIO_MULTILNMODE, _hSelf, _hInst, const_cast(radioboxTip.c_str())); + + oldFunclstToolbarProc = reinterpret_cast(::SetWindowLongPtr(::GetDlgItem(_hSelf, IDC_COLUMNPOS_EDIT), GWLP_WNDPROC, reinterpret_cast(editNumSpaceProc))); + ::SetDlgItemInt(_hSelf, IDC_COLONENUMBER_STATIC, svp._edgeNbColumn, FALSE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), isEnable); - } - INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { NppParameters& nppParam = NppParameters::getInstance(); @@ -673,7 +706,7 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa const ScintillaViewParams & svp = nppParam.getSVP(); ::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETPOS, TRUE, svp._borderWidth); ::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, svp._borderWidth, FALSE); - + initScintParam(); ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); @@ -773,39 +806,59 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa case IDC_CHECK_SHOWVERTICALEDGE: { - int modeID = 0; + int modeMsg = 0; bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_SHOWVERTICALEDGE, BM_GETCHECK, 0, 0)); if (isChecked) { ::SendDlgItemMessage(_hSelf, IDC_RADIO_LNMODE, BM_SETCHECK, TRUE, 0); svp._edgeMode = EDGE_LINE; - modeID = IDM_VIEW_EDGELINE; + modeMsg = NPPM_INTERNAL_EDGELINE; } else { ::SendDlgItemMessage(_hSelf, IDC_RADIO_LNMODE, BM_SETCHECK, FALSE, 0); ::SendDlgItemMessage(_hSelf, IDC_RADIO_BGMODE, BM_SETCHECK, FALSE, 0); + ::SendDlgItemMessage(_hSelf, IDC_RADIO_MULTILNMODE, BM_SETCHECK, FALSE, 0); svp._edgeMode = EDGE_NONE; - modeID = IDM_VIEW_EDGENONE; + modeMsg = IDM_VIEW_EDGENONE; } ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_LNMODE), isChecked); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_BGMODE), isChecked); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), isChecked); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), isChecked); - - ::SendMessage(_hParent, WM_COMMAND, modeID, 0); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_MULTILNMODE), isChecked); + + ::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), isChecked && !isCheckedOrNot(IDC_RADIO_MULTILNMODE)); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), isChecked && !isCheckedOrNot(IDC_RADIO_MULTILNMODE)); + + ::EnableWindow(::GetDlgItem(_hSelf, IDC_COLUMNPOS_EDIT), isChecked && isCheckedOrNot(IDC_RADIO_MULTILNMODE)); + + ::SendMessage(::GetParent(_hParent), modeMsg, 0, 0); return TRUE; } + case IDC_RADIO_LNMODE: svp._edgeMode = EDGE_LINE; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_EDGELINE, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_EDGELINE, 0, 0); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), TRUE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), TRUE); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_COLUMNPOS_EDIT), FALSE); return TRUE; case IDC_RADIO_BGMODE: svp._edgeMode = EDGE_BACKGROUND; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_EDGEBACKGROUND, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_EDGEBACKGROUND, 0, 0); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), TRUE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), TRUE); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_COLUMNPOS_EDIT), FALSE); return TRUE; - + + case IDC_RADIO_MULTILNMODE: + svp._edgeMode = EDGE_MULTILINE; + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_EDGEMULTILINE, 0, 0); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), FALSE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), FALSE); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_COLUMNPOS_EDIT), TRUE); + return TRUE; + case IDC_COLONENUMBER_STATIC: { NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker(); @@ -825,7 +878,7 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa ::SetDlgItemInt(_hSelf, IDC_COLONENUMBER_STATIC, svp._edgeNbColumn, FALSE); // Execute modified value - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_EDGE_SIZE, 0, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_EDGESETSIZE, 0, 0); } return TRUE; } @@ -850,18 +903,30 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa { case CBN_SELCHANGE : // == case LBN_SELCHANGE : { - switch (LOWORD(wParam)) + if (LOWORD(wParam) == IDC_WIDTH_COMBO) { - case IDC_WIDTH_COMBO: - { - nppGUI._caretWidth = static_cast(::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_GETCURSEL, 0, 0)); - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETWIDTH, 0, 0); - return TRUE; - } - default: - break; + nppGUI._caretWidth = static_cast(::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_GETCURSEL, 0, 0)); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETWIDTH, 0, 0); + return TRUE; } } + break; + + case EN_CHANGE : + { + if (LOWORD(wParam) == IDC_COLUMNPOS_EDIT) + { + TCHAR text[MAX_PATH]; + ::SendDlgItemMessage(_hSelf, IDC_COLUMNPOS_EDIT, WM_GETTEXT, MAX_PATH, reinterpret_cast(text)); + + if (str2numberVector(text, svp._edgeMultiColumnPos)) + { + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_EDGEMULTISETSIZE, 0, 0); + return TRUE; + } + } + } + break; } } } diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 05c2e56d..887bb24d 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -58,10 +58,13 @@ public : MarginsDlg() = default; virtual void destroy() { _verticalEdgeLineNbColVal.destroy(); + if (_multiEdgeTip) + ::DestroyWindow(_multiEdgeTip); }; private : URLCtrl _verticalEdgeLineNbColVal; + HWND _multiEdgeTip = nullptr; INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); void initScintParam(); }; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 83d0c95c..26ca9972 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -122,6 +122,9 @@ #define IDC_CHECK_DISABLEADVANCEDSCROLL (IDD_PREFERENCE_MARGEIN_BOX + 34) #define IDC_CHECK_NOEDGE (IDD_PREFERENCE_MARGEIN_BOX + 35) #define IDC_CHECK_SCROLLBEYONDLASTLINE (IDD_PREFERENCE_MARGEIN_BOX + 36) + + #define IDC_RADIO_MULTILNMODE (IDD_PREFERENCE_MARGEIN_BOX + 37) + #define IDC_COLUMNPOS_EDIT (IDD_PREFERENCE_MARGEIN_BOX + 38) #define IDD_PREFERENCE_DELIMITERSETTINGS_BOX 6250 //(IDD_PREFERENCE_BOX + 250) #define IDC_DELIMITERSETTINGS_GB_STATIC (IDD_PREFERENCE_DELIMITERSETTINGS_BOX + 1) diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index c01fef56..d16806e4 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -280,8 +280,8 @@ #define IDM_VIEW_ZOOMOUT (IDM_VIEW + 24) #define IDM_VIEW_TAB_SPACE (IDM_VIEW + 25) #define IDM_VIEW_EOL (IDM_VIEW + 26) - #define IDM_VIEW_EDGELINE (IDM_VIEW + 27) - #define IDM_VIEW_EDGEBACKGROUND (IDM_VIEW + 28) + //#define IDM_VIEW_EDGELINE (IDM_VIEW + 27) + //#define IDM_VIEW_EDGEBACKGROUND (IDM_VIEW + 28) #define IDM_VIEW_TOGGLE_UNFOLDALL (IDM_VIEW + 29) #define IDM_VIEW_FOLD_CURRENT (IDM_VIEW + 30) #define IDM_VIEW_UNFOLD_CURRENT (IDM_VIEW + 31) diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 5746b5ed..102c992f 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -419,7 +419,7 @@ #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_ (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) @@ -441,7 +441,12 @@ #define NPPM_INTERNAL_PRNTANDQUIT (NOTEPADPLUS_USER_INTERNAL + 47) #define NPPM_INTERNAL_SAVEBACKUP (NOTEPADPLUS_USER_INTERNAL + 48) #define NPPM_INTERNAL_STOPMONITORING (NOTEPADPLUS_USER_INTERNAL + 49) // Used by Monitoring feature - + #define NPPM_INTERNAL_EDGENONE (NOTEPADPLUS_USER_INTERNAL + 50) + #define NPPM_INTERNAL_EDGELINE (NOTEPADPLUS_USER_INTERNAL + 51) + #define NPPM_INTERNAL_EDGEBACKGROUND (NOTEPADPLUS_USER_INTERNAL + 52) + #define NPPM_INTERNAL_EDGEMULTILINE (NOTEPADPLUS_USER_INTERNAL + 53) + #define NPPM_INTERNAL_EDGESETSIZE (NOTEPADPLUS_USER_INTERNAL + 54) + #define NPPM_INTERNAL_EDGEMULTISETSIZE (NOTEPADPLUS_USER_INTERNAL + 55) //wParam: 0 //lParam: document new index // See Notepad_plus_msgs.h