Add message box with information about disabled backward regex searching
Fix #15239, close #15243
This commit is contained in:
parent
ea71d5ea4e
commit
07e95038cb
|
@ -1524,6 +1524,10 @@ Would you like to create those placeholders?
|
|||
NOTE: Choosing not to create the placeholders or closing them later, your session WILL BE MODIFIED ON EXIT! We suggest you backup your "session.xml" now."/>
|
||||
<RTLvsDirectWrite title="Cannot run RTL" message="RTL is not compatible with DirectWrite mode. Please disable DirectWrite mode in MISC. section of Preferences dialog, and restart Notepad++."/>
|
||||
<FileMemoryAllocationFailed title="Exception: File memory allocation failed" message="There is probably not enough contiguous free memory for the file being loaded by Notepad++."/><!-- HowToReproduce: Try to open multiple files with total size > ~700MB in the x86 Notepad++ (it will depend on the PC memory configuration and the current system memory usage...). -->
|
||||
<FindRegexBackwardDisabled title="Regex backward search disabled" message="By default, backward regex searching is disabled due to potentially unexpected results. To perform a backward search, open the Find dialog and select either normal or extended search mode instead of regular expression.
|
||||
Press the OK button to open the Find dialog or set focus on it.
|
||||
|
||||
If you require the backward regex searching feature, consult the user manual for instructions on enabling it."/>
|
||||
</MessageBox>
|
||||
<ClipboardHistory>
|
||||
<PanelTitle name="Clipboard History"/>
|
||||
|
|
|
@ -1524,6 +1524,10 @@ Would you like to create those placeholders?
|
|||
NOTE: Choosing not to create the placeholders or closing them later, your session WILL BE MODIFIED ON EXIT! We suggest you backup your "session.xml" now."/>
|
||||
<RTLvsDirectWrite title="Cannot run RTL" message="RTL is not compatible with DirectWrite mode. Please disable DirectWrite mode in MISC. section of Preferences dialog, and restart Notepad++."/>
|
||||
<FileMemoryAllocationFailed title="Exception: File memory allocation failed" message="There is probably not enough contiguous free memory for the file being loaded by Notepad++."/><!-- HowToReproduce: Try to open multiple files with total size > ~700MB in the x86 Notepad++ (it will depend on the PC memory configuration and the current system memory usage...). -->
|
||||
<FindRegexBackwardDisabled title="Regex backward search disabled" message="By default, backward regex searching is disabled due to potentially unexpected results. To perform a backward search, open the Find dialog and select either normal or extended search mode instead of regular expression.
|
||||
Press the OK button to open the Find dialog or set focus on it.
|
||||
|
||||
If you require the backward regex searching feature, consult the user manual for instructions on enabling it."/>
|
||||
</MessageBox>
|
||||
<ClipboardHistory>
|
||||
<PanelTitle name="Clipboard History"/>
|
||||
|
|
|
@ -601,6 +601,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||
//Search menu
|
||||
//disable "Search Results Window" under Search Menu
|
||||
::EnableMenuItem(_mainMenuHandle, IDM_FOCUS_ON_FOUND_RESULTS, MF_DISABLED | MF_GRAYED | MF_BYCOMMAND);
|
||||
::EnableMenuItem(_mainMenuHandle, IDM_SEARCH_GOTONEXTFOUND, MF_DISABLED | MF_GRAYED | MF_BYCOMMAND);
|
||||
::EnableMenuItem(_mainMenuHandle, IDM_SEARCH_GOTOPREVFOUND, MF_DISABLED | MF_GRAYED | MF_BYCOMMAND);
|
||||
|
||||
// Find dialog is not created yet
|
||||
::EnableMenuItem(_mainMenuHandle, IDM_SEARCH_FINDNEXT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
||||
::EnableMenuItem(_mainMenuHandle, IDM_SEARCH_FINDPREV, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
||||
|
||||
//Main menu is loaded, now load editor context menu items
|
||||
nppParam.getContextMenuFromXmlTree(_mainMenuHandle, _pluginsManager.getMenuHandle());
|
||||
|
|
|
@ -1367,6 +1367,8 @@ void Notepad_plus::command(int id)
|
|||
{
|
||||
// regex upward search is disabled
|
||||
// make this a no-action command
|
||||
|
||||
_findReplaceDlg.regexBackwardMsgBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1837,7 +1837,10 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||
{
|
||||
if (HIWORD(wParam) != 1 ||
|
||||
(getCurrentStatus() != DIALOG_TYPE::FIND_DLG &&
|
||||
getCurrentStatus() != DIALOG_TYPE::REPLACE_DLG))
|
||||
getCurrentStatus() != DIALOG_TYPE::REPLACE_DLG)
|
||||
|| (LOWORD(wParam) == IDM_SEARCH_FINDPREV &&
|
||||
(_options._searchType == FindRegex) &&
|
||||
!nppParamInst.regexBackward4PowerUser()))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1881,6 +1884,8 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||
// this can only happen when shift-key was pressed
|
||||
// regex upward search is disabled
|
||||
// turn user action into a no-action step
|
||||
|
||||
regexBackwardMsgBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3590,6 +3595,8 @@ void FindReplaceDlg::findAllIn(InWhat op)
|
|||
|
||||
//enable "Search Results Window" under Search Menu
|
||||
::EnableMenuItem(::GetMenu(_hParent), IDM_FOCUS_ON_FOUND_RESULTS, MF_ENABLED | MF_BYCOMMAND);
|
||||
::EnableMenuItem(::GetMenu(_hParent), IDM_SEARCH_GOTONEXTFOUND, MF_ENABLED | MF_BYCOMMAND);
|
||||
::EnableMenuItem(::GetMenu(_hParent), IDM_SEARCH_GOTOPREVFOUND, MF_ENABLED | MF_BYCOMMAND);
|
||||
}
|
||||
|
||||
::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0);
|
||||
|
@ -3754,6 +3761,38 @@ Finder* FindReplaceDlg::getFinderFrom(HWND hwnd)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
int FindReplaceDlg::regexBackwardMsgBox()
|
||||
{
|
||||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
|
||||
const int msgboxID = nppParam.getNativeLangSpeaker()->messageBox("FindRegexBackwardDisabled",
|
||||
(*_ppEditView)->getHParent(),
|
||||
L"By default, backward regex searching is disabled due to potentially unexpected results. " \
|
||||
L"To perform a backward search, open the Find dialog and select either normal or extended search mode instead of regular expression.\r\n" \
|
||||
L"Press the OK button to open the Find dialog or set focus on it.\r\n" \
|
||||
L"\r\n" \
|
||||
L"If you require the backward regex searching feature, consult the user manual for instructions on enabling it.",
|
||||
L"Regex backward search disabled",
|
||||
MB_OKCANCEL | MB_APPLMODAL | MB_ICONINFORMATION);
|
||||
|
||||
switch (msgboxID)
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
doDialog(FIND_DLG, nppParam.getNativeLangSpeaker()->isRTL());
|
||||
goToCenter();
|
||||
::SetFocus(::GetDlgItem(_hSelf, IDREGEXP));
|
||||
break;
|
||||
}
|
||||
|
||||
case IDCANCEL:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return msgboxID;
|
||||
}
|
||||
|
||||
void FindReplaceDlg::setSearchText(TCHAR * txt2find)
|
||||
{
|
||||
HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
||||
|
@ -4131,6 +4170,8 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
|
|||
// regex upward search is disabled
|
||||
// this macro step could have been recorded in an earlier version before it was not allowed, or hand-edited
|
||||
// make this a no-action macro step
|
||||
|
||||
regexBackwardMsgBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4157,6 +4198,8 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
|
|||
// regex upward search is disabled
|
||||
// this macro step could have been recorded in an earlier version before it was not allowed, or hand-edited
|
||||
// make this a no-action macro step
|
||||
|
||||
regexBackwardMsgBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4173,6 +4216,8 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
|
|||
// regex upward search is disabled
|
||||
// this macro step could have been recorded in an earlier version before it was disabled, or hand-edited
|
||||
// make this a no-action macro step
|
||||
|
||||
regexBackwardMsgBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4517,6 +4562,9 @@ void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow)
|
|||
{
|
||||
_isRTL = isRTL;
|
||||
create(IDD_FIND_REPLACE_DLG, isRTL, true, toShow);
|
||||
|
||||
::EnableMenuItem(::GetMenu(_hParent), IDM_SEARCH_FINDNEXT, MF_BYCOMMAND | MF_ENABLED);
|
||||
::EnableMenuItem(::GetMenu(_hParent), IDM_SEARCH_FINDPREV, MF_BYCOMMAND | MF_ENABLED);
|
||||
}
|
||||
|
||||
if (whichType == FINDINFILES_DLG)
|
||||
|
|
|
@ -399,6 +399,8 @@ public :
|
|||
DIALOG_TYPE getCurrentStatus() {return _currentStatus;};
|
||||
Finder* getFinderFrom(HWND hwnd);
|
||||
|
||||
int regexBackwardMsgBox();
|
||||
|
||||
protected :
|
||||
void resizeDialogElements();
|
||||
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
|
||||
|
|
Loading…
Reference in New Issue