[NEW_FEATURE] Refine the "HighLight all" feature in incremental search dialog.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@190 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
1eb46eaca3
commit
36706f13a4
@ -7390,12 +7390,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
return _toReduceTabBar?TRUE:FALSE;
|
return _toReduceTabBar?TRUE:FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NPPM_INTERNAL_MARKALL :
|
|
||||||
{
|
|
||||||
markSelectedTextInc(bool(wParam));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ADD: success->hwnd; failure->NULL
|
// ADD: success->hwnd; failure->NULL
|
||||||
// REMOVE: success->NULL; failure->hwnd
|
// REMOVE: success->NULL; failure->hwnd
|
||||||
case NPPM_MODELESSDIALOG :
|
case NPPM_MODELESSDIALOG :
|
||||||
@ -8304,33 +8298,3 @@ void Notepad_plus::markSelectedText()
|
|||||||
_findReplaceDlg.markAll2(text2Find);
|
_findReplaceDlg.markAll2(text2Find);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notepad_plus::markSelectedTextInc(bool enable)
|
|
||||||
{
|
|
||||||
if (!enable)
|
|
||||||
{//printStr("out");
|
|
||||||
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_INC);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get selection
|
|
||||||
CharacterRange range = _pEditView->getSelection();
|
|
||||||
//Dont mark if the selection has not changed.
|
|
||||||
if (range.cpMin == _prevSelectedRange.cpMin && range.cpMax == _prevSelectedRange.cpMax)
|
|
||||||
{
|
|
||||||
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_INC);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Clear marks
|
|
||||||
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_INC);
|
|
||||||
|
|
||||||
//If nothing selected, dont mark anything
|
|
||||||
if (range.cpMin == range.cpMax)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
char text2Find[MAX_PATH];
|
|
||||||
_pEditView->getSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false)
|
|
||||||
_findReplaceDlg.markAllInc(text2Find);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -959,17 +959,20 @@ int FindReplaceDlg::markAll(const char *txt2find)
|
|||||||
|
|
||||||
int FindReplaceDlg::markAll2(const char *txt2find)
|
int FindReplaceDlg::markAll2(const char *txt2find)
|
||||||
{
|
{
|
||||||
int nbFound = processAll(ProcessMarkAll_2, txt2find, NULL, true, NULL);
|
FindOption opt;
|
||||||
|
opt._isMatchCase = false;
|
||||||
|
opt._isWholeWord = true;
|
||||||
|
int nbFound = processAll(ProcessMarkAll_2, txt2find, NULL, true, NULL, &opt);
|
||||||
return nbFound;
|
return nbFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FindReplaceDlg::markAllInc(const char *txt2find)
|
int FindReplaceDlg::markAllInc(const char *txt2find, FindOption *opt)
|
||||||
{
|
{
|
||||||
int nbFound = processAll(ProcessMarkAll_IncSearch, txt2find, NULL, true, NULL);
|
int nbFound = processAll(ProcessMarkAll_IncSearch, txt2find, NULL, true, NULL, opt);
|
||||||
return nbFound;
|
return nbFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const char *txt2replace, bool isEntire, const char *fileName)
|
int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const char *txt2replace, bool isEntire, const char *fileName, FindOption *opt)
|
||||||
{
|
{
|
||||||
int nbReplaced = 0;
|
int nbReplaced = 0;
|
||||||
|
|
||||||
@ -982,7 +985,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
|
|||||||
if (!fileName)
|
if (!fileName)
|
||||||
fileName = "";
|
fileName = "";
|
||||||
|
|
||||||
FindOption *pOptions = &_options;
|
FindOption *pOptions = opt?opt:&_options;
|
||||||
bool isUnicode = (*_ppEditView)->getCurrentBuffer().getUnicodeMode() != uni8Bit;
|
bool isUnicode = (*_ppEditView)->getCurrentBuffer().getUnicodeMode() != uni8Bit;
|
||||||
|
|
||||||
int stringSizeFind = 0;
|
int stringSizeFind = 0;
|
||||||
@ -1024,12 +1027,12 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
|
|||||||
|
|
||||||
bool isRegExp = pOptions->_searchType == FindRegex;
|
bool isRegExp = pOptions->_searchType == FindRegex;
|
||||||
int flags = Searching::buildSearchFlags(pOptions);
|
int flags = Searching::buildSearchFlags(pOptions);
|
||||||
|
/*
|
||||||
if (op == ProcessMarkAll_2)
|
if (op == ProcessMarkAll_2)
|
||||||
flags = SCFIND_WHOLEWORD;
|
flags = SCFIND_WHOLEWORD;
|
||||||
else if (op == ProcessMarkAll_IncSearch)
|
else if (op == ProcessMarkAll_IncSearch)
|
||||||
flags ^= SCFIND_WHOLEWORD;
|
flags ^= SCFIND_WHOLEWORD;
|
||||||
|
*/
|
||||||
CharacterRange cr = (*_ppEditView)->getSelection();
|
CharacterRange cr = (*_ppEditView)->getSelection();
|
||||||
int docLength = int((*_ppEditView)->execute(SCI_GETLENGTH));
|
int docLength = int((*_ppEditView)->execute(SCI_GETLENGTH));
|
||||||
|
|
||||||
@ -1500,9 +1503,9 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
case IDC_INCFINDMATCHCASE:
|
||||||
case IDC_INCFINDTEXT :
|
case IDC_INCFINDTEXT :
|
||||||
{
|
case IDC_INCFINDHILITEALL :
|
||||||
if (HIWORD(wParam) == EN_CHANGE)
|
|
||||||
{
|
{
|
||||||
if (_doSearchFromBegin)
|
if (_doSearchFromBegin)
|
||||||
{
|
{
|
||||||
@ -1510,28 +1513,24 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
fo._isWholeWord = false;
|
fo._isWholeWord = false;
|
||||||
fo._isIncremental = true;
|
fo._isIncremental = true;
|
||||||
fo._isMatchCase = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_INCFINDMATCHCASE, BM_GETCHECK, 0, 0));
|
fo._isMatchCase = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_INCFINDMATCHCASE, BM_GETCHECK, 0, 0));
|
||||||
bool isHiLieAll = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_INCFINDHILITEALL, BM_GETCHECK, 0, 0));
|
|
||||||
|
|
||||||
string str2Search = _pFRDlg->getTextFromCombo(::GetDlgItem(_hSelf, IDC_INCFINDTEXT), isUnicode);
|
string str2Search = _pFRDlg->getTextFromCombo(::GetDlgItem(_hSelf, IDC_INCFINDTEXT), isUnicode);
|
||||||
_pFRDlg->processFindNext(str2Search.c_str(), &fo);
|
bool isFound = _pFRDlg->processFindNext(str2Search.c_str(), &fo);
|
||||||
|
if (!isFound)
|
||||||
if (isHiLieAll)
|
|
||||||
{
|
{
|
||||||
::SendMessage(_hParent, NPPM_INTERNAL_MARKALL, TRUE, 0);
|
CharacterRange range = (*(_pFRDlg->_ppEditView))->getSelection();
|
||||||
|
(*(_pFRDlg->_ppEditView))->execute(SCI_SETSEL, -1, range.cpMin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isHiLieAll = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_INCFINDHILITEALL, BM_GETCHECK, 0, 0));
|
||||||
|
if (str2Search == "")
|
||||||
|
isHiLieAll = false;
|
||||||
|
|
||||||
|
markSelectedTextInc(isHiLieAll, &fo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_doSearchFromBegin = true;
|
_doSearchFromBegin = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case IDC_INCFINDHILITEALL :
|
|
||||||
{
|
|
||||||
bool isHiLieAll = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_INCFINDHILITEALL, BM_GETCHECK, 0, 0));
|
|
||||||
//printStr(isHiLieAll?"yes":"no");
|
|
||||||
::SendMessage(_hParent, NPPM_INTERNAL_MARKALL, (BOOL)isHiLieAll, 0);
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1561,6 +1560,25 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FindIncrementDlg::markSelectedTextInc(bool enable, FindOption *opt)
|
||||||
|
{
|
||||||
|
(*(_pFRDlg->_ppEditView))->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_INC);
|
||||||
|
|
||||||
|
if (!enable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Get selection
|
||||||
|
CharacterRange range = (*(_pFRDlg->_ppEditView))->getSelection();
|
||||||
|
|
||||||
|
//If nothing selected, dont mark anything
|
||||||
|
if (range.cpMin == range.cpMax)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char text2Find[MAX_PATH];
|
||||||
|
(*(_pFRDlg->_ppEditView))->getSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false)
|
||||||
|
_pFRDlg->markAllInc(text2Find, opt);
|
||||||
|
}
|
||||||
|
|
||||||
void FindIncrementDlg::addToRebar(ReBar * rebar) {
|
void FindIncrementDlg::addToRebar(ReBar * rebar) {
|
||||||
if(_pRebar)
|
if(_pRebar)
|
||||||
return;
|
return;
|
||||||
|
@ -237,9 +237,9 @@ public :
|
|||||||
|
|
||||||
int markAll(const char *str2find);
|
int markAll(const char *str2find);
|
||||||
int markAll2(const char *str2find);
|
int markAll2(const char *str2find);
|
||||||
int markAllInc(const char *str2find);
|
int markAllInc(const char *str2find, FindOption *opt);
|
||||||
|
|
||||||
int processAll(ProcessOperation op, const char *txt2find, const char *txt2replace, bool isEntire = false, const char *fileName = NULL);
|
int processAll(ProcessOperation op, const char *txt2find, const char *txt2replace, bool isEntire = false, const char *fileName = NULL, FindOption *opt = NULL);
|
||||||
void replaceAllInOpenedDocs();
|
void replaceAllInOpenedDocs();
|
||||||
void findAllIn(InWhat op);
|
void findAllIn(InWhat op);
|
||||||
void setSearchText(const char * txt2find, bool isUTF8 = false) {
|
void setSearchText(const char * txt2find, bool isUTF8 = false) {
|
||||||
@ -413,6 +413,7 @@ private :
|
|||||||
|
|
||||||
bool _doSearchFromBegin;
|
bool _doSearchFromBegin;
|
||||||
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
void markSelectedTextInc(bool enable, FindOption *opt = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FIND_REPLACE_DLG_H
|
#endif //FIND_REPLACE_DLG_H
|
||||||
|
@ -684,7 +684,6 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
|||||||
{
|
{
|
||||||
if (getCurrentBuffer()._unicodeMode == uni8Bit)
|
if (getCurrentBuffer()._unicodeMode == uni8Bit)
|
||||||
execute(SCI_SETCODEPAGE, _codepage);
|
execute(SCI_SETCODEPAGE, _codepage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
execute(SCI_SETSTYLEBITS, 5);
|
execute(SCI_SETSTYLEBITS, 5);
|
||||||
|
@ -284,7 +284,7 @@
|
|||||||
#define NPPM_INTERNAL_ISTABBARREDUCED (NOTEPADPLUS_USER_INTERNAL + 12)
|
#define NPPM_INTERNAL_ISTABBARREDUCED (NOTEPADPLUS_USER_INTERNAL + 12)
|
||||||
#define NPPM_INTERNAL_ISFOCUSEDTAB (NOTEPADPLUS_USER_INTERNAL + 13)
|
#define NPPM_INTERNAL_ISFOCUSEDTAB (NOTEPADPLUS_USER_INTERNAL + 13)
|
||||||
#define NPPM_INTERNAL_GETMENU (NOTEPADPLUS_USER_INTERNAL + 14)
|
#define NPPM_INTERNAL_GETMENU (NOTEPADPLUS_USER_INTERNAL + 14)
|
||||||
#define NPPM_INTERNAL_MARKALL (NOTEPADPLUS_USER_INTERNAL + 15)
|
//#define NPPM_INTERNAL_MARKALL (NOTEPADPLUS_USER_INTERNAL + 15)
|
||||||
|
|
||||||
// See Notepad_plus_msgs.h
|
// See Notepad_plus_msgs.h
|
||||||
//#define NOTEPADPLUS_USER (WM_USER + 1000)
|
//#define NOTEPADPLUS_USER (WM_USER + 1000)
|
||||||
|
Loading…
Reference in New Issue
Block a user