From 5ba7f99590b6ade8a5fb13edc7cb9f9f0981e18f Mon Sep 17 00:00:00 2001
From: Scott Sumner <30118311+sasumner@users.noreply.github.com>
Date: Thu, 30 Jul 2020 08:35:46 -0400
Subject: [PATCH] Add search scope to Find window status bar output
Close #8632, close #8639
---
PowerEditor/installer/nativeLang/english.xml | 4 ++
.../src/ScitillaComponent/FindReplaceDlg.cpp | 64 +++++++++++++++----
.../src/ScitillaComponent/FindReplaceDlg.h | 1 +
3 files changed, 56 insertions(+), 13 deletions(-)
diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml
index da34f4cec..eb1853674 100644
--- a/PowerEditor/installer/nativeLang/english.xml
+++ b/PowerEditor/installer/nativeLang/english.xml
@@ -1238,6 +1238,10 @@ Find in all files except exe, obj && log:
+
+
+
+
diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp
index bc5be57e1..eaf25c719 100644
--- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp
+++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp
@@ -1307,13 +1307,15 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{
if (nbReplaced == 1)
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-replaceall-1-replaced", TEXT("Replace All: 1 occurrence was replaced."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-replaceall-1-replaced", TEXT("Replace All: 1 occurrence was replaced"));
}
else
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-replaceall-nb-replaced", TEXT("Replace All: $INT_REPLACE$ occurrences were replaced."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-replaceall-nb-replaced", TEXT("Replace All: $INT_REPLACE$ occurrences were replaced"));
result = stringReplace(result, TEXT("$INT_REPLACE$"), std::to_wstring(nbReplaced));
- }
+ }
+ result += TEXT(" ");
+ result += getScopeInfoForStatusBar(&_options);
}
setStatusbarMessage(result, FSMessage);
getFocus();
@@ -1342,13 +1344,15 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{
if (nbCounted == 1)
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-count-1-match", TEXT("Count: 1 match."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-count-1-match", TEXT("Count: 1 match"));
}
else
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-count-nb-matches", TEXT("Count: $INT_REPLACE$ matches."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-count-nb-matches", TEXT("Count: $INT_REPLACE$ matches"));
result = stringReplace(result, TEXT("$INT_REPLACE$"), std::to_wstring(nbCounted));
}
+ result += TEXT(" ");
+ result += getScopeInfoForStatusBar(&_options);
}
if (isMacroRecording) saveInMacro(wParam, FR_OP_FIND);
@@ -1382,13 +1386,15 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{
if (nbMarked == 1)
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-mark-1-match", TEXT("Mark: 1 match."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-mark-1-match", TEXT("Mark: 1 match"));
}
else
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-mark-nb-matches", TEXT("Mark: $INT_REPLACE$ matches."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-mark-nb-matches", TEXT("Mark: $INT_REPLACE$ matches"));
result = stringReplace(result, TEXT("$INT_REPLACE$"), std::to_wstring(nbMarked));
}
+ result += TEXT(" ");
+ result += getScopeInfoForStatusBar(&_options);
}
setStatusbarMessage(result, FSMessage);
getFocus();
@@ -2703,6 +2709,32 @@ void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus
}
}
+generic_string FindReplaceDlg::getScopeInfoForStatusBar(FindOption const *pFindOpt) const
+{
+ generic_string scope;
+
+ NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
+
+ if (pFindOpt->_isInSelection)
+ {
+ scope += pNativeSpeaker->getLocalizedStrFromID("find-status-scope-selection", TEXT("in selected text"));
+ }
+ else if (pFindOpt->_isWrapAround)
+ {
+ scope += pNativeSpeaker->getLocalizedStrFromID("find-status-scope-all", TEXT("in entire file"));
+ }
+ else if (pFindOpt->_whichDirection == DIR_UP)
+ {
+ scope += pNativeSpeaker->getLocalizedStrFromID("find-status-scope-backward", TEXT("from start-of-file to caret"));
+ }
+ else
+ {
+ scope += pNativeSpeaker->getLocalizedStrFromID("find-status-scope-forward", TEXT("from caret to end-of-file"));
+ }
+
+ return scope;
+}
+
void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_string& stringValue)
{
try
@@ -2852,13 +2884,15 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
{
if (nbReplaced == 1)
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-replaceall-1-replaced", TEXT("Replace All: 1 occurrence was replaced."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-replaceall-1-replaced", TEXT("Replace All: 1 occurrence was replaced"));
}
else
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-replaceall-nb-replaced", TEXT("Replace All: $INT_REPLACE$ occurrences were replaced."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-replaceall-nb-replaced", TEXT("Replace All: $INT_REPLACE$ occurrences were replaced"));
result = stringReplace(result, TEXT("$INT_REPLACE$"), std::to_wstring(nbReplaced));
}
+ result += TEXT(" ");
+ result += getScopeInfoForStatusBar(_env);
}
setStatusbarMessage(result, FSMessage);
@@ -2878,13 +2912,15 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
{
if (nbCounted == 1)
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-count-1-match", TEXT("Count: 1 match."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-count-1-match", TEXT("Count: 1 match"));
}
else
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-count-nb-matches", TEXT("Count: $INT_REPLACE$ matches."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-count-nb-matches", TEXT("Count: $INT_REPLACE$ matches"));
result = stringReplace(result, TEXT("$INT_REPLACE$"), std::to_wstring(nbCounted));
}
+ result += TEXT(" ");
+ result += getScopeInfoForStatusBar(_env);
}
setStatusbarMessage(result, FSMessage);
break;
@@ -2906,13 +2942,15 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
{
if (nbMarked == 1)
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-mark-1-match", TEXT("Mark: 1 match."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-mark-1-match", TEXT("Mark: 1 match"));
}
else
{
- result = pNativeSpeaker->getLocalizedStrFromID("find-status-mark-nb-matches", TEXT("Mark: $INT_REPLACE$ matches."));
+ result = pNativeSpeaker->getLocalizedStrFromID("find-status-mark-nb-matches", TEXT("Mark: $INT_REPLACE$ matches"));
result = stringReplace(result, TEXT("$INT_REPLACE$"), std::to_wstring(nbMarked));
}
+ result += TEXT(" ");
+ result += getScopeInfoForStatusBar(_env);
}
setStatusbarMessage(result, FSMessage);
diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h
index e7f6c3ecf..e1b9e4298 100644
--- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h
+++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h
@@ -334,6 +334,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);
+ generic_string getScopeInfoForStatusBar(FindOption const *pFindOpt) const;
Finder * createFinder();
bool removeFinder(Finder *finder2remove);