From 0e60bd89579cd939f2d72800ff4ee4e716c78a1a Mon Sep 17 00:00:00 2001 From: Don HO Date: Thu, 1 Feb 2018 10:09:24 +0100 Subject: [PATCH] Restore "Find Previous" & "Find Next" button in Find dialog The pair of button "Find Previous" and "Find Next" have been removed in the previous version due to some regressions. It's restored with being optional. --- PowerEditor/installer/nativeLang/chinese.xml | 3 +- PowerEditor/installer/nativeLang/english.xml | 3 +- .../nativeLang/english_customizable.xml | 3 +- PowerEditor/installer/nativeLang/french.xml | 3 +- PowerEditor/src/Parameters.cpp | 5 ++ PowerEditor/src/Parameters.h | 2 + .../src/ScitillaComponent/FindReplaceDlg.cpp | 90 ++++++++++++++++--- .../src/ScitillaComponent/FindReplaceDlg.h | 1 + .../src/ScitillaComponent/FindReplaceDlg.rc | 31 ++++--- .../src/ScitillaComponent/FindReplaceDlg_rc.h | 4 +- 10 files changed, 116 insertions(+), 29 deletions(-) diff --git a/PowerEditor/installer/nativeLang/chinese.xml b/PowerEditor/installer/nativeLang/chinese.xml index 054dfbfb..0c590d44 100644 --- a/PowerEditor/installer/nativeLang/chinese.xml +++ b/PowerEditor/installer/nativeLang/chinese.xml @@ -1,6 +1,6 @@ - +
@@ -1004,6 +1004,7 @@ + <1-to-2-buttons-tip value="2個按鈕模式"/> diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 3596b11e..616267fb 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1,6 +1,6 @@ - +
@@ -1012,6 +1012,7 @@ Your settings on cloud will be canceled. Please reset a coherent value via Prefe + <1-to-2-buttons-tip value="2 find buttons mode"/> diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 20881489..f7628802 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1,6 +1,6 @@ - +
@@ -1012,6 +1012,7 @@ Your settings on cloud will be canceled. Please reset a coherent value via Prefe + <1-to-2-buttons-tip value="2 find buttons mode"/> diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 78bbf486..c9cf426a 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1,6 +1,6 @@ - +
@@ -984,6 +984,7 @@ + <1-to-2-buttons-tip value="2 boutons Recherche"/> diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 8daea05f..b545bf30 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2281,6 +2281,10 @@ void NppParameters::feedFindHistoryParameters(TiXmlNode *node) boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("dotMatchesNewline")); if (boolStr) _findHistory._dotMatchesNewline = (lstrcmp(TEXT("yes"), boolStr) == 0); + + boolStr = (findHistoryRoot->ToElement())->Attribute(TEXT("isSearch2ButtonsMode")); + if (boolStr) + _findHistory._isSearch2ButtonsMode = (lstrcmp(TEXT("yes"), boolStr) == 0); } void NppParameters::feedShortcut(TiXmlNode *node) @@ -5716,6 +5720,7 @@ bool NppParameters::writeFindHistory() (findHistoryRoot->ToElement())->SetAttribute(TEXT("transparencyMode"), _findHistory._transparencyMode); (findHistoryRoot->ToElement())->SetAttribute(TEXT("transparency"), _findHistory._transparency); (findHistoryRoot->ToElement())->SetAttribute(TEXT("dotMatchesNewline"), _findHistory._dotMatchesNewline?TEXT("yes"):TEXT("no")); + (findHistoryRoot->ToElement())->SetAttribute(TEXT("isSearch2ButtonsMode"), _findHistory._isSearch2ButtonsMode?TEXT("yes"):TEXT("no")); TiXmlElement hist_element{TEXT("")}; diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index e328a3ac..b4ff55b1 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -1091,6 +1091,8 @@ struct FindHistory final enum searchMode{normal, extended, regExpr}; enum transparencyMode{none, onLossingFocus, persistant}; + bool _isSearch2ButtonsMode = false; + int _nbMaxFindHistoryPath = 10; int _nbMaxFindHistoryFilter = 10; int _nbMaxFindHistoryFind = 10; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 29655a5c..92ac5923 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -239,6 +239,9 @@ FindReplaceDlg::~FindReplaceDlg() if (_shiftTrickUpTip) ::DestroyWindow(_shiftTrickUpTip); + if (_2ButtonsTip) + ::DestroyWindow(_2ButtonsTip); + delete[] _uniFileName; } @@ -311,6 +314,9 @@ void FindReplaceDlg::fillFindHistory() ::SendDlgItemMessage(_hSelf, IDEXTENDED, BM_SETCHECK, findHistory._searchMode == FindHistory::extended, 0); ::SendDlgItemMessage(_hSelf, IDREGEXP, BM_SETCHECK, findHistory._searchMode == FindHistory::regExpr, 0); ::SendDlgItemMessage(_hSelf, IDREDOTMATCHNL, BM_SETCHECK, findHistory._dotMatchesNewline, 0); + + ::SendDlgItemMessage(_hSelf, IDC_2_BUTTONS_MODE, BM_SETCHECK, findHistory._isSearch2ButtonsMode, 0); + if (findHistory._searchMode == FindHistory::regExpr) { //regex doesn't allow wholeword @@ -707,6 +713,7 @@ void FindReplaceDlg::resizeDialogElements(LONG newWidth) IDD_FINDINFILES_BROWSE_BUTTON, IDCMARKALL, IDC_CLEAR_ALL, IDCCOUNTALL, IDC_FINDALL_OPENEDFILES, IDC_FINDALL_CURRENTFILE, IDREPLACE, IDREPLACEALL,IDC_REPLACE_OPENEDFILES, IDD_FINDINFILES_FIND_BUTTON, IDD_FINDINFILES_REPLACEINFILES, IDOK, IDCANCEL, + IDC_FINDPREV, IDC_FINDNEXT, IDC_2_BUTTONS_MODE }; const UINT flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS; @@ -794,11 +801,11 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM _findClosePos.top = p.y + 10; NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); - generic_string tip2show = pNativeSpeaker->getLocalizedStrFromID("shift-change-direction-tip"); - if (tip2show.empty()) - tip2show = TEXT("Use Shift+Enter to search in the opposite direction."); + generic_string searchButtonTip = pNativeSpeaker->getLocalizedStrFromID("shift-change-direction-tip"); + if (searchButtonTip.empty()) + searchButtonTip = TEXT("Use Shift+Enter to search in the opposite direction."); - _shiftTrickUpTip = CreateToolTip(IDOK, _hSelf, _hInst, const_cast(tip2show.c_str())); + _shiftTrickUpTip = CreateToolTip(IDOK, _hSelf, _hInst, const_cast(searchButtonTip.c_str())); if (_shiftTrickUpTip) { @@ -808,6 +815,19 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM SendMessage(_shiftTrickUpTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELPARAM((15000), (0))); } + generic_string checkboxTip = pNativeSpeaker->getLocalizedStrFromID("1-to-2-buttons-tip"); + if (checkboxTip.empty()) + checkboxTip = TEXT("2 find buttons mode"); + + _2ButtonsTip = CreateToolTip(IDC_2_BUTTONS_MODE, _hSelf, _hInst, const_cast(checkboxTip.c_str())); + + if (_2ButtonsTip) + { + SendMessage(_2ButtonsTip, TTM_ACTIVATE, TRUE, 0); + SendMessage(_2ButtonsTip, TTM_SETMAXTIPWIDTH, 0, 200); + // Make tip stay 15 seconds + SendMessage(_2ButtonsTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELPARAM((15000), (0))); + } return TRUE; } @@ -925,12 +945,25 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM switch (LOWORD(wParam)) { //Single actions + case IDC_2_BUTTONS_MODE: + { + bool is2ButtonsMode = isCheckedOrNot(IDC_2_BUTTONS_MODE); + findHistory._isSearch2ButtonsMode = is2ButtonsMode; + + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDPREV), is2ButtonsMode ? SW_SHOW : SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDNEXT), is2ButtonsMode ? SW_SHOW : SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDOK), is2ButtonsMode ? SW_HIDE : SW_SHOW); + } + break; + case IDCANCEL: (*_ppEditView)->execute(SCI_CALLTIPCANCEL); setStatusbarMessage(generic_string(), FSNoMessage); display(false); break; + case IDC_FINDPREV: + case IDC_FINDNEXT: case IDOK : // Find Next : only for FIND_DLG and REPLACE_DLG { setStatusbarMessage(generic_string(), FSNoMessage); @@ -945,12 +978,23 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM bool direction_bak = _options._whichDirection; - // if shift-key is pressed, revert search direction - // if shift-key is not pressed, use the normal setting - SHORT shift = GetKeyState(VK_SHIFT); - if (shift & SHIFTED) + if (LOWORD(wParam) == IDC_FINDPREV) { - _options._whichDirection = !_options._whichDirection; + _options._whichDirection = DIR_UP; + } + else if (LOWORD(wParam) == IDC_FINDNEXT) + { + _options._whichDirection = DIR_DOWN; + } + else // IDOK + { + // if shift-key is pressed, revert search direction + // if shift-key is not pressed, use the normal setting + SHORT shift = GetKeyState(VK_SHIFT); + if (shift & SHIFTED) + { + _options._whichDirection = !_options._whichDirection; + } } FindStatus findStatus = FSFound; @@ -2282,6 +2326,12 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable) ::ShowWindow(::GetDlgItem(_hSelf, IDC_REPLACE_OPENEDFILES),hideOrShow); ::ShowWindow(::GetDlgItem(_hSelf, IDC_REPLACEINSELECTION),hideOrShow); ::ShowWindow(::GetDlgItem(_hSelf, IDC_IN_SELECTION_CHECK), hideOrShow); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_2_BUTTONS_MODE), SW_SHOW); + bool is2ButtonMode = isCheckedOrNot(IDC_2_BUTTONS_MODE); + ::ShowWindow(::GetDlgItem(_hSelf, IDOK), is2ButtonMode ? SW_HIDE : SW_SHOW); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDPREV), !is2ButtonMode ? SW_HIDE : SW_SHOW); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDNEXT), !is2ButtonMode ? SW_HIDE : SW_SHOW); + // find controls ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_OPENEDFILES), !hideOrShow); @@ -2319,7 +2369,24 @@ void FindReplaceDlg::enableFindInFilesControls(bool isEnable) ::ShowWindow(::GetDlgItem(_hSelf, IDCCOUNTALL), isEnable?SW_HIDE:SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_OPENEDFILES), isEnable?SW_HIDE:SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_CURRENTFILE), isEnable?SW_HIDE:SW_SHOW); - ::ShowWindow(::GetDlgItem(_hSelf, IDOK), isEnable?SW_HIDE:SW_SHOW); + + if (isEnable) + { + ::ShowWindow(::GetDlgItem(_hSelf, IDC_2_BUTTONS_MODE), SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDOK), SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDPREV), SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDNEXT), SW_HIDE); + } + else + { + ::ShowWindow(::GetDlgItem(_hSelf, IDC_2_BUTTONS_MODE), SW_SHOW); + bool is2ButtonMode = isCheckedOrNot(IDC_2_BUTTONS_MODE); + + ::ShowWindow(::GetDlgItem(_hSelf, IDOK), is2ButtonMode ? SW_HIDE : SW_SHOW); + + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDPREV), !is2ButtonMode ? SW_HIDE : SW_SHOW); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDNEXT), !is2ButtonMode ? SW_HIDE : SW_SHOW); + } ::ShowWindow(::GetDlgItem(_hSelf, IDC_MARKLINE_CHECK), isEnable?SW_HIDE:SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_PURGE_CHECK), isEnable?SW_HIDE:SW_SHOW); @@ -2703,6 +2770,9 @@ void FindReplaceDlg::enableMarkFunc() ::ShowWindow(::GetDlgItem(_hSelf, IDCCOUNTALL),SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_CURRENTFILE),SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDOK),SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_2_BUTTONS_MODE), SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDPREV), SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDNEXT), SW_HIDE); _currentStatus = MARK_DLG; gotoCorrectTab(); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index 3e6eb1c6..67039796 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -358,6 +358,7 @@ private : std::vector _findersOfFinder; HWND _shiftTrickUpTip = nullptr; + HWND _2ButtonsTip = nullptr; bool _isRTL; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc index f8f1f00f..3c95b6dc 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc @@ -31,7 +31,7 @@ #include #include "FindReplaceDlg_rc.h" -IDD_FIND_REPLACE_DLG DIALOGEX 36, 44, 367, 200 +IDD_FIND_REPLACE_DLG DIALOGEX 36, 44, 382, 200 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME EXSTYLE WS_EX_TOOLWINDOW CAPTION "Replace" @@ -54,11 +54,11 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,101,94,15 CONTROL "Book&mark line",IDC_MARKLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,52,100,15 CONTROL "Purge for each search",IDC_PURGE_CHECK,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,12,66,99,16 - PUSHBUTTON "Mark All",IDCMARKALL,268,20,90,14 + PUSHBUTTON "Mark All",IDCMARKALL,268,20,91,14 GROUPBOX "",IDC_REPLACEINSELECTION,192,50,170,23 CONTROL "In select&ion",IDC_IN_SELECTION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,58,59,10 - PUSHBUTTON "Clear all marks",IDC_CLEAR_ALL,268,38,90,14 - CONTROL "Backward direction", IDC_BACKWARDDIRECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 76, 140, 15 + PUSHBUTTON "Clear all marks",IDC_CLEAR_ALL,268,38,91,14 + CONTROL "Backward direction", IDC_BACKWARDDIRECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 76, 140, 15 CONTROL "Match &whole word only",IDWHOLEWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,88,140,15 CONTROL "Match &case",IDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,100,140,15 CONTROL "Wra&p around",IDWRAP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,12,112,110,15 @@ -68,16 +68,19 @@ BEGIN "Button",BS_AUTORADIOBUTTON,12,155,145,10 CONTROL "Re&gular expression",IDREGEXP,"Button",BS_AUTORADIOBUTTON,12,167,78,10 CONTROL "&. matches newline",IDREDOTMATCHNL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,167,68,9 - PUSHBUTTON "Find Next",IDOK,268,20,90,14,WS_GROUP - PUSHBUTTON "Coun&t",IDCCOUNTALL,268,38,90,14 - PUSHBUTTON "Find All in All &Opened Documents",IDC_FINDALL_OPENEDFILES,268,56,90,21,BS_MULTILINE - PUSHBUTTON "Find All in Current Document",IDC_FINDALL_CURRENTFILE,268,80,90,21,BS_MULTILINE - PUSHBUTTON "&Replace",IDREPLACE,268,38,90,14 - PUSHBUTTON "Replace &All",IDREPLACEALL,268,56,90,14 - PUSHBUTTON "Replace All in All &Opened Documents",IDC_REPLACE_OPENEDFILES,268,74,90,21,BS_MULTILINE - PUSHBUTTON "Find All",IDD_FINDINFILES_FIND_BUTTON,268,20,90,14,WS_GROUP - PUSHBUTTON "&Replace in Files",IDD_FINDINFILES_REPLACEINFILES,268,38,90,14 - PUSHBUTTON "Close",IDCANCEL,268,98,90,14 + PUSHBUTTON "<< ", IDC_FINDPREV, 268, 20, 45, 14, WS_GROUP | BS_MULTILINE + PUSHBUTTON " >>", IDC_FINDNEXT, 313, 20, 45, 14, WS_GROUP | BS_MULTILINE + PUSHBUTTON "Find Next",IDOK,268,20,91,14,WS_GROUP + CONTROL "", IDC_2_BUTTONS_MODE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 363, 20, 15, 15 + PUSHBUTTON "Coun&t",IDCCOUNTALL,268,38,91,14 + PUSHBUTTON "Find All in All &Opened Documents",IDC_FINDALL_OPENEDFILES,268,56,91,21,BS_MULTILINE + PUSHBUTTON "Find All in Current Document",IDC_FINDALL_CURRENTFILE,268,80,91,21,BS_MULTILINE + PUSHBUTTON "&Replace",IDREPLACE,268,38,91,14 + PUSHBUTTON "Replace &All",IDREPLACEALL,268,56,91,14 + PUSHBUTTON "Replace All in All &Opened Documents",IDC_REPLACE_OPENEDFILES,268,74,91,21,BS_MULTILINE + PUSHBUTTON "Find All",IDD_FINDINFILES_FIND_BUTTON,268,20,91,14,WS_GROUP + PUSHBUTTON "&Replace in Files",IDD_FINDINFILES_REPLACEINFILES,268,38,91,14 + PUSHBUTTON "Close",IDCANCEL,268,98,91,14 GROUPBOX "",IDC_TRANSPARENT_GRPBOX,258,131,99,48 CONTROL "Transparenc&y",IDC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,254,131,80,10 CONTROL "On losing focus",IDC_TRANSPARENT_LOSSFOCUS_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,268,143,85,10 diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h index 3bde2445..b0e1f3ab 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h @@ -134,7 +134,9 @@ #define IDEXTENDED_FIFOLDER 1718 #define IDREGEXP_FIFOLDER 1719 #define IDREDOTMATCHNL_FIFOLDER 1720 -//#define IDC_FINDPREV 1721 +#define IDC_FINDPREV 1721 #define IDC_BACKWARDDIRECTION 1722 +#define IDC_FINDNEXT 1723 +#define IDC_2_BUTTONS_MODE 1724 #endif //FINDREPLACE_DLG_H