diff options
author | Neil <nyamatongwe@gmail.com> | 2014-05-03 18:01:22 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2014-05-03 18:01:22 +1000 |
commit | c3e5215e06bd8ff394a9911b5573969cc55681a0 (patch) | |
tree | 097a99fce5619ad78dd5f66f6de0539e24063e83 /src/Editor.cxx | |
parent | e7f79269406933b3edef09c5e6ece9f0d8a99bad (diff) | |
download | scintilla-mirror-c3e5215e06bd8ff394a9911b5573969cc55681a0.tar.gz |
Turn on MSVC 'possible loss of data' warnings and add explicit casts.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 764 |
1 files changed, 386 insertions, 378 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 946e0fe2b..1e1d7bf07 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -113,7 +113,7 @@ Editor::Editor() { stylesValid = false; technology = SC_TECHNOLOGY_DEFAULT; - scaleRGBAImage = 100; + scaleRGBAImage = 100.0f; cursorMode = SC_CURSORNORMAL; @@ -397,7 +397,7 @@ PRectangle Editor::GetTextRectangle() { int Editor::LinesOnScreen() { PRectangle rcClient = GetClientRectangle(); - int htClient = rcClient.bottom - rcClient.top; + int htClient = static_cast<int>(rcClient.bottom - rcClient.top); //Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1); return htClient / vs.lineHeight; } @@ -506,16 +506,16 @@ Point Editor::LocationFromPosition(int pos) { int Editor::XFromPosition(int pos) { Point pt = LocationFromPosition(pos); - return pt.x - vs.textStart + xOffset; + return static_cast<int>(pt.x) - vs.textStart + xOffset; } int Editor::XFromPosition(SelectionPosition sp) { Point pt = LocationFromPosition(sp); - return pt.x - vs.textStart + xOffset; + return static_cast<int>(pt.x) - vs.textStart + xOffset; } int Editor::LineFromLocation(Point pt) const { - return cs.DocFromDisplay(pt.y / vs.lineHeight + topLine); + return cs.DocFromDisplay(static_cast<int>(pt.y) / vs.lineHeight + topLine); } void Editor::SetTopLine(int topLineNew) { @@ -542,7 +542,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, } pt = DocumentPointFromView(pt); pt.x = pt.x - vs.textStart; - int visibleLine = floor(pt.y / vs.lineHeight); + int visibleLine = static_cast<int>(floor(pt.y / vs.lineHeight)); if (!canReturnInvalid && (visibleLine < 0)) visibleLine = 0; const int lineDoc = cs.DocFromDisplay(visibleLine); @@ -568,8 +568,8 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, } if (virtualSpace) { const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth; - const int spaceOffset = (pt.x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / - spaceWidth; + const int spaceOffset = static_cast<int>( + (pt.x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth); return SelectionPosition(rangeSubLine.end + posLineStart, spaceOffset); } else if (canReturnInvalid) { if (pt.x < (ll->positions[rangeSubLine.end] - subLineStart)) { @@ -611,7 +611,8 @@ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) { return SelectionPosition(pdoc->MovePositionOutsideChar(positionInLine + posLineStart, 1)); } const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth; - const int spaceOffset = (x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth; + const int spaceOffset = static_cast<int>( + (x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth); return SelectionPosition(rangeSubLine.end + posLineStart, spaceOffset); } return SelectionPosition(0); @@ -711,13 +712,13 @@ PRectangle Editor::RectangleFromRange(Range r) { const PRectangle rcClientDrawing = GetClientDrawingRectangle(); PRectangle rc; const int leftTextOverlap = ((xOffset == 0) && (vs.leftMarginWidth > 0)) ? 1 : 0; - rc.left = vs.textStart - leftTextOverlap; - rc.top = (minLine - TopLineOfMain()) * vs.lineHeight; + rc.left = static_cast<XYPOSITION>(vs.textStart - leftTextOverlap); + rc.top = static_cast<XYPOSITION>((minLine - TopLineOfMain()) * vs.lineHeight); if (rc.top < rcClientDrawing.top) rc.top = rcClientDrawing.top; // Extend to right of prepared area if any to prevent artifacts from caret line highlight rc.right = rcClientDrawing.right; - rc.bottom = (maxLine - TopLineOfMain() + 1) * vs.lineHeight; + rc.bottom = static_cast<XYPOSITION>((maxLine - TopLineOfMain() + 1) * vs.lineHeight); return rc; } @@ -1022,7 +1023,7 @@ Point Editor::PointMainCaret() { */ void Editor::SetLastXChosen() { Point pt = PointMainCaret(); - lastXChosen = pt.x + xOffset; + lastXChosen = static_cast<int>(pt.x) + xOffset; } void Editor::ScrollTo(int line, bool moveThumb) { @@ -1167,7 +1168,7 @@ void Editor::MoveCaretInsideView(bool ensureVisible) { false, false, UserVirtualSpace()), Selection::noSel, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { - int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight; + int yOfLastLineFullyDisplayed = static_cast<int>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight; MovePositionTo(SPositionFromLocation( Point(lastXChosen - xOffset, static_cast<int>(rcClient.top) + yOfLastLineFullyDisplayed), false, false, UserVirtualSpace()), @@ -1359,7 +1360,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran // Horizontal positioning if ((options & xysHorizontal) && !Wrapping()) { - const int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2; + const int halfScreen = Platform::Maximum(static_cast<int>(rcClient.Width()) - 4, 4) / 2; const bool bSlop = (caretXPolicy & CARET_SLOP) != 0; const bool bStrict = (caretXPolicy & CARET_STRICT) != 0; const bool bJump = (caretXPolicy & CARET_JUMPS) != 0; @@ -1380,7 +1381,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran if (bEven) { xMarginL = xMarginR; } else { - xMarginL = rcClient.Width() - xMarginR - 4; + xMarginL = static_cast<int>(rcClient.Width()) - xMarginR - 4; } } if (bJump && bEven) { @@ -1395,7 +1396,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran newXY.xOffset -= xMoveL; } else { // Move just enough to allow to display the caret - newXY.xOffset -= (rcClient.left + xMarginL) - pt.x; + newXY.xOffset -= static_cast<int>((rcClient.left + xMarginL) - pt.x); } } else if (pt.x >= rcClient.right - xMarginR) { // Caret is on the right of the display @@ -1403,7 +1404,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran newXY.xOffset += xMoveR; } else { // Move just enough to allow to display the caret - newXY.xOffset += pt.x - (rcClient.right - xMarginR) + 1; + newXY.xOffset += static_cast<int>(pt.x - (rcClient.right - xMarginR) + 1); } } } else { // Not strict @@ -1412,7 +1413,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran if (bEven) { xMoveL = xMoveR; } else { - xMoveL = rcClient.Width() - xMoveR - 4; + xMoveL = static_cast<int>(rcClient.Width()) - xMoveR - 4; } if (pt.x < rcClient.left) { // Caret is on the left of the display @@ -1428,31 +1429,31 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran // Strict or going out of display if (bEven) { // Center caret - newXY.xOffset += pt.x - rcClient.left - halfScreen; + newXY.xOffset += static_cast<int>(pt.x - rcClient.left - halfScreen); } else { // Put caret on right - newXY.xOffset += pt.x - rcClient.right + 1; + newXY.xOffset += static_cast<int>(pt.x - rcClient.right + 1); } } else { // Move just enough to allow to display the caret if (pt.x < rcClient.left) { // Caret is on the left of the display if (bEven) { - newXY.xOffset -= rcClient.left - pt.x; + newXY.xOffset -= static_cast<int>(rcClient.left - pt.x); } else { - newXY.xOffset += pt.x - rcClient.right + 1; + newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1; } } else if (pt.x >= rcClient.right) { // Caret is on the right of the display - newXY.xOffset += pt.x - rcClient.right + 1; + newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1; } } } // In case of a jump (find result) largely out of display, adjust the offset to display the caret if (pt.x + xOffset < rcClient.left + newXY.xOffset) { - newXY.xOffset = pt.x + xOffset - rcClient.left - 2; + newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 2; } else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) { - newXY.xOffset = pt.x + xOffset - rcClient.right + 2; + newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 2; if (vs.caretStyle == CARETSTYLE_BLOCK) { // Ensure we can see a good portion of the block caret newXY.xOffset += static_cast<int>(vs.aveCharWidth); @@ -1461,14 +1462,14 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran if (!(range.caret == range.anchor)) { if (ptAnchor.x < pt.x) { // Shift to left to show anchor or as much of range as possible - int maxOffset = ptAnchor.x + xOffset - rcClient.left - 1; - int minOffset = pt.x + xOffset - rcClient.right + 1; + int maxOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.left) - 1; + int minOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 1; newXY.xOffset = std::min(newXY.xOffset, maxOffset); newXY.xOffset = std::max(newXY.xOffset, minOffset); } else { // Shift to right to show anchor or as much of range as possible - int minOffset = ptAnchor.x + xOffset - rcClient.right + 1; - int maxOffset = pt.x + xOffset - rcClient.left - 1; + int minOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.right) + 1; + int maxOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 1; newXY.xOffset = std::max(newXY.xOffset, minOffset); newXY.xOffset = std::min(newXY.xOffset, maxOffset); } @@ -1494,7 +1495,7 @@ void Editor::SetXYScroll(XYScrollPosition newXY) { PRectangle rcText = GetTextRectangle(); if (horizontalScrollBarVisible && rcText.Width() + xOffset > scrollWidth) { - scrollWidth = xOffset + rcText.Width(); + scrollWidth = xOffset + static_cast<int>(rcText.Width()); SetScrollBars(); } } @@ -1638,9 +1639,9 @@ bool Editor::WrapLines(enum wrapScope ws) { if (lineToWrap < lineToWrapEnd) { PRectangle rcTextArea = GetClientRectangle(); - rcTextArea.left = vs.textStart; + rcTextArea.left = static_cast<XYPOSITION>(vs.textStart); rcTextArea.right -= vs.rightMarginWidth; - wrapWidth = rcTextArea.Width(); + wrapWidth = static_cast<int>(rcTextArea.Width()); RefreshStyleData(); AutoSurface surface(this); if (surface) { @@ -1707,7 +1708,7 @@ void Editor::LinesSplit(int pixelWidth) { if (!RangeContainsProtected(targetStart, targetEnd)) { if (pixelWidth == 0) { PRectangle rcText = GetTextRectangle(); - pixelWidth = rcText.Width(); + pixelWidth = static_cast<int>(rcText.Width()); } int lineStart = pdoc->LineFromPosition(targetStart); int lineEnd = pdoc->LineFromPosition(targetEnd); @@ -1762,8 +1763,8 @@ static int WidthStyledText(Surface *surface, ViewStyle &vs, int styleOffset, size_t endSegment = start; while ((endSegment+1 < len) && (static_cast<size_t>(styles[endSegment+1]) == style)) endSegment++; - width += surface->WidthText(vs.styles[style+styleOffset].font, text + start, - static_cast<int>(endSegment - start + 1)); + width += static_cast<int>(surface->WidthText(vs.styles[style + styleOffset].font, text + start, + static_cast<int>(endSegment - start + 1))); start = endSegment + 1; } return width; @@ -1778,8 +1779,8 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con if (st.multipleStyles) { widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine); } else { - widthSubLine = surface->WidthText(vs.styles[styleOffset + st.style].font, - st.text + start, static_cast<int>(lenLine)); + widthSubLine = static_cast<int>(surface->WidthText(vs.styles[styleOffset + st.style].font, + st.text + start, static_cast<int>(lenLine))); } if (widthSubLine > widthMax) widthMax = widthSubLine; @@ -1792,7 +1793,7 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle const StyledText &st, size_t start, size_t length) { if (st.multipleStyles) { - int x = rcText.left; + int x = static_cast<int>(rcText.left); size_t i = 0; while (i < length) { size_t end = i; @@ -1800,13 +1801,13 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle while (end < length-1 && st.styles[start+end+1] == style) end++; style += styleOffset; - int width = surface->WidthText(vs.styles[style].font, - st.text + start + i, static_cast<int>(end - i + 1)); + int width = static_cast<int>(surface->WidthText(vs.styles[style].font, + st.text + start + i, static_cast<int>(end - i + 1))); PRectangle rcSegment = rcText; - rcSegment.left = x; - rcSegment.right = x + width + 1; + rcSegment.left = static_cast<XYPOSITION>(x); + rcSegment.right = static_cast<XYPOSITION>(x + width + 1); surface->DrawTextNoClip(rcSegment, vs.styles[style].font, - ascent, st.text + start + i, + static_cast<XYPOSITION>(ascent), st.text + start + i, static_cast<int>(end - i + 1), vs.styles[style].fore, vs.styles[style].back); @@ -1835,7 +1836,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { Point ptOrigin = GetVisibleOriginInMain(); rcMargin.Move(0, -ptOrigin.y); rcMargin.left = 0; - rcMargin.right = vs.fixedColumnWidth; + rcMargin.right = static_cast<XYPOSITION>(vs.fixedColumnWidth); if (!rc.Intersects(rcMargin)) return; @@ -1891,9 +1892,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back); } - const int lineStartPaint = (rcMargin.top + ptOrigin.y) / vs.lineHeight; + const int lineStartPaint = static_cast<int>(rcMargin.top + ptOrigin.y) / vs.lineHeight; int visibleLine = TopLineOfMain() + lineStartPaint; - int yposScreen = lineStartPaint * vs.lineHeight - ptOrigin.y; + int yposScreen = lineStartPaint * vs.lineHeight - static_cast<int>(ptOrigin.y); // Work out whether the top line is whitespace located after a // lessening of fold level which implies a 'fold tail' but which should not // be displayed until the last of a sequence of whitespace. @@ -2030,8 +2031,8 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { marks &= vs.ms[margin].mask; PRectangle rcMarker = rcSelMargin; - rcMarker.top = yposScreen; - rcMarker.bottom = yposScreen + vs.lineHeight; + rcMarker.top = static_cast<XYPOSITION>(yposScreen); + rcMarker.bottom = static_cast<XYPOSITION>(yposScreen + vs.lineHeight); if (vs.ms[margin].style == SC_MARGIN_NUMBER) { if (firstSubLine) { char number[100] = ""; @@ -2076,7 +2077,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); rcMarker.left = rcMarker.right - width - 3; } - DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent, + DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, static_cast<int>(rcMarker.top) + vs.maxAscent, stMargin, 0, stMargin.length); } } @@ -2125,19 +2126,19 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { } void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { - int ydiff = (rcTab.bottom - rcTab.top) / 2; - int xhead = rcTab.right - 1 - ydiff; + int ydiff = static_cast<int>(rcTab.bottom - rcTab.top) / 2; + int xhead = static_cast<int>(rcTab.right) - 1 - ydiff; if (xhead <= rcTab.left) { - ydiff -= rcTab.left - xhead - 1; - xhead = rcTab.left - 1; + ydiff -= static_cast<int>(rcTab.left) - xhead - 1; + xhead = static_cast<int>(rcTab.left) - 1; } if ((rcTab.left + 2) < (rcTab.right - 1)) - surface->MoveTo(rcTab.left + 2, ymid); + surface->MoveTo(static_cast<int>(rcTab.left) + 2, ymid); else - surface->MoveTo(rcTab.right - 1, ymid); - surface->LineTo(rcTab.right - 1, ymid); + surface->MoveTo(static_cast<int>(rcTab.right) - 1, ymid); + surface->LineTo(static_cast<int>(rcTab.right) - 1, ymid); surface->LineTo(xhead, ymid - ydiff); - surface->MoveTo(rcTab.right - 1, ymid); + surface->MoveTo(static_cast<int>(rcTab.right) - 1, ymid); surface->LineTo(xhead, ymid + ydiff); } @@ -2433,15 +2434,15 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace, surface->PenColour(wrapColour); enum { xa = 1 }; // gap before start - int w = rcPlace.right - rcPlace.left - xa - 1; + int w = static_cast<int>(rcPlace.right - rcPlace.left) - xa - 1; bool xStraight = isEndMarker; // x-mirrored symbol for start marker - int x0 = xStraight ? rcPlace.left : rcPlace.right - 1; - int y0 = rcPlace.top; + int x0 = static_cast<int>(xStraight ? rcPlace.left : rcPlace.right - 1); + int y0 = static_cast<int>(rcPlace.top); - int dy = (rcPlace.bottom - rcPlace.top) / 5; - int y = (rcPlace.bottom - rcPlace.top) / 2 + dy; + int dy = static_cast<int>(rcPlace.bottom - rcPlace.top) / 5; + int y = static_cast<int>(rcPlace.bottom - rcPlace.top) / 2 + dy; struct Relative { Surface *surface; @@ -2484,8 +2485,8 @@ void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, surface->FillRectangle(rcSegment, textBack); } Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; - int normalCharHeight = surface->Ascent(ctrlCharsFont) - - surface->InternalLeading(ctrlCharsFont); + int normalCharHeight = static_cast<int>(surface->Ascent(ctrlCharsFont) - + surface->InternalLeading(ctrlCharsFont)); PRectangle rcCChar = rcSegment; rcCChar.left = rcCChar.left + 1; rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; @@ -2517,7 +2518,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * spaceWidth; } - XYPOSITION xEol = ll->positions[lineEnd] - subLineStart; + XYPOSITION xEol = static_cast<XYPOSITION>(ll->positions[lineEnd] - subLineStart); // Fill the virtual space and show selections within it if (virtualSpace) { @@ -2532,8 +2533,10 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange); if (!portion.Empty()) { const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; - rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; - rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; + rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - + static_cast<XYPOSITION>(subLineStart) + portion.start.VirtualSpace() * spaceWidth; + rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - + static_cast<XYPOSITION>(subLineStart) + portion.end.VirtualSpace() * spaceWidth; rcSegment.left = (rcSegment.left > rcLine.left) ? rcSegment.left : rcLine.left; rcSegment.right = (rcSegment.right < rcLine.right) ? rcSegment.right : rcLine.right; surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, r == sel.Main())); @@ -2555,8 +2558,8 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin XYPOSITION blobsWidth = 0; if (lastSubLine) { for (int eolPos=ll->numCharsBeforeEOL; eolPos<ll->numCharsInLine; eolPos++) { - rcSegment.left = xStart + ll->positions[eolPos] - subLineStart + virtualSpace; - rcSegment.right = xStart + ll->positions[eolPos+1] - subLineStart + virtualSpace; + rcSegment.left = xStart + ll->positions[eolPos] - static_cast<XYPOSITION>(subLineStart) + virtualSpace; + rcSegment.right = xStart + ll->positions[eolPos + 1] - static_cast<XYPOSITION>(subLineStart) + virtualSpace; blobsWidth += rcSegment.Width(); char hexits[4]; const char *ctrlChar; @@ -2746,23 +2749,23 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { - int indent = pdoc->GetLineIndentation(line) * vsDraw.spaceWidth; + int indent = static_cast<int>(pdoc->GetLineIndentation(line) * vsDraw.spaceWidth); PRectangle rcSegment = rcLine; int annotationLine = subLine - ll->lines; const StyledText stAnnotation = pdoc->AnnotationStyledText(line); if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) { surface->FillRectangle(rcSegment, vsDraw.styles[0].back); - rcSegment.left = xStart; + rcSegment.left = static_cast<XYPOSITION>(xStart); if (trackLineWidth || (vs.annotationVisible == ANNOTATION_BOXED)) { // Only care about calculating width if tracking or need to draw box int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation); if (vs.annotationVisible == ANNOTATION_BOXED) { - widthAnnotation += vsDraw.spaceWidth * 2; // Margins + widthAnnotation += static_cast<int>(vsDraw.spaceWidth * 2); // Margins } if (widthAnnotation > lineWidthMaxSeen) lineWidthMaxSeen = widthAnnotation; if (vs.annotationVisible == ANNOTATION_BOXED) { - rcSegment.left = xStart + indent; + rcSegment.left = static_cast<XYPOSITION>(xStart + indent); rcSegment.right = rcSegment.left + widthAnnotation; } } @@ -2781,21 +2784,21 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back); rcText.left += vsDraw.spaceWidth; } - DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent, + DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, static_cast<int>(rcText.top + vsDraw.maxAscent), stAnnotation, start, lengthAnnotation); if (vs.annotationVisible == ANNOTATION_BOXED) { surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore); - surface->MoveTo(rcSegment.left, rcSegment.top); - surface->LineTo(rcSegment.left, rcSegment.bottom); - surface->MoveTo(rcSegment.right, rcSegment.top); - surface->LineTo(rcSegment.right, rcSegment.bottom); + surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.top)); + surface->LineTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.bottom)); + surface->MoveTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.top)); + surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.bottom)); if (subLine == ll->lines) { - surface->MoveTo(rcSegment.left, rcSegment.top); - surface->LineTo(rcSegment.right, rcSegment.top); + surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.top)); + surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.top)); } if (subLine == ll->lines+annotationLines-1) { - surface->MoveTo(rcSegment.left, rcSegment.bottom - 1); - surface->LineTo(rcSegment.right, rcSegment.bottom - 1); + surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.bottom - 1)); + surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.bottom - 1)); } } } @@ -2897,7 +2900,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // draw continuation rect PRectangle rcPlace = rcSegment; - rcPlace.left = ll->positions[startseg] + xStart - subLineStart; + rcPlace.left = ll->positions[startseg] + xStart - static_cast<XYPOSITION>(subLineStart); rcPlace.right = rcPlace.left + ll->wrapIndent; // default bgnd here.. @@ -2941,8 +2944,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis const int i = ts.end() - 1; const int iDoc = i + posLineStart; - rcSegment.left = ll->positions[ts.start] + xStart - subLineStart; - rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart; + rcSegment.left = ll->positions[ts.start] + xStart - static_cast<XYPOSITION>(subLineStart); + rcSegment.right = ll->positions[ts.end()] + xStart - static_cast<XYPOSITION>(subLineStart); // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. if (rcSegment.Intersects(rcLine)) { @@ -2976,9 +2979,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (ll->chars[cpos + ts.start] == ' ') { if (drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { - PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart, + PRectangle rcSpace( + ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart), rcSegment.top, - ll->positions[cpos + ts.start + 1] + xStart - subLineStart, + ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart), rcSegment.bottom); surface->FillRectangle(rcSpace, vsDraw.whitespaceColours.back); } @@ -3001,8 +3005,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true); if (vsDraw.edgeState == EDGE_LINE) { - int edgeX = vsDraw.theEdge * vsDraw.spaceWidth; - rcSegment.left = edgeX + xStart; + int edgeX = static_cast<int>(vsDraw.theEdge * vsDraw.spaceWidth); + rcSegment.left = static_cast<XYPOSITION>(edgeX + xStart); if ((ll->wrapIndent != 0) && (lineStart != 0)) rcSegment.left -= ll->wrapIndent; rcSegment.right = rcSegment.left + 1; @@ -3033,8 +3037,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis const int i = ts.end() - 1; const int iDoc = i + posLineStart; - rcSegment.left = ll->positions[ts.start] + xStart - subLineStart; - rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart; + rcSegment.left = ll->positions[ts.start] + xStart - static_cast<XYPOSITION>(subLineStart); + rcSegment.right = ll->positions[ts.end()] + xStart - static_cast<XYPOSITION>(subLineStart); // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. if (rcSegment.Intersects(rcLine)) { @@ -3062,11 +3066,11 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis surface->FillRectangle(rcSegment, textBack); } if (inIndentation && vsDraw.viewIndentationGuides == ivReal) { - for (int indentCount = (ll->positions[i] + epsilon) / indentWidth; + for (int indentCount = static_cast<int>((ll->positions[i] + epsilon) / indentWidth); indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { - int xIndent = indentCount * indentWidth; + int xIndent = static_cast<int>(indentCount * indentWidth); DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } @@ -3079,7 +3083,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis surface->PenColour(textFore); PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); - DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2); + DrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2)); } } } else { @@ -3118,24 +3122,26 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (!twoPhaseDraw && drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { textBack = vsDraw.whitespaceColours.back; - PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart, + PRectangle rcSpace( + ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart), rcSegment.top, - ll->positions[cpos + ts.start + 1] + xStart - subLineStart, + ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart), rcSegment.bottom); surface->FillRectangle(rcSpace, textBack); } - PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f); + PRectangle rcDot(xmid + xStart - static_cast<XYPOSITION>(subLineStart), + rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f); rcDot.right = rcDot.left + vs.whitespaceSize; rcDot.bottom = rcDot.top + vs.whitespaceSize; surface->FillRectangle(rcDot, textFore); } } if (inIndentation && vsDraw.viewIndentationGuides == ivReal) { - for (int indentCount = (ll->positions[cpos + ts.start] + epsilon) / indentWidth; + for (int indentCount = static_cast<int>((ll->positions[cpos + ts.start] + epsilon) / indentWidth); indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { - int xIndent = indentCount * indentWidth; + int xIndent = static_cast<int>(indentCount * indentWidth); DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } @@ -3168,7 +3174,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth) && (subLine == 0)) { int indentSpace = pdoc->GetLineIndentation(line); - int xStartText = ll->positions[pdoc->GetLineIndentPosition(line) - posLineStart]; + int xStartText = static_cast<int>(ll->positions[pdoc->GetLineIndentPosition(line) - posLineStart]); // Find the most recent line with some text @@ -3207,7 +3213,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } for (int indentPos = pdoc->IndentSize(); indentPos < indentSpace; indentPos += pdoc->IndentSize()) { - int xIndent = indentPos * vsDraw.spaceWidth; + int xIndent = static_cast<int>(indentPos * vsDraw.spaceWidth); if (xIndent < xStartText) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); @@ -3238,8 +3244,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange); if (!portion.Empty()) { const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; - rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; - rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; + rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - + static_cast<XYPOSITION>(subLineStart) + portion.start.VirtualSpace() * spaceWidth; + rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - + static_cast<XYPOSITION>(subLineStart) + portion.end.VirtualSpace() * spaceWidth; if ((ll->wrapIndent != 0) && (lineStart != 0)) { if ((portion.start.Position() - posLineStart) == lineStart && sel.Range(r).ContainsCharacter(portion.start.Position() - 1)) rcSegment.left -= static_cast<int>(ll->wrapIndent); // indentation added to xStart was truncated to int, so we do the same here @@ -3407,10 +3415,10 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { if (bufferedDraw) { if (!pixmapLine->Initialised()) { PRectangle rcClient = GetClientRectangle(); - pixmapLine->InitPixMap(rcClient.Width(), vs.lineHeight, + pixmapLine->InitPixMap(static_cast<int>(rcClient.Width()), vs.lineHeight, surfaceWindow, wMain.GetID()); pixmapSelMargin->InitPixMap(vs.fixedColumnWidth, - rcClient.Height(), surfaceWindow, wMain.GetID()); + static_cast<int>(rcClient.Height()), surfaceWindow, wMain.GetID()); } } } @@ -3464,7 +3472,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS xposCaret += xStart; if (posDrag.IsValid()) { /* Dragging text, use a line caret */ - rcCaret.left = RoundXYPosition(xposCaret - caretWidthOffset); + rcCaret.left = static_cast<XYPOSITION>(RoundXYPosition(xposCaret - caretWidthOffset)); rcCaret.right = rcCaret.left + vsDraw.caretWidth; } else if (inOverstrike && drawOverstrikeCaret) { /* Overstrike (insert mode), use a modified bar caret */ @@ -3482,7 +3490,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS } } else { /* Line caret */ - rcCaret.left = RoundXYPosition(xposCaret - caretWidthOffset); + rcCaret.left = static_cast<XYPOSITION>(RoundXYPosition(xposCaret - caretWidthOffset)); rcCaret.right = rcCaret.left + vsDraw.caretWidth; } ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour; @@ -3517,9 +3525,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n", // rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); - int screenLinePaintFirst = rcArea.top / vs.lineHeight; + int screenLinePaintFirst = static_cast<int>(rcArea.top) / vs.lineHeight; - int xStart = vs.textStart - xOffset + ptOrigin.x; + int xStart = vs.textStart - xOffset + static_cast<int>(ptOrigin.x); int ypos = 0; if (!bufferedDraw) ypos += screenLinePaintFirst * vs.lineHeight; @@ -3650,8 +3658,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { GetHotSpotRange(ll->hsStart, ll->hsEnd); PRectangle rcLine = rcTextArea; - rcLine.top = ypos; - rcLine.bottom = ypos + vs.lineHeight; + rcLine.top = static_cast<XYPOSITION>(ypos); + rcLine.bottom = static_cast<XYPOSITION>(ypos + vs.lineHeight); bool bracesIgnoreStyle = false; if ((vs.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) || @@ -3661,7 +3669,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1)); // Highlight the current braces if any ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle), - highlightGuideColumn * vs.spaceWidth, bracesIgnoreStyle); + static_cast<int>(highlightGuideColumn * vs.spaceWidth), bracesIgnoreStyle); if (leftTextOverlap && bufferedDraw) { PRectangle rcSpacer = rcLine; @@ -3711,7 +3719,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } lineWidthMaxSeen = Platform::Maximum( - lineWidthMaxSeen, ll->positions[ll->numCharsInLine]); + lineWidthMaxSeen, static_cast<int>(ll->positions[ll->numCharsInLine])); //durCopy += et.Duration(true); } @@ -3730,14 +3738,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { // Right column limit indicator PRectangle rcBeyondEOF = (vs.marginInside) ? rcClient : rcArea; - rcBeyondEOF.left = vs.textStart; + rcBeyondEOF.left = static_cast<XYPOSITION>(vs.textStart); rcBeyondEOF.right = rcBeyondEOF.right - ((vs.marginInside) ? vs.rightMarginWidth : 0); - rcBeyondEOF.top = (cs.LinesDisplayed() - TopLineOfMain()) * vs.lineHeight; + rcBeyondEOF.top = static_cast<XYPOSITION>((cs.LinesDisplayed() - TopLineOfMain()) * vs.lineHeight); if (rcBeyondEOF.top < rcBeyondEOF.bottom) { surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back); if (vs.edgeState == EDGE_LINE) { - int edgeX = vs.theEdge * vs.spaceWidth; - rcBeyondEOF.left = edgeX + xStart; + int edgeX = static_cast<int>(vs.theEdge * vs.spaceWidth); + rcBeyondEOF.left = static_cast<XYPOSITION>(edgeX + xStart); rcBeyondEOF.right = rcBeyondEOF.left + 1; surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour); } @@ -3842,8 +3850,8 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { // Determining width must hapen after fonts have been realised in Refresh int lineNumberWidth = 0; if (lineNumberIndex >= 0) { - lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, - "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace)); + lineNumberWidth = static_cast<int>(surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, + "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace))); vsPrint.ms[lineNumberIndex].width = lineNumberWidth; vsPrint.Refresh(*surfaceMeasure, pdoc->tabInChars); // Recalculate fixedColumnWidth } @@ -3891,11 +3899,11 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { ll.containsCaret = false; - PRectangle rcLine; - rcLine.left = pfr->rc.left; - rcLine.top = ypos; - rcLine.right = pfr->rc.right - 1; - rcLine.bottom = ypos + vsPrint.lineHeight; + PRectangle rcLine( + pfr->rc.left, + ypos, + pfr->rc.right - 1, + ypos + vsPrint.lineHeight); // When document line is wrapped over multiple display lines, find where // to start printing from to ensure a particular position is on the first @@ -3925,7 +3933,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number)); surface->FlushCachedState(); surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font, - ypos + vsPrint.maxAscent, number, istrlen(number), + static_cast<XYPOSITION>(ypos + vsPrint.maxAscent), number, istrlen(number), vsPrint.styles[STYLE_LINENUMBER].fore, vsPrint.styles[STYLE_LINENUMBER].back); } @@ -3937,8 +3945,8 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { if (ypos + vsPrint.lineHeight <= pfr->rc.bottom) { if (visibleLine >= 0) { if (draw) { - rcLine.top = ypos; - rcLine.bottom = ypos + vsPrint.lineHeight; + rcLine.top = static_cast<XYPOSITION>(ypos); + rcLine.bottom = static_cast<XYPOSITION>(ypos + vsPrint.lineHeight); DrawLine(surface, vsPrint, lineDoc, visibleLine, xStart, rcLine, &ll, iwl); } ypos += vsPrint.lineHeight; @@ -3964,7 +3972,7 @@ int Editor::TextWidth(int style, const char *text) { RefreshStyleData(); AutoSurface surface(this); if (surface) { - return surface->WidthText(vs.styles[style].font, text, istrlen(text)); + return static_cast<int>(surface->WidthText(vs.styles[style].font, text, istrlen(text))); } else { return 1; } @@ -4002,7 +4010,7 @@ void Editor::ChangeSize() { SetScrollBars(); if (Wrapping()) { PRectangle rcTextArea = GetClientRectangle(); - rcTextArea.left = vs.textStart; + rcTextArea.left = static_cast<XYPOSITION>(vs.textStart); rcTextArea.right -= vs.rightMarginWidth; if (wrapWidth != rcTextArea.Width()) { NeedWrapping(); @@ -4639,8 +4647,8 @@ void Editor::NotifyDwelling(Point pt, bool state) { SCNotification scn = {}; scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND; scn.position = PositionFromLocation(pt, true); - scn.x = pt.x + vs.ExternalMarginWidth(); - scn.y = pt.y; + scn.x = static_cast<int>(pt.x + vs.ExternalMarginWidth()); + scn.y = static_cast<int>(pt.y); NotifyParent(scn); } @@ -5210,7 +5218,7 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { if (vs.annotationVisible) { int lineDoc = pdoc->LineFromPosition(caretToUse.Position()); Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc)); - int subLine = (pt.y - ptStartLine.y) / vs.lineHeight; + int subLine = static_cast<int>(pt.y - ptStartLine.y) / vs.lineHeight; if (direction < 0 && subLine == 0) { int lineDisplay = cs.DisplayFromDoc(lineDoc); @@ -5222,7 +5230,7 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { } } - int newY = pt.y + (1 + skipLines) * direction * vs.lineHeight; + int newY = static_cast<int>(pt.y) + (1 + skipLines) * direction * vs.lineHeight; SelectionPosition posNew = SPositionFromLocation( Point(lastXChosen - xOffset, newY), false, false, UserVirtualSpace()); @@ -5797,7 +5805,7 @@ int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) { if (msg) { if (consumed) *consumed = true; - return WndProc(msg, 0, 0); + return static_cast<int>(WndProc(msg, 0, 0)); } else { if (consumed) *consumed = false; @@ -5917,7 +5925,7 @@ long Editor::FindText( (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, - wParam, + static_cast<int>(wParam), &lengthFound); if (pos != -1) { ft->chrgText.cpMin = pos; @@ -5963,7 +5971,7 @@ long Editor::SearchText( (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, - wParam, + static_cast<int>(wParam), &lengthFound); } else { pos = pdoc->FindText(searchAnchor, 0, txt, @@ -5971,7 +5979,7 @@ long Editor::SearchText( (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, - wParam, + static_cast<int>(wParam), &lengthFound); } if (pos != -1) { @@ -6125,8 +6133,8 @@ void Editor::DisplayCursor(Window::Cursor c) { } bool Editor::DragThreshold(Point ptStart, Point ptNow) { - int xMove = ptStart.x - ptNow.x; - int yMove = ptStart.y - ptNow.y; + int xMove = static_cast<int>(ptStart.x - ptNow.x); + int yMove = static_cast<int>(ptStart.y - ptNow.y); int distanceSquared = xMove * xMove + yMove * yMove; return distanceSquared > 16; } @@ -6245,8 +6253,8 @@ bool Editor::PointInSelMargin(Point pt) { // Really means: "Point in a margin" if (vs.fixedColumnWidth > 0) { // There is a margin PRectangle rcSelMargin = GetClientRectangle(); - rcSelMargin.right = vs.textStart - vs.leftMarginWidth; - rcSelMargin.left = vs.textStart - vs.fixedColumnWidth; + rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart - vs.leftMarginWidth); + rcSelMargin.left = static_cast<XYPOSITION>(vs.textStart - vs.fixedColumnWidth); return rcSelMargin.Contains(pt); } else { return false; @@ -6520,7 +6528,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie } lastClickTime = curTime; lastClick = pt; - lastXChosen = pt.x + xOffset; + lastXChosen = static_cast<int>(pt.x) + xOffset; ShowCaretAtCurrentPosition(); } @@ -6772,7 +6780,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { SetRectangularRange(); lastClickTime = curTime; lastClick = pt; - lastXChosen = pt.x + xOffset; + lastXChosen = static_cast<int>(pt.x) + xOffset; if (sel.selType == Selection::selStream) { SetLastXChosen(); } @@ -6853,7 +6861,7 @@ int Editor::PositionAfterArea(PRectangle rcArea) const { // The start of the document line after the display line after the area // This often means that the line after a modification is restyled which helps // detect multiline comment additions and heals single line comments - int lineAfter = TopLineOfMain() + (rcArea.bottom - 1) / vs.lineHeight + 1; + int lineAfter = TopLineOfMain() + static_cast<int>(rcArea.bottom - 1) / vs.lineHeight + 1; if (lineAfter < cs.LinesDisplayed()) return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1); else @@ -6907,7 +6915,7 @@ bool Editor::PaintContainsMargin() { return false; } PRectangle rcSelMargin = GetClientRectangle(); - rcSelMargin.right = vs.textStart; + rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart); return PaintContains(rcSelMargin); } @@ -7341,7 +7349,7 @@ void Editor::AddStyledText(char *buffer, int appendLength) { SetEmptySelection(sel.MainCaret() + lengthInserted); } -static bool ValidMargin(unsigned long wParam) { +static bool ValidMargin(uptr_t wParam) { return wParam <= SC_MAX_MARGIN; } @@ -7353,16 +7361,16 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLESETFORE: - vs.styles[wParam].fore = ColourDesired(lParam); + vs.styles[wParam].fore = ColourDesired(static_cast<long>(lParam)); break; case SCI_STYLESETBACK: - vs.styles[wParam].back = ColourDesired(lParam); + vs.styles[wParam].back = ColourDesired(static_cast<long>(lParam)); break; case SCI_STYLESETBOLD: vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL; break; case SCI_STYLESETWEIGHT: - vs.styles[wParam].weight = lParam; + vs.styles[wParam].weight = static_cast<int>(lParam); break; case SCI_STYLESETITALIC: vs.styles[wParam].italic = lParam != 0; @@ -7371,14 +7379,14 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam vs.styles[wParam].eolFilled = lParam != 0; break; case SCI_STYLESETSIZE: - vs.styles[wParam].size = lParam * SC_FONT_SIZE_MULTIPLIER; + vs.styles[wParam].size = static_cast<int>(lParam * SC_FONT_SIZE_MULTIPLIER); break; case SCI_STYLESETSIZEFRACTIONAL: - vs.styles[wParam].size = lParam; + vs.styles[wParam].size = static_cast<int>(lParam); break; case SCI_STYLESETFONT: if (lParam != 0) { - vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam)); + vs.SetStyleFontName(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); } break; case SCI_STYLESETUNDERLINE: @@ -7388,7 +7396,7 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam vs.styles[wParam].caseForce = static_cast<Style::ecaseForced>(lParam); break; case SCI_STYLESETCHARACTERSET: - vs.styles[wParam].characterSet = lParam; + vs.styles[wParam].characterSet = static_cast<int>(lParam); pdoc->SetCaseFolder(NULL); break; case SCI_STYLESETVISIBLE: @@ -7527,11 +7535,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_COPYRANGE: - CopyRangeToClipboard(wParam, lParam); + CopyRangeToClipboard(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_COPYTEXT: - CopyText(wParam, CharPtrFromSPtr(lParam)); + CopyText(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); break; case SCI_PASTE: @@ -7564,12 +7572,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return topLine; case SCI_SETFIRSTVISIBLELINE: - ScrollTo(wParam); + ScrollTo(static_cast<int>(wParam)); break; case SCI_GETLINE: { // Risk of overwriting the end of the buffer - int lineStart = pdoc->LineStart(wParam); - int lineEnd = pdoc->LineStart(wParam + 1); + int lineStart = pdoc->LineStart(static_cast<int>(wParam)); + int lineEnd = pdoc->LineStart(static_cast<int>(wParam + 1)); if (lParam == 0) { return lineEnd - lineStart; } @@ -7626,7 +7634,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_LINEFROMPOSITION: if (static_cast<int>(wParam) < 0) return 0; - return pdoc->LineFromPosition(wParam); + return pdoc->LineFromPosition(static_cast<int>(wParam)); case SCI_POSITIONFROMLINE: if (static_cast<int>(wParam) < 0) @@ -7637,14 +7645,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return -1; //if (wParam > pdoc->LineFromPosition(pdoc->Length())) // Useful test, anyway... // return -1; - return pdoc->LineStart(wParam); + return pdoc->LineStart(static_cast<int>(wParam)); // Replacement of the old Scintilla interpretation of EM_LINELENGTH case SCI_LINELENGTH: if ((static_cast<int>(wParam) < 0) || (static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length()))) return 0; - return pdoc->LineStart(wParam + 1) - pdoc->LineStart(wParam); + return pdoc->LineStart(static_cast<int>(wParam) + 1) - pdoc->LineStart(static_cast<int>(wParam)); case SCI_REPLACESEL: { if (lParam == 0) @@ -7660,14 +7668,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETTARGETSTART: - targetStart = wParam; + targetStart = static_cast<int>(wParam); break; case SCI_GETTARGETSTART: return targetStart; case SCI_SETTARGETEND: - targetEnd = wParam; + targetEnd = static_cast<int>(wParam); break; case SCI_GETTARGETEND: @@ -7685,42 +7693,42 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_REPLACETARGET: PLATFORM_ASSERT(lParam); - return ReplaceTarget(false, CharPtrFromSPtr(lParam), wParam); + return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast<int>(wParam)); case SCI_REPLACETARGETRE: PLATFORM_ASSERT(lParam); - return ReplaceTarget(true, CharPtrFromSPtr(lParam), wParam); + return ReplaceTarget(true, CharPtrFromSPtr(lParam), static_cast<int>(wParam)); case SCI_SEARCHINTARGET: PLATFORM_ASSERT(lParam); - return SearchInTarget(CharPtrFromSPtr(lParam), wParam); + return SearchInTarget(CharPtrFromSPtr(lParam), static_cast<int>(wParam)); case SCI_SETSEARCHFLAGS: - searchFlags = wParam; + searchFlags = static_cast<int>(wParam); break; case SCI_GETSEARCHFLAGS: return searchFlags; case SCI_GETTAG: - return GetTag(CharPtrFromSPtr(lParam), wParam); + return GetTag(CharPtrFromSPtr(lParam), static_cast<int>(wParam)); case SCI_POSITIONBEFORE: - return pdoc->MovePositionOutsideChar(wParam - 1, -1, true); + return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) - 1, -1, true); case SCI_POSITIONAFTER: - return pdoc->MovePositionOutsideChar(wParam + 1, 1, true); + return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) + 1, 1, true); case SCI_POSITIONRELATIVE: - return Platform::Clamp(pdoc->GetRelativePosition(wParam, lParam), 0, pdoc->Length()); + return Platform::Clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length()); case SCI_LINESCROLL: - ScrollTo(topLine + lParam); - HorizontalScrollTo(xOffset + static_cast<int>(wParam) * vs.spaceWidth); + ScrollTo(topLine + static_cast<int>(lParam)); + HorizontalScrollTo(xOffset + static_cast<int>(wParam)* static_cast<int>(vs.spaceWidth)); return 1; case SCI_SETXOFFSET: - xOffset = wParam; + xOffset = static_cast<int>(wParam); ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); SetHorizontalScrollPos(); Redraw(); @@ -7751,17 +7759,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam < 0) { return 0; } else { - Point pt = LocationFromPosition(lParam); + Point pt = LocationFromPosition(static_cast<int>(lParam)); // Convert to view-relative - return pt.x - vs.textStart + vs.fixedColumnWidth; + return static_cast<int>(pt.x) - vs.textStart + vs.fixedColumnWidth; } case SCI_POINTYFROMPOSITION: if (lParam < 0) { return 0; } else { - Point pt = LocationFromPosition(lParam); - return pt.y; + Point pt = LocationFromPosition(static_cast<int>(lParam)); + return static_cast<int>(pt.y); } case SCI_FINDTEXT: @@ -7797,13 +7805,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.rightMarginWidth; case SCI_SETMARGINLEFT: - lastXChosen += lParam - vs.leftMarginWidth; - vs.leftMarginWidth = lParam; + lastXChosen += static_cast<int>(lParam) - vs.leftMarginWidth; + vs.leftMarginWidth = static_cast<int>(lParam); InvalidateStyleRedraw(); break; case SCI_SETMARGINRIGHT: - vs.rightMarginWidth = lParam; + vs.rightMarginWidth = static_cast<int>(lParam); InvalidateStyleRedraw(); break; @@ -7813,20 +7821,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam == 0) return 0; const int lengthInserted = pdoc->InsertString( - CurrentPosition(), CharPtrFromSPtr(lParam), wParam); + CurrentPosition(), CharPtrFromSPtr(lParam), static_cast<int>(wParam)); SetEmptySelection(sel.MainCaret() + lengthInserted); return 0; } case SCI_ADDSTYLEDTEXT: if (lParam) - AddStyledText(CharPtrFromSPtr(lParam), wParam); + AddStyledText(CharPtrFromSPtr(lParam), static_cast<int>(wParam)); return 0; case SCI_INSERTTEXT: { if (lParam == 0) return 0; - int insertPos = wParam; + int insertPos = static_cast<int>(wParam); if (static_cast<int>(wParam) == -1) insertPos = CurrentPosition(); int newCurrent = CurrentPosition(); @@ -7840,11 +7848,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CHANGEINSERTION: PLATFORM_ASSERT(lParam); - pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), wParam); + pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), static_cast<int>(wParam)); return 0; case SCI_APPENDTEXT: - pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), wParam); + pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), static_cast<int>(wParam)); return 0; case SCI_CLEARALL: @@ -7852,7 +7860,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; case SCI_DELETERANGE: - pdoc->DeleteChars(wParam, lParam); + pdoc->DeleteChars(static_cast<int>(wParam), static_cast<int>(lParam)); return 0; case SCI_CLEARDOCUMENTSTYLE: @@ -7878,7 +7886,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return caret.period; case SCI_SETCARETPERIOD: - CaretSetPeriod(wParam); + CaretSetPeriod(static_cast<int>(wParam)); break; case SCI_GETWORDCHARS: @@ -7920,19 +7928,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->Length(); case SCI_ALLOCATE: - pdoc->Allocate(wParam); + pdoc->Allocate(static_cast<int>(wParam)); break; case SCI_GETCHARAT: - return pdoc->CharAt(wParam); + return pdoc->CharAt(static_cast<int>(wParam)); case SCI_SETCURRENTPOS: if (sel.IsRectangular()) { - sel.Rectangular().caret.SetPosition(wParam); + sel.Rectangular().caret.SetPosition(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); } else { - SetSelection(wParam, sel.MainAnchor()); + SetSelection(static_cast<int>(wParam), sel.MainAnchor()); } break; @@ -7941,11 +7949,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETANCHOR: if (sel.IsRectangular()) { - sel.Rectangular().anchor.SetPosition(wParam); + sel.Rectangular().anchor.SetPosition(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); } else { - SetSelection(sel.MainCaret(), wParam); + SetSelection(sel.MainCaret(), static_cast<int>(wParam)); } break; @@ -7953,32 +7961,32 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor(); case SCI_SETSELECTIONSTART: - SetSelection(Platform::Maximum(sel.MainCaret(), wParam), wParam); + SetSelection(Platform::Maximum(sel.MainCaret(), static_cast<int>(wParam)), static_cast<int>(wParam)); break; case SCI_GETSELECTIONSTART: return sel.LimitsForRectangularElseMain().start.Position(); case SCI_SETSELECTIONEND: - SetSelection(wParam, Platform::Minimum(sel.MainAnchor(), wParam)); + SetSelection(static_cast<int>(wParam), Platform::Minimum(sel.MainAnchor(), static_cast<int>(wParam))); break; case SCI_GETSELECTIONEND: return sel.LimitsForRectangularElseMain().end.Position(); case SCI_SETEMPTYSELECTION: - SetEmptySelection(wParam); + SetEmptySelection(static_cast<int>(wParam)); break; case SCI_SETPRINTMAGNIFICATION: - printParameters.magnification = wParam; + printParameters.magnification = static_cast<int>(wParam); break; case SCI_GETPRINTMAGNIFICATION: return printParameters.magnification; case SCI_SETPRINTCOLOURMODE: - printParameters.colourMode = wParam; + printParameters.colourMode = static_cast<int>(wParam); break; case SCI_GETPRINTCOLOURMODE: @@ -7995,7 +8003,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (static_cast<int>(wParam) >= pdoc->Length()) return 0; else - return pdoc->StyleAt(wParam); + return pdoc->StyleAt(static_cast<int>(wParam)); case SCI_REDO: Redo(); @@ -8027,10 +8035,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0; case SCI_MARKERLINEFROMHANDLE: - return pdoc->LineFromHandle(wParam); + return pdoc->LineFromHandle(static_cast<int>(wParam)); case SCI_MARKERDELETEHANDLE: - pdoc->DeleteMarkFromHandle(wParam); + pdoc->DeleteMarkFromHandle(static_cast<int>(wParam)); break; case SCI_GETVIEWWS: @@ -8050,27 +8058,27 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_POSITIONFROMPOINT: - return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam), + return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), false, false); case SCI_POSITIONFROMPOINTCLOSE: - return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam), + return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), true, false); case SCI_CHARPOSITIONFROMPOINT: - return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam), + return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), false, true); case SCI_CHARPOSITIONFROMPOINTCLOSE: - return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam), + return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), true, true); case SCI_GOTOLINE: - GoToLine(wParam); + GoToLine(static_cast<int>(wParam)); break; case SCI_GOTOPOS: - SetEmptySelection(wParam); + SetEmptySelection(static_cast<int>(wParam)); EnsureCaretVisible(); break; @@ -8098,11 +8106,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->eolMode; case SCI_SETEOLMODE: - pdoc->eolMode = wParam; + pdoc->eolMode = static_cast<int>(wParam); break; case SCI_SETLINEENDTYPESALLOWED: - if (pdoc->SetLineEndTypesAllowed(wParam)) { + if (pdoc->SetLineEndTypesAllowed(static_cast<int>(wParam))) { cs.Clear(); cs.InsertLines(0, pdoc->LinesTotal() - 1); SetAnnotationHeights(0, pdoc->LinesTotal()); @@ -8117,17 +8125,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->GetLineEndTypesActive(); case SCI_STARTSTYLING: - pdoc->StartStyling(wParam, static_cast<char>(lParam)); + pdoc->StartStyling(static_cast<int>(wParam), static_cast<char>(lParam)); break; case SCI_SETSTYLING: - pdoc->SetStyleFor(wParam, static_cast<char>(lParam)); + pdoc->SetStyleFor(static_cast<int>(wParam), static_cast<char>(lParam)); break; case SCI_SETSTYLINGEX: // Specify a complete styling buffer if (lParam == 0) return 0; - pdoc->SetStyles(wParam, CharPtrFromSPtr(lParam)); + pdoc->SetStyles(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); break; case SCI_SETBUFFEREDDRAW: @@ -8156,7 +8164,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETTABWIDTH: if (wParam > 0) { - pdoc->tabInChars = wParam; + pdoc->tabInChars = static_cast<int>(wParam); if (pdoc->indentInChars == 0) pdoc->actualIndentInChars = pdoc->tabInChars; } @@ -8167,7 +8175,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->tabInChars; case SCI_SETINDENT: - pdoc->indentInChars = wParam; + pdoc->indentInChars = static_cast<int>(wParam); if (pdoc->indentInChars != 0) pdoc->actualIndentInChars = pdoc->indentInChars; else @@ -8187,14 +8195,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->useTabs; case SCI_SETLINEINDENTATION: - pdoc->SetLineIndentation(wParam, lParam); + pdoc->SetLineIndentation(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_GETLINEINDENTATION: - return pdoc->GetLineIndentation(wParam); + return pdoc->GetLineIndentation(static_cast<int>(wParam)); case SCI_GETLINEINDENTPOSITION: - return pdoc->GetLineIndentPosition(wParam); + return pdoc->GetLineIndentPosition(static_cast<int>(wParam)); case SCI_SETTABINDENTS: pdoc->tabIndents = wParam != 0; @@ -8211,7 +8219,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->backspaceUnindents; case SCI_SETMOUSEDWELLTIME: - dwellDelay = wParam; + dwellDelay = static_cast<int>(wParam); ticksToDwell = dwellDelay; break; @@ -8219,13 +8227,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return dwellDelay; case SCI_WORDSTARTPOSITION: - return pdoc->ExtendWordSelect(wParam, -1, lParam != 0); + return pdoc->ExtendWordSelect(static_cast<int>(wParam), -1, lParam != 0); case SCI_WORDENDPOSITION: - return pdoc->ExtendWordSelect(wParam, 1, lParam != 0); + return pdoc->ExtendWordSelect(static_cast<int>(wParam), 1, lParam != 0); case SCI_SETWRAPMODE: - if (vs.SetWrapState(wParam)) { + if (vs.SetWrapState(static_cast<int>(wParam))) { xOffset = 0; ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); InvalidateStyleRedraw(); @@ -8237,7 +8245,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapState; case SCI_SETWRAPVISUALFLAGS: - if (vs.SetWrapVisualFlags(wParam)) { + if (vs.SetWrapVisualFlags(static_cast<int>(wParam))) { InvalidateStyleRedraw(); ReconfigureScrollBars(); } @@ -8247,7 +8255,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapVisualFlags; case SCI_SETWRAPVISUALFLAGSLOCATION: - if (vs.SetWrapVisualFlagsLocation(wParam)) { + if (vs.SetWrapVisualFlagsLocation(static_cast<int>(wParam))) { InvalidateStyleRedraw(); } break; @@ -8256,7 +8264,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapVisualFlagsLocation; case SCI_SETWRAPSTARTINDENT: - if (vs.SetWrapVisualStartIndent(wParam)) { + if (vs.SetWrapVisualStartIndent(static_cast<int>(wParam))) { InvalidateStyleRedraw(); ReconfigureScrollBars(); } @@ -8266,7 +8274,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapVisualStartIndent; case SCI_SETWRAPINDENTMODE: - if (vs.SetWrapIndentMode(wParam)) { + if (vs.SetWrapIndentMode(static_cast<int>(wParam))) { InvalidateStyleRedraw(); ReconfigureScrollBars(); } @@ -8276,7 +8284,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapIndentMode; case SCI_SETLAYOUTCACHE: - llc.SetLevel(wParam); + llc.SetLevel(static_cast<int>(wParam)); break; case SCI_GETLAYOUTCACHE: @@ -8293,7 +8301,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { PLATFORM_ASSERT(wParam > 0); if ((wParam > 0) && (wParam != static_cast<unsigned int >(scrollWidth))) { lineWidthMaxSeen = 0; - scrollWidth = wParam; + scrollWidth = static_cast<int>(wParam); SetScrollBars(); } break; @@ -8313,13 +8321,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_LINESSPLIT: - LinesSplit(wParam); + LinesSplit(static_cast<int>(wParam)); break; case SCI_TEXTWIDTH: PLATFORM_ASSERT(wParam < vs.styles.size()); PLATFORM_ASSERT(lParam); - return TextWidth(wParam, CharPtrFromSPtr(lParam)); + return TextWidth(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); case SCI_TEXTHEIGHT: return vs.lineHeight; @@ -8338,7 +8346,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETCARETSTICKY: PLATFORM_ASSERT(wParam <= SC_CARETSTICKY_WHITESPACE); if (wParam <= SC_CARETSTICKY_WHITESPACE) { - caretSticky = wParam; + caretSticky = static_cast<int>(wParam); } break; @@ -8350,10 +8358,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETCOLUMN: - return pdoc->GetColumn(wParam); + return pdoc->GetColumn(static_cast<int>(wParam)); case SCI_FINDCOLUMN: - return pdoc->FindColumn(wParam, lParam); + return pdoc->FindColumn(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_SETHSCROLLBAR : if (horizontalScrollBarVisible != (wParam != 0)) { @@ -8389,7 +8397,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETHIGHLIGHTGUIDE: if ((highlightGuideColumn != static_cast<int>(wParam)) || (wParam > 0)) { - highlightGuideColumn = wParam; + highlightGuideColumn = static_cast<int>(wParam); Redraw(); } break; @@ -8398,11 +8406,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return highlightGuideColumn; case SCI_GETLINEENDPOSITION: - return pdoc->LineEnd(wParam); + return pdoc->LineEnd(static_cast<int>(wParam)); case SCI_SETCODEPAGE: - if (ValidCodePage(wParam)) { - if (pdoc->SetDBCSCodePage(wParam)) { + if (ValidCodePage(static_cast<int>(wParam))) { + if (pdoc->SetDBCSCodePage(static_cast<int>(wParam))) { cs.Clear(); cs.InsertLines(0, pdoc->LinesTotal() - 1); SetAnnotationHeights(0, pdoc->LinesTotal()); @@ -8427,7 +8435,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { // Marker definition and setting case SCI_MARKERDEFINE: if (wParam <= MARKER_MAX) { - vs.markers[wParam].markType = lParam; + vs.markers[wParam].markType = static_cast<int>(lParam); vs.CalcLargestMarkerHeight(); } InvalidateStyleData(); @@ -8442,13 +8450,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_MARKERSETFORE: if (wParam <= MARKER_MAX) - vs.markers[wParam].fore = ColourDesired(lParam); + vs.markers[wParam].fore = ColourDesired(static_cast<long>(lParam)); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSETBACKSELECTED: if (wParam <= MARKER_MAX) - vs.markers[wParam].backSelected = ColourDesired(lParam); + vs.markers[wParam].backSelected = ColourDesired(static_cast<long>(lParam)); InvalidateStyleData(); RedrawSelMargin(); break; @@ -8458,26 +8466,26 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_MARKERSETBACK: if (wParam <= MARKER_MAX) - vs.markers[wParam].back = ColourDesired(lParam); + vs.markers[wParam].back = ColourDesired(static_cast<long>(lParam)); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSETALPHA: if (wParam <= MARKER_MAX) - vs.markers[wParam].alpha = lParam; + vs.markers[wParam].alpha = static_cast<int>(lParam); InvalidateStyleRedraw(); break; case SCI_MARKERADD: { - int markerID = pdoc->AddMark(wParam, lParam); + int markerID = pdoc->AddMark(static_cast<int>(wParam), static_cast<int>(lParam)); return markerID; } case SCI_MARKERADDSET: if (lParam != 0) - pdoc->AddMarkSet(wParam, lParam); + pdoc->AddMarkSet(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_MARKERDELETE: - pdoc->DeleteMark(wParam, lParam); + pdoc->DeleteMark(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_MARKERDELETEALL: @@ -8485,13 +8493,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_MARKERGET: - return pdoc->GetMark(wParam); + return pdoc->GetMark(static_cast<int>(wParam)); case SCI_MARKERNEXT: - return pdoc->MarkerNext(wParam, lParam); + return pdoc->MarkerNext(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_MARKERPREVIOUS: { - for (int iLine = wParam; iLine >= 0; iLine--) { + for (int iLine = static_cast<int>(wParam); iLine >= 0; iLine--) { if ((pdoc->GetMark(iLine) & lParam) != 0) return iLine; } @@ -8508,20 +8516,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_RGBAIMAGESETWIDTH: - sizeRGBAImage.x = wParam; + sizeRGBAImage.x = static_cast<XYPOSITION>(wParam); break; case SCI_RGBAIMAGESETHEIGHT: - sizeRGBAImage.y = wParam; + sizeRGBAImage.y = static_cast<XYPOSITION>(wParam); break; case SCI_RGBAIMAGESETSCALE: - scaleRGBAImage = wParam; + scaleRGBAImage = static_cast<float>(wParam); break; case SCI_MARKERDEFINERGBAIMAGE: if (wParam <= MARKER_MAX) { - vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0, reinterpret_cast<unsigned char *>(lParam)); + vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0f, reinterpret_cast<unsigned char *>(lParam)); vs.CalcLargestMarkerHeight(); } InvalidateStyleData(); @@ -8530,7 +8538,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETMARGINTYPEN: if (ValidMargin(wParam)) { - vs.ms[wParam].style = lParam; + vs.ms[wParam].style = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8545,8 +8553,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (ValidMargin(wParam)) { // Short-circuit if the width is unchanged, to avoid unnecessary redraw. if (vs.ms[wParam].width != lParam) { - lastXChosen += lParam - vs.ms[wParam].width; - vs.ms[wParam].width = lParam; + lastXChosen += static_cast<int>(lParam) - vs.ms[wParam].width; + vs.ms[wParam].width = static_cast<int>(lParam); InvalidateStyleRedraw(); } } @@ -8560,7 +8568,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETMARGINMASKN: if (ValidMargin(wParam)) { - vs.ms[wParam].mask = lParam; + vs.ms[wParam].mask = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8586,7 +8594,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETMARGINCURSORN: if (ValidMargin(wParam)) - vs.ms[wParam].cursor = lParam; + vs.ms[wParam].cursor = static_cast<int>(lParam); break; case SCI_GETMARGINCURSORN: @@ -8641,17 +8649,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETSTYLEBITS: vs.EnsureStyle((1 << wParam) - 1); - pdoc->SetStylingBits(wParam); + pdoc->SetStylingBits(static_cast<int>(wParam)); break; case SCI_GETSTYLEBITS: return pdoc->stylingBits; case SCI_SETLINESTATE: - return pdoc->SetLineState(wParam, lParam); + return pdoc->SetLineState(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_GETLINESTATE: - return pdoc->GetLineState(wParam); + return pdoc->GetLineState(static_cast<int>(wParam)); case SCI_GETMAXLINESTATE: return pdoc->GetMaxLineState(); @@ -8672,114 +8680,114 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETCARETLINEBACK: return vs.caretLineBackground.AsLong(); case SCI_SETCARETLINEBACK: - vs.caretLineBackground = wParam; + vs.caretLineBackground = static_cast<int>(wParam); InvalidateStyleRedraw(); break; case SCI_GETCARETLINEBACKALPHA: return vs.caretLineAlpha; case SCI_SETCARETLINEBACKALPHA: - vs.caretLineAlpha = wParam; + vs.caretLineAlpha = static_cast<int>(wParam); InvalidateStyleRedraw(); break; // Folding messages case SCI_VISIBLEFROMDOCLINE: - return cs.DisplayFromDoc(wParam); + return cs.DisplayFromDoc(static_cast<int>(wParam)); case SCI_DOCLINEFROMVISIBLE: - return cs.DocFromDisplay(wParam); + return cs.DocFromDisplay(static_cast<int>(wParam)); case SCI_WRAPCOUNT: - return WrapCount(wParam); + return WrapCount(static_cast<int>(wParam)); case SCI_SETFOLDLEVEL: { - int prev = pdoc->SetLevel(wParam, lParam); - if (prev != lParam) + int prev = pdoc->SetLevel(static_cast<int>(wParam), static_cast<int>(lParam)); + if (prev != static_cast<int>(lParam)) RedrawSelMargin(); return prev; } case SCI_GETFOLDLEVEL: - return pdoc->GetLevel(wParam); + return pdoc->GetLevel(static_cast<int>(wParam)); case SCI_GETLASTCHILD: - return pdoc->GetLastChild(wParam, lParam); + return pdoc->GetLastChild(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_GETFOLDPARENT: - return pdoc->GetFoldParent(wParam); + return pdoc->GetFoldParent(static_cast<int>(wParam)); case SCI_SHOWLINES: - cs.SetVisible(wParam, lParam, true); + cs.SetVisible(static_cast<int>(wParam), static_cast<int>(lParam), true); SetScrollBars(); Redraw(); break; case SCI_HIDELINES: if (wParam > 0) - cs.SetVisible(wParam, lParam, false); + cs.SetVisible(static_cast<int>(wParam), static_cast<int>(lParam), false); SetScrollBars(); Redraw(); break; case SCI_GETLINEVISIBLE: - return cs.GetVisible(wParam); + return cs.GetVisible(static_cast<int>(wParam)); case SCI_GETALLLINESVISIBLE: return cs.HiddenLines() ? 0 : 1; case SCI_SETFOLDEXPANDED: - SetFoldExpanded(wParam, lParam != 0); + SetFoldExpanded(static_cast<int>(wParam), lParam != 0); break; case SCI_GETFOLDEXPANDED: - return cs.GetExpanded(wParam); + return cs.GetExpanded(static_cast<int>(wParam)); case SCI_SETAUTOMATICFOLD: - foldAutomatic = wParam; + foldAutomatic = static_cast<int>(wParam); break; case SCI_GETAUTOMATICFOLD: return foldAutomatic; case SCI_SETFOLDFLAGS: - foldFlags = wParam; + foldFlags = static_cast<int>(wParam); Redraw(); break; case SCI_TOGGLEFOLD: - FoldLine(wParam, SC_FOLDACTION_TOGGLE); + FoldLine(static_cast<int>(wParam), SC_FOLDACTION_TOGGLE); break; case SCI_FOLDLINE: - FoldLine(wParam, lParam); + FoldLine(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_FOLDCHILDREN: - FoldExpand(wParam, lParam, pdoc->GetLevel(wParam)); + FoldExpand(static_cast<int>(wParam), static_cast<int>(lParam), pdoc->GetLevel(static_cast<int>(wParam))); break; case SCI_FOLDALL: - FoldAll(wParam); + FoldAll(static_cast<int>(wParam)); break; case SCI_EXPANDCHILDREN: - FoldExpand(wParam, SC_FOLDACTION_EXPAND, lParam); + FoldExpand(static_cast<int>(wParam), SC_FOLDACTION_EXPAND, static_cast<int>(lParam)); break; case SCI_CONTRACTEDFOLDNEXT: - return ContractedFoldNext(wParam); + return ContractedFoldNext(static_cast<int>(wParam)); case SCI_ENSUREVISIBLE: - EnsureLineVisible(wParam, false); + EnsureLineVisible(static_cast<int>(wParam), false); break; case SCI_ENSUREVISIBLEENFORCEPOLICY: - EnsureLineVisible(wParam, true); + EnsureLineVisible(static_cast<int>(wParam), true); break; case SCI_SCROLLRANGE: - ScrollRange(SelectionRange(lParam, wParam)); + ScrollRange(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam))); break; case SCI_SEARCHANCHOR: @@ -8791,18 +8799,18 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return SearchText(iMessage, wParam, lParam); case SCI_SETXCARETPOLICY: - caretXPolicy = wParam; - caretXSlop = lParam; + caretXPolicy = static_cast<int>(wParam); + caretXSlop = static_cast<int>(lParam); break; case SCI_SETYCARETPOLICY: - caretYPolicy = wParam; - caretYSlop = lParam; + caretYPolicy = static_cast<int>(wParam); + caretYSlop = static_cast<int>(lParam); break; case SCI_SETVISIBLEPOLICY: - visiblePolicy = wParam; - visibleSlop = lParam; + visiblePolicy = static_cast<int>(wParam); + visibleSlop = static_cast<int>(lParam); break; case SCI_LINESONSCREEN: @@ -8810,19 +8818,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETSELFORE: vs.selColours.fore = ColourOptional(wParam, lParam); - vs.selAdditionalForeground = ColourDesired(lParam); + vs.selAdditionalForeground = ColourDesired(static_cast<long>(lParam)); InvalidateStyleRedraw(); break; case SCI_SETSELBACK: vs.selColours.back = ColourOptional(wParam, lParam); - vs.selAdditionalBackground = ColourDesired(lParam); + vs.selAdditionalBackground = ColourDesired(static_cast<long>(lParam)); InvalidateStyleRedraw(); break; case SCI_SETSELALPHA: - vs.selAlpha = wParam; - vs.selAdditionalAlpha = wParam; + vs.selAlpha = static_cast<int>(wParam); + vs.selAdditionalAlpha = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -8848,7 +8856,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETCARETFORE: - vs.caretcolour = ColourDesired(wParam); + vs.caretcolour = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; @@ -8857,7 +8865,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETCARETSTYLE: if (wParam <= CARETSTYLE_BLOCK) - vs.caretStyle = wParam; + vs.caretStyle = static_cast<int>(wParam); else /* Default to the line caret */ vs.caretStyle = CARETSTYLE_LINE; @@ -8873,7 +8881,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { else if (wParam >= 3) vs.caretWidth = 3; else - vs.caretWidth = wParam; + vs.caretWidth = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -8881,13 +8889,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.caretWidth; case SCI_ASSIGNCMDKEY: - kmap.AssignCmdKey(Platform::LowShortFromLong(wParam), - Platform::HighShortFromLong(wParam), lParam); + kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)), + Platform::HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam)); break; case SCI_CLEARCMDKEY: - kmap.AssignCmdKey(Platform::LowShortFromLong(wParam), - Platform::HighShortFromLong(wParam), SCI_NULL); + kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)), + Platform::HighShortFromLong(static_cast<long>(wParam)), SCI_NULL); break; case SCI_CLEARALLCMDKEYS: @@ -8896,7 +8904,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETSTYLE: if (wParam <= INDIC_MAX) { - vs.indicators[wParam].style = lParam; + vs.indicators[wParam].style = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8906,7 +8914,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETFORE: if (wParam <= INDIC_MAX) { - vs.indicators[wParam].fore = ColourDesired(lParam); + vs.indicators[wParam].fore = ColourDesired(static_cast<long>(lParam)); InvalidateStyleRedraw(); } break; @@ -8926,7 +8934,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETALPHA: if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) { - vs.indicators[wParam].fillAlpha = lParam; + vs.indicators[wParam].fillAlpha = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8936,7 +8944,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETOUTLINEALPHA: if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) { - vs.indicators[wParam].outlineAlpha = lParam; + vs.indicators[wParam].outlineAlpha = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8945,35 +8953,35 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return (wParam <= INDIC_MAX) ? vs.indicators[wParam].outlineAlpha : 0; case SCI_SETINDICATORCURRENT: - pdoc->decorations.SetCurrentIndicator(wParam); + pdoc->decorations.SetCurrentIndicator(static_cast<int>(wParam)); break; case SCI_GETINDICATORCURRENT: return pdoc->decorations.GetCurrentIndicator(); case SCI_SETINDICATORVALUE: - pdoc->decorations.SetCurrentValue(wParam); + pdoc->decorations.SetCurrentValue(static_cast<int>(wParam)); break; case SCI_GETINDICATORVALUE: return pdoc->decorations.GetCurrentValue(); case SCI_INDICATORFILLRANGE: - pdoc->DecorationFillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam); + pdoc->DecorationFillRange(static_cast<int>(wParam), pdoc->decorations.GetCurrentValue(), static_cast<int>(lParam)); break; case SCI_INDICATORCLEARRANGE: - pdoc->DecorationFillRange(wParam, 0, lParam); + pdoc->DecorationFillRange(static_cast<int>(wParam), 0, static_cast<int>(lParam)); break; case SCI_INDICATORALLONFOR: - return pdoc->decorations.AllOnFor(wParam); + return pdoc->decorations.AllOnFor(static_cast<int>(wParam)); case SCI_INDICATORVALUEAT: - return pdoc->decorations.ValueAt(wParam, lParam); + return pdoc->decorations.ValueAt(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_INDICATORSTART: - return pdoc->decorations.Start(wParam, lParam); + return pdoc->decorations.Start(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_INDICATOREND: - return pdoc->decorations.End(wParam, lParam); + return pdoc->decorations.End(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_LINEDOWN: case SCI_LINEDOWNEXTEND: @@ -9070,13 +9078,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return KeyCommand(iMessage); case SCI_BRACEHIGHLIGHT: - SetBraceHighlight(static_cast<int>(wParam), lParam, STYLE_BRACELIGHT); + SetBraceHighlight(static_cast<int>(wParam), static_cast<int>(lParam), STYLE_BRACELIGHT); break; case SCI_BRACEHIGHLIGHTINDICATOR: if (lParam >= 0 && lParam <= INDIC_MAX) { vs.braceHighlightIndicatorSet = wParam != 0; - vs.braceHighlightIndicator = lParam; + vs.braceHighlightIndicator = static_cast<int>(lParam); } break; @@ -9087,14 +9095,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_BRACEBADLIGHTINDICATOR: if (lParam >= 0 && lParam <= INDIC_MAX) { vs.braceBadLightIndicatorSet = wParam != 0; - vs.braceBadLightIndicator = lParam; + vs.braceBadLightIndicator = static_cast<int>(lParam); } break; case SCI_BRACEMATCH: // wParam is position of char to find brace for, // lParam is maximum amount of text to restyle to find it - return pdoc->BraceMatch(wParam, lParam); + return pdoc->BraceMatch(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_GETVIEWEOL: return vs.viewEOL; @@ -9105,7 +9113,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETZOOM: - vs.zoomLevel = wParam; + vs.zoomLevel = static_cast<int>(wParam); InvalidateStyleRedraw(); NotifyZoom(); break; @@ -9117,7 +9125,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.theEdge; case SCI_SETEDGECOLUMN: - vs.theEdge = wParam; + vs.theEdge = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9125,7 +9133,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.edgeState; case SCI_SETEDGEMODE: - vs.edgeState = wParam; + vs.edgeState = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9133,7 +9141,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.edgecolour.AsLong(); case SCI_SETEDGECOLOUR: - vs.edgecolour = ColourDesired(wParam); + vs.edgecolour = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; @@ -9162,25 +9170,25 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CREATELOADER: { Document *doc = new Document(); doc->AddRef(); - doc->Allocate(wParam); + doc->Allocate(static_cast<int>(wParam)); doc->SetUndoCollection(false); return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc)); } case SCI_SETMODEVENTMASK: - modEventMask = wParam; + modEventMask = static_cast<int>(wParam); return 0; case SCI_GETMODEVENTMASK: return modEventMask; case SCI_CONVERTEOLS: - pdoc->ConvertLineEnds(wParam); + pdoc->ConvertLineEnds(static_cast<int>(wParam)); SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document return 0; case SCI_SETLENGTHFORENCODE: - lengthForEncode = wParam; + lengthForEncode = static_cast<int>(wParam); return 0; case SCI_SELECTIONISRECTANGLE: @@ -9226,8 +9234,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { } case SCI_GETLINESELSTARTPOSITION: case SCI_GETLINESELENDPOSITION: { - SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)), - SelectionPosition(pdoc->LineEnd(wParam))); + SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(static_cast<int>(wParam))), + SelectionPosition(pdoc->LineEnd(static_cast<int>(wParam)))); for (size_t r=0; r<sel.Count(); r++) { SelectionSegment portion = sel.Range(r).Intersect(segmentLine); if (portion.start.IsValid()) { @@ -9252,7 +9260,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return hasFocus; case SCI_SETSTATUS: - errorStatus = wParam; + errorStatus = static_cast<int>(wParam); break; case SCI_GETSTATUS: @@ -9266,7 +9274,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return mouseDownCaptures; case SCI_SETCURSOR: - cursorMode = wParam; + cursorMode = static_cast<int>(wParam); DisplayCursor(Window::cursorText); break; @@ -9274,7 +9282,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return cursorMode; case SCI_SETCONTROLCHARSYMBOL: - vs.controlCharSymbol = wParam; + vs.controlCharSymbol = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9363,13 +9371,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return reinterpret_cast<sptr_t>(pdoc->BufferPointer()); case SCI_GETRANGEPOINTER: - return reinterpret_cast<sptr_t>(pdoc->RangePointer(wParam, lParam)); + return reinterpret_cast<sptr_t>(pdoc->RangePointer(static_cast<int>(wParam), static_cast<int>(lParam))); case SCI_GETGAPPOSITION: return pdoc->GapPosition(); case SCI_SETEXTRAASCENT: - vs.extraAscent = wParam; + vs.extraAscent = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9377,7 +9385,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.extraAscent; case SCI_SETEXTRADESCENT: - vs.extraDescent = wParam; + vs.extraDescent = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9385,7 +9393,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.extraDescent; case SCI_MARGINSETSTYLEOFFSET: - vs.marginStyleOffset = wParam; + vs.marginStyleOffset = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9393,36 +9401,36 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.marginStyleOffset; case SCI_SETMARGINOPTIONS: - marginOptions = wParam; + marginOptions = static_cast<int>(wParam); break; case SCI_GETMARGINOPTIONS: return marginOptions; case SCI_MARGINSETTEXT: - pdoc->MarginSetText(wParam, CharPtrFromSPtr(lParam)); + pdoc->MarginSetText(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); break; case SCI_MARGINGETTEXT: { - const StyledText st = pdoc->MarginStyledText(wParam); + const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam)); return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length); } case SCI_MARGINSETSTYLE: - pdoc->MarginSetStyle(wParam, lParam); + pdoc->MarginSetStyle(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_MARGINGETSTYLE: { - const StyledText st = pdoc->MarginStyledText(wParam); + const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam)); return st.style; } case SCI_MARGINSETSTYLES: - pdoc->MarginSetStyles(wParam, reinterpret_cast<const unsigned char *>(lParam)); + pdoc->MarginSetStyles(static_cast<int>(wParam), reinterpret_cast<const unsigned char *>(lParam)); break; case SCI_MARGINGETSTYLES: { - const StyledText st = pdoc->MarginStyledText(wParam); + const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam)); return BytesResult(lParam, st.styles, st.length); } @@ -9431,48 +9439,48 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_ANNOTATIONSETTEXT: - pdoc->AnnotationSetText(wParam, CharPtrFromSPtr(lParam)); + pdoc->AnnotationSetText(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); break; case SCI_ANNOTATIONGETTEXT: { - const StyledText st = pdoc->AnnotationStyledText(wParam); + const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam)); return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length); } case SCI_ANNOTATIONGETSTYLE: { - const StyledText st = pdoc->AnnotationStyledText(wParam); + const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam)); return st.style; } case SCI_ANNOTATIONSETSTYLE: - pdoc->AnnotationSetStyle(wParam, lParam); + pdoc->AnnotationSetStyle(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_ANNOTATIONSETSTYLES: - pdoc->AnnotationSetStyles(wParam, reinterpret_cast<const unsigned char *>(lParam)); + pdoc->AnnotationSetStyles(static_cast<int>(wParam), reinterpret_cast<const unsigned char *>(lParam)); break; case SCI_ANNOTATIONGETSTYLES: { - const StyledText st = pdoc->AnnotationStyledText(wParam); + const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam)); return BytesResult(lParam, st.styles, st.length); } case SCI_ANNOTATIONGETLINES: - return pdoc->AnnotationLines(wParam); + return pdoc->AnnotationLines(static_cast<int>(wParam)); case SCI_ANNOTATIONCLEARALL: pdoc->AnnotationClearAll(); break; case SCI_ANNOTATIONSETVISIBLE: - SetAnnotationVisible(wParam); + SetAnnotationVisible(static_cast<int>(wParam)); break; case SCI_ANNOTATIONGETVISIBLE: return vs.annotationVisible; case SCI_ANNOTATIONSETSTYLEOFFSET: - vs.annotationStyleOffset = wParam; + vs.annotationStyleOffset = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9484,10 +9492,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_ALLOCATEEXTENDEDSTYLES: - return vs.AllocateExtendedStyles(wParam); + return vs.AllocateExtendedStyles(static_cast<int>(wParam)); case SCI_ADDUNDOACTION: - pdoc->AddUndoAction(wParam, lParam & UNDO_MAY_COALESCE); + pdoc->AddUndoAction(static_cast<int>(wParam), lParam & UNDO_MAY_COALESCE); break; case SCI_SETMOUSESELECTIONRECTANGULARSWITCH: @@ -9514,7 +9522,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return additionalSelectionTyping; case SCI_SETMULTIPASTE: - multiPasteMode = wParam; + multiPasteMode = static_cast<int>(wParam); break; case SCI_GETMULTIPASTE: @@ -9548,22 +9556,22 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETSELECTION: - sel.SetSelection(SelectionRange(wParam, lParam)); + sel.SetSelection(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam))); Redraw(); break; case SCI_ADDSELECTION: - sel.AddSelection(SelectionRange(wParam, lParam)); + sel.AddSelection(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam))); Redraw(); break; case SCI_DROPSELECTIONN: - sel.DropSelection(wParam); + sel.DropSelection(static_cast<int>(wParam)); Redraw(); break; case SCI_SETMAINSELECTION: - sel.SetMain(wParam); + sel.SetMain(static_cast<int>(wParam)); Redraw(); break; @@ -9571,7 +9579,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Main(); case SCI_SETSELECTIONNCARET: - sel.Range(wParam).caret.SetPosition(lParam); + sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam)); Redraw(); break; @@ -9579,14 +9587,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Range(wParam).caret.Position(); case SCI_SETSELECTIONNANCHOR: - sel.Range(wParam).anchor.SetPosition(lParam); + sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam)); Redraw(); break; case SCI_GETSELECTIONNANCHOR: return sel.Range(wParam).anchor.Position(); case SCI_SETSELECTIONNCARETVIRTUALSPACE: - sel.Range(wParam).caret.SetVirtualSpace(lParam); + sel.Range(wParam).caret.SetVirtualSpace(static_cast<int>(lParam)); Redraw(); break; @@ -9594,7 +9602,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Range(wParam).caret.VirtualSpace(); case SCI_SETSELECTIONNANCHORVIRTUALSPACE: - sel.Range(wParam).anchor.SetVirtualSpace(lParam); + sel.Range(wParam).anchor.SetVirtualSpace(static_cast<int>(lParam)); Redraw(); break; @@ -9602,7 +9610,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Range(wParam).anchor.VirtualSpace(); case SCI_SETSELECTIONNSTART: - sel.Range(wParam).anchor.SetPosition(lParam); + sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam)); Redraw(); break; @@ -9610,7 +9618,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Range(wParam).Start().Position(); case SCI_SETSELECTIONNEND: - sel.Range(wParam).caret.SetPosition(lParam); + sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam)); Redraw(); break; @@ -9621,7 +9629,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().caret.SetPosition(wParam); + sel.Rectangular().caret.SetPosition(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); break; @@ -9633,7 +9641,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().anchor.SetPosition(wParam); + sel.Rectangular().anchor.SetPosition(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); break; @@ -9645,7 +9653,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().caret.SetVirtualSpace(wParam); + sel.Rectangular().caret.SetVirtualSpace(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); break; @@ -9657,7 +9665,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().anchor.SetVirtualSpace(wParam); + sel.Rectangular().anchor.SetVirtualSpace(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); break; @@ -9666,24 +9674,24 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Rectangular().anchor.VirtualSpace(); case SCI_SETVIRTUALSPACEOPTIONS: - virtualSpaceOptions = wParam; + virtualSpaceOptions = static_cast<int>(wParam); break; case SCI_GETVIRTUALSPACEOPTIONS: return virtualSpaceOptions; case SCI_SETADDITIONALSELFORE: - vs.selAdditionalForeground = ColourDesired(wParam); + vs.selAdditionalForeground = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; case SCI_SETADDITIONALSELBACK: - vs.selAdditionalBackground = ColourDesired(wParam); + vs.selAdditionalBackground = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; case SCI_SETADDITIONALSELALPHA: - vs.selAdditionalAlpha = wParam; + vs.selAdditionalAlpha = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9691,7 +9699,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.selAdditionalAlpha; case SCI_SETADDITIONALCARETFORE: - vs.additionalCaretColour = ColourDesired(wParam); + vs.additionalCaretColour = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; @@ -9709,11 +9717,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_CHANGELEXERSTATE: - pdoc->ChangeLexerState(wParam, lParam); + pdoc->ChangeLexerState(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_SETIDENTIFIER: - SetCtrlID(wParam); + SetCtrlID(static_cast<int>(wParam)); break; case SCI_GETIDENTIFIER: @@ -9727,7 +9735,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return technology; case SCI_COUNTCHARACTERS: - return pdoc->CountCharacters(wParam, lParam); + return pdoc->CountCharacters(static_cast<int>(wParam), static_cast<int>(lParam)); default: return DefWndProc(iMessage, wParam, lParam); |