aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2009-08-26 10:48:18 +0000
committernyamatongwe <devnull@localhost>2009-08-26 10:48:18 +0000
commit14cfe75a40f8d92df6655d49f22cb325ddad9faf (patch)
tree1d4a17c53614d85917a198b948d6d96e174c7c8a /src
parent22a86737d86366ca685297ba544a1c3cdae08c4d (diff)
downloadscintilla-mirror-14cfe75a40f8d92df6655d49f22cb325ddad9faf.tar.gz
Avoid breaking text into substrings on selection boundaries for drawing
when the selection is empty (thus only needing a caret drawn) or when the selection settings do not need the text drawn as pieces such as when the selection is drawn translucently.
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx9
-rw-r--r--src/PositionCache.cxx20
-rw-r--r--src/PositionCache.h2
3 files changed, 20 insertions, 11 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 9f50e331d..2d438e8db 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -2600,11 +2600,15 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
}
+ bool selBackDrawn = vsDraw.selbackset &&
+ ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA));
+
// Does not take margin into account but not significant
int xStartVisible = subLineStart - xStart;
ll->psel = &sel;
- BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible);
+
+ BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible, selBackDrawn);
int next = bfBack.First();
// Background drawing loop
@@ -2694,7 +2698,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
inIndentation = subLine == 0; // Do not handle indentation except on first subline.
// Foreground drawing loop
- BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible);
+ BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible,
+ ((!twoPhaseDraw && selBackDrawn) || vsDraw.selforeset));
next = bfFore.First();
while (next < lineEnd) {
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 580a1797c..fa2d581e1 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -386,7 +386,7 @@ static int NextBadU(const char *s, int p, int len, int &trailBytes) {
return -1;
}
-BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart) :
+BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart, bool breakForSelection) :
ll(ll_),
lineStart(lineStart_),
lineEnd(lineEnd_),
@@ -412,13 +412,17 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL
nextBreak--;
}
- SelectionSegment segmentLine(SelectionPosition(posLineStart), SelectionPosition(posLineStart + lineEnd));
- for (size_t r=0; r<ll->psel->Count(); r++) {
- SelectionSegment portion = ll->psel->Range(r).Intersect(segmentLine);
- if (portion.start.IsValid())
- Insert(portion.start.Position() - posLineStart - 1);
- if (portion.end.IsValid())
- Insert(portion.end.Position() - posLineStart - 1);
+ if (breakForSelection) {
+ SelectionSegment segmentLine(SelectionPosition(posLineStart), SelectionPosition(posLineStart + lineEnd));
+ for (size_t r=0; r<ll->psel->Count(); r++) {
+ SelectionSegment portion = ll->psel->Range(r).Intersect(segmentLine);
+ if (!(portion.start == portion.end)) {
+ if (portion.start.IsValid())
+ Insert(portion.start.Position() - posLineStart - 1);
+ if (portion.end.IsValid())
+ Insert(portion.end.Position() - posLineStart - 1);
+ }
+ }
}
Insert(ll->edgeColumn - 1);
diff --git a/src/PositionCache.h b/src/PositionCache.h
index a86881070..e99ae5870 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -136,7 +136,7 @@ class BreakFinder {
int subBreak;
void Insert(int val);
public:
- BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart);
+ BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart, bool breakForSelection);
~BreakFinder();
int First();
int Next();