aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xgtk/PlatGTK.cxx4
-rw-r--r--include/Compat.h17
-rw-r--r--src/CallTip.cxx6
-rw-r--r--src/EditView.cxx10
-rw-r--r--src/Indicator.cxx6
5 files changed, 28 insertions, 15 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 66a2daac2..207c6ceba 100755
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -469,8 +469,8 @@ void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired
void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) {
PenColour(back);
if (context && (rc.left < maxCoordinate)) { // Protect against out of range
- rc.left = lround(rc.left);
- rc.right = lround(rc.right);
+ rc.left = Sci::round(rc.left);
+ rc.right = Sci::round(rc.right);
cairo_rectangle(context, rc.left, rc.top,
rc.right - rc.left, rc.bottom - rc.top);
cairo_fill(context);
diff --git a/include/Compat.h b/include/Compat.h
index 712ff1373..d69a9a2c1 100644
--- a/include/Compat.h
+++ b/include/Compat.h
@@ -6,6 +6,7 @@
#ifdef __cplusplus
+#include <cmath>
#include <cstddef>
#include <memory>
#include <type_traits>
@@ -13,6 +14,18 @@
namespace Sci {
+// std::round (not present on older MacOSX SDKs)
+template<class T>
+T round(T arg) {
+ return round(arg);
+}
+
+// std::lround (not present on older MacOSX SDKs)
+template<class T>
+long lround(T arg) {
+ return lround(arg);
+}
+
// std::make_unique
template<class T> struct _Unique_if {
typedef std::unique_ptr<T> _Single_object;
@@ -37,7 +50,7 @@ template<class T>
template<class T, class... Args>
typename _Unique_if<T>::_Known_bound
make_unique(Args&&...) = delete;
-
+
// std::size
template <typename T, size_t N>
constexpr size_t size(const T (&)[N]) noexcept {
@@ -48,4 +61,4 @@ constexpr size_t size(const T (&)[N]) noexcept {
#endif
-#endif \ No newline at end of file
+#endif
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index db66878ce..a78f8cab0 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -153,7 +153,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
} else if (IsTabCharacter(s[startSeg])) {
xEnd = NextTabPos(x);
} else {
- xEnd = x + static_cast<int>(lround(surface->WidthText(font, s + startSeg, endSeg - startSeg)));
+ xEnd = x + static_cast<int>(Sci::lround(surface->WidthText(font, s + startSeg, endSeg - startSeg)));
if (draw) {
rcClient.left = static_cast<XYPOSITION>(x);
rcClient.right = static_cast<XYPOSITION>(xEnd);
@@ -175,7 +175,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>(round(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font)));
+ const int ascent = static_cast<int>(Sci::round(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font)));
// For each line...
// Draw the definition in three parts: before highlight, highlighted, after highlight
@@ -279,7 +279,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>(Sci::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 3ae7a5d67..9418cf597 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -1173,8 +1173,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 = Sci::round(rcSegment.left);
+ rcBox.right = Sci::round(rcSegment.right);
const IntegerRectangle ircBox(rcBox);
surface->MoveTo(ircBox.left, ircBox.top);
surface->LineTo(ircBox.left, ircBox.bottom);
@@ -1333,7 +1333,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
for (size_t r = 0; (r<model.sel.Count()) || drawDrag; r++) {
const bool mainCaret = r == model.sel.Main();
SelectionPosition posCaret = (drawDrag ? model.posDrag : model.sel.Range(r).caret);
- if ((vsDraw.DrawCaretInsideSelection(model.inOverstrike, imeCaretBlockOverride)) &&
+ if ((vsDraw.DrawCaretInsideSelection(model.inOverstrike, imeCaretBlockOverride)) &&
!drawDrag &&
posCaret > model.sel.Range(r).anchor) {
if (posCaret.VirtualSpace() > 0)
@@ -1381,7 +1381,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 = Sci::round(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
} else if ((caretShape == ViewStyle::CaretShape::bar) && drawOverstrikeCaret) {
/* Overstrike (insert mode), use a modified bar caret */
@@ -1399,7 +1399,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
}
} else {
/* Line caret */
- rcCaret.left = round(xposCaret - caretWidthOffset);
+ rcCaret.left = Sci::round(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
}
const ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour;
diff --git a/src/Indicator.cxx b/src/Indicator.cxx
index 1d594d214..742e59b75 100644
--- a/src/Indicator.cxx
+++ b/src/Indicator.cxx
@@ -24,8 +24,8 @@ using namespace Scintilla;
static PRectangle PixelGridAlign(const PRectangle &rc) noexcept {
// Move left and right side to nearest pixel to avoid blurry visuals
- return PRectangle(round(rc.left), std::floor(rc.top),
- round(rc.right), std::floor(rc.bottom));
+ return PRectangle(Sci::round(rc.left), std::floor(rc.top),
+ Sci::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 {
@@ -202,7 +202,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
if (rcCharacter.Width() >= 0.1) {
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 ix = Sci::round(x);
const XYPOSITION iy = std::floor(rc.top + 1.0f);
Point pts[] = {
Point(ix - pixelHeight, iy + pixelHeight), // Left