From d51edabbad124cbd8e0ef9fedb288f8e26db1cab Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 14 Nov 2023 04:24:35 +0100 Subject: [PATCH] Add tip to Wrap around compatible commands Also add range info to Find & replace 0 matches info. --- PowerEditor/installer/nativeLang/english.xml | 1 + .../nativeLang/english_customizable.xml | 1 + PowerEditor/installer/nativeLang/french.xml | 1 + .../nativeLang/taiwaneseMandarin.xml | 5 +- .../src/ScintillaComponent/FindReplaceDlg.cpp | 64 +++++++++++++++---- 5 files changed, 56 insertions(+), 16 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index d210cdec5ab4..9cb3307591df 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1666,6 +1666,7 @@ Find in all files but exclude all folders log or logs recursively: + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index e9baa93da0e8..8e5ddd2598e6 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1666,6 +1666,7 @@ Find in all files but exclude all folders log or logs recursively: + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 9dc9eb42d771..ceaa225e61e4 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1652,6 +1652,7 @@ Rechercher dans tous les fichiers mais pas dans les dossiers log ou logs récurs + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index 4aae298765eb..d9e0ddf130c1 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -1530,9 +1530,10 @@ - + - + + diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 5c750d626bdc..5aa51a66fe65 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -30,6 +30,8 @@ FindOption FindReplaceDlg::_options; #define SHIFTED 0x8000 +const wstring noFoundPotentialReason = L"The given occurence cannot be found. You may have forgotten to check \"Wrap around\" (to ON), \"Match case\" (to OFF), or \"Match whole word only\" (to OFF)."; + void addText2Combo(const TCHAR * txt2add, HWND hCombo) { if (!hCombo) return; @@ -1984,7 +1986,14 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA result += TEXT(" "); result += getScopeInfoForStatusBar(&_options); - setStatusbarMessage(result, FSMessage); + wstring reasonMsg; + bool isTheMostLaxMode = _options._isWrapAround && !_options._isMatchCase && !_options._isWholeWord; + if (nbReplaced == 0 && !isTheMostLaxMode) + { + reasonMsg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find-pebkac-maybe", noFoundPotentialReason); + } + + setStatusbarMessage(result, FSMessage, reasonMsg); } getFocus(); } @@ -2021,8 +2030,15 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA } result += TEXT(" "); result += getScopeInfoForStatusBar(&_options); - - setStatusbarMessage(result, FSMessage); + + wstring reasonMsg; + bool isTheMostLaxMode = _options._isWrapAround && !_options._isMatchCase && !_options._isWholeWord; + if (nbCounted == 0 && !isTheMostLaxMode) + { + reasonMsg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find-pebkac-maybe", noFoundPotentialReason); + } + + setStatusbarMessage(result, FSMessage, reasonMsg); } if (isMacroRecording) @@ -2068,7 +2084,14 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA result += TEXT(" "); result += getScopeInfoForStatusBar(&_options); - setStatusbarMessage(result, FSMessage); + wstring reasonMsg; + bool isTheMostLaxMode = _options._isWrapAround && !_options._isMatchCase && !_options._isWholeWord; + if (nbMarked == 0 && !isTheMostLaxMode) + { + reasonMsg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find-pebkac-maybe", noFoundPotentialReason); + } + + setStatusbarMessage(result, FSMessage, reasonMsg); } getFocus(); @@ -2482,18 +2505,20 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op //failed, or failed twice with wrap if (pOptions->_incrementalType == NotIncremental) //incremental search doesnt trigger messages { - generic_string newTxt2find = stringReplace(txt2find, TEXT("&"), TEXT("&&")); - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); wstring warningMsg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find", L"Find: Can't find the text \"$STR_REPLACE$\""); + wstring newTxt2find = stringReplace(txt2find, L"&", L"&&"); + warningMsg = stringReplace(warningMsg, L"$STR_REPLACE$", newTxt2find); + + warningMsg += TEXT(" "); + warningMsg += getScopeInfoForStatusBar(&_options); wstring reasonMsg; - bool isTheMostLaxMode = pOptions->_isWrapAround && !pOptions->_isMatchCase && !pOptions->_isWholeWord; + bool isTheMostLaxMode = _options._isWrapAround && !_options._isMatchCase && !_options._isWholeWord; if (!isTheMostLaxMode) { - reasonMsg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find-pebkac-maybe", L"The given occurence cannot be found. You may have forgotten to check \"Wrap around\" (to ON), \"Match case\" (to OFF), or \"Match whole word only\" (to OFF)."); + reasonMsg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find-pebkac-maybe", noFoundPotentialReason); } - - warningMsg = stringReplace(warningMsg, L"$STR_REPLACE$", newTxt2find); setStatusbarMessage(warningMsg, FSNotFound, reasonMsg); // if the dialog is not shown, pass the focus to his parent(ie. Notepad++) @@ -2641,11 +2666,22 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl } else { - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); - generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replace-not-found", TEXT("Replace: no occurrence was found.")); - if (_statusbarTooltipMsg.empty()) // Tooltip message non-empty means there's a find problem - so we keep the message as it is and not erase it - setStatusbarMessage(msg, FSNotFound); + { + NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-replace-not-found", TEXT("Replace: no occurrence was found")); + + msg += L" "; + msg += getScopeInfoForStatusBar(&_options); + + wstring reasonMsg; + bool isTheMostLaxMode = _options._isWrapAround && !_options._isMatchCase && !_options._isWholeWord; + if (!isTheMostLaxMode) + { + reasonMsg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find-pebkac-maybe", noFoundPotentialReason); + } + setStatusbarMessage(msg, FSNotFound, reasonMsg); + } } return moreMatches;