Skip to content

Commit

Permalink
Add tip to Wrap around compatible commands
Browse files Browse the repository at this point in the history
Also add range info to Find & replace 0 matches info.
  • Loading branch information
donho committed Nov 14, 2023
1 parent cf36dd5 commit d51edab
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 16 deletions.
1 change: 1 addition & 0 deletions PowerEditor/installer/nativeLang/english.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ Find in all files but exclude all folders log or logs recursively:
<find-status-replace-not-found value="Replace: no occurrence was found"/>
<find-status-replace-readonly value="Replace: Cannot replace text. The current document is read only"/>
<find-status-cannot-find value="Find: Can't find the text &quot;$STR_REPLACE$&quot;"/>
<find-status-cannot-find-pebkac-maybe value="The given occurence cannot be found. You may have forgotten to check &quot;Wrap around&quot; (to ON), &quot;Match case&quot; (to OFF), or &quot;Match whole word only&quot; (to OFF)."/>
<find-status-scope-selection value="in selected text"/>
<find-status-scope-all value="in entire file"/>
<find-status-scope-backward value="from start-of-file to caret"/>
Expand Down
1 change: 1 addition & 0 deletions PowerEditor/installer/nativeLang/english_customizable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ Find in all files but exclude all folders log or logs recursively:
<find-status-replace-not-found value="Replace: no occurrence was found"/>
<find-status-replace-readonly value="Replace: Cannot replace text. The current document is read only"/>
<find-status-cannot-find value="Find: Can't find the text &quot;$STR_REPLACE$&quot;"/>
<find-status-cannot-find-pebkac-maybe value="The given occurence cannot be found. You may have forgotten to check &quot;Wrap around&quot; (to ON), &quot;Match case&quot; (to OFF), or &quot;Match whole word only&quot; (to OFF)."/>
<find-status-scope-selection value="in selected text"/>
<find-status-scope-all value="in entire file"/>
<find-status-scope-backward value="from start-of-file to caret"/>
Expand Down
1 change: 1 addition & 0 deletions PowerEditor/installer/nativeLang/french.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@ Rechercher dans tous les fichiers mais pas dans les dossiers log ou logs récurs
<find-status-replace-not-found value="Remplacer : aucune occurrence n'a été trouvée"/>
<find-status-replace-readonly value="Remplacer : l'opération a échoué. Le fichier est en lecture seule"/>
<find-status-cannot-find value="Rechercher : &quot;$STR_REPLACE$&quot; n'a pas été trouvé"/>
<find-status-cannot-find-pebkac-maybe value="L'occurrence donnée n’a pas été trouvée. Vous avez peut-être oublié de cocher &quot;Boucler&quot; (activé), &quot;Respecter la casse&quot; (désactivé), ou &quot;Mot entier uniquement&quot; (désactivé)."/>
<find-status-scope-selection value="dans le texte sélectionné"/>
<find-status-scope-all value="dans le fichier"/>
<find-status-scope-backward value="du début du fichier au curseur"/>
Expand Down
5 changes: 3 additions & 2 deletions PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1530,9 +1530,10 @@
<find-status-replace-top-reached value="取代:從下面取代了 1 個相符的字串。搜尋已抵達文件開首。"/>
<find-status-replaced-next-found value="取代:取代了 1 個字串。找到下一個字串。"/>
<find-status-replaced-next-not-found value="取代:取代了 1 個字串。找不到下一個字串。"/>
<find-status-replace-not-found value="取代:找不到搜尋字串"/>
<find-status-replace-not-found value="取代:找不到搜尋字串"/>
<find-status-replace-readonly value="取代:檔案唯讀,無法取代字串。"/>
<find-status-cannot-find value="搜尋:找不到搜尋字串「$STR_REPLACE$」。"/>
<find-status-cannot-find value="搜尋:找不到搜尋字串「$STR_REPLACE$」"/>
<find-status-cannot-find-pebkac-maybe value="找不到指定的字串。你可能忘記設定「循環」(設為開啟)、「區分大小寫」(設為關閉)或「僅符合整個單字」(設為關閉)"/>
<find-status-scope-selection value="在所選取的字串中"/>
<find-status-scope-all value="在整個檔案中"/>
<find-status-scope-backward value="從文件開始到游標位置"/>
Expand Down
64 changes: 50 additions & 14 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d51edab

Please sign in to comment.