diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index a0103901..0983eea9 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1766,6 +1766,33 @@ bool Notepad_plus::findInOpenedFiles() 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) { Printer printer; @@ -7087,6 +7114,12 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } + case WM_FINDALL_INCURRENTDOC : + { + findInCurrentFile(); + return TRUE; + } + case WM_FINDINFILES : { return findInFiles(); diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 6daa10e4..806c80a1 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -724,6 +724,7 @@ private: void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText); bool replaceAllFiles(); bool findInOpenedFiles(); + bool findInCurrentFile(); bool matchInList(const TCHAR *fileName, const vector & patterns); void getMatchedFileNames(const TCHAR *dir, const vector & patterns, vector & fileNames, bool isRecursive, bool isInHiddenDir); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 367c44a1..c20ae725 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -577,9 +577,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP _findInFilesClosePos.left = p.x; _findInFilesClosePos.top = p.y; - p = getLeftTopPoint(::GetDlgItem(_hSelf, IDC_REPLACE_OPENEDFILES)); + p = getLeftTopPoint(::GetDlgItem(_hSelf, IDCANCEL)); _findClosePos.left = p.x; _findClosePos.top = p.y + 10; + return TRUE; } @@ -695,6 +696,13 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP } return TRUE; + case IDC_FINDALL_CURRENTFILE : + { + updateCombo(IDFINDWHAT); + findAllIn(CURRENT_DOC); + } + return TRUE; + case IDD_FINDINFILES_FIND_BUTTON : { const int filterSize = 256; @@ -1492,7 +1500,17 @@ void FindReplaceDlg::findAllIn(InWhat op) ::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); if (_findAllResult) @@ -1532,7 +1550,7 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable) ::ShowWindow(::GetDlgItem(_hSelf, IDC_STYLEFOUND_CHECK),!hideOrShow); ::ShowWindow(::GetDlgItem(_hSelf, IDC_PURGE_CHECK),!hideOrShow); ::ShowWindow(::GetDlgItem(_hSelf, IDC_CLEAR_ALL),!hideOrShow); -//::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDINFILES),!hideOrShow); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_FINDALL_CURRENTFILE),!hideOrShow); gotoCorrectTab(); @@ -1551,6 +1569,7 @@ void FindReplaceDlg::enableFindInFilesControls(bool isEnable) ::ShowWindow(::GetDlgItem(_hSelf, IDWRAP), 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_CURRENTFILE), 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); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index b7522e49..ad3770bd 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -36,7 +36,7 @@ enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG}; //#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 { FoundInfo(int start, int end, const TCHAR *fullPath) diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc index 91c5ab0f..7d3e21d6 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc @@ -60,6 +60,7 @@ BEGIN PUSHBUTTON "Find Next",IDOK,217,20,90,14,WS_GROUP 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 current document",IDC_FINDALL_CURRENTFILE,217,80,90,21,BS_MULTILINE PUSHBUTTON "&Replace",IDREPLACE,217,38,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 diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h index 0e0f83c3..6c93f6a9 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h @@ -44,6 +44,7 @@ //#define IDC_FINDINFILES 1637 #define IDC_FINDINFILES_LAUNCH 1638 #define IDC_GETCURRENTDOCTYPE 1639 +#define IDC_FINDALL_CURRENTFILE 1641 //#define IDSWITCH 1640 #define IDD_FINDINFILES_DLG 1650 diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 25763f8f..588ffec1 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -62,6 +62,7 @@ typedef void * SCINTILLA_PTR; #define WM_DOOPEN (SCINTILLA_USER + 8) #define WM_FINDINFILES (SCINTILLA_USER + 9) #define WM_REPLACEINFILES (SCINTILLA_USER + 10) +#define WM_FINDALL_INCURRENTDOC (SCINTILLA_USER + 11) const int NB_FOLDER_STATE = 7;