[BUG_FIXED] Fix replace inaccurate bug.

[NEW] Increase Find what and replace with fields to 2047 characters.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@441 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2009-03-28 15:41:02 +00:00
parent 2eda8ec256
commit fbd300f33a
9 changed files with 132 additions and 71 deletions

View File

@ -693,11 +693,11 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly)
} }
} }
_isFileOpening = true;
BufferID buffer = MainFileManager->loadFile(longFileName); BufferID buffer = MainFileManager->loadFile(longFileName);
if (buffer != BUFFER_INVALID) if (buffer != BUFFER_INVALID)
{ {
_isFileOpening = true;
Buffer * buf = MainFileManager->getBufferByID(buffer); Buffer * buf = MainFileManager->getBufferByID(buffer);
// if file is read only, we set the view read only // if file is read only, we set the view read only
if (isReadOnly) if (isReadOnly)
@ -2499,19 +2499,27 @@ BOOL Notepad_plus::notify(SCNotification *notification)
case SCN_UPDATEUI: case SCN_UPDATEUI:
{ {
NppParameters *nppParam = NppParameters::getInstance();
// if it's searching/replacing, then do nothing
if (nppParam->_isFindReplacing)
break;
if (notification->nmhdr.hwndFrom != _pEditView->getHSelf()) if (notification->nmhdr.hwndFrom != _pEditView->getHSelf())
break; break;
braceMatch(); braceMatch();
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI(); const NppGUI & nppGui = nppParam->getNppGUI();
if (nppGUI._enableTagsMatchHilite/* && _pEditView->getHSelf() == notification->nmhdr.hwndFrom*/)
if (nppGui._enableTagsMatchHilite)
{ {
XmlMatchedTagsHighlighter xmlTagMatchHiliter(_pEditView); XmlMatchedTagsHighlighter xmlTagMatchHiliter(_pEditView);
xmlTagMatchHiliter.tagMatch(nppGUI._enableTagAttrsHilite); xmlTagMatchHiliter.tagMatch(nppGui._enableTagAttrsHilite);
} }
_smartHighlighter.highlightView(notifyView); if (nppGui._enableSmartHilite)
_smartHighlighter.highlightView(notifyView);
updateStatusBar(); updateStatusBar();
AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub;
@ -2521,7 +2529,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
case SCN_SCROLLED: case SCN_SCROLLED:
{ {
_smartHighlighter.highlightView(notifyView); const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
if (nppGUI._enableSmartHilite)
_smartHighlighter.highlightView(notifyView);
break; break;
} }
@ -2576,7 +2586,10 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (_syncInfo.doSync()) if (_syncInfo.doSync())
doSynScorll(HWND(notification->nmhdr.hwndFrom)); doSynScorll(HWND(notification->nmhdr.hwndFrom));
if (_linkTriggered) NppParameters *nppParam = NppParameters::getInstance();
// if it's searching/replacing, then do nothing
if (_linkTriggered && !nppParam->_isFindReplacing)
{ {
int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL;
if ((urlAction == 1) || (urlAction == 2)) if ((urlAction == 1) || (urlAction == 2))
@ -3192,7 +3205,7 @@ void Notepad_plus::command(int id)
case IDM_SEARCH_FIND : case IDM_SEARCH_FIND :
case IDM_SEARCH_REPLACE : case IDM_SEARCH_REPLACE :
{ {
const int strSize = 64; const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR str[strSize]; TCHAR str[strSize];
bool isFirstTime = !_findReplaceDlg.isCreated(); bool isFirstTime = !_findReplaceDlg.isCreated();
@ -3215,7 +3228,7 @@ void Notepad_plus::command(int id)
} }
case IDM_SEARCH_FINDINCREMENT : case IDM_SEARCH_FINDINCREMENT :
{ {
const int strSize = 64; const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR str[strSize]; TCHAR str[strSize];
_pEditView->getGenericSelectedText(str, strSize); _pEditView->getGenericSelectedText(str, strSize);
@ -3269,7 +3282,7 @@ void Notepad_plus::command(int id)
} }
case IDM_SEARCH_MARKALL : case IDM_SEARCH_MARKALL :
{ {
const int strSize = 64; const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR text2Find[strSize]; TCHAR text2Find[strSize];
_pEditView->getGenericSelectedText(text2Find, strSize); _pEditView->getGenericSelectedText(text2Find, strSize);
@ -7313,7 +7326,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
} }
case NPPM_LAUNCHFINDINFILESDLG : case NPPM_LAUNCHFINDINFILESDLG :
{ {
const int strSize = 64; const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR str[strSize]; TCHAR str[strSize];
bool isFirstTime = !_findReplaceDlg.isCreated(); bool isFirstTime = !_findReplaceDlg.isCreated();
@ -7664,7 +7677,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETCURRENTWORD : case NPPM_GETCURRENTWORD :
{ {
const int strSize = MAX_PATH*8; const int strSize = CURRENTWORD_MAXLENGTH;
TCHAR str[strSize]; TCHAR str[strSize];
_pEditView->getGenericSelectedText((TCHAR *)str, strSize); _pEditView->getGenericSelectedText((TCHAR *)str, strSize);

View File

@ -506,7 +506,7 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty
_pXmlShortcutDoc(NULL), _pXmlContextMenuDoc(NULL), _pXmlSessionDoc(NULL),\ _pXmlShortcutDoc(NULL), _pXmlContextMenuDoc(NULL), _pXmlSessionDoc(NULL),\
_nbUserLang(0), _nbExternalLang(0), _hUser32(NULL), _hUXTheme(NULL),\ _nbUserLang(0), _nbExternalLang(0), _hUser32(NULL), _hUXTheme(NULL),\
_transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\ _transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\
_isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false) _isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false), _isFindReplacing(false)
{ {
_findHistory._nbFindHistoryPath = 0; _findHistory._nbFindHistoryPath = 0;
_findHistory._nbFindHistoryFilter = 0; _findHistory._nbFindHistoryFilter = 0;

View File

@ -1179,6 +1179,7 @@ public:
bool reloadContextMenuFromXmlTree(HMENU mainMenuHadle); bool reloadContextMenuFromXmlTree(HMENU mainMenuHadle);
winVer getWinVersion() { return _winVersion;}; winVer getWinVersion() { return _winVersion;};
FindHistory & getFindHistory() {return _findHistory;}; FindHistory & getFindHistory() {return _findHistory;};
bool _isFindReplacing; // an on the fly variable for find/replace functions
#ifdef UNICODE #ifdef UNICODE
LocalizationSwicher & getLocalizationSwitcher() { LocalizationSwicher & getLocalizationSwitcher() {

View File

@ -166,14 +166,14 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add); i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
#else #else
TCHAR text[MAX_PATH]; TCHAR text[FINDREPLACE_MAXLENGTH];
bool isWin9x = _winVer <= WV_ME; bool isWin9x = _winVer <= WV_ME;
wchar_t wchars2Add[MAX_PATH]; wchar_t wchars2Add[FINDREPLACE_MAXLENGTH];
wchar_t textW[MAX_PATH]; wchar_t textW[FINDREPLACE_MAXLENGTH];
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0); int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
if (isUTF8) if (isUTF8)
::MultiByteToWideChar(CP_UTF8, 0, txt2add, -1, wchars2Add, MAX_PATH - 1); ::MultiByteToWideChar(CP_UTF8, 0, txt2add, -1, wchars2Add, FINDREPLACE_MAXLENGTH - 1);
for ( ; i < count ; i++) for ( ; i < count ; i++)
{ {
@ -185,7 +185,7 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
else else
{ {
::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text); ::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
::MultiByteToWideChar(CP_ACP, 0, text, -1, textW, MAX_PATH - 1); ::MultiByteToWideChar(CP_ACP, 0, text, -1, textW, FINDREPLACE_MAXLENGTH - 1);
} }
if (!wcscmp(wchars2Add, textW)) if (!wcscmp(wchars2Add, textW))
@ -214,7 +214,7 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
i = ::SendMessageW(hCombo, CB_INSERTSTRING, 0, (LPARAM)wchars2Add); i = ::SendMessageW(hCombo, CB_INSERTSTRING, 0, (LPARAM)wchars2Add);
else else
{ {
::WideCharToMultiByte(CP_ACP, 0, wchars2Add, -1, text, MAX_PATH - 1, NULL, NULL); ::WideCharToMultiByte(CP_ACP, 0, wchars2Add, -1, text, FINDREPLACE_MAXLENGTH - 1, NULL, NULL);
i = ::SendMessageA(hCombo, CB_INSERTSTRING, 0, (LPARAM)text); i = ::SendMessageA(hCombo, CB_INSERTSTRING, 0, (LPARAM)text);
} }
} }
@ -224,29 +224,29 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
generic_string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool isUnicode) const generic_string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool isUnicode) const
{ {
TCHAR str[MAX_PATH]; TCHAR str[FINDREPLACE_MAXLENGTH];
#ifdef UNICODE #ifdef UNICODE
::SendMessage(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)str); ::SendMessage(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, (LPARAM)str);
#else #else
bool isWin9x = _winVer <= WV_ME; bool isWin9x = _winVer <= WV_ME;
if (isUnicode) if (isUnicode)
{ {
wchar_t wchars[MAX_PATH]; wchar_t wchars[FINDREPLACE_MAXLENGTH];
if ( !isWin9x ) if ( !isWin9x )
{ {
::SendMessageW(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)wchars); ::SendMessageW(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, (LPARAM)wchars);
} }
else else
{ {
char achars[MAX_PATH]; char achars[FINDREPLACE_MAXLENGTH];
::SendMessageA(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)achars); ::SendMessageA(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, (LPARAM)achars);
::MultiByteToWideChar(CP_ACP, 0, achars, -1, wchars, MAX_PATH - 1); ::MultiByteToWideChar(CP_ACP, 0, achars, -1, wchars, FINDREPLACE_MAXLENGTH - 1);
} }
::WideCharToMultiByte(CP_UTF8, 0, wchars, -1, str, MAX_PATH - 1, NULL, NULL); ::WideCharToMultiByte(CP_UTF8, 0, wchars, -1, str, FINDREPLACE_MAXLENGTH - 1, NULL, NULL);
} }
else else
{ {
::SendMessage(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)str); ::SendMessage(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, (LPARAM)str);
} }
#endif #endif
@ -401,7 +401,7 @@ void FindReplaceDlg::saveComboHistory(int id, int maxcount, int & oldcount, gene
int i, count; int i, count;
bool isUnicode = false; bool isUnicode = false;
HWND hCombo; HWND hCombo;
TCHAR text[500]; //yniq - any need for dynamic allocation? TCHAR text[FINDREPLACE_MAXLENGTH];
hCombo = ::GetDlgItem(_hSelf, id); hCombo = ::GetDlgItem(_hSelf, id);
count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0); count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
@ -596,15 +596,6 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
{ {
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
/*
// Wrap arround active by default
::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, BST_CHECKED, 0);
// Normal search active by default
::SendDlgItemMessage(_hSelf, IDNORMAL, BM_SETCHECK, BST_CHECKED, 0);
if (_isRecursive)
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK, BM_SETCHECK, BST_CHECKED, 0);
*/
RECT arc; RECT arc;
::GetWindowRect(::GetDlgItem(_hSelf, IDCANCEL), &arc); ::GetWindowRect(::GetDlgItem(_hSelf, IDCANCEL), &arc);
_findInFilesClosePos.bottom = _replaceClosePos.bottom = _findClosePos.bottom = arc.bottom - arc.top; _findInFilesClosePos.bottom = _replaceClosePos.bottom = _findClosePos.bottom = arc.bottom - arc.top;
@ -676,6 +667,15 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
checkVal = BST_CHECKED; checkVal = BST_CHECKED;
_isInSelection = true; _isInSelection = true;
} }
// Searching/replacing in column selection is not allowed
if ((*_ppEditView)->execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE)
{
checkVal = BST_UNCHECKED;
_isInSelection = false;
nbSelected = 0;
}
::SendDlgItemMessage(_hSelf, IDC_IN_SELECTION_CHECK, BM_SETCHECK, checkVal, 0); ::SendDlgItemMessage(_hSelf, IDC_IN_SELECTION_CHECK, BM_SETCHECK, checkVal, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_IN_SELECTION_CHECK), nbSelected); ::EnableWindow(::GetDlgItem(_hSelf, IDC_IN_SELECTION_CHECK), nbSelected);
@ -700,7 +700,8 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case WM_COMMAND : case WM_COMMAND :
{ {
FindHistory & findHistory = (NppParameters::getInstance())->getFindHistory(); NppParameters *nppParamInst = NppParameters::getInstance();
FindHistory & findHistory = nppParamInst->getFindHistory();
switch (wParam) switch (wParam)
{ {
case IDCANCEL : // Close case IDCANCEL : // Close
@ -715,7 +716,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
generic_string str2Search = getTextFromCombo(hFindCombo, isUnicode); generic_string str2Search = getTextFromCombo(hFindCombo, isUnicode);
updateCombo(IDFINDWHAT); updateCombo(IDFINDWHAT);
nppParamInst->_isFindReplacing = true;
processFindNext(str2Search.c_str()); processFindNext(str2Search.c_str());
nppParamInst->_isFindReplacing = false;
} }
return TRUE; return TRUE;
@ -729,7 +733,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
generic_string str2Search = getTextFromCombo(hFindCombo, isUnicode); generic_string str2Search = getTextFromCombo(hFindCombo, isUnicode);
generic_string str2Replace = getTextFromCombo(hReplaceCombo, isUnicode); generic_string str2Replace = getTextFromCombo(hReplaceCombo, isUnicode);
updateCombos(); updateCombos();
nppParamInst->_isFindReplacing = true;
processReplace(str2Search.c_str(), str2Replace.c_str()); processReplace(str2Search.c_str(), str2Replace.c_str());
nppParamInst->_isFindReplacing = false;
} }
} }
return TRUE; return TRUE;
@ -739,7 +746,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
if (_currentStatus == FIND_DLG) if (_currentStatus == FIND_DLG)
{ {
updateCombo(IDFINDWHAT); updateCombo(IDFINDWHAT);
nppParamInst->_isFindReplacing = true;
findAllIn(ALL_OPEN_DOCS); findAllIn(ALL_OPEN_DOCS);
nppParamInst->_isFindReplacing = false;
} }
} }
return TRUE; return TRUE;
@ -747,7 +757,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case IDC_FINDALL_CURRENTFILE : case IDC_FINDALL_CURRENTFILE :
{ {
updateCombo(IDFINDWHAT); updateCombo(IDFINDWHAT);
nppParamInst->_isFindReplacing = true;
findAllIn(CURRENT_DOC); findAllIn(CURRENT_DOC);
nppParamInst->_isFindReplacing = false;
} }
return TRUE; return TRUE;
@ -768,7 +781,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
_directory += TEXT("\\"); _directory += TEXT("\\");
updateCombo(IDFINDWHAT); updateCombo(IDFINDWHAT);
nppParamInst->_isFindReplacing = true;
findAllIn(FILES_IN_DIR); findAllIn(FILES_IN_DIR);
nppParamInst->_isFindReplacing = false;
} }
return TRUE; return TRUE;
@ -797,7 +813,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
{ {
updateCombo(IDFINDWHAT); updateCombo(IDFINDWHAT);
updateCombo(IDREPLACEWITH); updateCombo(IDREPLACEWITH);
nppParamInst->_isFindReplacing = true;
::SendMessage(_hParent, WM_REPLACEINFILES, 0, 0); ::SendMessage(_hParent, WM_REPLACEINFILES, 0, 0);
nppParamInst->_isFindReplacing = false;
} }
} }
return TRUE; return TRUE;
@ -807,7 +826,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
if (_currentStatus == REPLACE_DLG) if (_currentStatus == REPLACE_DLG)
{ {
updateCombos(); updateCombos();
nppParamInst->_isFindReplacing = true;
replaceAllInOpenedDocs(); replaceAllInOpenedDocs();
nppParamInst->_isFindReplacing = false;
} }
} }
return TRUE; return TRUE;
@ -818,9 +840,11 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
{ {
updateCombos(); updateCombos();
nppParamInst->_isFindReplacing = true;
(*_ppEditView)->execute(SCI_BEGINUNDOACTION); (*_ppEditView)->execute(SCI_BEGINUNDOACTION);
int nbReplaced = processAll(ProcessReplaceAll, NULL, NULL); int nbReplaced = processAll(ProcessReplaceAll, NULL, NULL);
(*_ppEditView)->execute(SCI_ENDUNDOACTION); (*_ppEditView)->execute(SCI_ENDUNDOACTION);
nppParamInst->_isFindReplacing = false;
TCHAR result[64]; TCHAR result[64];
if (nbReplaced < 0) if (nbReplaced < 0)
@ -853,7 +877,9 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
{ {
updateCombo(IDFINDWHAT); updateCombo(IDFINDWHAT);
nppParamInst->_isFindReplacing = true;
int nbMarked = processAll(ProcessMarkAll, NULL, NULL); int nbMarked = processAll(ProcessMarkAll, NULL, NULL);
nppParamInst->_isFindReplacing = false;
TCHAR result[128]; TCHAR result[128];
if (nbMarked < 0) if (nbMarked < 0)
lstrcpy(result, TEXT("The regular expression to search is formed badly.\r\nIs it resulting in nothing?")); lstrcpy(result, TEXT("The regular expression to search is formed badly.\r\nIs it resulting in nothing?"));
@ -1898,8 +1924,8 @@ void FindIncrementDlg::markSelectedTextInc(bool enable, FindOption *opt)
if (range.cpMin == range.cpMax) if (range.cpMin == range.cpMax)
return; return;
TCHAR text2Find[MAX_PATH]; TCHAR text2Find[FINDREPLACE_MAXLENGTH];
(*(_pFRDlg->_ppEditView))->getGenericSelectedText(text2Find, MAX_PATH, false); //do not expand selection (false) (*(_pFRDlg->_ppEditView))->getGenericSelectedText(text2Find, FINDREPLACE_MAXLENGTH, false); //do not expand selection (false)
_pFRDlg->markAllInc(text2Find, opt); _pFRDlg->markAllInc(text2Find, opt);
} }

View File

@ -29,6 +29,8 @@
#define FIND_RECURSIVE 1 #define FIND_RECURSIVE 1
#define FIND_INHIDDENDIR 2 #define FIND_INHIDDENDIR 2
#define FINDREPLACE_MAXLENGTH 2048
enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG}; enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG};
#define DIR_DOWN true #define DIR_DOWN true

