[NEW_FEATURE] Add "Find all in current file" feature.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@423 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
a7b0ebc94b
commit
66a072889b
@ -1766,6 +1766,33 @@ bool Notepad_plus::findInOpenedFiles()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Notepad_plus::findInCurrentFile()
|
||||||
|
{
|
||||||
|
int nbTotal = 0;
|
||||||
|
Buffer * pBuf = _pEditView->getCurrentBuffer();
|
||||||
|
ScintillaEditView *pOldView = _pEditView;
|
||||||
|
_pEditView = &_invisibleEditView;
|
||||||
|
Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER);
|
||||||
|
|
||||||
|
const bool isEntireDoc = true;
|
||||||
|
|
||||||
|
_findReplaceDlg.beginNewFilesSearch();
|
||||||
|
|
||||||
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||||
|
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? 0 : SC_CP_UTF8);
|
||||||
|
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, NULL, NULL, isEntireDoc, pBuf->getFullPathName());
|
||||||
|
|
||||||
|
_findReplaceDlg.finishFilesSearch(nbTotal);
|
||||||
|
|
||||||
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
|
||||||
|
_pEditView = pOldView;
|
||||||
|
|
||||||
|
_findReplaceDlg.putFindResult(nbTotal);
|
||||||
|
if (nbTotal) _findReplaceDlg.display(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Notepad_plus::filePrint(bool showDialog)
|
void Notepad_plus::filePrint(bool showDialog)
|
||||||
{
|
{
|
||||||
Printer printer;
|
Printer printer;
|
||||||
@ -7087,6 +7114,12 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_FINDALL_INCURRENTDOC :
|
||||||
|
{
|
||||||
|
findInCurrentFile();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_FINDINFILES :
|
case WM_FINDINFILES :
|
||||||
{
|
{
|
||||||
return findInFiles();
|
return findInFiles();
|
||||||
|
@ -724,6 +724,7 @@ private:
|
|||||||
void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText);
|
void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText);
|
||||||
bool replaceAllFiles();
|
bool replaceAllFiles();
|
||||||
bool findInOpenedFiles();
|
bool findInOpenedFiles();
|
||||||
|
bool findInCurrentFile();
|
||||||
|
|
||||||
bool matchInList(const TCHAR *fileName, const vector<generic_string> & patterns);
|
bool matchInList(const TCHAR *fileName, const vector<generic_string> & patterns);
|
||||||
void getMatchedFileNames(const TCHAR *dir, const vector<generic_string> & patterns, vector<generic_string> & fileNames, bool isRecursive, bool isInHiddenDir);
|
void getMatchedFileNames(const TCHAR *dir, const vector<generic_string> & patterns, vector<generic_string> & fileNames, bool isRecursive, bool isInHiddenDir);
|
||||||
|
@ -577,9 +577,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
_findInFilesClosePos.left = p.x;
|
_findInFilesClosePos.left = p.x;
|
||||||
_findInFilesClosePos.top = p.y;
|
_findInFilesClosePos.top = p.y;
|
||||||
|
|
||||||
p = getLeftTopPoint(::GetDlgItem(_hSelf, IDC_REPLACE_OPENEDFILES));
|
p = getLeftTopPoint(::GetDlgItem(_hSelf, IDCANCEL));
|
||||||
_findClosePos.left = p.x;
|
_findClosePos.left = p.x;
|
||||||
_findClosePos.top = p.y + 10;
|
_findClosePos.top = p.y + 10;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,6 +696,13 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
case IDC_FINDALL_CURRENTFILE :
|
||||||
|
{
|
||||||
|
updateCombo(IDFINDWHAT);
|
||||||
|
findAllIn(CURRENT_DOC);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
case IDD_FINDINFILES_FIND_BUTTON :
|
case IDD_FINDINFILES_FIND_BUTTON :
|
||||||
{
|
{
|
||||||
const int filterSize = 256;
|
const int filterSize = 256;
|
||||||
@ -1492,7 +1500,17 @@ void FindReplaceDlg::findAllIn(InWhat op)
|
|||||||
|
|
||||||
::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0);
|
::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0);
|
||||||
|
|
||||||
if (::SendMessage(_hParent, (op==ALL_OPEN_DOCS)?WM_FINDALL_INOPENEDDOC:WM_FINDINFILES, 0, 0))
|
int cmdid = 0;
|
||||||
|
if (op == ALL_OPEN_DOCS)
|
||||||
|
cmdid = WM_FINDALL_INOPENEDDOC;
|
||||||
|
else if (op == FILES_IN_DIR)
|
||||||
|
cmdid = WM_FINDINFILES;
|
||||||
|
else if (op == CURRENT_DOC)
|
||||||
|
cmdid = WM_FINDALL_INCURRENTDOC;
|
||||||
|
|
||||||
|
if (!cmdid) return;
|
||||||
|
|
||||||
|
if (::SendMessage(_hParent, cmdid, 0, 0))
|
||||||
{
|
{
|
||||||
wsprintf(_findAllResultStr, TEXT("%d hits"), _findAllResult);
|
wsprintf(_findAllResultStr, TEXT("%d hits"), _findAllResult);
|
||||||
if (_findAllResult)
|
if (_findAllResult)
|
||||||
@ -1532,7 +1550,7 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable)
|
|||||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_STYLEFOUND_CHECK),!hideOrShow);
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_STYLEFOUND_CHECK),!hideOrShow);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_PURGE_CHECK),!hideOrShow);
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_PURGE_CHECK),!hideOrShow);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_CLEAR_ALL),!hideOrShow);
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_CLEAR_ALL),!hideOrShow);
|
||||||
//::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDINFILES),!hideOrShow);
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_CURRENTFILE),!hideOrShow);
|
||||||
|
|
||||||
gotoCorrectTab();
|
gotoCorrectTab();
|
||||||
|
|
||||||
@ -1551,6 +1569,7 @@ void FindReplaceDlg::enableFindInFilesControls(bool isEnable)
|
|||||||
::ShowWindow(::GetDlgItem(_hSelf, IDWRAP), isEnable?SW_HIDE:SW_SHOW);
|
::ShowWindow(::GetDlgItem(_hSelf, IDWRAP), isEnable?SW_HIDE:SW_SHOW);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDCCOUNTALL), isEnable?SW_HIDE:SW_SHOW);
|
::ShowWindow(::GetDlgItem(_hSelf, IDCCOUNTALL), isEnable?SW_HIDE:SW_SHOW);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_OPENEDFILES), isEnable?SW_HIDE:SW_SHOW);
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_OPENEDFILES), isEnable?SW_HIDE:SW_SHOW);
|
||||||
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_CURRENTFILE), isEnable?SW_HIDE:SW_SHOW);
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDOK), isEnable?SW_HIDE:SW_SHOW);
|
::ShowWindow(::GetDlgItem(_hSelf, IDOK), isEnable?SW_HIDE:SW_SHOW);
|
||||||
|
|
||||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_STATIC), isEnable?SW_HIDE:SW_SHOW);
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_STATIC), isEnable?SW_HIDE:SW_SHOW);
|
||||||
|
@ -36,7 +36,7 @@ enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG};
|
|||||||
|
|
||||||
//#define FIND_REPLACE_STR_MAX 256
|
//#define FIND_REPLACE_STR_MAX 256
|
||||||
|
|
||||||
enum InWhat{ALL_OPEN_DOCS, FILES_IN_DIR};
|
enum InWhat{ALL_OPEN_DOCS, FILES_IN_DIR, CURRENT_DOC};
|
||||||
|
|
||||||
struct FoundInfo {
|
struct FoundInfo {
|
||||||
FoundInfo(int start, int end, const TCHAR *fullPath)
|
FoundInfo(int start, int end, const TCHAR *fullPath)
|
||||||
|
@ -60,6 +60,7 @@ BEGIN
|
|||||||
PUSHBUTTON "Find Next",IDOK,217,20,90,14,WS_GROUP
|
PUSHBUTTON "Find Next",IDOK,217,20,90,14,WS_GROUP
|
||||||
PUSHBUTTON "Coun&t",IDCCOUNTALL,217,38,90,14
|
PUSHBUTTON "Coun&t",IDCCOUNTALL,217,38,90,14
|
||||||
PUSHBUTTON "Find all in all &opened documents",IDC_FINDALL_OPENEDFILES,217,56,90,21,BS_MULTILINE
|
PUSHBUTTON "Find all in all &opened documents",IDC_FINDALL_OPENEDFILES,217,56,90,21,BS_MULTILINE
|
||||||
|
PUSHBUTTON "Find all in current document",IDC_FINDALL_CURRENTFILE,217,80,90,21,BS_MULTILINE
|
||||||
PUSHBUTTON "&Replace",IDREPLACE,217,38,90,14
|
PUSHBUTTON "&Replace",IDREPLACE,217,38,90,14
|
||||||
PUSHBUTTON "Replace &All",IDREPLACEALL,217,56,90,14
|
PUSHBUTTON "Replace &All",IDREPLACEALL,217,56,90,14
|
||||||
PUSHBUTTON "Replace all in all &opened documents",IDC_REPLACE_OPENEDFILES,217,74,90,21,BS_MULTILINE
|
PUSHBUTTON "Replace all in all &opened documents",IDC_REPLACE_OPENEDFILES,217,74,90,21,BS_MULTILINE
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
//#define IDC_FINDINFILES 1637
|
//#define IDC_FINDINFILES 1637
|
||||||
#define IDC_FINDINFILES_LAUNCH 1638
|
#define IDC_FINDINFILES_LAUNCH 1638
|
||||||
#define IDC_GETCURRENTDOCTYPE 1639
|
#define IDC_GETCURRENTDOCTYPE 1639
|
||||||
|
#define IDC_FINDALL_CURRENTFILE 1641
|
||||||
//#define IDSWITCH 1640
|
//#define IDSWITCH 1640
|
||||||
|
|
||||||
#define IDD_FINDINFILES_DLG 1650
|
#define IDD_FINDINFILES_DLG 1650
|
||||||
|
@ -62,6 +62,7 @@ typedef void * SCINTILLA_PTR;
|
|||||||
#define WM_DOOPEN (SCINTILLA_USER + 8)
|
#define WM_DOOPEN (SCINTILLA_USER + 8)
|
||||||
#define WM_FINDINFILES (SCINTILLA_USER + 9)
|
#define WM_FINDINFILES (SCINTILLA_USER + 9)
|
||||||
#define WM_REPLACEINFILES (SCINTILLA_USER + 10)
|
#define WM_REPLACEINFILES (SCINTILLA_USER + 10)
|
||||||
|
#define WM_FINDALL_INCURRENTDOC (SCINTILLA_USER + 11)
|
||||||
|
|
||||||
const int NB_FOLDER_STATE = 7;
|
const int NB_FOLDER_STATE = 7;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user