From e96e419f7475509f0f69105bd3dcb171141f0112 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 19 Jan 2010 21:49:36 +0000 Subject: [PATCH] [NEW] (Author : Darko Martinovic) Add "set find text and find next" feature. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@599 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 24 +++++++++++++++++++ PowerEditor/src/Notepad_plus.rc | 2 ++ PowerEditor/src/Parameters.cpp | 6 +++-- .../src/ScitillaComponent/FindReplaceDlg.cpp | 5 ++-- .../src/ScitillaComponent/FindReplaceDlg.h | 2 +- PowerEditor/src/menuCmdID.h | 3 +++ 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 86e64fff..4aa66861 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3775,6 +3775,28 @@ void Notepad_plus::command(int id) } break; + case IDM_SEARCH_SETANDFINDNEXT : + case IDM_SEARCH_SETANDFINDPREV : + { + bool isFirstTime = !_findReplaceDlg.isCreated(); + if (isFirstTime) + _findReplaceDlg.doDialog(FIND_DLG, _isRTL, false); + + const int strSize = FINDREPLACE_MAXLENGTH; + TCHAR str[strSize]; + _pEditView->getGenericSelectedText(str, strSize); + _findReplaceDlg.setSearchText(str); + setFindReplaceFolderFilter(NULL, NULL); + if (isFirstTime) + changeFindReplaceDlgLang(); + + FindOption op = _findReplaceDlg.getCurrentOptions(); + op._whichDirection = (id == IDM_SEARCH_SETANDFINDNEXT?DIR_DOWN:DIR_UP); + + _findReplaceDlg.processFindNext(str, &op); + break; + } + case IDM_SEARCH_GOTONEXTFOUND: { _findReplaceDlg.gotoNextFoundResult(); @@ -5377,6 +5399,8 @@ void Notepad_plus::command(int id) case IDM_EDIT_DELETE: case IDM_SEARCH_FINDNEXT : case IDM_SEARCH_FINDPREV : + case IDM_SEARCH_SETANDFINDNEXT : + case IDM_SEARCH_SETANDFINDPREV : case IDM_SEARCH_GOTOMATCHINGBRACE : case IDM_SEARCH_TOGGLE_BOOKMARK : case IDM_SEARCH_NEXT_BOOKMARK: diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index fc51fac2..2d96c3d4 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -267,6 +267,8 @@ BEGIN MENUITEM "Find in Files...", IDM_SEARCH_FINDINFILES MENUITEM "Find &Next", IDM_SEARCH_FINDNEXT MENUITEM "Find &Previous", IDM_SEARCH_FINDPREV + MENUITEM "Select and Find Next", IDM_SEARCH_SETANDFINDNEXT + MENUITEM "Select and Find Previous", IDM_SEARCH_SETANDFINDPREV MENUITEM "Find (Volatile) Next", IDM_SEARCH_VOLATILE_FINDNEXT MENUITEM "Find (Volatile) Previous", IDM_SEARCH_VOLATILE_FINDPREV MENUITEM "&Replace...", IDM_SEARCH_REPLACE diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 9c8975de..5ac08f82 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -103,8 +103,10 @@ WinMenuKeyDefinition winKeyDefs[] = { {VK_F, IDM_SEARCH_FINDINFILES, true, false, true, NULL}, {VK_F3, IDM_SEARCH_FINDNEXT, false, false, false, NULL}, {VK_F3, IDM_SEARCH_FINDPREV, false, false, true, NULL}, - {VK_F3, IDM_SEARCH_VOLATILE_FINDNEXT, true, false, false, NULL}, - {VK_F3, IDM_SEARCH_VOLATILE_FINDPREV, true, false, true, NULL}, + {VK_F3, IDM_SEARCH_VOLATILE_FINDNEXT, true, true, false, NULL}, + {VK_F3, IDM_SEARCH_VOLATILE_FINDPREV, true, true, true, NULL}, + {VK_F3, IDM_SEARCH_SETANDFINDNEXT, true, false, false, NULL}, + {VK_F3, IDM_SEARCH_SETANDFINDPREV, true, false, true, NULL}, {VK_F4, IDM_SEARCH_GOTONEXTFOUND, false, false, false, NULL}, {VK_F4, IDM_SEARCH_GOTOPREVFOUND, false, false, true, NULL}, {VK_F7, IDM_FOCUS_ON_FOUND_RESULTS, false, false, false, NULL}, diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 22caedd8..bd2052e3 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -1828,7 +1828,7 @@ void FindReplaceDlg::initOptionsFromDlg() ::EnableWindow(::GetDlgItem(_hSelf, IDCMARKALL), (_doMarkLine || _doStyleFoundToken)); } -void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL) +void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow) { if (!isCreated()) { @@ -1842,7 +1842,8 @@ void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL) enableReplaceFunc(whichType == REPLACE_DLG); ::SetFocus(::GetDlgItem(_hSelf, IDFINDWHAT)); - display(); + //display(); + display(toShow); } LRESULT FAR PASCAL FindReplaceDlg::finderProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index 2bcf6452..d0eff957 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -175,7 +175,7 @@ public : void initOptionsFromDlg(); - void doDialog(DIALOG_TYPE whichType, bool isRTL = false); + void doDialog(DIALOG_TYPE whichType, bool isRTL = false, bool toShow = true); bool processFindNext(const TCHAR *txt2find, FindOption *options = NULL, FindStatus *oFindStatus = NULL); bool processReplace(const TCHAR *txt2find, const TCHAR *txt2replace, FindOption *options = NULL); diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 80974003..499844af 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -150,6 +150,9 @@ #define IDM_FOCUS_ON_FOUND_RESULTS (IDM_SEARCH + 45) #define IDM_SEARCH_GOTONEXTFOUND (IDM_SEARCH + 46) #define IDM_SEARCH_GOTOPREVFOUND (IDM_SEARCH + 47) + + #define IDM_SEARCH_SETANDFINDNEXT (IDM_SEARCH + 48) + #define IDM_SEARCH_SETANDFINDPREV (IDM_SEARCH + 49) #define IDM_VIEW (IDM + 4000)