Enhance Find Dialog: display extra info in the status bar
Fix #14307, close #14347
This commit is contained in:
parent
812745d850
commit
05f339b0cf
|
@ -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-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-replace-readonly value="Replace: Cannot replace text. The current document is read only"/>
|
||||||
<find-status-cannot-find value="Find: Can't find the text "$STR_REPLACE$""/>
|
<find-status-cannot-find value="Find: Can't find the text "$STR_REPLACE$""/>
|
||||||
|
<find-status-cannot-find-pebkac-maybe value="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)."/>
|
||||||
<find-status-scope-selection value="in selected text"/>
|
<find-status-scope-selection value="in selected text"/>
|
||||||
<find-status-scope-all value="in entire file"/>
|
<find-status-scope-all value="in entire file"/>
|
||||||
<find-status-scope-backward value="from start-of-file to caret"/>
|
<find-status-scope-backward value="from start-of-file to caret"/>
|
||||||
|
|
|
@ -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-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-replace-readonly value="Replace: Cannot replace text. The current document is read only"/>
|
||||||
<find-status-cannot-find value="Find: Can't find the text "$STR_REPLACE$""/>
|
<find-status-cannot-find value="Find: Can't find the text "$STR_REPLACE$""/>
|
||||||
|
<find-status-cannot-find-pebkac-maybe value="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)."/>
|
||||||
<find-status-scope-selection value="in selected text"/>
|
<find-status-scope-selection value="in selected text"/>
|
||||||
<find-status-scope-all value="in entire file"/>
|
<find-status-scope-all value="in entire file"/>
|
||||||
<find-status-scope-backward value="from start-of-file to caret"/>
|
<find-status-scope-backward value="from start-of-file to caret"/>
|
||||||
|
|
|
@ -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-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-replace-readonly value="Remplacer : l'opération a échoué. Le fichier est en lecture seule"/>
|
||||||
<find-status-cannot-find value="Rechercher : "$STR_REPLACE$" n'a pas été trouvé"/>
|
<find-status-cannot-find value="Rechercher : "$STR_REPLACE$" 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 "Boucler" (activé), "Respecter la casse" (désactivé), ou "Mot entier uniquement" (désactivé)."/>
|
||||||
<find-status-scope-selection value="dans le texte sélectionné"/>
|
<find-status-scope-selection value="dans le texte sélectionné"/>
|
||||||
<find-status-scope-all value="dans le fichier"/>
|
<find-status-scope-all value="dans le fichier"/>
|
||||||
<find-status-scope-backward value="du début du fichier au curseur"/>
|
<find-status-scope-backward value="du début du fichier au curseur"/>
|
||||||
|
|
|
@ -1530,9 +1530,10 @@
|
||||||
<find-status-replace-top-reached value="取代:從下面取代了 1 個相符的字串。搜尋已抵達文件開首。"/>
|
<find-status-replace-top-reached value="取代:從下面取代了 1 個相符的字串。搜尋已抵達文件開首。"/>
|
||||||
<find-status-replaced-next-found value="取代:取代了 1 個字串。找到下一個字串。"/>
|
<find-status-replaced-next-found value="取代:取代了 1 個字串。找到下一個字串。"/>
|
||||||
<find-status-replaced-next-not-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-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-selection value="在所選取的字串中"/>
|
||||||
<find-status-scope-all value="在整個檔案中"/>
|
<find-status-scope-all value="在整個檔案中"/>
|
||||||
<find-status-scope-backward value="從文件開始到游標位置"/>
|
<find-status-scope-backward value="從文件開始到游標位置"/>
|
||||||
|
|
|
@ -30,6 +30,8 @@ FindOption FindReplaceDlg::_options;
|
||||||
|
|
||||||
#define SHIFTED 0x8000
|
#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)
|
void addText2Combo(const TCHAR * txt2add, HWND hCombo)
|
||||||
{
|
{
|
||||||
if (!hCombo) return;
|
if (!hCombo) return;
|
||||||
|
@ -1984,7 +1986,14 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||||
result += TEXT(" ");
|
result += TEXT(" ");
|
||||||
result += getScopeInfoForStatusBar(&_options);
|
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();
|
getFocus();
|
||||||
}
|
}
|
||||||
|
@ -2021,8 +2030,15 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||||
}
|
}
|
||||||
result += TEXT(" ");
|
result += TEXT(" ");
|
||||||
result += getScopeInfoForStatusBar(&_options);
|
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)
|
if (isMacroRecording)
|
||||||
|
@ -2068,7 +2084,14 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||||
result += TEXT(" ");
|
result += TEXT(" ");
|
||||||
result += getScopeInfoForStatusBar(&_options);
|
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();
|
getFocus();
|
||||||
|
@ -2480,13 +2503,30 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||||
if (oFindStatus)
|
if (oFindStatus)
|
||||||
*oFindStatus = FSNotFound;
|
*oFindStatus = FSNotFound;
|
||||||
//failed, or failed twice with wrap
|
//failed, or failed twice with wrap
|
||||||
if (NotIncremental == pOptions->_incrementalType) //incremental search doesnt trigger messages
|
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$\"");
|
||||||
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find", TEXT("Find: Can't find the text \"$STR_REPLACE$\""));
|
wstring newTxt2find = stringReplace(txt2find, L"&", L"&&");
|
||||||
msg = stringReplace(msg, TEXT("$STR_REPLACE$"), newTxt2find);
|
|
||||||
setStatusbarMessage(msg, FSNotFound);
|
if (newTxt2find.length() > 32) // truncate the search string to display, if the search string is too long
|
||||||
|
{
|
||||||
|
newTxt2find.erase(28);
|
||||||
|
newTxt2find += L"...";
|
||||||
|
}
|
||||||
|
|
||||||
|
warningMsg = stringReplace(warningMsg, L"$STR_REPLACE$", newTxt2find);
|
||||||
|
|
||||||
|
warningMsg += TEXT(" ");
|
||||||
|
warningMsg += 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(warningMsg, FSNotFound, reasonMsg);
|
||||||
|
|
||||||
// if the dialog is not shown, pass the focus to his parent(ie. Notepad++)
|
// if the dialog is not shown, pass the focus to his parent(ie. Notepad++)
|
||||||
if (!::IsWindowVisible(_hSelf))
|
if (!::IsWindowVisible(_hSelf))
|
||||||
|
@ -2633,11 +2673,22 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl
|
||||||
}
|
}
|
||||||
else
|
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
|
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;
|
return moreMatches;
|
||||||
|
@ -3609,14 +3660,15 @@ void FindReplaceDlg::saveInMacro(size_t cmd, int cmdType)
|
||||||
::SendMessage(_hParent, WM_FRSAVE_INT, IDC_FRCOMMAND_EXEC, cmd);
|
::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)
|
if (_statusbarTooltipWnd)
|
||||||
{
|
{
|
||||||
::DestroyWindow(_statusbarTooltipWnd);
|
::DestroyWindow(_statusbarTooltipWnd);
|
||||||
_statusbarTooltipWnd = nullptr;
|
_statusbarTooltipWnd = nullptr;
|
||||||
}
|
}
|
||||||
_statusbarTooltipMsg = (pTooltipMsg && (*pTooltipMsg)) ? s2ws(pTooltipMsg) : TEXT("");
|
|
||||||
|
_statusbarTooltipMsg = tooltipMsg;
|
||||||
|
|
||||||
if (staus == FSNotFound)
|
if (staus == FSNotFound)
|
||||||
{
|
{
|
||||||
|
@ -3662,8 +3714,9 @@ void FindReplaceDlg::setStatusbarMessageWithRegExprErr(ScintillaEditView* pEditV
|
||||||
|
|
||||||
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||||
std::wstring result = pNativeSpeaker->getLocalizedStrFromID("find-status-invalid-re", TEXT("Find: Invalid Regular Expression"));
|
std::wstring result = pNativeSpeaker->getLocalizedStrFromID("find-status-invalid-re", TEXT("Find: Invalid Regular Expression"));
|
||||||
|
string s = msg;
|
||||||
setStatusbarMessage(result, FSNotFound, msg);
|
|
||||||
|
setStatusbarMessage(result, FSNotFound, s2ws(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
generic_string FindReplaceDlg::getScopeInfoForStatusBar(FindOption const *pFindOpt) const
|
generic_string FindReplaceDlg::getScopeInfoForStatusBar(FindOption const *pFindOpt) const
|
||||||
|
@ -4448,7 +4501,7 @@ void FindReplaceDlg::drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
||||||
|
|
||||||
::DrawText(lpDrawItemStruct->hDC, ptStr, lstrlen(ptStr), &rect, DT_SINGLELINE | DT_VCENTER | DT_LEFT);
|
::DrawText(lpDrawItemStruct->hDC, ptStr, lstrlen(ptStr), &rect, DT_SINGLELINE | DT_VCENTER | DT_LEFT);
|
||||||
|
|
||||||
if (_statusbarTooltipMsg.length() == 0) return;
|
if (_statusbarTooltipMsg.empty()) return;
|
||||||
|
|
||||||
SIZE size{};
|
SIZE size{};
|
||||||
::GetTextExtentPoint32(lpDrawItemStruct->hDC, ptStr, lstrlen(ptStr), &size);
|
::GetTextExtentPoint32(lpDrawItemStruct->hDC, ptStr, lstrlen(ptStr), &size);
|
||||||
|
|
|
@ -386,7 +386,7 @@ public :
|
||||||
|
|
||||||
void execSavedCommand(int cmd, uptr_t intValue, const generic_string& stringValue);
|
void execSavedCommand(int cmd, uptr_t intValue, const generic_string& stringValue);
|
||||||
void clearMarks(const FindOption& opt);
|
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);
|
void setStatusbarMessageWithRegExprErr(ScintillaEditView* pEditView);
|
||||||
generic_string getScopeInfoForStatusBar(FindOption const *pFindOpt) const;
|
generic_string getScopeInfoForStatusBar(FindOption const *pFindOpt) const;
|
||||||
Finder * createFinder();
|
Finder * createFinder();
|
||||||
|
|
Loading…
Reference in New Issue