View File

@ -16,7 +16,7 @@
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "SmartHighlighter.h" #include "SmartHighlighter.h"
#include "Parameters.h" //#include "Parameters.h"
#define MAXLINEHIGHLIGHT 400 //prevent highlighter from doing too much work when a lot is visible #define MAXLINEHIGHLIGHT 400 //prevent highlighter from doing too much work when a lot is visible
@ -28,10 +28,6 @@ SmartHighlighter::SmartHighlighter(FindReplaceDlg * pFRDlg)
void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView) void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView)
{ {
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
if (!nppGUI._enableSmartHilite)
return;
//Get selection //Get selection
CharacterRange range = pHighlightView->getSelection(); CharacterRange range = pHighlightView->getSelection();

View File

@ -111,7 +111,7 @@ void expandNppEnvironmentStrs(const TCHAR *strSrc, TCHAR *stringDest, size_t str
{ {
if (iEnd != -1) if (iEnd != -1)
{ {
TCHAR str[256]; TCHAR str[MAX_PATH];
int m = 0; int m = 0;
for (int k = iBegin ; k <= iEnd ; k++) for (int k = iBegin ; k <= iEnd ; k++)
str[m++] = strSrc[k]; str[m++] = strSrc[k];
@ -121,64 +121,85 @@ void expandNppEnvironmentStrs(const TCHAR *strSrc, TCHAR *stringDest, size_t str
if (internalVar == VAR_NOT_RECOGNIZED) if (internalVar == VAR_NOT_RECOGNIZED)
{ {
i = iBegin - 2; i = iBegin - 2;
stringDest[j++] = strSrc[i]; if (j < (strDestLen-1))
stringDest[j++] = strSrc[i];
else
break;
} }
else else
{ {
TCHAR expandedStr[256]; TCHAR expandedStr[CURRENTWORD_MAXLENGTH];
if (internalVar == CURRENT_LINE || internalVar == CURRENT_COLUMN) if (internalVar == CURRENT_LINE || internalVar == CURRENT_COLUMN)
{ {
int lineNumber = ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, 0, 0); int lineNumber = ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, 0, 0);
wsprintf(expandedStr, TEXT("%d"), lineNumber); wsprintf(expandedStr, TEXT("%d"), lineNumber);
} }
else else
::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, MAX_PATH, (LPARAM)expandedStr); ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, CURRENTWORD_MAXLENGTH, (LPARAM)expandedStr);
for (int p = 0 ; p < lstrlen(expandedStr) ; p++) for (int p = 0 ; p < lstrlen(expandedStr) ; p++)
stringDest[j++] = expandedStr[p]; {
if (j < (strDestLen-1))
stringDest[j++] = expandedStr[p];
else
break;
}
} }
} }
else else
{ {
i = iBegin - 2; i = iBegin - 2;
stringDest[j++] = strSrc[i]; if (j < (strDestLen-1))
stringDest[j++] = strSrc[i];
else
break;
} }
} }
else else
stringDest[j++] = strSrc[i]; if (j < (strDestLen-1))
stringDest[j++] = strSrc[i];
else
break;
} }
stringDest[j] = '\0'; stringDest[j] = '\0';
} }
HINSTANCE Command::run(HWND hWnd) HINSTANCE Command::run(HWND hWnd)
{ {
const int argsIntermediateLen = MAX_PATH*2;
const int args2ExecLen = CURRENTWORD_MAXLENGTH+MAX_PATH*2;
TCHAR cmdPure[MAX_PATH]; TCHAR cmdPure[MAX_PATH];
TCHAR cmdIntermediate[MAX_PATH]; TCHAR cmdIntermediate[MAX_PATH];
TCHAR cmd2Exec[MAX_PATH]; TCHAR cmd2Exec[MAX_PATH];
TCHAR args[MAX_PATH]; TCHAR args[MAX_PATH];
TCHAR argsIntermediate[MAX_PATH]; TCHAR argsIntermediate[argsIntermediateLen];
TCHAR args2Exec[MAX_PATH]; TCHAR args2Exec[args2ExecLen];
extractArgs(cmdPure, args, _cmdLine.c_str()); extractArgs(cmdPure, args, _cmdLine.c_str());
::ExpandEnvironmentStrings(cmdPure, cmdIntermediate, MAX_PATH); int nbTchar = ::ExpandEnvironmentStrings(cmdPure, cmdIntermediate, MAX_PATH);
::ExpandEnvironmentStrings(args, argsIntermediate, MAX_PATH); if (!nbChar)
expandNppEnvironmentStrs(cmdIntermediate, cmd2Exec, MAX_PATH, hWnd); lstrcpy(cmdIntermediate, cmdPure);
expandNppEnvironmentStrs(argsIntermediate, args2Exec, MAX_PATH, hWnd); else if (nbTchar >= MAX_PATH)
cmdIntermediate[MAX_PATH-1] = '\0';
return ::ShellExecute(hWnd, TEXT("open"), cmd2Exec, args2Exec, TEXT("."), SW_SHOW); nbTchar = ::ExpandEnvironmentStrings(args, argsIntermediate, argsIntermediateLen);
if (!nbChar)
lstrcpy(argsIntermediate, args);
else if (nbTchar >= argsIntermediateLen)
argsIntermediate[argsIntermediateLen-1] = '\0';
expandNppEnvironmentStrs(cmdIntermediate, cmd2Exec, MAX_PATH, hWnd);
expandNppEnvironmentStrs(argsIntermediate, args2Exec, args2ExecLen, hWnd);
HINSTANCE res = ::ShellExecute(hWnd, TEXT("open"), cmd2Exec, args2Exec, TEXT("."), SW_SHOW);
return res;
} }
BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
{/* {
case WM_INITDIALOG :
{
getClientRect(_rc);
return TRUE;
}
*/
case WM_COMMAND : case WM_COMMAND :
{ {
switch (wParam) switch (wParam)

View File

@ -27,6 +27,8 @@
using namespace std; using namespace std;
#define CURRENTWORD_MAXLENGTH 2048
const TCHAR fullCurrentPath[] = TEXT("FULL_CURRENT_PATH"); const TCHAR fullCurrentPath[] = TEXT("FULL_CURRENT_PATH");
const TCHAR currentDirectory[] = TEXT("CURRENT_DIRECTORY"); const TCHAR currentDirectory[] = TEXT("CURRENT_DIRECTORY");
const TCHAR onlyFileName[] = TEXT("FILE_NAME"); const TCHAR onlyFileName[] = TEXT("FILE_NAME");

View File

@ -75,7 +75,7 @@
<Keywords name="instre1">as case class data default deriving do else hiding if import in infix infixl infixr instance let module newtype of proc qualified rec then type where _</Keywords> <Keywords name="instre1">as case class data default deriving do else hiding if import in infix infixl infixr instance let module newtype of proc qualified rec then type where _</Keywords>
</Language> </Language>
<Language name="html" ext="html htm shtml shtm xhtml" commentLine="" commentStart="&lt;!--" commentEnd="--&gt;"> <Language name="html" ext="html htm shtml shtm xhtml" commentLine="" commentStart="&lt;!--" commentEnd="--&gt;">
<Keywords name="instre1">!doctype a abbr accept-charset accept accesskey acronym action address align alink alt applet archive area axis b background base basefont bdo bgcolor big blockquote body border br button caption cellpadding cellspacing center char charoff charset checkbox checked cite class classid clear code codebase codetype col colgroup color cols colspan compact content coords data datafld dataformatas datapagesize datasrc datetime dd declare defer del dfn dir disabled div dl dt em enctype event face fieldset file font for form frame frameborder frameset h1 h2 h3 h4 h5 h6 head headers height hidden hr href hreflang hspace html http-equiv i id iframe image img input ins isindex ismap kbd label lang language leftmargin legend li link longdesc map marginwidth marginheight maxlength media menu meta method multiple name noframes nohref noresize noscript noshade nowrap object ol onblur onchange onclick ondblclick onfocus onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseover onmouseout onmouseup optgroup option onreset onselect onsubmit onunload p param password profile pre prompt public q radio readonly rel reset rev rows rowspan rules s samp scheme scope script scrolling select selected shape size small span src standby start strike strong style sub submit summary sup tabindex table target tbody td text textarea tfoot th thead title topmargin tr tt type u ul usemap valign value valuetype var version vlink vspace width xml xmlns</Keywords> <Keywords name="instre1">!doctype a abbr accept-charset accept accesskey acronym action address align alink alt applet archive area axis b background base basefont bdo bgcolor big blockquote body border br button caption cellpadding cellspacing center char charoff charset checkbox checked cite class classid clear code codebase codetype col colgroup color cols colspan compact content coords data datafld dataformatas datapagesize datasrc datetime dd declare defer del dfn dir disabled div dl dt em embed enctype event face fieldset file font for form frame frameborder frameset h1 h2 h3 h4 h5 h6 head headers height hidden hr href hreflang hspace html http-equiv i id iframe image img input ins isindex ismap kbd label lang language leftmargin legend li link longdesc map marginwidth marginheight maxlength media menu meta method multiple name noframes nohref noresize noscript noshade nowrap object ol onblur onchange onclick ondblclick onfocus onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseover onmouseout onmouseup optgroup option onreset onselect onsubmit onunload p param password profile pre prompt public q radio readonly rel reset rev rows rowspan rules s samp scheme scope script scrolling select selected shape size small span src standby start strike strong style sub submit summary sup tabindex table target tbody td text textarea tfoot th thead title topmargin tr tt type u ul usemap valign value valuetype var version vlink vspace width xml xmlns</Keywords>
</Language> </Language>
<Language name="ini" ext="ini inf reg url" commentLine=";"> <Language name="ini" ext="ini inf reg url" commentLine=";">
</Language> </Language>