2012-04-15 16:54:38 +00:00
|
|
|
// This file is part of Notepad++ project
|
|
|
|
// Copyright (C)2003 Don HO <don.h@free.fr>
|
2009-04-24 23:34:47 +00:00
|
|
|
//
|
2012-04-15 16:54:38 +00:00
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
2009-04-24 23:34:47 +00:00
|
|
|
//
|
2012-04-15 16:54:38 +00:00
|
|
|
// Note that the GPL places important restrictions on "derived works", yet
|
|
|
|
// it does not provide a detailed definition of that term. To avoid
|
|
|
|
// misunderstandings, we consider an application to constitute a
|
|
|
|
// "derivative work" for the purpose of this license if it does any of the
|
|
|
|
// following:
|
|
|
|
// 1. Integrates source code from Notepad++.
|
|
|
|
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
|
|
|
// installer, such as those produced by InstallShield.
|
|
|
|
// 3. Links to a library or executes a program that does any of the above.
|
2009-04-24 23:34:47 +00:00
|
|
|
//
|
2012-04-15 16:54:38 +00:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
#ifndef FIND_REPLACE_DLG_H
|
|
|
|
#define FIND_REPLACE_DLG_H
|
|
|
|
|
2009-09-04 00:10:01 +00:00
|
|
|
#ifndef FINDREPLACE_DLG_H
|
2009-04-24 23:34:47 +00:00
|
|
|
#include "FindReplaceDlg_rc.h"
|
2009-09-04 00:10:01 +00:00
|
|
|
#endif //FINDREPLACE_DLG_H
|
|
|
|
|
|
|
|
#ifndef SCINTILLA_EDIT_VIEW_H
|
2009-04-24 23:34:47 +00:00
|
|
|
#include "ScintillaEditView.h"
|
2009-09-04 00:10:01 +00:00
|
|
|
#endif //SCINTILLA_EDIT_VIEW_H
|
2009-04-24 23:34:47 +00:00
|
|
|
|
2009-09-04 00:10:01 +00:00
|
|
|
#ifndef DOCKINGDLGINTERFACE_H
|
|
|
|
#include "DockingDlgInterface.h"
|
|
|
|
#endif //DOCKINGDLGINTERFACE_H
|
2009-04-24 23:34:47 +00:00
|
|
|
|
2012-02-13 01:45:05 +00:00
|
|
|
#include "BoostRegexSearch.h"
|
2013-05-11 20:55:09 +00:00
|
|
|
#include "StatusBar.h"
|
2012-02-13 01:45:05 +00:00
|
|
|
|
2009-04-24 23:34:47 +00:00
|
|
|
#define FIND_RECURSIVE 1
|
|
|
|
#define FIND_INHIDDENDIR 2
|
|
|
|
|
|
|
|
#define FINDREPLACE_MAXLENGTH 2048
|
|
|
|
|
2011-01-19 21:05:40 +00:00
|
|
|
enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG, MARK_DLG};
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
#define DIR_DOWN true
|
|
|
|
#define DIR_UP false
|
|
|
|
|
|
|
|
//#define FIND_REPLACE_STR_MAX 256
|
|
|
|
|
|
|
|
enum InWhat{ALL_OPEN_DOCS, FILES_IN_DIR, CURRENT_DOC};
|
|
|
|
|
|
|
|
struct FoundInfo {
|
|
|
|
FoundInfo(int start, int end, const TCHAR *fullPath)
|
|
|
|
: _start(start), _end(end), _fullPath(fullPath) {};
|
|
|
|
int _start;
|
|
|
|
int _end;
|
2009-08-03 00:37:30 +00:00
|
|
|
generic_string _fullPath;
|
2009-04-24 23:34:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TargetRange {
|
|
|
|
int targetStart;
|
|
|
|
int targetEnd;
|
|
|
|
};
|
|
|
|
|
2009-06-27 00:34:11 +00:00
|
|
|
enum SearchIncrementalType { NotIncremental, FirstIncremental, NextIncremental };
|
2009-04-24 23:34:47 +00:00
|
|
|
enum SearchType { FindNormal, FindExtended, FindRegex };
|
|
|
|
enum ProcessOperation { ProcessFindAll, ProcessReplaceAll, ProcessCountAll, ProcessMarkAll, ProcessMarkAll_2, ProcessMarkAll_IncSearch, ProcessMarkAllExt };
|
|
|
|
|
2010-08-15 18:52:55 +00:00
|
|
|
struct FindOption
|
|
|
|
{
|
2009-04-24 23:34:47 +00:00
|
|
|
bool _isWholeWord;
|
|
|
|
bool _isMatchCase;
|
|
|
|
bool _isWrapAround;
|
|
|
|
bool _whichDirection;
|
2009-06-27 00:34:11 +00:00
|
|
|
SearchIncrementalType _incrementalType;
|
2009-04-24 23:34:47 +00:00
|
|
|
SearchType _searchType;
|
2010-08-15 18:52:55 +00:00
|
|
|
bool _doPurge;
|
|
|
|
bool _doMarkLine;
|
|
|
|
bool _isInSelection;
|
|
|
|
generic_string _str2Search;
|
|
|
|
generic_string _str4Replace;
|
|
|
|
generic_string _filters;
|
|
|
|
generic_string _directory;
|
|
|
|
bool _isRecursive;
|
|
|
|
bool _isInHiddenDir;
|
2012-02-13 01:45:05 +00:00
|
|
|
bool _dotMatchesNewline;
|
2010-08-15 18:52:55 +00:00
|
|
|
FindOption() : _isWholeWord(true), _isMatchCase(true), _searchType(FindNormal),\
|
|
|
|
_isWrapAround(true), _whichDirection(DIR_DOWN), _incrementalType(NotIncremental),
|
2011-01-19 21:05:40 +00:00
|
|
|
_doPurge(false), _doMarkLine(false),
|
2012-02-13 01:45:05 +00:00
|
|
|
_isInSelection(false), _isRecursive(true), _isInHiddenDir(false),
|
|
|
|
_dotMatchesNewline(false),
|
2010-08-15 18:52:55 +00:00
|
|
|
_filters(TEXT("")), _directory(TEXT("")) {};
|
2009-04-24 23:34:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//This class contains generic search functions as static functions for easy access
|
|
|
|
class Searching {
|
|
|
|
public:
|
|
|
|
static int convertExtendedToString(const TCHAR * query, TCHAR * result, int length);
|
|
|
|
static TargetRange t;
|
2010-08-15 18:52:55 +00:00
|
|
|
static int buildSearchFlags(const FindOption * option) {
|
2009-04-24 23:34:47 +00:00
|
|
|
return (option->_isWholeWord ? SCFIND_WHOLEWORD : 0) |
|
|
|
|
(option->_isMatchCase ? SCFIND_MATCHCASE : 0) |
|
2012-02-13 01:45:05 +00:00
|
|
|
(option->_searchType == FindRegex ? SCFIND_REGEXP|SCFIND_POSIX : 0) |
|
|
|
|
((option->_searchType == FindRegex && option->_dotMatchesNewline) ? SCFIND_REGEXP_DOTMATCHESNL : 0);
|
2009-04-24 23:34:47 +00:00
|
|
|
};
|
|
|
|
static void displaySectionCentered(int posStart, int posEnd, ScintillaEditView * pEditView, bool isDownwards = true);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool readBase(const TCHAR * str, int * value, int base, int size);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//Finder: Dockable window that contains search results
|
|
|
|
class Finder : public DockingDlgInterface {
|
|
|
|
friend class FindReplaceDlg;
|
|
|
|
public:
|
|
|
|
Finder() : DockingDlgInterface(IDD_FINDRESULT), _pMainFoundInfos(&_foundInfos1), _pMainMarkings(&_markings1) {
|
|
|
|
_MarkingsStruct._length = 0;
|
|
|
|
_MarkingsStruct._markings = NULL;
|
|
|
|
};
|
|
|
|
|
|
|
|
~Finder() {
|
|
|
|
_scintView.destroy();
|
|
|
|
}
|
|
|
|
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) {
|
|
|
|
DockingDlgInterface::init(hInst, hPere);
|
|
|
|
_ppEditView = ppEditView;
|
|
|
|
};
|
|
|
|
|
2009-09-04 00:10:01 +00:00
|
|
|
void addSearchLine(const TCHAR *searchName);
|
|
|
|
void addFileNameTitle(const TCHAR * fileName);
|
|
|
|
void addFileHitCount(int count);
|
|
|
|
void addSearchHitCount(int count);
|
|
|
|
void add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline, int lineNb);
|
2009-04-24 23:34:47 +00:00
|
|
|
void setFinderStyle();
|
2009-09-04 00:10:01 +00:00
|
|
|
void removeAll();
|
2009-10-09 00:42:10 +00:00
|
|
|
void openAll();
|
2009-09-04 00:10:01 +00:00
|
|
|
void beginNewFilesSearch();
|
|
|
|
void finishFilesSearch(int count);
|
2009-04-24 23:34:47 +00:00
|
|
|
void gotoNextFoundResult(int direction);
|
|
|
|
void GotoFoundLine();
|
|
|
|
void DeleteResult();
|
|
|
|
|
|
|
|
protected :
|
|
|
|
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
|
|
|
bool notify(SCNotification *notification);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
enum { searchHeaderLevel = SC_FOLDLEVELBASE + 1, fileHeaderLevel, resultLevel };
|
|
|
|
|
|
|
|
ScintillaEditView **_ppEditView;
|
|
|
|
std::vector<FoundInfo> _foundInfos1;
|
|
|
|
std::vector<FoundInfo> _foundInfos2;
|
|
|
|
std::vector<FoundInfo>* _pMainFoundInfos;
|
|
|
|
std::vector<SearchResultMarking> _markings1;
|
|
|
|
std::vector<SearchResultMarking> _markings2;
|
|
|
|
std::vector<SearchResultMarking>* _pMainMarkings;
|
|
|
|
SearchResultMarkings _MarkingsStruct;
|
|
|
|
|
|
|
|
ScintillaEditView _scintView;
|
|
|
|
unsigned int nFoundFiles;
|
|
|
|
|
|
|
|
int _lastFileHeaderPos;
|
|
|
|
int _lastSearchHeaderPos;
|
|
|
|
|
|
|
|
void setFinderReadOnly(bool isReadOnly) {
|
|
|
|
_scintView.execute(SCI_SETREADONLY, isReadOnly);
|
|
|
|
};
|
|
|
|
|
|
|
|
static FoundInfo EmptyFoundInfo;
|
|
|
|
static SearchResultMarking EmptySearchResultMarking;
|
|
|
|
};
|
|
|
|
|
2013-01-25 00:46:29 +00:00
|
|
|
|
2013-05-11 20:55:09 +00:00
|
|
|
enum FindStatus { FSFound, FSNotFound, FSTopReached, FSEndReached, FSMessage, FSNoMessage};
|
2013-01-25 00:46:29 +00:00
|
|
|
|
|
|
|
enum FindNextType {
|
|
|
|
FINDNEXTTYPE_FINDNEXT,
|
|
|
|
FINDNEXTTYPE_REPLACENEXT,
|
|
|
|
FINDNEXTTYPE_FINDNEXTFORREPLACE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-24 23:34:47 +00:00
|
|
|
class FindReplaceDlg : public StaticDialog
|
|
|
|
{
|
|
|
|
friend class FindIncrementDlg;
|
|
|
|
public :
|
2010-08-15 18:52:55 +00:00
|
|
|
static FindOption _options;
|
|
|
|
static FindOption* _env;
|
|
|
|
FindReplaceDlg() : StaticDialog(), _pFinder(NULL), _isRTL(false),\
|
2009-04-24 23:34:47 +00:00
|
|
|
_fileNameLenMax(1024) {
|
|
|
|
_uniFileName = new char[(_fileNameLenMax + 3) * 2];
|
|
|
|
_winVer = (NppParameters::getInstance())->getWinVersion();
|
2010-08-15 18:52:55 +00:00
|
|
|
_env = &_options;
|
2009-04-24 23:34:47 +00:00
|
|
|
};
|
2009-09-04 00:10:01 +00:00
|
|
|
~FindReplaceDlg();
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) {
|
|
|
|
Window::init(hInst, hPere);
|
|
|
|
if (!ppEditView)
|
2010-05-25 23:41:58 +00:00
|
|
|
throw std::runtime_error("FindIncrementDlg::init : ppEditView is null.");
|
2009-04-24 23:34:47 +00:00
|
|
|
_ppEditView = ppEditView;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual void create(int dialogID, bool isRTL = false);
|
|
|
|
|
2009-09-04 00:10:01 +00:00
|
|
|
void initOptionsFromDlg();
|
2009-04-24 23:34:47 +00:00
|
|
|
|
2010-01-19 21:49:36 +00:00
|
|
|
void doDialog(DIALOG_TYPE whichType, bool isRTL = false, bool toShow = true);
|
2013-01-25 00:46:29 +00:00
|
|
|
bool processFindNext(const TCHAR *txt2find, const FindOption *options = NULL, FindStatus *oFindStatus = NULL, FindNextType findNextType = FINDNEXTTYPE_FINDNEXT);
|
2010-08-15 18:52:55 +00:00
|
|
|
bool processReplace(const TCHAR *txt2find, const TCHAR *txt2replace, const FindOption *options = NULL);
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
int markAll(const TCHAR *txt2find, int styleID);
|
2009-09-19 21:43:11 +00:00
|
|
|
//int markAll2(const TCHAR *str2find);
|
2010-08-15 18:52:55 +00:00
|
|
|
int markAllInc(const FindOption *opt);
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
|
2010-08-15 18:52:55 +00:00
|
|
|
int processAll(ProcessOperation op, const FindOption *opt, bool isEntire = false, const TCHAR *fileName = NULL, int colourStyleID = -1);
|
|
|
|
// int processAll(ProcessOperation op, const TCHAR *txt2find, const TCHAR *txt2replace, bool isEntire = false, const TCHAR *fileName = NULL, const FindOption *opt = NULL, int colourStyleID = -1);
|
|
|
|
int processRange(ProcessOperation op, const TCHAR *txt2find, const TCHAR *txt2replace, int startRange, int endRange, const TCHAR *fileName = NULL, const FindOption *opt = NULL, int colourStyleID = -1);
|
2009-04-24 23:34:47 +00:00
|
|
|
void replaceAllInOpenedDocs();
|
|
|
|
void findAllIn(InWhat op);
|
2009-09-04 00:10:01 +00:00
|
|
|
void setSearchText(TCHAR * txt2find);
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
void gotoNextFoundResult(int direction = 0) {if (_pFinder) _pFinder->gotoNextFoundResult(direction);};
|
|
|
|
|
|
|
|
void putFindResult(int result) {
|
|
|
|
_findAllResult = result;
|
|
|
|
};
|
2010-08-15 18:52:55 +00:00
|
|
|
const TCHAR * getDir2Search() const {return _env->_directory.c_str();};
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
void getPatterns(vector<generic_string> & patternVect);
|
|
|
|
|
|
|
|
void launchFindInFilesDlg() {
|
|
|
|
doDialog(FINDINFILES_DLG);
|
|
|
|
};
|
|
|
|
|
2009-09-04 00:10:01 +00:00
|
|
|
void setFindInFilesDirFilter(const TCHAR *dir, const TCHAR *filters);
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
generic_string getText2search() const {
|
2010-08-15 18:52:55 +00:00
|
|
|
return _env->_str2Search;
|
2009-04-24 23:34:47 +00:00
|
|
|
};
|
|
|
|
|
2010-08-15 18:52:55 +00:00
|
|
|
const generic_string & getFilters() const {return _env->_filters;};
|
|
|
|
const generic_string & getDirectory() const {return _env->_directory;};
|
|
|
|
const FindOption & getCurrentOptions() const {return *_env;};
|
|
|
|
bool isRecursive() const { return _env->_isRecursive; };
|
|
|
|
bool isInHiddenDir() const { return _env->_isInHiddenDir; };
|
2009-04-24 23:34:47 +00:00
|
|
|
void saveFindHistory();
|
|
|
|
void changeTabName(DIALOG_TYPE index, const TCHAR *name2change) {
|
|
|
|
TCITEM tie;
|
|
|
|
tie.mask = TCIF_TEXT;
|
|
|
|
tie.pszText = (TCHAR *)name2change;
|
|
|
|
TabCtrl_SetItem(_tab.getHSelf(), index, &tie);
|
|
|
|
}
|
|
|
|
void beginNewFilesSearch()
|
|
|
|
{
|
|
|
|
_pFinder->beginNewFilesSearch();
|
|
|
|
_pFinder->addSearchLine(getText2search().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void finishFilesSearch(int count)
|
|
|
|
{
|
|
|
|
_pFinder->finishFilesSearch(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void focusOnFinder() {
|
|
|
|
// Show finder and set focus
|
|
|
|
if (_pFinder)
|
|
|
|
{
|
|
|
|
::SendMessage(_hParent, NPPM_DMMSHOW, 0, (LPARAM)_pFinder->getHSelf());
|
|
|
|
_pFinder->_scintView.getFocus();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
HWND getHFindResults() {
|
|
|
|
if (_pFinder)
|
|
|
|
return _pFinder->_scintView.getHSelf();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void updateFinderScintilla() {
|
|
|
|
if (_pFinder && _pFinder->isCreated() && _pFinder->isVisible())
|
|
|
|
{
|
|
|
|
_pFinder->setFinderStyle();
|
|
|
|
}
|
2013-05-11 20:55:09 +00:00
|
|
|
};
|
|
|
|
|
2010-08-15 18:52:55 +00:00
|
|
|
void execSavedCommand(int cmd, int intValue, generic_string stringValue);
|
2013-05-11 20:55:09 +00:00
|
|
|
void setStatusbarMessage(const generic_string & msg, FindStatus staus);
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
protected :
|
|
|
|
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
|
|
|
void addText2Combo(const TCHAR * txt2add, HWND comboID, bool isUTF8 = false);
|
|
|
|
generic_string getTextFromCombo(HWND hCombo, bool isUnicode = false) const;
|
|
|
|
static LONG originalFinderProc;
|
|
|
|
|
|
|
|
// Window procedure for the finder
|
2009-09-04 00:10:01 +00:00
|
|
|
static LRESULT FAR PASCAL finderProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
2009-06-10 00:17:42 +00:00
|
|
|
void combo2ExtendedMode(int comboID);
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
private :
|
|
|
|
|
2010-08-15 18:52:55 +00:00
|
|
|
DIALOG_TYPE _currentStatus;
|
2009-04-24 23:34:47 +00:00
|
|
|
RECT _findClosePos, _replaceClosePos, _findInFilesClosePos;
|
|
|
|
|
|
|
|
ScintillaEditView **_ppEditView;
|
|
|
|
Finder *_pFinder;
|
|
|
|
bool _isRTL;
|
|
|
|
|
|
|
|
int _findAllResult;
|
|
|
|
TCHAR _findAllResultStr[1024];
|
|
|
|
|
|
|
|
int _fileNameLenMax;
|
|
|
|
char *_uniFileName;
|
|
|
|
|
|
|
|
TabBar _tab;
|
|
|
|
winVer _winVer;
|
2013-05-11 20:55:09 +00:00
|
|
|
StatusBar _statusBar;
|
|
|
|
FindStatus _statusbarFindStatus;
|
2009-04-24 23:34:47 +00:00
|
|
|
|
2013-01-25 00:46:29 +00:00
|
|
|
|
|
|
|
|
2009-04-24 23:34:47 +00:00
|
|
|
void enableReplaceFunc(bool isEnable);
|
|
|
|
void enableFindInFilesControls(bool isEnable = true);
|
2009-09-04 00:10:01 +00:00
|
|
|
void enableFindInFilesFunc();
|
2011-01-19 21:05:40 +00:00
|
|
|
void enableMarkAllControls(bool isEnable);
|
|
|
|
void enableMarkFunc();
|
2009-04-24 23:34:47 +00:00
|
|
|
|
2009-09-04 00:10:01 +00:00
|
|
|
void setDefaultButton(int nID) {
|
2009-04-24 23:34:47 +00:00
|
|
|
SendMessage(_hSelf, DM_SETDEFID, (WPARAM)nID, 0L);
|
2009-09-04 00:10:01 +00:00
|
|
|
};
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
void gotoCorrectTab() {
|
|
|
|
int currentIndex = _tab.getCurrentTabIndex();
|
|
|
|
if (currentIndex != _currentStatus)
|
|
|
|
_tab.activateAt(_currentStatus);
|
|
|
|
};
|
2013-05-11 20:55:09 +00:00
|
|
|
|
|
|
|
FindStatus getFindStatus() {
|
|
|
|
return this->_statusbarFindStatus;
|
|
|
|
}
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
void updateCombos();
|
|
|
|
void updateCombo(int comboID) {
|
|
|
|
bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit;
|
|
|
|
HWND hCombo = ::GetDlgItem(_hSelf, comboID);
|
|
|
|
addText2Combo(getTextFromCombo(hCombo, isUnicode).c_str(), hCombo, isUnicode);
|
|
|
|
};
|
|
|
|
void fillFindHistory();
|
2009-09-29 00:14:48 +00:00
|
|
|
void fillComboHistory(int id, const std::vector<generic_string> & strings);
|
|
|
|
int saveComboHistory(int id, int maxcount, vector<generic_string> & strings);
|
2010-08-15 18:52:55 +00:00
|
|
|
static const int FR_OP_FIND = 1;
|
|
|
|
static const int FR_OP_REPLACE = 2;
|
|
|
|
static const int FR_OP_FIF = 4;
|
|
|
|
static const int FR_OP_GLOBAL = 8;
|
|
|
|
void saveInMacro(int cmd, int cmdType);
|
2013-05-11 20:55:09 +00:00
|
|
|
void drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
|
2013-01-25 00:46:29 +00:00
|
|
|
|
2009-04-24 23:34:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//FindIncrementDlg: incremental search dialog, docked in rebar
|
|
|
|
class FindIncrementDlg : public StaticDialog
|
|
|
|
{
|
|
|
|
public :
|
2013-05-11 20:55:09 +00:00
|
|
|
FindIncrementDlg() : _pFRDlg(NULL), _pRebar(NULL), _findStatus(FSFound) {};
|
2009-09-04 00:10:01 +00:00
|
|
|
void init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg, bool isRTL = false);
|
2009-04-24 23:34:47 +00:00
|
|
|
virtual void destroy();
|
|
|
|
virtual void display(bool toShow = true) const;
|
|
|
|
#ifdef UNICODE
|
2009-07-04 11:33:17 +00:00
|
|
|
void setSearchText(const TCHAR * txt2find, bool) {
|
2009-04-24 23:34:47 +00:00
|
|
|
::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find);
|
2009-07-04 11:33:17 +00:00
|
|
|
};
|
2009-04-24 23:34:47 +00:00
|
|
|
#else
|
2009-07-04 11:33:17 +00:00
|
|
|
void setSearchText(const TCHAR * txt2find, bool isUTF8 = false) {
|
2009-04-24 23:34:47 +00:00
|
|
|
if (!isUTF8)
|
|
|
|
{
|
|
|
|
::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const int wideBufferSize = 256;
|
|
|
|
WCHAR wchars[wideBufferSize];
|
|
|
|
::MultiByteToWideChar(CP_UTF8, 0, txt2find, -1, wchars, wideBufferSize);
|
|
|
|
winVer winVersion = NppParameters::getInstance()->getWinVersion();
|
|
|
|
if (winVersion <= WV_ME) {
|
|
|
|
//Cannot simply take txt2find since its UTF8
|
|
|
|
char ansiBuffer[wideBufferSize]; //Assuming no more than 2 bytes for each wchar (SBCS or DBCS, no UTF8 and sorts)
|
|
|
|
::WideCharToMultiByte(CP_ACP, 0, wchars, -1, ansiBuffer, wideBufferSize, NULL, NULL);
|
|
|
|
::SendDlgItemMessageA(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)ansiBuffer);
|
|
|
|
} else {
|
|
|
|
::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars);
|
|
|
|
}
|
2009-07-04 11:33:17 +00:00
|
|
|
};
|
2009-04-24 23:34:47 +00:00
|
|
|
#endif
|
2009-07-04 11:33:17 +00:00
|
|
|
|
2009-09-04 00:10:01 +00:00
|
|
|
void setFindStatus(FindStatus iStatus);
|
2009-08-03 23:21:08 +00:00
|
|
|
|
|
|
|
FindStatus getFindStatus() {
|
2013-05-11 20:55:09 +00:00
|
|
|
return _findStatus;
|
2009-08-03 23:21:08 +00:00
|
|
|
}
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
void addToRebar(ReBar * rebar);
|
|
|
|
private :
|
|
|
|
bool _isRTL;
|
|
|
|
FindReplaceDlg *_pFRDlg;
|
2013-05-11 20:55:09 +00:00
|
|
|
FindStatus _findStatus;
|
2009-04-24 23:34:47 +00:00
|
|
|
|
|
|
|
ReBar * _pRebar;
|
|
|
|
REBARBANDINFO _rbBand;
|
|
|
|
|
|
|
|
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
|
|
|
void markSelectedTextInc(bool enable, FindOption *opt = NULL);
|
|
|
|
};
|
|
|
|
|
2013-01-25 00:46:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-24 23:34:47 +00:00
|
|
|
#endif //FIND_REPLACE_DLG_H
|