[ENHANCEMENT] (Author: Andreas Jonsson) Enhance folding performance on large document.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@936 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
78a38c1c28
commit
301492a3a6
@ -1922,13 +1922,8 @@ void Notepad_plus::addHotSpot(bool docIsModifing)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int firstVisibleLine = _pEditView->execute(SCI_GETFIRSTVISIBLELINE);
|
||||
int startPos = _pEditView->execute(SCI_POSITIONFROMLINE, _pEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLine));
|
||||
int linesOnScreen = _pEditView->execute(SCI_LINESONSCREEN);
|
||||
int lineCount = _pEditView->execute(SCI_GETLINECOUNT);
|
||||
int endPos = _pEditView->execute(SCI_POSITIONFROMLINE,_pEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLine + min(linesOnScreen, lineCount)));
|
||||
|
||||
int startPos = 0, endPos = -1;
|
||||
_pEditView->getVisibleStartAndEndPosition(&startPos, &endPos);
|
||||
|
||||
_pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX);
|
||||
|
||||
|
@ -1577,7 +1577,9 @@ void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask)
|
||||
void ScintillaEditView::collapse(int level2Collapse, bool mode)
|
||||
{
|
||||
// The following code is needed :
|
||||
execute(SCI_COLOURISE, 0, -1);
|
||||
int startPos = 0, endPos = -1;
|
||||
getVisibleStartAndEndPosition(&startPos, &endPos);
|
||||
execute(SCI_COLOURISE, startPos, endPos);
|
||||
// according to the Scitilla document :
|
||||
// This requests the current lexer or the container (if the lexer is set to SCLEX_CONTAINER)
|
||||
// to style the document between startPos and endPos. If endPos is -1, the document is styled from startPos to the end.
|
||||
@ -1612,7 +1614,9 @@ void ScintillaEditView::foldCurrentPos(bool mode)
|
||||
void ScintillaEditView::fold(int line, bool mode)
|
||||
{
|
||||
// The following code is needed :
|
||||
execute(SCI_COLOURISE, 0, -1);
|
||||
int startPos = 0, endPos = -1;
|
||||
getVisibleStartAndEndPosition(&startPos, &endPos);
|
||||
execute(SCI_COLOURISE, startPos, endPos);
|
||||
// according to the Scitilla document :
|
||||
// This requests the current lexer or the container (if the lexer is set to SCLEX_CONTAINER)
|
||||
// to style the document between startPos and endPos. If endPos is -1, the document is styled from startPos to the end.
|
||||
@ -1730,6 +1734,17 @@ void ScintillaEditView::replaceSelWith(const char * replaceText)
|
||||
execute(SCI_REPLACESEL, 0, (WPARAM)replaceText);
|
||||
}
|
||||
|
||||
void ScintillaEditView::getVisibleStartAndEndPosition(int * startPos, int * endPos)
|
||||
{
|
||||
assert(startPos != nullptr && endPos != nullptr);
|
||||
|
||||
int firstVisibleLine = execute(SCI_GETFIRSTVISIBLELINE);
|
||||
*startPos = execute(SCI_POSITIONFROMLINE, execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLine));
|
||||
int linesOnScreen = execute(SCI_LINESONSCREEN);
|
||||
int lineCount = execute(SCI_GETLINECOUNT);
|
||||
*endPos = execute(SCI_POSITIONFROMLINE, execute(SCI_DOCLINEFROMVISIBLE, firstVisibleLine + min(linesOnScreen, lineCount)));
|
||||
}
|
||||
|
||||
char * ScintillaEditView::getWordFromRange(char * txt, int size, int pos1, int pos2)
|
||||
{
|
||||
if (!size)
|
||||
|
@ -256,6 +256,7 @@ public:
|
||||
return (range.cpMax - range.cpMin);
|
||||
};
|
||||
|
||||
void getVisibleStartAndEndPosition(int * startPos, int * endPos);
|
||||
char * getWordFromRange(char * txt, int size, int pos1, int pos2);
|
||||
char * getSelectedText(char * txt, int size, bool expand = true);
|
||||
char * getWordOnCaretPos(char * txt, int size);
|
||||
|
Loading…
Reference in New Issue
Block a user