[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 :
|
||||
{
|
||||
LangType lt = _pEditView->getCurrentDocType();
|
||||
if (lt == L_TXT)
|
||||
_pEditView->defineDocType(L_CPP);
|
||||
_pEditView->defineDocType(lt);
|
||||
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
||||
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -8248,42 +8244,6 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy)
|
|||
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()
|
||||
{
|
||||
|
@ -8312,8 +8272,19 @@ void Notepad_plus::markSelectedText()
|
|||
char text2Find[MAX_PATH];
|
||||
_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;
|
||||
op._isWholeWord = false;
|
||||
op._isWholeWord = true;
|
||||
_findReplaceDlg.markAll2(text2Find);
|
||||
}
|
||||
|
||||
|
|
|
@ -683,8 +683,55 @@ private:
|
|||
|
||||
void setFileOpenSaveDlgFilters(FileDialog & fDlg);
|
||||
void reloadOnSwitchBack();
|
||||
|
||||
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
|
||||
|
|
|
@ -547,12 +547,12 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||
if (nbCounted < 0)
|
||||
strcpy(result, "The regular expression to search is formed badly.\r\nIs it resulting in nothing?");
|
||||
else
|
||||
{
|
||||
{
|
||||
itoa(nbCounted, result, 10);
|
||||
strcat(result, " tokens are found.");
|
||||
}
|
||||
::MessageBox(_hSelf, result, "", MB_OK);
|
||||
}
|
||||
::MessageBox(_hSelf, result, "", MB_OK);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
|
@ -580,11 +580,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||
{
|
||||
if (_currentStatus == FIND_DLG)
|
||||
{
|
||||
LangType lt = (*_ppEditView)->getCurrentDocType();
|
||||
if (lt == L_TXT)
|
||||
(*_ppEditView)->defineDocType(L_CPP);
|
||||
(*_ppEditView)->defineDocType(lt);
|
||||
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
||||
(*_ppEditView)->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -605,14 +601,14 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||
bool isRegex = (_options._searchType == FindRegex);
|
||||
if (isRegex) { //regex doesnt allow wholeword
|
||||
_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);
|
||||
|
||||
if (isRegex) { //regex doesnt allow upward search
|
||||
::SendDlgItemMessage(_hSelf, IDDIRECTIONDOWN, BM_SETCHECK, BST_CHECKED, 0);
|
||||
::SendDlgItemMessage(_hSelf, IDDIRECTIONUP, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
_options._whichDirection = DIR_DOWN;
|
||||
::SendDlgItemMessage(_hSelf, IDDIRECTIONUP, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
_options._whichDirection = DIR_DOWN;
|
||||
}
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDDIRECTIONUP), (BOOL)!isRegex);
|
||||
return TRUE; }
|
||||
|
@ -795,15 +791,15 @@ bool FindReplaceDlg::processFindNext(const char *txt2find, FindOption *options)
|
|||
if (!pOptions->_isIncremental) { //incremental search doesnt trigger messages
|
||||
const char stringMaxSize = 64;
|
||||
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);
|
||||
if (strlen(pText) > stringMaxSize) {
|
||||
strcat(message, "...");
|
||||
}
|
||||
::MessageBox(_hSelf, message, "Find", MB_OK);
|
||||
// if the dialog is not shown, pass the focus to his parent(ie. Notepad++)
|
||||
if (!::IsWindowVisible(_hSelf))
|
||||
::SetFocus((*_ppEditView)->getHSelf());
|
||||
strcat(message, "...");
|
||||
}
|
||||
::MessageBox(_hSelf, message, "Find", MB_OK);
|
||||
// if the dialog is not shown, pass the focus to his parent(ie. Notepad++)
|
||||
if (!::IsWindowVisible(_hSelf))
|
||||
::SetFocus((*_ppEditView)->getHSelf());
|
||||
}
|
||||
delete [] pText;
|
||||
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 (_doPurge) {
|
||||
if ((_doStyleFoundToken) && (_doPurge))
|
||||
if (_doMarkLine)
|
||||
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
||||
|
||||
if (_doStyleFoundToken)
|
||||
{
|
||||
LangType lt = (*_ppEditView)->getCurrentDocType();
|
||||
if (lt == L_TXT)
|
||||
(*_ppEditView)->defineDocType(L_CPP);
|
||||
(*_ppEditView)->defineDocType(lt);
|
||||
}
|
||||
{
|
||||
(*_ppEditView)->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE);
|
||||
}
|
||||
if (_doStyleFoundToken)
|
||||
{
|
||||
|
@ -1081,7 +1073,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
|
|||
bool isRealloc = false;
|
||||
|
||||
if (_maxNbCharAllocated < nbChar) //line longer than buffer, resize buffer
|
||||
{
|
||||
{
|
||||
isRealloc = true;
|
||||
_maxNbCharAllocated = nbChar;
|
||||
delete [] _line;
|
||||
|
@ -1114,52 +1106,51 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
|
|||
startPosition = posFind + foundTextLen;
|
||||
break; }
|
||||
case ProcessReplaceAll: {
|
||||
(*_ppEditView)->execute(SCI_SETTARGETSTART, start);
|
||||
(*_ppEditView)->execute(SCI_SETTARGETEND, end);
|
||||
(*_ppEditView)->execute(SCI_SETTARGETSTART, start);
|
||||
(*_ppEditView)->execute(SCI_SETTARGETEND, end);
|
||||
int replacedLength = (*_ppEditView)->execute(isRegExp?SCI_REPLACETARGETRE:SCI_REPLACETARGET, (WPARAM)stringSizeReplace, (LPARAM)pTextReplace);
|
||||
|
||||
startPosition = (direction == DIR_UP)?posFind - replacedLength:posFind + replacedLength;
|
||||
if ((_isInSelection) && (!isEntire))
|
||||
{
|
||||
endPosition = endPosition - foundTextLen + replacedLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (direction == DIR_DOWN)
|
||||
endPosition = docLength = docLength - foundTextLen + replacedLength;
|
||||
}
|
||||
startPosition = (direction == DIR_UP)?posFind - replacedLength:posFind + replacedLength;
|
||||
if ((_isInSelection) && (!isEntire))
|
||||
{
|
||||
endPosition = endPosition - foundTextLen + replacedLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (direction == DIR_DOWN)
|
||||
endPosition = docLength = docLength - foundTextLen + replacedLength;
|
||||
}
|
||||
break; }
|
||||
case ProcessMarkAll: {
|
||||
if (_doStyleFoundToken)
|
||||
{
|
||||
(*_ppEditView)->execute(SCI_STARTSTYLING, start, STYLING_MASK);
|
||||
(*_ppEditView)->execute(SCI_SETSTYLING, end - start, SCE_UNIVERSAL_FOUND_STYLE);
|
||||
(*_ppEditView)->execute(SCI_COLOURISE, start, end+1);
|
||||
}
|
||||
if (_doStyleFoundToken)
|
||||
{
|
||||
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE);
|
||||
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
|
||||
}
|
||||
|
||||
if (_doMarkLine)
|
||||
{
|
||||
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posFind);
|
||||
int state = (*_ppEditView)->execute(SCI_MARKERGET, lineNumber);
|
||||
if (_doMarkLine)
|
||||
{
|
||||
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posFind);
|
||||
int state = (*_ppEditView)->execute(SCI_MARKERGET, lineNumber);
|
||||
|
||||
if (!(state & (1 << MARK_BOOKMARK)))
|
||||
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
|
||||
}
|
||||
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
|
||||
if (!(state & (1 << MARK_BOOKMARK)))
|
||||
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
|
||||
}
|
||||
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
|
||||
break; }
|
||||
case ProcessMarkAll_2: {
|
||||
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_2);
|
||||
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
|
||||
|
||||
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
|
||||
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
|
||||
|
||||
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
|
||||
break; }
|
||||
case ProcessCountAll: {
|
||||
startPosition = posFind + foundTextLen;
|
||||
startPosition = posFind + foundTextLen;
|
||||
break; }
|
||||
default: {
|
||||
delete [] pTextFind;
|
||||
delete [] pTextReplace;
|
||||
return nbReplaced;
|
||||
return nbReplaced;
|
||||
break; }
|
||||
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
|
|||
|
||||
// smart hilighting
|
||||
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();
|
||||
|
||||
|
@ -660,7 +660,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
|||
if (iFind != -1)
|
||||
{
|
||||
Style & styleFind = stylers.getStyler(iFind);
|
||||
setSpecialStyle(styleFind);
|
||||
setSpecialIndicator(styleFind);
|
||||
}
|
||||
|
||||
iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE_2);
|
||||
|
|
|
@ -611,6 +611,12 @@ public:
|
|||
|
||||
void recalcHorizontalScrollbar();
|
||||
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:
|
||||
static HINSTANCE _hLib;
|
||||
|
@ -670,13 +676,6 @@ protected:
|
|||
void setStyle(Style styleToSet); //NOT by reference (style edited)
|
||||
void setSpecialStyle(Style & styleToSet); //by reference
|
||||
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 setXmlLexer(LangType type);
|
||||
void setUserLexer();
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#ifndef RESOURCE_H
|
||||
#define RESOURCE_H
|
||||
|
||||
#define NOTEPAD_PLUS_VERSION "Notepad++ v4.8.5"
|
||||
#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_DIGITALVALUE 4, 8, 5, 0
|
||||
#define NOTEPAD_PLUS_VERSION "Notepad++ v4.9"
|
||||
#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, 9, 0, 0
|
||||
|
||||
#ifndef IDC_STATIC
|
||||
#define IDC_STATIC -1
|
||||
|
|
Loading…
Reference in New Issue