[NEW_FEATURE] Mark All is change to indicator way from style way.
Fix the smart highlighting performance issue. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@177 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
936d040e40
commit
65bb6ceb7f
|
@ -2901,11 +2901,7 @@ void Notepad_plus::command(int id)
|
||||||
|
|
||||||
case IDM_SEARCH_UNMARKALL :
|
case IDM_SEARCH_UNMARKALL :
|
||||||
{
|
{
|
||||||
LangType lt = _pEditView->getCurrentDocType();
|
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE);
|
||||||
if (lt == L_TXT)
|
|
||||||
_pEditView->defineDocType(L_CPP);
|
|
||||||
_pEditView->defineDocType(lt);
|
|
||||||
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8248,42 +8244,6 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void Notepad_plus::markSelectedText()
|
|
||||||
{
|
|
||||||
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
|
|
||||||
if (!nppGUI._enableSmartHilite)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Get selection
|
|
||||||
CharacterRange range = _pEditView->getSelection();
|
|
||||||
//Dont mark if the selection has not changed.
|
|
||||||
if (range.cpMin == _prevSelectedRange.cpMin && range.cpMax == _prevSelectedRange.cpMax)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_prevSelectedRange = range;
|
|
||||||
|
|
||||||
//Clear marks
|
|
||||||
LangType lt = _pEditView->getCurrentDocType();
|
|
||||||
if (lt == L_TXT)
|
|
||||||
_pEditView->defineDocType(L_CPP);
|
|
||||||
_pEditView->defineDocType(lt);
|
|
||||||
|
|
||||||
//If nothing selected, dont mark anything
|
|
||||||
if (range.cpMin == range.cpMax)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char text2Find[MAX_PATH];
|
|
||||||
_pEditView->getSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false)
|
|
||||||
|
|
||||||
FindOption op;
|
|
||||||
op._isWholeWord = false;
|
|
||||||
_findReplaceDlg.markAll2(text2Find);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Notepad_plus::markSelectedText()
|
void Notepad_plus::markSelectedText()
|
||||||
{
|
{
|
||||||
|
@ -8312,8 +8272,19 @@ void Notepad_plus::markSelectedText()
|
||||||
char text2Find[MAX_PATH];
|
char text2Find[MAX_PATH];
|
||||||
_pEditView->getSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false)
|
_pEditView->getSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false)
|
||||||
|
|
||||||
|
if (!isQualifiedWord(text2Find))
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned char c = (unsigned char)_pEditView->execute(SCI_GETCHARAT, range.cpMax);
|
||||||
|
if (c)
|
||||||
|
{
|
||||||
|
if (isWordChar(char(c)))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
FindOption op;
|
FindOption op;
|
||||||
op._isWholeWord = false;
|
op._isWholeWord = true;
|
||||||
_findReplaceDlg.markAll2(text2Find);
|
_findReplaceDlg.markAll2(text2Find);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -683,8 +683,55 @@ private:
|
||||||
|
|
||||||
void setFileOpenSaveDlgFilters(FileDialog & fDlg);
|
void setFileOpenSaveDlgFilters(FileDialog & fDlg);
|
||||||
void reloadOnSwitchBack();
|
void reloadOnSwitchBack();
|
||||||
|
|
||||||
void markSelectedText();
|
void markSelectedText();
|
||||||
|
|
||||||
|
bool isQualifiedWord(const char *str)
|
||||||
|
{
|
||||||
|
for (size_t i = 0 ; i < strlen(str) ; i++)
|
||||||
|
{
|
||||||
|
if (!isWordChar(str[i]))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool isWordChar(char ch) const {
|
||||||
|
if (ch < 0x20)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch(ch)
|
||||||
|
{
|
||||||
|
case ' ':
|
||||||
|
case ' ':
|
||||||
|
case '\n':
|
||||||
|
case '\r':
|
||||||
|
case '.':
|
||||||
|
case '(':
|
||||||
|
case ')':
|
||||||
|
case '[':
|
||||||
|
case ']':
|
||||||
|
case '+':
|
||||||
|
case '-':
|
||||||
|
case '*':
|
||||||
|
case '/':
|
||||||
|
case '!':
|
||||||
|
case '#':
|
||||||
|
//case '@':
|
||||||
|
case '^':
|
||||||
|
case '%':
|
||||||
|
case '$':
|
||||||
|
case '"':
|
||||||
|
case '~':
|
||||||
|
case '&':
|
||||||
|
case '{':
|
||||||
|
case '}':
|
||||||
|
case '|':
|
||||||
|
case '=':
|
||||||
|
case '\\':
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //NOTEPAD_PLUS_H
|
#endif //NOTEPAD_PLUS_H
|
||||||
|
|
|
@ -547,12 +547,12 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||||
if (nbCounted < 0)
|
if (nbCounted < 0)
|
||||||
strcpy(result, "The regular expression to search is formed badly.\r\nIs it resulting in nothing?");
|
strcpy(result, "The regular expression to search is formed badly.\r\nIs it resulting in nothing?");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
itoa(nbCounted, result, 10);
|
itoa(nbCounted, result, 10);
|
||||||
strcat(result, " tokens are found.");
|
strcat(result, " tokens are found.");
|
||||||
}
|
|
||||||
::MessageBox(_hSelf, result, "", MB_OK);
|
|
||||||
}
|
}
|
||||||
|
::MessageBox(_hSelf, result, "", MB_OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -580,11 +580,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||||
{
|
{
|
||||||
if (_currentStatus == FIND_DLG)
|
if (_currentStatus == FIND_DLG)
|
||||||
{
|
{
|
||||||
LangType lt = (*_ppEditView)->getCurrentDocType();
|
(*_ppEditView)->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE);
|
||||||
if (lt == L_TXT)
|
|
||||||
(*_ppEditView)->defineDocType(L_CPP);
|
|
||||||
(*_ppEditView)->defineDocType(lt);
|
|
||||||
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -605,14 +601,14 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||||
bool isRegex = (_options._searchType == FindRegex);
|
bool isRegex = (_options._searchType == FindRegex);
|
||||||
if (isRegex) { //regex doesnt allow wholeword
|
if (isRegex) { //regex doesnt allow wholeword
|
||||||
_options._isWholeWord = false;
|
_options._isWholeWord = false;
|
||||||
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, _options._isWholeWord?BST_CHECKED:BST_UNCHECKED, 0);
|
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, _options._isWholeWord?BST_CHECKED:BST_UNCHECKED, 0);
|
||||||
}
|
}
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDWHOLEWORD), (BOOL)!isRegex);
|
::EnableWindow(::GetDlgItem(_hSelf, IDWHOLEWORD), (BOOL)!isRegex);
|
||||||
|
|
||||||
if (isRegex) { //regex doesnt allow upward search
|
if (isRegex) { //regex doesnt allow upward search
|
||||||
::SendDlgItemMessage(_hSelf, IDDIRECTIONDOWN, BM_SETCHECK, BST_CHECKED, 0);
|
::SendDlgItemMessage(_hSelf, IDDIRECTIONDOWN, BM_SETCHECK, BST_CHECKED, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDDIRECTIONUP, BM_SETCHECK, BST_UNCHECKED, 0);
|
::SendDlgItemMessage(_hSelf, IDDIRECTIONUP, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||||
_options._whichDirection = DIR_DOWN;
|
_options._whichDirection = DIR_DOWN;
|
||||||
}
|
}
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDDIRECTIONUP), (BOOL)!isRegex);
|
::EnableWindow(::GetDlgItem(_hSelf, IDDIRECTIONUP), (BOOL)!isRegex);
|
||||||
return TRUE; }
|
return TRUE; }
|
||||||
|
@ -795,15 +791,15 @@ bool FindReplaceDlg::processFindNext(const char *txt2find, FindOption *options)
|
||||||
if (!pOptions->_isIncremental) { //incremental search doesnt trigger messages
|
if (!pOptions->_isIncremental) { //incremental search doesnt trigger messages
|
||||||
const char stringMaxSize = 64;
|
const char stringMaxSize = 64;
|
||||||
char message[30 + stringMaxSize + 5]; //message, string, dots
|
char message[30 + stringMaxSize + 5]; //message, string, dots
|
||||||
strcpy(message, "Can't find the text:\r\n");
|
strcpy(message, "Can't find the text:\r\n");
|
||||||
strncat(message, pText, stringMaxSize);
|
strncat(message, pText, stringMaxSize);
|
||||||
if (strlen(pText) > stringMaxSize) {
|
if (strlen(pText) > stringMaxSize) {
|
||||||
strcat(message, "...");
|
strcat(message, "...");
|
||||||
}
|
}
|
||||||
::MessageBox(_hSelf, message, "Find", MB_OK);
|
::MessageBox(_hSelf, message, "Find", MB_OK);
|
||||||
// if the dialog is not shown, pass the focus to his parent(ie. Notepad++)
|
// if the dialog is not shown, pass the focus to his parent(ie. Notepad++)
|
||||||
if (!::IsWindowVisible(_hSelf))
|
if (!::IsWindowVisible(_hSelf))
|
||||||
::SetFocus((*_ppEditView)->getHSelf());
|
::SetFocus((*_ppEditView)->getHSelf());
|
||||||
}
|
}
|
||||||
delete [] pText;
|
delete [] pText;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1024,17 +1020,13 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
|
||||||
|
|
||||||
if (op == ProcessMarkAll) //if marking, check if purging is needed
|
if (op == ProcessMarkAll) //if marking, check if purging is needed
|
||||||
{
|
{
|
||||||
if (_doPurge) {
|
if ((_doStyleFoundToken) && (_doPurge))
|
||||||
if (_doMarkLine)
|
if (_doMarkLine)
|
||||||
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
||||||
|
|
||||||
if (_doStyleFoundToken)
|
if (_doStyleFoundToken)
|
||||||
{
|
{
|
||||||
LangType lt = (*_ppEditView)->getCurrentDocType();
|
(*_ppEditView)->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE);
|
||||||
if (lt == L_TXT)
|
|
||||||
(*_ppEditView)->defineDocType(L_CPP);
|
|
||||||
(*_ppEditView)->defineDocType(lt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (_doStyleFoundToken)
|
if (_doStyleFoundToken)
|
||||||
{
|
{
|
||||||
|
@ -1081,7 +1073,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
|
||||||
bool isRealloc = false;
|
bool isRealloc = false;
|
||||||
|
|
||||||
if (_maxNbCharAllocated < nbChar) //line longer than buffer, resize buffer
|
if (_maxNbCharAllocated < nbChar) //line longer than buffer, resize buffer
|
||||||
{
|
{
|
||||||
isRealloc = true;
|
isRealloc = true;
|
||||||
_maxNbCharAllocated = nbChar;
|
_maxNbCharAllocated = nbChar;
|
||||||
delete [] _line;
|
delete [] _line;
|
||||||
|
@ -1114,52 +1106,51 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
|
||||||
startPosition = posFind + foundTextLen;
|
startPosition = posFind + foundTextLen;
|
||||||
break; }
|
break; }
|
||||||
case ProcessReplaceAll: {
|
case ProcessReplaceAll: {
|
||||||
(*_ppEditView)->execute(SCI_SETTARGETSTART, start);
|
(*_ppEditView)->execute(SCI_SETTARGETSTART, start);
|
||||||
(*_ppEditView)->execute(SCI_SETTARGETEND, end);
|
(*_ppEditView)->execute(SCI_SETTARGETEND, end);
|
||||||
int replacedLength = (*_ppEditView)->execute(isRegExp?SCI_REPLACETARGETRE:SCI_REPLACETARGET, (WPARAM)stringSizeReplace, (LPARAM)pTextReplace);
|
int replacedLength = (*_ppEditView)->execute(isRegExp?SCI_REPLACETARGETRE:SCI_REPLACETARGET, (WPARAM)stringSizeReplace, (LPARAM)pTextReplace);
|
||||||
|
|
||||||
startPosition = (direction == DIR_UP)?posFind - replacedLength:posFind + replacedLength;
|
startPosition = (direction == DIR_UP)?posFind - replacedLength:posFind + replacedLength;
|
||||||
if ((_isInSelection) && (!isEntire))
|
if ((_isInSelection) && (!isEntire))
|
||||||
{
|
{
|
||||||
endPosition = endPosition - foundTextLen + replacedLength;
|
endPosition = endPosition - foundTextLen + replacedLength;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (direction == DIR_DOWN)
|
if (direction == DIR_DOWN)
|
||||||
endPosition = docLength = docLength - foundTextLen + replacedLength;
|
endPosition = docLength = docLength - foundTextLen + replacedLength;
|
||||||
}
|
}
|
||||||
break; }
|
break; }
|
||||||
case ProcessMarkAll: {
|
case ProcessMarkAll: {
|
||||||
if (_doStyleFoundToken)
|
if (_doStyleFoundToken)
|
||||||
{
|
{
|
||||||
(*_ppEditView)->execute(SCI_STARTSTYLING, start, STYLING_MASK);
|
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE);
|
||||||
(*_ppEditView)->execute(SCI_SETSTYLING, end - start, SCE_UNIVERSAL_FOUND_STYLE);
|
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
|
||||||
(*_ppEditView)->execute(SCI_COLOURISE, start, end+1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (_doMarkLine)
|
if (_doMarkLine)
|
||||||
{
|
{
|
||||||
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posFind);
|
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posFind);
|
||||||
int state = (*_ppEditView)->execute(SCI_MARKERGET, lineNumber);
|
int state = (*_ppEditView)->execute(SCI_MARKERGET, lineNumber);
|
||||||
|
|
||||||
if (!(state & (1 << MARK_BOOKMARK)))
|
if (!(state & (1 << MARK_BOOKMARK)))
|
||||||
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
|
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
|
||||||
}
|
}
|
||||||
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
|
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
|
||||||
break; }
|
break; }
|
||||||
case ProcessMarkAll_2: {
|
case ProcessMarkAll_2: {
|
||||||
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_2);
|
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_2);
|
||||||
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
|
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
|
||||||
|
|
||||||
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
|
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
|
||||||
break; }
|
break; }
|
||||||
case ProcessCountAll: {
|
case ProcessCountAll: {
|
||||||
startPosition = posFind + foundTextLen;
|
startPosition = posFind + foundTextLen;
|
||||||
break; }
|
break; }
|
||||||
default: {
|
default: {
|
||||||
delete [] pTextFind;
|
delete [] pTextFind;
|
||||||
delete [] pTextReplace;
|
delete [] pTextReplace;
|
||||||
return nbReplaced;
|
return nbReplaced;
|
||||||
break; }
|
break; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
|
||||||
|
|
||||||
// smart hilighting
|
// smart hilighting
|
||||||
execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_FOUND_STYLE_2, INDIC_ROUNDBOX);
|
execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_FOUND_STYLE_2, INDIC_ROUNDBOX);
|
||||||
execute(SCI_INDICSETFORE, SCE_UNIVERSAL_FOUND_STYLE_2, blue);
|
execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_FOUND_STYLE, INDIC_ROUNDBOX);
|
||||||
|
|
||||||
_pParameter = NppParameters::getInstance();
|
_pParameter = NppParameters::getInstance();
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
||||||
if (iFind != -1)
|
if (iFind != -1)
|
||||||
{
|
{
|
||||||
Style & styleFind = stylers.getStyler(iFind);
|
Style & styleFind = stylers.getStyler(iFind);
|
||||||
setSpecialStyle(styleFind);
|
setSpecialIndicator(styleFind);
|
||||||
}
|
}
|
||||||
|
|
||||||
iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE_2);
|
iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE_2);
|
||||||
|
|
|
@ -611,6 +611,12 @@ public:
|
||||||
|
|
||||||
void recalcHorizontalScrollbar();
|
void recalcHorizontalScrollbar();
|
||||||
void foldChanged(int line, int levelNow, int levelPrev);
|
void foldChanged(int line, int levelNow, int levelPrev);
|
||||||
|
void clearIndicator(int indicatorNumber) {
|
||||||
|
int docStart = 0;
|
||||||
|
int docEnd = getCurrentDocLen();
|
||||||
|
execute(SCI_SETINDICATORCURRENT, indicatorNumber);
|
||||||
|
execute(SCI_INDICATORCLEARRANGE, docStart, docEnd-docStart);
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static HINSTANCE _hLib;
|
static HINSTANCE _hLib;
|
||||||
|
@ -670,13 +676,6 @@ protected:
|
||||||
void setStyle(Style styleToSet); //NOT by reference (style edited)
|
void setStyle(Style styleToSet); //NOT by reference (style edited)
|
||||||
void setSpecialStyle(Style & styleToSet); //by reference
|
void setSpecialStyle(Style & styleToSet); //by reference
|
||||||
void setSpecialIndicator(Style & styleToSet);
|
void setSpecialIndicator(Style & styleToSet);
|
||||||
void clearIndicator(int indicatorNumber) {
|
|
||||||
int docStart = 0;
|
|
||||||
int docEnd = getCurrentDocLen();
|
|
||||||
execute(SCI_SETINDICATORCURRENT, indicatorNumber);
|
|
||||||
execute(SCI_INDICATORCLEARRANGE, docStart, docEnd-docStart);
|
|
||||||
};
|
|
||||||
|
|
||||||
void setCppLexer(LangType type);
|
void setCppLexer(LangType type);
|
||||||
void setXmlLexer(LangType type);
|
void setXmlLexer(LangType type);
|
||||||
void setUserLexer();
|
void setUserLexer();
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
#ifndef RESOURCE_H
|
#ifndef RESOURCE_H
|
||||||
#define RESOURCE_H
|
#define RESOURCE_H
|
||||||
|
|
||||||
#define NOTEPAD_PLUS_VERSION "Notepad++ v4.8.5"
|
#define NOTEPAD_PLUS_VERSION "Notepad++ v4.9"
|
||||||
#define VERSION_VALUE "4.85\0" // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71
|
#define VERSION_VALUE "4.9\0" // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71
|
||||||
#define VERSION_DIGITALVALUE 4, 8, 5, 0
|
#define VERSION_DIGITALVALUE 4, 9, 0, 0
|
||||||
|
|
||||||
#ifndef IDC_STATIC
|
#ifndef IDC_STATIC
|
||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
|
|
Loading…
Reference in New Issue