aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/EditView.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2023-01-15 13:15:03 +1100
committerNeil <nyamatongwe@gmail.com>2023-01-15 13:15:03 +1100
commit75b9e2e143d73d0399ea3a9a8ae5c973fadc4b42 (patch)
treef973fa5f046e6a90556e05d2185000d8fda95cfb /src/EditView.cxx
parentb0b1287f399bc033708ef82a8e799759f14adb29 (diff)
downloadscintilla-mirror-75b9e2e143d73d0399ea3a9a8ae5c973fadc4b42.tar.gz
Simplify DrawIndentGuide and move decision to offset out of loop.
Diffstat (limited to 'src/EditView.cxx')
-rw-r--r--src/EditView.cxx17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 487623865..61d0e53cb 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -2199,8 +2199,8 @@ ColourRGBA InvertedLight(ColourRGBA orig) noexcept {
}
-void EditView::DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, XYPOSITION start, PRectangle rcSegment, bool highlight) {
- const Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0);
+void EditView::DrawIndentGuide(Surface *surface, XYPOSITION start, PRectangle rcSegment, bool highlight, bool offset) {
+ const Point from = Point::FromInts(0, offset ? 1 : 0);
const PRectangle rcCopyArea(start + 1, rcSegment.top,
start + 2, rcSegment.bottom);
surface->Copy(rcCopyArea, from,
@@ -2221,6 +2221,9 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
// Does not take margin into account but not significant
const XYPOSITION xStartVisible = static_cast<XYPOSITION>(subLineStart-xStart);
+ // When lineHeight is odd, dotted indent guides are drawn offset by 1 on odd lines to join together.
+ const bool offsetGuide = (lineVisible & 1) && (vsDraw.lineHeight & 1);
+
// Same baseline used for all text
const XYPOSITION ybase = rcLine.top + vsDraw.maxAscent;
@@ -2299,8 +2302,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
indentCount++) {
if (indentCount > 0) {
const XYPOSITION xIndent = std::floor(indentCount * indentWidth);
- DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
- (ll->xHighlightGuide == xIndent));
+ DrawIndentGuide(surface, xIndent + xStart, rcSegment, ll->xHighlightGuide == xIndent, offsetGuide);
}
}
}
@@ -2391,8 +2393,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
indentCount++) {
if (indentCount > 0) {
const XYPOSITION xIndent = std::floor(indentCount * indentWidth);
- DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
- (ll->xHighlightGuide == xIndent));
+ DrawIndentGuide(surface, xIndent + xStart, rcSegment, ll->xHighlightGuide == xIndent, offsetGuide);
}
}
}
@@ -2464,11 +2465,11 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode
model.pdoc->GetLineIndentation(lineNextWithText));
}
+ const bool offsetGuide = (lineVisible & 1) && (vsDraw.lineHeight & 1);
for (int indentPos = model.pdoc->IndentSize(); indentPos < indentSpace; indentPos += model.pdoc->IndentSize()) {
const XYPOSITION xIndent = std::floor(indentPos * vsDraw.spaceWidth);
if (xIndent < xStartText) {
- DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcLine,
- (ll->xHighlightGuide == xIndent));
+ DrawIndentGuide(surface, xIndent + xStart, rcLine, ll->xHighlightGuide == xIndent, offsetGuide);
}
}
}