aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2011-04-27 12:57:15 +1000
committernyamatongwe <unknown>2011-04-27 12:57:15 +1000
commit56ed1e9e1c7f02aa7a8110c3b084690822e334c5 (patch)
treef2f6a13a7287d40121bf3078388276c98e9f34c8 /src
parentfaf8032d98758218e2ae4dd1380aa6e4ecded41d (diff)
downloadscintilla-mirror-56ed1e9e1c7f02aa7a8110c3b084690822e334c5.tar.gz
Optimize fold marker highlight. Feature #3282649.
From Jérôme LAFORGE.
Diffstat (limited to 'src')
-rw-r--r--src/Document.cxx19
-rw-r--r--src/Document.h2
-rw-r--r--src/Editor.cxx4
3 files changed, 15 insertions, 10 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index b9b284e96..eb818b515 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -355,16 +355,18 @@ int Document::GetFoldParent(int line) {
}
}
-void Document::GetHighlightDelimiters(int line, HighlightDelimiter &highlightDelimiter) {
+void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, int line, int topLine, int bottomLine) {
+ int noNeedToParseBefore = Platform::Minimum(line, topLine) - 1;
+ int noNeedToParseAfter = Platform::Maximum(line, bottomLine) + 1;
int endLine = LineFromPosition(Length());
- int beginFoldBlock = -1;
+ int beginFoldBlock = noNeedToParseBefore;
int endFoldBlock = -1;
- int beginMarginCorrectlyDrawnZone = -1;
- int endMarginCorrectlyDrawnZone = endLine + 1;
+ int beginMarginCorrectlyDrawnZone = noNeedToParseBefore;
+ int endMarginCorrectlyDrawnZone = noNeedToParseAfter;
int endOfTailOfWhiteFlag = -1; //endOfTailOfWhiteFlag points the last SC_FOLDLEVELWHITEFLAG if follow a fold block. Otherwise endOfTailOfWhiteFlag points end of fold block.
int level = GetLevel(line);
int levelNumber = -1;
- int lineLookLevel = -1;
+ int lineLookLevel = 0;
int lineLookLevelNumber = -1;
int lineLook = line;
bool beginFoldBlockFound = false;
@@ -375,7 +377,7 @@ void Document::GetHighlightDelimiters(int line, HighlightDelimiter &highlightDel
/*******************************************************************************/
/* search backward (beginFoldBlock & beginMarginCorrectlyDrawnZone) */
/*******************************************************************************/
- for (endOfTailOfWhiteFlag = line; lineLook >= 0 && (!beginFoldBlockFound || !beginMarginCorrectlyDrawnZoneFound); --lineLook) {
+ for (endOfTailOfWhiteFlag = line; (lineLook > noNeedToParseBefore || (lineLookLevel & SC_FOLDLEVELWHITEFLAG)) && (!beginFoldBlockFound || !beginMarginCorrectlyDrawnZoneFound); --lineLook) {
lineLookLevel = GetLevel(lineLook);
if (levelNumber != -1) {
lineLookLevelNumber = lineLookLevel & SC_FOLDLEVELNUMBERMASK;
@@ -395,7 +397,8 @@ void Document::GetHighlightDelimiters(int line, HighlightDelimiter &highlightDel
beginMarginCorrectlyDrawnZone = lineLook - 1;
}
} else if (!beginFoldBlockFound && lineLookLevelNumber == SC_FOLDLEVELBASE) {
- beginFoldBlockFound = true; //beginFoldBlock already set to -1.
+ beginFoldBlockFound = true;
+ beginFoldBlock = -1;
}
} else if (!(lineLookLevel & SC_FOLDLEVELWHITEFLAG)) {
endOfTailOfWhiteFlag = lineLook - 1;
@@ -421,7 +424,7 @@ void Document::GetHighlightDelimiters(int line, HighlightDelimiter &highlightDel
} else {
lineLook = line;
}
- for (; lineLook <= endLine && (!endFoldBlockFound || !endMarginCorrectlyDrawnZoneFound); ++lineLook) {
+ for (; lineLook < noNeedToParseAfter && (!endFoldBlockFound || !endMarginCorrectlyDrawnZoneFound); ++lineLook) {
lineLookLevel = GetLevel(lineLook);
lineLookLevelNumber = lineLookLevel & SC_FOLDLEVELNUMBERMASK;
if (!endFoldBlockFound && !(lineLookLevel & SC_FOLDLEVELWHITEFLAG) && lineLookLevelNumber < levelNumber) {
diff --git a/src/Document.h b/src/Document.h
index 125a4a0a6..274aa0baa 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -340,7 +340,7 @@ public:
void ClearLevels();
int GetLastChild(int lineParent, int level=-1);
int GetFoldParent(int line);
- void GetHighlightDelimiters(int line, HighlightDelimiter &hDelimiter);
+ void GetHighlightDelimiters(HighlightDelimiter &hDelimiter, int line, int topLine, int bottomLine);
void Indent(bool forwards);
int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 05531a650..afeffc86f 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1730,7 +1730,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
}
}
if (highlightDelimiter.isEnabled && (vs.ms[margin].mask & SC_MASK_FOLDERS)) {
- pdoc->GetHighlightDelimiters(pdoc->LineFromPosition(CurrentPosition()), highlightDelimiter);
+ int lineBack = cs.DocFromDisplay(topLine);
+ int lineFront = cs.DocFromDisplay(((rcMargin.bottom - rcMargin.top) / vs.lineHeight) + topLine) + 1;
+ pdoc->GetHighlightDelimiters(highlightDelimiter, pdoc->LineFromPosition(CurrentPosition()), lineBack, lineFront);
}
// Old code does not know about new markers needed to distinguish all cases