aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2019-03-25 11:00:39 +1100
committerNeil <nyamatongwe@gmail.com>2019-03-25 11:00:39 +1100
commit1cf755b51cc643240f60131a8fac5e990cfa5e9f (patch)
tree1a1a8d12e390942dc456b6df0d64d51701c1b9af /src
parent5344ef2aee7eaca738b0bddab8d9025bf49f1137 (diff)
downloadscintilla-mirror-1cf755b51cc643240f60131a8fac5e990cfa5e9f.tar.gz
Use generic versions of ceil, floor, round, lround, trunc from <cmath>.
Diffstat (limited to 'src')
-rw-r--r--src/CallTip.cxx6
-rw-r--r--src/EditView.cxx18
-rw-r--r--src/Indicator.cxx10
-rw-r--r--src/PositionCache.cxx2
4 files changed, 18 insertions, 18 deletions
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index 12df236d7..0cc818d44 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -155,7 +155,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
xEnd = NextTabPos(x);
} else {
std::string_view segText(s + startSeg, endSeg - startSeg);
- xEnd = x + static_cast<int>(lround(surface->WidthText(font, segText)));
+ xEnd = x + static_cast<int>(std::lround(surface->WidthText(font, segText)));
if (draw) {
rcClient.left = static_cast<XYPOSITION>(x);
rcClient.right = static_cast<XYPOSITION>(xEnd);
@@ -176,7 +176,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
// To make a nice small call tip window, it is only sized to fit most normal characters without accents
- const int ascent = static_cast<int>(lround(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font)));
+ const int ascent = static_cast<int>(std::round(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font)));
// For each line...
// Draw the definition in three parts: before highlight, highlighted, after highlight
@@ -280,7 +280,7 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co
rectDown = PRectangle(0,0,0,0);
offsetMain = insetX; // changed to right edge of any arrows
const int width = PaintContents(surfaceMeasure.get(), false) + insetX;
- lineHeight = static_cast<int>(lround(surfaceMeasure->Height(font)));
+ lineHeight = static_cast<int>(std::lround(surfaceMeasure->Height(font)));
// The returned
// rectangle is aligned to the right edge of the last arrow encountered in
diff --git a/src/EditView.cxx b/src/EditView.cxx
index a29df0f2f..fa433d3ef 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -700,7 +700,7 @@ Range EditView::RangeDisplayLine(Surface *surface, const EditModel &model, Sci::
SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditModel &model, PointDocument pt, bool canReturnInvalid,
bool charPosition, bool virtualSpace, const ViewStyle &vs, const PRectangle rcClient) {
pt.x = pt.x - vs.textStart;
- Sci::Line visibleLine = static_cast<int>(floor(pt.y / vs.lineHeight));
+ Sci::Line visibleLine = static_cast<int>(std::floor(pt.y / vs.lineHeight));
if (!canReturnInvalid && (visibleLine < 0))
visibleLine = 0;
const Sci::Line lineDoc = model.pcs->DocFromDisplay(visibleLine);
@@ -878,7 +878,7 @@ static void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle r
surface->FillRectangle(rcSegment, textBack);
}
FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font;
- const int normalCharHeight = static_cast<int>(ceil(vsDraw.styles[STYLE_CONTROLCHAR].capitalHeight));
+ const int normalCharHeight = static_cast<int>(std::ceil(vsDraw.styles[STYLE_CONTROLCHAR].capitalHeight));
PRectangle rcCChar = rcSegment;
rcCChar.left = rcCChar.left + 1;
rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight;
@@ -1261,8 +1261,8 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
if (model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_BOXED) {
surface->PenColour(textFore);
PRectangle rcBox = rcSegment;
- rcBox.left = round(rcSegment.left);
- rcBox.right = round(rcSegment.right);
+ rcBox.left = std::round(rcSegment.left);
+ rcBox.right = std::round(rcSegment.right);
const IntegerRectangle ircBox(rcBox);
surface->MoveTo(ircBox.left, ircBox.top);
surface->LineTo(ircBox.left, ircBox.bottom);
@@ -1479,7 +1479,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
const ViewStyle::CaretShape caretShape = drawDrag ? ViewStyle::CaretShape::line : vsDraw.CaretShapeForMode(model.inOverstrike);
if (drawDrag) {
/* Dragging text, use a line caret */
- rcCaret.left = round(xposCaret - caretWidthOffset);
+ rcCaret.left = std::round(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
} else if ((caretShape == ViewStyle::CaretShape::bar) && drawOverstrikeCaret) {
/* Overstrike (insert mode), use a modified bar caret */
@@ -1497,7 +1497,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
}
} else {
/* Line caret */
- rcCaret.left = round(xposCaret - caretWidthOffset);
+ rcCaret.left = std::round(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
}
const ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour;
@@ -1841,7 +1841,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth;
indentCount++) {
if (indentCount > 0) {
- const XYPOSITION xIndent = floor(indentCount * indentWidth);
+ const XYPOSITION xIndent = std::floor(indentCount * indentWidth);
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
(ll->xHighlightGuide == xIndent));
}
@@ -1920,7 +1920,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth;
indentCount++) {
if (indentCount > 0) {
- const XYPOSITION xIndent = floor(indentCount * indentWidth);
+ const XYPOSITION xIndent = std::floor(indentCount * indentWidth);
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
(ll->xHighlightGuide == xIndent));
}
@@ -1997,7 +1997,7 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode
}
for (int indentPos = model.pdoc->IndentSize(); indentPos < indentSpace; indentPos += model.pdoc->IndentSize()) {
- const XYPOSITION xIndent = floor(indentPos * vsDraw.spaceWidth);
+ const XYPOSITION xIndent = std::floor(indentPos * vsDraw.spaceWidth);
if (xIndent < xStartText) {
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcLine,
(ll->xHighlightGuide == xIndent));
diff --git a/src/Indicator.cxx b/src/Indicator.cxx
index 5ab0a7813..8db760f2b 100644
--- a/src/Indicator.cxx
+++ b/src/Indicator.cxx
@@ -25,8 +25,8 @@ using namespace Scintilla;
static PRectangle PixelGridAlign(const PRectangle &rc) {
// Move left and right side to nearest pixel to avoid blurry visuals
- return PRectangle(round(rc.left), floor(rc.top),
- round(rc.right), floor(rc.bottom));
+ return PRectangle(std::round(rc.left), std::floor(rc.top),
+ std::round(rc.right), std::floor(rc.bottom));
}
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const {
@@ -201,10 +201,10 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
surface->FillRectangle(rcComposition, sacDraw.fore);
} else if (sacDraw.style == INDIC_POINT || sacDraw.style == INDIC_POINTCHARACTER) {
if (rcCharacter.Width() >= 0.1) {
- const XYPOSITION pixelHeight = floor(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase
+ const XYPOSITION pixelHeight = std::floor(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase
const XYPOSITION x = (sacDraw.style == INDIC_POINT) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2);
- const XYPOSITION ix = round(x);
- const XYPOSITION iy = floor(rc.top + 1.0f);
+ const XYPOSITION ix = std::round(x);
+ const XYPOSITION iy = std::floor(rc.top + 1.0f);
Point pts[] = {
Point(ix - pixelHeight, iy + pixelHeight), // Left
Point(ix + pixelHeight, iy + pixelHeight), // Right
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index aeb8d8bcf..65c90dd1d 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -348,7 +348,7 @@ XYPOSITION ScreenLine::RepresentationWidth(size_t position) const {
}
XYPOSITION ScreenLine::TabPositionAfter(XYPOSITION xPosition) const {
- return (floor((xPosition + TabWidthMinimumPixels()) / TabWidth()) + 1) * TabWidth();
+ return (std::floor((xPosition + TabWidthMinimumPixels()) / TabWidth()) + 1) * TabWidth();
}
LineLayoutCache::LineLayoutCache() :