diff options
-rw-r--r-- | src/Document.cxx | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 34 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 2 |
3 files changed, 19 insertions, 19 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 6efcb37fa..12cd735ab 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -559,7 +559,7 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sc } Sci::Position Document::ClampPositionIntoDocument(Sci::Position pos) const { - return std::clamp(pos, static_cast<Sci::Position>(0), Length()); + return std::clamp<Sci::Position>(pos, 0, Length()); } bool Document::IsCrLf(Sci::Position pos) const { diff --git a/src/Editor.cxx b/src/Editor.cxx index 09858df74..d0a8f37b3 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -901,11 +901,11 @@ SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveD Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc); if (moveDir > 0) { // lineDisplay is already line before fold as lines in fold use display line of line after fold - lineDisplay = std::clamp(lineDisplay, static_cast<Sci::Line>(0), pcs->LinesDisplayed()); + lineDisplay = std::clamp<Sci::Line>(lineDisplay, 0, pcs->LinesDisplayed()); return SelectionPosition( pdoc->LineStart(pcs->DocFromDisplay(lineDisplay))); } else { - lineDisplay = std::clamp(lineDisplay - 1, static_cast<Sci::Line>(0), pcs->LinesDisplayed()); + lineDisplay = std::clamp<Sci::Line>(lineDisplay - 1, 0, pcs->LinesDisplayed()); return SelectionPosition( pdoc->LineEnd(pcs->DocFromDisplay(lineDisplay))); } @@ -930,7 +930,7 @@ void Editor::SetLastXChosen() { } void Editor::ScrollTo(Sci::Line line, bool moveThumb) { - const Sci::Line topLineNew = std::clamp(line, static_cast<Sci::Line>(0), MaxScrollPos()); + const Sci::Line topLineNew = std::clamp<Sci::Line>(line, 0, MaxScrollPos()); if (topLineNew != topLine) { // Try to optimise small scrolls #ifndef UNDER_CE @@ -1164,7 +1164,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran } else { // yMarginT must equal to caretYSlop, with a minimum of 1 and // a maximum of slightly less than half the heigth of the text area. - yMarginT = std::clamp(static_cast<Sci::Line>(caretYSlop), static_cast<Sci::Line>(1), halfScreen); + yMarginT = std::clamp<Sci::Line>(caretYSlop, 1, halfScreen); if (bEven) { yMarginB = yMarginT; } else { @@ -1174,7 +1174,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran yMoveT = yMarginT; if (bEven) { if (bJump) { - yMoveT = std::clamp(static_cast<Sci::Line>(caretYSlop * 3), static_cast<Sci::Line>(1), halfScreen); + yMoveT = std::clamp<Sci::Line>(caretYSlop * 3, 1, halfScreen); } yMoveB = yMoveT; } else { @@ -1189,7 +1189,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran } } else { // Not strict yMoveT = bJump ? caretYSlop * 3 : caretYSlop; - yMoveT = std::clamp(yMoveT, static_cast<Sci::Line>(1), halfScreen); + yMoveT = std::clamp<Sci::Line>(yMoveT, 1, halfScreen); if (bEven) { yMoveB = yMoveT; } else { @@ -1239,7 +1239,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran newXY.topLine = std::min(newXY.topLine, lineCaret); } } - newXY.topLine = std::clamp(newXY.topLine, static_cast<Sci::Line>(0), MaxScrollPos()); + newXY.topLine = std::clamp<Sci::Line>(newXY.topLine, 0, MaxScrollPos()); } // Horizontal positioning @@ -1562,7 +1562,7 @@ bool Editor::WrapLines(WrapScope ws) { if (wrapOccurred) { SetScrollBars(); - SetTopLine(std::clamp(goodTopLine, static_cast<Sci::Line>(0), MaxScrollPos())); + SetTopLine(std::clamp<Sci::Line>(goodTopLine, 0, MaxScrollPos())); SetVerticalScrollPos(); } @@ -1814,7 +1814,7 @@ void Editor::SetScrollBars() { // TODO: ensure always showing as many lines as possible // May not be, if, for example, window made larger if (topLine > MaxScrollPos()) { - SetTopLine(std::clamp(topLine, static_cast<Sci::Line>(0), MaxScrollPos())); + SetTopLine(std::clamp<Sci::Line>(topLine, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } @@ -2619,7 +2619,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { if (mh.linesAdded != 0) { // Avoid scrolling of display if change before current display if (mh.position < posTopLine && !CanDeferToLastStep(mh)) { - const Sci::Line newTop = std::clamp(topLine + mh.linesAdded, static_cast<Sci::Line>(0), MaxScrollPos()); + const Sci::Line newTop = std::clamp<Sci::Line>(topLine + mh.linesAdded, 0, MaxScrollPos()); if (newTop != topLine) { SetTopLine(newTop); SetVerticalScrollPos(); @@ -2855,8 +2855,8 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) { } else { const Point pt = LocationFromPosition(sel.MainCaret()); - topLineNew = std::clamp( - topLine + direction * LinesToScroll(), static_cast<Sci::Line>(0), MaxScrollPos()); + topLineNew = std::clamp<Sci::Line>( + topLine + direction * LinesToScroll(), 0, MaxScrollPos()); newPos = SPositionFromLocation( Point::FromInts(lastXChosen - xOffset, static_cast<int>(pt.y) + direction * (vs.lineHeight * static_cast<int>(LinesToScroll()))), @@ -5390,18 +5390,18 @@ void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) { const Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc); if (visiblePolicy & VISIBLE_SLOP) { if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) { - SetTopLine(std::clamp(lineDisplay - visibleSlop, static_cast<Sci::Line>(0), MaxScrollPos())); + SetTopLine(std::clamp<Sci::Line>(lineDisplay - visibleSlop, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } else if ((lineDisplay > topLine + LinesOnScreen() - 1) || ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) { - SetTopLine(std::clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, static_cast<Sci::Line>(0), MaxScrollPos())); + SetTopLine(std::clamp<Sci::Line>(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } } else { if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) { - SetTopLine(std::clamp(lineDisplay - LinesOnScreen() / 2 + 1, static_cast<Sci::Line>(0), MaxScrollPos())); + SetTopLine(std::clamp<Sci::Line>(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } @@ -6003,9 +6003,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->MovePositionOutsideChar(static_cast<Sci::Position>(wParam) + 1, 1, true); case SCI_POSITIONRELATIVE: - return std::clamp(pdoc->GetRelativePosition( + return std::clamp<Sci::Position>(pdoc->GetRelativePosition( static_cast<Sci::Position>(wParam), lParam), - static_cast<Sci::Position>(0), pdoc->Length()); + 0, pdoc->Length()); case SCI_LINESCROLL: ScrollTo(topLine + static_cast<Sci::Line>(lParam)); diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 76f33fa44..1e9d6d5a3 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -458,7 +458,7 @@ void ViewStyle::CalcLargestMarkerHeight() { } int ViewStyle::GetFrameWidth() const { - return static_cast<int>(std::clamp(caretLineFrame, 1, lineHeight / 3)); + return std::clamp(caretLineFrame, 1, lineHeight / 3); } bool ViewStyle::IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const { |