[ENHANCEMENT] Add "End Reached" and "Top Reached" status in find/replace dialog StatusBar.

Make "Error", "End Reached" and "Top Reached" status visible (flash main window) if find/replace dialog is hidden.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1047 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2013-05-20 21:56:30 +00:00
parent b0f47da58b
commit 71234725a1
2 changed files with 43 additions and 15 deletions

View File

@ -510,8 +510,12 @@ void Notepad_plus::command(int id)
FindOption op = _findReplaceDlg.getCurrentOptions(); FindOption op = _findReplaceDlg.getCurrentOptions();
op._whichDirection = (id == IDM_SEARCH_FINDNEXT?DIR_DOWN:DIR_UP); op._whichDirection = (id == IDM_SEARCH_FINDNEXT?DIR_DOWN:DIR_UP);
generic_string s = _findReplaceDlg.getText2search(); generic_string s = _findReplaceDlg.getText2search();
FindStatus status = FSNoMessage;
_findReplaceDlg.processFindNext(s.c_str(), &op); _findReplaceDlg.processFindNext(s.c_str(), &op, &status);
if (status == FSEndReached)
_findReplaceDlg.setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the top. The end of document has been reached."), FSEndReached);
else if (status == FSTopReached)
_findReplaceDlg.setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the bottom. The begin of document has been reached."), FSTopReached);
break; break;
} }
break; break;
@ -535,7 +539,12 @@ void Notepad_plus::command(int id)
FindOption op = _findReplaceDlg.getCurrentOptions(); FindOption op = _findReplaceDlg.getCurrentOptions();
op._whichDirection = (id == IDM_SEARCH_SETANDFINDNEXT?DIR_DOWN:DIR_UP); op._whichDirection = (id == IDM_SEARCH_SETANDFINDNEXT?DIR_DOWN:DIR_UP);
_findReplaceDlg.processFindNext(str, &op); FindStatus status = FSNoMessage;
_findReplaceDlg.processFindNext(str, &op, &status);
if (status == FSEndReached)
_findReplaceDlg.setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the top. The end of document has been reached."), FSEndReached);
else if (status == FSTopReached)
_findReplaceDlg.setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the bottom. The begin of document has been reached."), FSTopReached);
break; break;
} }
@ -568,7 +577,14 @@ void Notepad_plus::command(int id)
FindOption op; FindOption op;
op._isWholeWord = false; op._isWholeWord = false;
op._whichDirection = (id == IDM_SEARCH_VOLATILE_FINDNEXT?DIR_DOWN:DIR_UP); op._whichDirection = (id == IDM_SEARCH_VOLATILE_FINDNEXT?DIR_DOWN:DIR_UP);
_findReplaceDlg.processFindNext(text2Find, &op);
FindStatus status = FSNoMessage;
_findReplaceDlg.processFindNext(text2Find, &op, &status);
if (status == FSEndReached)
_findReplaceDlg.setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the top. The end of document has been reached."), FSEndReached);
else if (status == FSTopReached)
_findReplaceDlg.setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the bottom. The begin of document has been reached."), FSTopReached);
break; break;
} }

View File

@ -694,10 +694,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
FindStatus findStatus = FSFound; FindStatus findStatus = FSFound;
processFindNext(_options._str2Search.c_str(), _env, &findStatus); processFindNext(_options._str2Search.c_str(), _env, &findStatus);
if(findStatus == FSEndReached) if (findStatus == FSEndReached)
setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the top. The end of document has been reached."), FSMessage); setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the top. The end of document has been reached."), FSEndReached);
else if(findStatus == FSTopReached) else if (findStatus == FSTopReached)
setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the bottom. The begin of document has been reached."), FSMessage); setStatusbarMessage(TEXT("Find: Found the 1st occurrence from the bottom. The begin of document has been reached."), FSTopReached);
nppParamInst->_isFindReplacing = false; nppParamInst->_isFindReplacing = false;
} }
@ -1373,13 +1373,11 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl
if (status == FSEndReached) if (status == FSEndReached)
{ {
setStatusbarMessage(TEXT("Replace: Replaced the 1st occurrence from the top. The end of document has been reached."), FSMessage); setStatusbarMessage(TEXT("Replace: Replaced the 1st occurrence from the top. The end of document has been reached."), FSEndReached);
//displayMsgDone = true;
} }
else if (status == FSTopReached) else if (status == FSTopReached)
{ {
setStatusbarMessage(TEXT("Replace: Replaced the 1st occurrence from the bottom. The begin of document has been reached."), FSMessage); setStatusbarMessage(TEXT("Replace: Replaced the 1st occurrence from the bottom. The begin of document has been reached."), FSTopReached);
//displayMsgDone = true;
} }
else else
{ {
@ -1973,10 +1971,20 @@ void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus
if (staus == FSNotFound) if (staus == FSNotFound)
{ {
::MessageBeep(0xFFFFFFFF); ::MessageBeep(0xFFFFFFFF);
FlashWindow(_hSelf, TRUE); HWND hwnd2Flash = isVisible()?_hSelf:GetParent(_hSelf);
FlashWindow(hwnd2Flash, TRUE);
} }
else if (staus == FSTopReached || staus == FSEndReached)
{
if (!isVisible())
FlashWindow(::GetParent(_hSelf), TRUE);
}
if (isVisible())
{
_statusbarFindStatus = staus; _statusbarFindStatus = staus;
_statusBar.setOwnerDrawText(msg.c_str()); _statusBar.setOwnerDrawText(msg.c_str());
}
} }
void FindReplaceDlg::execSavedCommand(int cmd, int intValue, generic_string stringValue) void FindReplaceDlg::execSavedCommand(int cmd, int intValue, generic_string stringValue)
@ -2311,6 +2319,10 @@ void FindReplaceDlg::drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{ {
fgColor = RGB(0, 0, 0xFF); // blue fgColor = RGB(0, 0, 0xFF); // blue
} }
else if (_statusbarFindStatus == FSTopReached || _statusbarFindStatus == FSEndReached)
{
fgColor = RGB(0, 166, 0); // green
}
else if (_statusbarFindStatus == FSNoMessage) else if (_statusbarFindStatus == FSNoMessage)
{ {
ptStr = TEXT(""); ptStr = TEXT("");