aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2014-03-27 16:15:21 +1100
committerNeil Hodgson <nyamatongwe@gmail.com>2014-03-27 16:15:21 +1100
commitc7062988fae7ef98dc94b4b4956d01cbd4c6226c (patch)
treeb1ae114e1758ffa8a46f9346ef23185373df1986 /src
parentaefef213c2343b1e753664b2e606b91ed68db57b (diff)
downloadscintilla-mirror-c7062988fae7ef98dc94b4b4956d01cbd4c6226c.tar.gz
Improve scrolling by performing styling in methods called before drawing instead of inside drawing
which then caused the drawing to be abandoned, and black blocks to appear on-screen. Discard responsive scrolling overdraw when that overdrawn content is invalid. Style just the visible area instead of the whole document when styling changes run beyond painting area.
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx20
-rw-r--r--src/Editor.h2
2 files changed, 19 insertions, 3 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 6c29e7100..6381f7eab 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -386,6 +386,10 @@ PRectangle Editor::GetClientRectangle() {
return wMain.GetClientPosition();
}
+PRectangle Editor::GetClientDrawingRectangle() {
+ return GetClientRectangle();
+}
+
PRectangle Editor::GetTextRectangle() {
PRectangle rc = GetClientRectangle();
rc.left += vs.textStart;
@@ -649,6 +653,10 @@ void Editor::RedrawRect(PRectangle rc) {
}
}
+void Editor::DiscardOverdraw() {
+ // Overridden on platforms that may draw outside visible area.
+}
+
void Editor::Redraw() {
//Platform::DebugPrintf("Redraw all\n");
PRectangle rcClient = GetClientRectangle();
@@ -659,7 +667,10 @@ void Editor::Redraw() {
}
void Editor::RedrawSelMargin(int line, bool allAfter) {
- if (!AbandonPaint()) {
+ bool abandonDraw = false;
+ if (!wMargin.GetID()) // Margin in main window so may need to abandon and retry
+ abandonDraw = AbandonPaint();
+ if (!abandonDraw) {
if (vs.maskInLine) {
Redraw();
} else {
@@ -6780,7 +6791,7 @@ int Editor::PositionAfterArea(PRectangle rcArea) const {
// The start of the document line after the display line after the area
// This often means that the line after a modification is restyled which helps
// detect multiline comment additions and heals single line comments
- int lineAfter = topLine + (rcArea.bottom - 1) / vs.lineHeight + 1;
+ int lineAfter = TopLineOfMain() + (rcArea.bottom - 1) / vs.lineHeight + 1;
if (lineAfter < cs.LinesDisplayed())
return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1);
else
@@ -6790,7 +6801,7 @@ int Editor::PositionAfterArea(PRectangle rcArea) const {
// Style to a position within the view. If this causes a change at end of last line then
// affects later lines so style all the viewed text.
void Editor::StyleToPositionInView(Position pos) {
- int endWindow = (vs.marginInside) ? (PositionAfterArea(GetClientRectangle())) : (pdoc->Length());
+ int endWindow = PositionAfterArea(GetClientDrawingRectangle());
if (pos > endWindow)
pos = endWindow;
int styleAtEnd = pdoc->StyleAt(pos-1);
@@ -6798,6 +6809,9 @@ void Editor::StyleToPositionInView(Position pos) {
if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) {
// Style at end of line changed so is multi-line change like starting a comment
// so require rest of window to be styled.
+ DiscardOverdraw(); // Prepared bitmaps may be invalid
+ // DiscardOverdraw may have truncated client drawing area so recalculate endWindow
+ endWindow = PositionAfterArea(GetClientDrawingRectangle());
pdoc->EnsureStyledTo(endWindow);
}
}
diff --git a/src/Editor.h b/src/Editor.h
index 588967d64..810175b58 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -338,6 +338,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
Point DocumentPointFromView(Point ptView); // Convert a point from view space to document
int TopLineOfMain() const; // Return the line at Main's y coordinate 0
virtual PRectangle GetClientRectangle();
+ virtual PRectangle GetClientDrawingRectangle();
PRectangle GetTextRectangle();
int LinesOnScreen();
@@ -357,6 +358,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool AbandonPaint();
virtual void RedrawRect(PRectangle rc);
+ virtual void DiscardOverdraw();
virtual void Redraw();
void RedrawSelMargin(int line=-1, bool allAfter=false);
PRectangle RectangleFromRange(int start, int end);