From 55df104606e61bdb3fcb79ee730e4f45ce59b1b5 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 10 Nov 2024 03:51:33 +0100 Subject: [PATCH] Refactoring (part 2) --- PowerEditor/src/NppBigSwitch.cpp | 91 +++++++++++++++---- PowerEditor/src/NppCommands.cpp | 73 --------------- .../WinControls/Preference/preferenceDlg.cpp | 26 +++--- PowerEditor/src/menuCmdID.h | 22 ++--- PowerEditor/src/resource.h | 34 +++---- 5 files changed, 113 insertions(+), 133 deletions(-) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 2ce2c1bce..060d2e375 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -2253,22 +2253,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return MainFileManager.getFileNameFromBuffer(reinterpret_cast(wParam), reinterpret_cast(lParam)); } - case NPPM_INTERNAL_ENABLECHECKDOCOPT: - { - NppGUI& nppgui = nppParam.getNppGUI(); - if (wParam == CHECKDOCOPT_NONE) - nppgui._fileAutoDetection = cdDisabled; - else if (wParam == CHECKDOCOPT_UPDATESILENTLY) - nppgui._fileAutoDetection = (cdEnabledOld | cdAutoUpdate); - else if (wParam == CHECKDOCOPT_UPDATEGO2END) - nppgui._fileAutoDetection = (cdEnabledOld | cdGo2end); - else if (wParam == (CHECKDOCOPT_UPDATESILENTLY | CHECKDOCOPT_UPDATEGO2END)) - nppgui._fileAutoDetection = (cdEnabledOld | cdGo2end | cdAutoUpdate); - - return TRUE; - } - - case WM_ACTIVATE: { if (wParam != WA_INACTIVE && _pEditView && _pNonEditView) @@ -3083,7 +3067,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa ScintillaViewParams &svp = const_cast(nppParam.getSVP()); svp._lineNumberMarginDynamicWidth = lParam == LINENUMWIDTH_DYNAMIC; - ::SendMessage(hwnd, WM_COMMAND, IDM_VIEW_LINENUMBER, 0); + ::SendMessage(hwnd, NPPM_INTERNAL_LINENUMBER, 0, 0); return TRUE; } @@ -3781,6 +3765,79 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return fileName.length(); } + case NPPM_INTERNAL_HILITECURRENTLINE: + { + const ScintillaViewParams& svp = nppParam.getSVP(); + + const COLORREF bgColour{ nppParam.getCurLineHilitingColour() }; + const LPARAM frameWidth{ (svp._currentLineHiliteMode == LINEHILITE_FRAME) ? svp._currentLineFrameWidth : 0 }; + + if (svp._currentLineHiliteMode != LINEHILITE_NONE) + { + _mainEditView.setElementColour(SC_ELEMENT_CARET_LINE_BACK, bgColour); + _subEditView.setElementColour(SC_ELEMENT_CARET_LINE_BACK, bgColour); + } + else + { + _mainEditView.execute(SCI_RESETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, 0); + _subEditView.execute(SCI_RESETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, 0); + } + + _mainEditView.execute(SCI_SETCARETLINEFRAME, frameWidth); + _subEditView.execute(SCI_SETCARETLINEFRAME, frameWidth); + } + break; + + case NPPM_INTERNAL_LINENUMBER: + case NPPM_INTERNAL_SYMBOLMARGIN: + { + int margin; + if (message == NPPM_INTERNAL_LINENUMBER) + margin = ScintillaEditView::_SC_MARGE_LINENUMBER; + else //if (message == IDM_VIEW_SYMBOLMARGIN) + margin = ScintillaEditView::_SC_MARGE_SYMBOL; + + if (_mainEditView.hasMarginShowed(margin)) + { + _mainEditView.showMargin(margin, false); + _subEditView.showMargin(margin, false); + } + else + { + _mainEditView.showMargin(margin); + _subEditView.showMargin(margin); + } + } + break; + + case NPPM_INTERNAL_LWDEF: + case NPPM_INTERNAL_LWALIGN: + case NPPM_INTERNAL_LWINDENT: + { + int mode = (message == NPPM_INTERNAL_LWALIGN) ? SC_WRAPINDENT_SAME : \ + (message == NPPM_INTERNAL_LWINDENT) ? SC_WRAPINDENT_INDENT : SC_WRAPINDENT_FIXED; + _mainEditView.execute(SCI_SETWRAPINDENTMODE, mode); + _subEditView.execute(SCI_SETWRAPINDENTMODE, mode); + } + break; + + case NPPM_INTERNAL_FOLDSYMBOLSIMPLE: + case NPPM_INTERNAL_FOLDSYMBOLARROW: + case NPPM_INTERNAL_FOLDSYMBOLCIRCLE: + case NPPM_INTERNAL_FOLDSYMBOLBOX: + case NPPM_INTERNAL_FOLDSYMBOLNONE: + { + folderStyle fStyle = + (message == NPPM_INTERNAL_FOLDSYMBOLSIMPLE) ? FOLDER_STYLE_SIMPLE : \ + (message == NPPM_INTERNAL_FOLDSYMBOLARROW) ? FOLDER_STYLE_ARROW : \ + (message == NPPM_INTERNAL_FOLDSYMBOLCIRCLE) ? FOLDER_STYLE_CIRCLE : \ + (message == NPPM_INTERNAL_FOLDSYMBOLNONE) ? FOLDER_STYLE_NONE : FOLDER_STYLE_BOX; + + _mainEditView.setMakerStyle(fStyle); + _subEditView.setMakerStyle(fStyle); + } + break; + case NPPM_INTERNAL_TOOLBARREDUCE: { toolBarStatusType state = _toolBar.getState(); diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index d7cf45af3..2a1db337a 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -3978,79 +3978,6 @@ void Notepad_plus::command(int id) } break; - case IDM_VIEW_LINENUMBER: - case IDM_VIEW_SYMBOLMARGIN: - { - int margin; - if (id == IDM_VIEW_LINENUMBER) - margin = ScintillaEditView::_SC_MARGE_LINENUMBER; - else //if (id == IDM_VIEW_SYMBOLMARGIN) - margin = ScintillaEditView::_SC_MARGE_SYMBOL; - - if (_mainEditView.hasMarginShowed(margin)) - { - _mainEditView.showMargin(margin, false); - _subEditView.showMargin(margin, false); - } - else - { - _mainEditView.showMargin(margin); - _subEditView.showMargin(margin); - } - } - break; - - case IDM_VIEW_FOLDERMAGIN_SIMPLE: - case IDM_VIEW_FOLDERMAGIN_ARROW: - case IDM_VIEW_FOLDERMAGIN_CIRCLE: - case IDM_VIEW_FOLDERMAGIN_BOX: - case IDM_VIEW_FOLDERMAGIN: - { - folderStyle fStyle = (id == IDM_VIEW_FOLDERMAGIN_SIMPLE) ? FOLDER_STYLE_SIMPLE : \ - (id == IDM_VIEW_FOLDERMAGIN_ARROW) ? FOLDER_STYLE_ARROW : \ - (id == IDM_VIEW_FOLDERMAGIN_CIRCLE) ? FOLDER_STYLE_CIRCLE : \ - (id == IDM_VIEW_FOLDERMAGIN) ? FOLDER_STYLE_NONE : FOLDER_STYLE_BOX; - - _mainEditView.setMakerStyle(fStyle); - _subEditView.setMakerStyle(fStyle); - } - break; - - case IDM_VIEW_CURLINE_HILITING: - { - NppParameters& nppParams = NppParameters::getInstance(); - const ScintillaViewParams& svp = nppParams.getSVP(); - - const COLORREF bgColour { nppParams.getCurLineHilitingColour() }; - const LPARAM frameWidth { (svp._currentLineHiliteMode == LINEHILITE_FRAME) ? svp._currentLineFrameWidth : 0 }; - - if (svp._currentLineHiliteMode != LINEHILITE_NONE) - { - _mainEditView.setElementColour(SC_ELEMENT_CARET_LINE_BACK, bgColour); - _subEditView.setElementColour(SC_ELEMENT_CARET_LINE_BACK, bgColour); - } - else - { - _mainEditView.execute(SCI_RESETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, 0); - _subEditView.execute(SCI_RESETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, 0); - } - - _mainEditView.execute(SCI_SETCARETLINEFRAME, frameWidth); - _subEditView.execute(SCI_SETCARETLINEFRAME, frameWidth); - } - break; - - case IDM_VIEW_LWDEF: - case IDM_VIEW_LWALIGN: - case IDM_VIEW_LWINDENT: - { - int mode = (id == IDM_VIEW_LWALIGN) ? SC_WRAPINDENT_SAME : \ - (id == IDM_VIEW_LWINDENT) ? SC_WRAPINDENT_INDENT : SC_WRAPINDENT_FIXED; - _mainEditView.execute(SCI_SETWRAPINDENTMODE, mode); - _subEditView.execute(SCI_SETWRAPINDENTMODE, mode); - } - break; - default : if (id > IDM_FILEMENU_LASTONE && id < (IDM_FILEMENU_LASTONE + _lastRecentFileList.getMaxNbLRF() + 1)) { diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index cf80c5b1a..a8c83fc1d 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -892,7 +892,7 @@ void EditingSubDlg::changeLineHiliteMode(bool enableSlider) ::EnableWindow(::GetDlgItem(_hSelf, IDC_CARETLINEFRAME_WIDTH_SLIDER), enableSlider); redrawDlgItem(IDC_CARETLINEFRAME_WIDTH_STATIC); redrawDlgItem(IDC_CARETLINEFRAME_WIDTH_DISPLAY); - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_CURLINE_HILITING, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_HILITECURRENTLINE, 0, 0); } bool hasOnlyNumSpaceInClipboard() @@ -1155,17 +1155,17 @@ intptr_t CALLBACK EditingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM case IDC_RADIO_LWDEF: svp._lineWrapMethod = LINEWRAP_DEFAULT; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LWDEF, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_LWDEF, 0, 0); return TRUE; case IDC_RADIO_LWALIGN: svp._lineWrapMethod = LINEWRAP_ALIGNED; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LWALIGN, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_LWALIGN, 0, 0); return TRUE; case IDC_RADIO_LWINDENT: svp._lineWrapMethod = LINEWRAP_INDENT; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LWINDENT, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_LWINDENT, 0, 0); return TRUE; default : @@ -2236,20 +2236,20 @@ intptr_t CALLBACK MarginsBorderEdgeSubDlg::run_dlgProc(UINT message, WPARAM wPar svp._lineNumberMarginShow = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_LINENUMBERMARGE, BM_GETCHECK, 0, 0)); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DYNAMIC), svp._lineNumberMarginShow); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_CONSTANT), svp._lineNumberMarginShow); - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LINENUMBER, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_LINENUMBER, 0, 0); return TRUE; case IDC_RADIO_DYNAMIC: svp._lineNumberMarginDynamicWidth = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_RADIO_DYNAMIC, BM_GETCHECK, 0, 0)); - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LINENUMBER, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_LINENUMBER, 0, 0); return TRUE; case IDC_RADIO_CONSTANT: svp._lineNumberMarginDynamicWidth = !(BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_RADIO_CONSTANT, BM_GETCHECK, 0, 0)); - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LINENUMBER, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_LINENUMBER, 0, 0); return TRUE; case IDC_CHECK_BOOKMARKMARGE: svp._bookMarkMarginShow = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_BOOKMARKMARGE, BM_GETCHECK, 0, 0)); - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_SYMBOLMARGIN, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SYMBOLMARGIN, 0, 0); return TRUE; case IDC_CHECK_CHANGHISTORYMARGIN: @@ -2323,24 +2323,24 @@ intptr_t CALLBACK MarginsBorderEdgeSubDlg::run_dlgProc(UINT message, WPARAM wPar case IDC_RADIO_SIMPLE: svp._folderStyle = FOLDER_STYLE_SIMPLE; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_FOLDERMAGIN_SIMPLE, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_FOLDSYMBOLSIMPLE, 0, 0); return TRUE; case IDC_RADIO_ARROW: svp._folderStyle = FOLDER_STYLE_ARROW; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_FOLDERMAGIN_ARROW, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_FOLDSYMBOLARROW, 0, 0); return TRUE; case IDC_RADIO_CIRCLE: svp._folderStyle = FOLDER_STYLE_CIRCLE; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_FOLDERMAGIN_CIRCLE, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_FOLDSYMBOLCIRCLE, 0, 0); return TRUE; case IDC_RADIO_BOX: svp._folderStyle = FOLDER_STYLE_BOX; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_FOLDERMAGIN_BOX, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_FOLDSYMBOLBOX, 0, 0); return TRUE; case IDC_RADIO_FOLDMARGENONE: svp._folderStyle = FOLDER_STYLE_NONE; - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_FOLDERMAGIN, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_FOLDSYMBOLNONE, 0, 0); return TRUE; case IDC_CHECK_EDGEBGMODE: diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 1108d1f36..2d824f299 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -284,16 +284,16 @@ #define IDM_VIEW_POSTIT (IDM_VIEW + 9) #define IDM_VIEW_FOLDALL (IDM_VIEW + 10) #define IDM_VIEW_DISTRACTIONFREE (IDM_VIEW + 11) - #define IDM_VIEW_LINENUMBER (IDM_VIEW + 12) - #define IDM_VIEW_SYMBOLMARGIN (IDM_VIEW + 13) - #define IDM_VIEW_FOLDERMAGIN (IDM_VIEW + 14) - #define IDM_VIEW_FOLDERMAGIN_SIMPLE (IDM_VIEW + 15) - #define IDM_VIEW_FOLDERMAGIN_ARROW (IDM_VIEW + 16) - #define IDM_VIEW_FOLDERMAGIN_CIRCLE (IDM_VIEW + 17) - #define IDM_VIEW_FOLDERMAGIN_BOX (IDM_VIEW + 18) + //#define IDM_VIEW_LINENUMBER (IDM_VIEW + 12) + //#define IDM_VIEW_SYMBOLMARGIN (IDM_VIEW + 13) + //#define IDM_VIEW_FOLDERMAGIN (IDM_VIEW + 14) + //#define IDM_VIEW_FOLDERMAGIN_SIMPLE (IDM_VIEW + 15) + //#define IDM_VIEW_FOLDERMAGIN_ARROW (IDM_VIEW + 16) + //#define IDM_VIEW_FOLDERMAGIN_CIRCLE (IDM_VIEW + 17) + //#define IDM_VIEW_FOLDERMAGIN_BOX (IDM_VIEW + 18) #define IDM_VIEW_ALL_CHARACTERS (IDM_VIEW + 19) #define IDM_VIEW_INDENT_GUIDE (IDM_VIEW + 20) - #define IDM_VIEW_CURLINE_HILITING (IDM_VIEW + 21) + //#define IDM_VIEW_CURLINE_HILITING (IDM_VIEW + 21) #define IDM_VIEW_WRAP (IDM_VIEW + 22) #define IDM_VIEW_ZOOMIN (IDM_VIEW + 23) #define IDM_VIEW_ZOOMOUT (IDM_VIEW + 24) @@ -318,9 +318,9 @@ //#define IDM_VIEW_DRAWTABBAR_VERTICAL (IDM_VIEW + 43) //#define IDM_VIEW_DRAWTABBAR_MULTILINE (IDM_VIEW + 44) //#define IDM_VIEW_DOCCHANGEMARGIN (IDM_VIEW + 45) - #define IDM_VIEW_LWDEF (IDM_VIEW + 46) - #define IDM_VIEW_LWALIGN (IDM_VIEW + 47) - #define IDM_VIEW_LWINDENT (IDM_VIEW + 48) + //#define IDM_VIEW_LWDEF (IDM_VIEW + 46) + //#define IDM_VIEW_LWALIGN (IDM_VIEW + 47) + //#define IDM_VIEW_LWINDENT (IDM_VIEW + 48) #define IDM_VIEW_SUMMARY (IDM_VIEW + 49) #define IDM_VIEW_FOLD (IDM_VIEW + 50) diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 1d4edc667..0d0c3c5f4 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -716,33 +716,29 @@ #define NPPM_INTERNAL_TABDBCLK2CLOSE (NOTEPADPLUS_USER_INTERNAL + 87) #define NPPM_INTERNAL_VERTICALTABBAR (NOTEPADPLUS_USER_INTERNAL + 88) #define NPPM_INTERNAL_MULTILINETABBAR (NOTEPADPLUS_USER_INTERNAL + 89) - #define NPPM_INTERNAL_TOOLBARREDUCE (NOTEPADPLUS_USER_INTERNAL + 90) #define NPPM_INTERNAL_TOOLBARREDUCESET2 (NOTEPADPLUS_USER_INTERNAL + 91) #define NPPM_INTERNAL_TOOLBARENLARGE (NOTEPADPLUS_USER_INTERNAL + 92) #define NPPM_INTERNAL_TOOLBARENLARGESET2 (NOTEPADPLUS_USER_INTERNAL + 93) #define NPPM_INTERNAL_TOOLBARSTANDARD (NOTEPADPLUS_USER_INTERNAL + 94) + #define NPPM_INTERNAL_LINENUMBER (NOTEPADPLUS_USER_INTERNAL + 95) + #define NPPM_INTERNAL_SYMBOLMARGIN (NOTEPADPLUS_USER_INTERNAL + 96) + #define NPPM_INTERNAL_HILITECURRENTLINE (NOTEPADPLUS_USER_INTERNAL + 97) + #define NPPM_INTERNAL_FOLDSYMBOLSIMPLE (NOTEPADPLUS_USER_INTERNAL + 98) + #define NPPM_INTERNAL_FOLDSYMBOLARROW (NOTEPADPLUS_USER_INTERNAL + 99) + #define NPPM_INTERNAL_FOLDSYMBOLCIRCLE (NOTEPADPLUS_USER_INTERNAL + 100) + #define NPPM_INTERNAL_FOLDSYMBOLBOX (NOTEPADPLUS_USER_INTERNAL + 101) + #define NPPM_INTERNAL_FOLDSYMBOLNONE (NOTEPADPLUS_USER_INTERNAL + 102) + #define NPPM_INTERNAL_LWDEF (NOTEPADPLUS_USER_INTERNAL + 103) + #define NPPM_INTERNAL_LWALIGN (NOTEPADPLUS_USER_INTERNAL + 104) + #define NPPM_INTERNAL_LWINDENT (NOTEPADPLUS_USER_INTERNAL + 105) + #define NPPM_INTERNAL_CHECKDOCSTATUS (NOTEPADPLUS_USER_INTERNAL + 106) -// See Notepad_plus_msgs.h -//#define NOTEPADPLUS_USER (WM_USER + 1000) - - // - // Used by Doc Monitor plugin - // - #define NPPM_INTERNAL_CHECKDOCSTATUS (NPPMSG + 53) - // VOID NPPM_CHECKDOCSTATUS(0, 0) - // check all opened documents status. - // If files are modified, then reloaod (with or without prompt, it depends on settings). - // if files are deleted, then prompt user to close the documents - - #define NPPM_INTERNAL_ENABLECHECKDOCOPT (NPPMSG + 54) - // VOID NPPM_ENABLECHECKDOCOPT(OPT, 0) - // where OPT is : - #define CHECKDOCOPT_NONE 0 - #define CHECKDOCOPT_UPDATESILENTLY 1 - #define CHECKDOCOPT_UPDATEGO2END 2 +// See Notepad_plus_msgs.h +//#define NPPMSG (WM_USER + 1000) + #define SCINTILLA_USER (WM_USER + 2000)