Skip to content

Commit

Permalink
Better PEBKAC display
Browse files Browse the repository at this point in the history
  • Loading branch information
donho committed Nov 12, 2023
1 parent f8c7f5e commit cf36dd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2486,17 +2486,15 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
wstring warningMsg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find", L"Find: Can't find the text \"$STR_REPLACE$\"");

if (!pOptions->_isWrapAround)
wstring reasonMsg;
bool isTheMostLaxMode = pOptions->_isWrapAround && !pOptions->_isMatchCase && !pOptions->_isWholeWord;
if (!isTheMostLaxMode)
{
wstring sep = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find-separator", L": ");
wstring reasonMsg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find-no-wrap", L"turn on \"Wrap around\" maybe?");

warningMsg += sep;
warningMsg += reasonMsg;
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).");
}

warningMsg = stringReplace(warningMsg, L"$STR_REPLACE$", newTxt2find);
setStatusbarMessage(warningMsg, FSNotFound);
setStatusbarMessage(warningMsg, FSNotFound, reasonMsg);

// if the dialog is not shown, pass the focus to his parent(ie. Notepad++)
if (!::IsWindowVisible(_hSelf))
Expand Down Expand Up @@ -3619,14 +3617,15 @@ void FindReplaceDlg::saveInMacro(size_t cmd, int cmdType)
::SendMessage(_hParent, WM_FRSAVE_INT, IDC_FRCOMMAND_EXEC, cmd);
}

void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus staus, char const *pTooltipMsg)
void FindReplaceDlg::setStatusbarMessage(const wstring & msg, FindStatus staus, wstring tooltipMsg)
{
if (_statusbarTooltipWnd)
{
::DestroyWindow(_statusbarTooltipWnd);
_statusbarTooltipWnd = nullptr;
}
_statusbarTooltipMsg = (pTooltipMsg && (*pTooltipMsg)) ? s2ws(pTooltipMsg) : TEXT("");

_statusbarTooltipMsg = tooltipMsg;

if (staus == FSNotFound)
{
Expand Down Expand Up @@ -3672,8 +3671,9 @@ void FindReplaceDlg::setStatusbarMessageWithRegExprErr(ScintillaEditView* pEditV

NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
std::wstring result = pNativeSpeaker->getLocalizedStrFromID("find-status-invalid-re", TEXT("Find: Invalid Regular Expression"));

setStatusbarMessage(result, FSNotFound, msg);
string s = msg;

setStatusbarMessage(result, FSNotFound, s2ws(s));
}

generic_string FindReplaceDlg::getScopeInfoForStatusBar(FindOption const *pFindOpt) const
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public :

void execSavedCommand(int cmd, uptr_t intValue, const generic_string& stringValue);
void clearMarks(const FindOption& opt);
void setStatusbarMessage(const generic_string & msg, FindStatus staus, char const *pTooltipMsg = NULL);
void setStatusbarMessage(const std::wstring & msg, FindStatus staus, std::wstring tooltipMsg = L"");
void setStatusbarMessageWithRegExprErr(ScintillaEditView* pEditView);
generic_string getScopeInfoForStatusBar(FindOption const *pFindOpt) const;
Finder * createFinder();
Expand Down

0 comments on commit cf36dd5

Please sign in to comment.