From 9ce4f642c737a90a535c081cce71d79eb85effd0 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 14 Jan 2026 08:45:02 +1100 Subject: Encapsulate updating maximum width for scroll bar adjustment. --- src/EditView.cxx | 22 ++++++++++------------ src/EditView.h | 1 + 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(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(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(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(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(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(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, -- cgit v1.2.3