[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:
donho 2008-04-22 23:04:13 +00:00
parent 936d040e40
commit 65bb6ceb7f
6 changed files with 120 additions and 112 deletions

View File

@ -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);
} }

View File

@ -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

View File

@ -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;
@ -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)
{ {
@ -1132,9 +1124,8 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
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)

View File

@ -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);

View File

@ -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();

View File

@ -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