diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 7e270bd45a9..6a2f6a69657 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -703,6 +703,8 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM _findClosePos.left = p.x; _findClosePos.top = p.y + 10; + ::SendMessage(GetDlgItem(_hSelf, IDC_PROGRESSBAR), PBM_SETPOS, (WPARAM)0, 0); + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); generic_string tip2show = pNativeSpeaker->getLocalizedStrFromID("shift-change-direction-tip"); if (tip2show.empty()) @@ -1749,7 +1751,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl if (op == ProcessReplaceAll || op == ProcessFindAll) flags |= SCFIND_REGEXP_EMPTYMATCH_NOTAFTERMATCH; - + ::SendMessage(GetDlgItem(_hSelf, IDC_PROGRESSBAR), PBM_SETPOS, (WPARAM)0, 0); + const clock_t beginTime = clock(); if (op == ProcessMarkAll && colourStyleID == -1) //if marking, check if purging is needed { @@ -1786,6 +1789,33 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl int foundTextLen = targetEnd - targetStart; int replaceDelta = 0; + // Update progress information + if (nbProcessed % 1000 == 0) + { + double progress = 100.0*double(targetStart) / double(findReplaceInfo._endRange); + ::SendMessage(GetDlgItem(_hSelf, IDC_PROGRESSBAR), PBM_SETPOS, (WPARAM)int(progress), 0); + + double elapsedSeconds = double(clock() - beginTime) / CLOCKS_PER_SEC; + if (progress > 1.0) + { + double onePercentElapsedTime = elapsedSeconds / progress; + double remainingSeconds = onePercentElapsedTime* (100.0 - progress); + generic_string result; + + TCHAR moreInfo[64]; + if (remainingSeconds < 60.0) + wsprintf(moreInfo, TEXT("Remaining time: %d seconds"), int(remainingSeconds)); + else + { + int nRemainingMinutes = int(remainingSeconds / 60.0); + int nRemainingSeconds = int(remainingSeconds) % 60; + wsprintf(moreInfo, TEXT("Remaining time: %d minutes %d seconds"), nRemainingMinutes, nRemainingSeconds); + } + result = moreInfo; + + setStatusbarMessage(result, FSMessage); + } + } switch (op) { @@ -1967,6 +1997,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl findReplaceInfo._endRange += replaceDelta; //adjust end of range in case of replace } + ::SendMessage(GetDlgItem(_hSelf, IDC_PROGRESSBAR), PBM_SETPOS, (WPARAM)100, 0); delete [] pTextFind; delete [] pTextReplace; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index b6427d89161..78e53806003 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -171,7 +171,7 @@ protected : }; bool isLineActualSearchResult(const generic_string & s) const; - generic_string & prepareStringForClipboard(generic_string & s) const; + generic_string & prepareStringForClipboard(generic_string & s) const; static FoundInfo EmptyFoundInfo; static SearchResultMarking EmptySearchResultMarking; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc index 84159662bab..4a8022f4664 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc @@ -85,6 +85,8 @@ BEGIN CONTROL "Always",IDC_TRANSPARENT_ALWAYS_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,268,155,85,10 CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,265,166,85,10 CONTROL "&. matches newline",IDREDOTMATCHNL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,167,68,9 + CONTROL "" , IDC_PROGRESSBAR, "msctls_progress32" , PBS_SMOOTH , 5, 180, 356, 5 + END IDB_INCREMENTAL_BG BITMAP "../icons/incrementalBg.bmp" diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h index b8e11daf299..98c0fe80b5e 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h @@ -134,5 +134,6 @@ #define IDEXTENDED_FIFOLDER 1718 #define IDREGEXP_FIFOLDER 1719 #define IDREDOTMATCHNL_FIFOLDER 1720 +#define IDC_PROGRESSBAR 1722 #endif //FINDREPLACE_DLG_H