aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2026-01-14 08:45:02 +1100
committerNeil <nyamatongwe@gmail.com>2026-01-14 08:45:02 +1100
commit9ce4f642c737a90a535c081cce71d79eb85effd0 (patch)
tree90cc4a386ffffac739d7d278a3d05fcd84db6c0b
parentf06acbb8f212ca5fdf599b89f4229f1e67f0c41a (diff)
downloadscintilla-mirror-9ce4f642c737a90a535c081cce71d79eb85effd0.tar.gz
Encapsulate updating maximum width for scroll bar adjustment.
-rw-r--r--src/EditView.cxx22
-rw-r--r--src/EditView.h1
2 files changed, 11 insertions, 12 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 3bf0a1fbb..16887b717 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -948,6 +948,10 @@ void FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle
}
+void EditView::UpdateMaxWidth(XYPOSITION width) noexcept {
+ lineWidthMaxSeen = std::max(lineWidthMaxSeen, static_cast<int>(width));
+}
+
void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
Sci::Line line, int xStart, PRectangle rcLine, int subLine, Sci::Position lineEnd, XYPOSITION subLineStart, ColourOptional background) {
@@ -1161,10 +1165,8 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
false, StyleFoldDisplayText, -1);
if (model.trackLineWidth) {
- if (rcSegment.right + 1> lineWidthMaxSeen) {
- // Fold display text border drawn on rcSegment.right with width 1 is the last visible object of the line
- lineWidthMaxSeen = static_cast<int>(rcSegment.right + 1);
- }
+ // Fold display text border drawn on rcSegment.right with width 1 is the last visible object of the line
+ UpdateMaxWidth(rcSegment.right + 1);
}
if (FlagSet(phase, DrawPhase::back)) {
@@ -1288,10 +1290,8 @@ void EditView::DrawEOLAnnotationText(Surface *surface, const EditModel &model, c
false, static_cast<int>(style), -1);
if (model.trackLineWidth) {
- if (rcSegment.right + 1> lineWidthMaxSeen) {
- // EOL Annotation text border drawn on rcSegment.right with width 1 is the last visible object of the line
- lineWidthMaxSeen = static_cast<int>(rcSegment.right + 1);
- }
+ // EOL Annotation text border drawn on rcSegment.right with width 1 is the last visible object of the line
+ UpdateMaxWidth(rcSegment.right + 1);
}
if (FlagSet(phase, DrawPhase::back)) {
@@ -1387,8 +1387,7 @@ void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const Vi
rcSegment.left = static_cast<XYPOSITION>(xStart + indent);
rcSegment.right = rcSegment.left + widthAnnotation;
}
- if (widthAnnotation > lineWidthMaxSeen)
- lineWidthMaxSeen = widthAnnotation;
+ UpdateMaxWidth(widthAnnotation);
}
const int annotationLines = model.pdoc->AnnotationLines(line);
size_t start = 0;
@@ -2612,8 +2611,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, const V
surfaceWindow->Copy(rcCopyArea, from, *pixmapLine);
}
- lineWidthMaxSeen = std::max(
- lineWidthMaxSeen, static_cast<int>(ll->positions[ll->numCharsInLine]));
+ UpdateMaxWidth(ll->positions[ll->numCharsInLine]);
#if defined(TIME_PAINTING)
durCopy += ep.Duration(true);
#endif
diff --git a/src/EditView.h b/src/EditView.h
index 1e28d25c5..2bd27d630 100644
--- a/src/EditView.h
+++ b/src/EditView.h
@@ -133,6 +133,7 @@ public:
Sci::Position StartEndDisplayLine(Surface *surface, const EditModel &model, Sci::Position pos, bool start, const ViewStyle &vs);
private:
+ void UpdateMaxWidth(XYPOSITION width) noexcept;
void DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
Sci::Line line, int xStart, PRectangle rcLine, int subLine, Sci::Position lineEnd, XYPOSITION subLineStart, ColourOptional background);
void DrawFoldDisplayText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,