summaryrefslogtreecommitdiffstats
path: root/scintilla/src/Editor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'scintilla/src/Editor.cxx')
-rw-r--r--scintilla/src/Editor.cxx1129
1 files changed, 599 insertions, 530 deletions
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx
index 334643c..8f33350 100644
--- a/scintilla/src/Editor.cxx
+++ b/scintilla/src/Editor.cxx
@@ -88,10 +88,6 @@ Timer::Timer() :
Idler::Idler() :
state(false), idlerID(0) {}
-static int RoundXYPosition(XYPOSITION xyPos) {
- return int(xyPos+0.5);
-}
-
static inline bool IsControlCharacter(int ch) {
// iscntrl returns true for lots of chars > 127 which are displayable
return ch >= 0 && ch < ' ';
@@ -117,7 +113,7 @@ Editor::Editor() {
stylesValid = false;
technology = SC_TECHNOLOGY_DEFAULT;
- scaleRGBAImage = 100;
+ scaleRGBAImage = 100.0f;
cursorMode = SC_CURSORNORMAL;
@@ -401,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;
}
@@ -510,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) {
@@ -546,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);
@@ -572,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)) {
@@ -615,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);
@@ -679,8 +676,7 @@ void Editor::RedrawSelMargin(int line, bool allAfter) {
PRectangle rcSelMargin = GetClientRectangle();
rcSelMargin.right = rcSelMargin.left + vs.fixedColumnWidth;
if (line != -1) {
- int position = pdoc->LineStart(line);
- PRectangle rcLine = RectangleFromRange(position, position);
+ PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)));
// Inflate line rectangle if there are image markers with height larger than line height
if (vs.largestMarkerHeight > vs.lineHeight) {
@@ -710,31 +706,25 @@ void Editor::RedrawSelMargin(int line, bool allAfter) {
}
}
-PRectangle Editor::RectangleFromRange(int start, int end) {
- int minPos = start;
- if (minPos > end)
- minPos = end;
- int maxPos = start;
- if (maxPos < end)
- maxPos = end;
- int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(minPos));
- int lineDocMax = pdoc->LineFromPosition(maxPos);
- int maxLine = cs.DisplayFromDoc(lineDocMax) + cs.GetHeight(lineDocMax) - 1;
- PRectangle rcClient = GetTextRectangle();
+PRectangle Editor::RectangleFromRange(Range r) {
+ const int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(r.First()));
+ const int maxLine = cs.DisplayLastFromDoc(pdoc->LineFromPosition(r.Last()));
+ 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;
- if (rc.top < rcClient.top)
- rc.top = rcClient.top;
- rc.right = rcClient.right;
- rc.bottom = (maxLine - TopLineOfMain() + 1) * 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 = static_cast<XYPOSITION>((maxLine - TopLineOfMain() + 1) * vs.lineHeight);
return rc;
}
void Editor::InvalidateRange(int start, int end) {
- RedrawRect(RectangleFromRange(start, end));
+ RedrawRect(RectangleFromRange(Range(start, end)));
}
int Editor::CurrentPosition() const {
@@ -1033,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) {
@@ -1096,7 +1086,7 @@ void Editor::VerticalCentreCaret() {
// Avoid 64 bit compiler warnings.
// Scintilla does not support text buffers larger than 2**31
static int istrlen(const char *s) {
- return static_cast<int>(strlen(s));
+ return static_cast<int>(s ? strlen(s) : 0);
}
void Editor::MoveSelectedLines(int lineDelta) {
@@ -1150,13 +1140,13 @@ void Editor::MoveSelectedLines(int lineDelta) {
const char *eol = StringFromEOLMode(pdoc->eolMode);
if (currentLine + lineDelta >= pdoc->LinesTotal())
- pdoc->InsertCString(pdoc->Length(), eol);
+ pdoc->InsertString(pdoc->Length(), eol, istrlen(eol));
GoToLine(currentLine + lineDelta);
- pdoc->InsertCString(CurrentPosition(), selectedText.Data());
+ selectionLength = pdoc->InsertString(CurrentPosition(), selectedText.Data(), selectionLength);
if (appendEol) {
- pdoc->InsertCString(CurrentPosition() + selectionLength, eol);
- selectionLength += istrlen(eol);
+ const int lengthInserted = pdoc->InsertString(CurrentPosition() + selectionLength, eol, istrlen(eol));
+ selectionLength += lengthInserted;
}
SetSelection(CurrentPosition(), CurrentPosition() + selectionLength);
}
@@ -1174,13 +1164,13 @@ void Editor::MoveCaretInsideView(bool ensureVisible) {
Point pt = PointMainCaret();
if (pt.y < rcClient.top) {
MovePositionTo(SPositionFromLocation(
- Point(lastXChosen - xOffset, rcClient.top),
+ Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top)),
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, rcClient.top + yOfLastLineFullyDisplayed),
+ Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top) + yOfLastLineFullyDisplayed),
false, false, UserVirtualSpace()),
Selection::noSel, ensureVisible);
}
@@ -1229,7 +1219,7 @@ so the caret can move in the same direction longer before the policy is applied
If even is not set, instead of having symmetrical UZs,
the left and bottom UZs are extended up to right and top UZs respectively.
-This way, we favour the displaying of useful information: the begining of lines,
+This way, we favour the displaying of useful information: the beginning of lines,
where most code reside, and the lines after the caret, eg. the body of a function.
| | | | |
@@ -1370,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;
@@ -1391,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) {
@@ -1406,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
@@ -1414,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
@@ -1423,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
@@ -1439,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);
@@ -1472,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);
}
@@ -1505,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();
}
}
@@ -1542,6 +1532,14 @@ void Editor::DropCaret() {
InvalidateCaret();
}
+void Editor::CaretSetPeriod(int period) {
+ if (caret.period != period) {
+ caret.period = period;
+ caret.on = true;
+ InvalidateCaret();
+ }
+}
+
void Editor::InvalidateCaret() {
if (posDrag.IsValid()) {
InvalidateRange(posDrag.Position(), posDrag.Position() + 1);
@@ -1641,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) {
@@ -1686,8 +1684,8 @@ void Editor::LinesJoin() {
pdoc->DelChar(pos);
if (prevNonWS) {
// Ensure at least one space separating previous lines
- pdoc->InsertChar(pos, ' ');
- targetEnd++;
+ const int lengthInserted = pdoc->InsertString(pos, " ", 1);
+ targetEnd += lengthInserted;
}
} else {
prevNonWS = pdoc->CharAt(pos) != ' ';
@@ -1710,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);
@@ -1722,12 +1720,14 @@ void Editor::LinesSplit(int pixelWidth) {
if (surface && ll) {
unsigned int posLineStart = pdoc->LineStart(line);
LayoutLine(line, surface, vs, ll, pixelWidth);
+ int lengthInsertedTotal = 0;
for (int subLine = 1; subLine < ll->lines; subLine++) {
- pdoc->InsertCString(
- static_cast<int>(posLineStart + (subLine - 1) * strlen(eol) +
+ const int lengthInserted = pdoc->InsertString(
+ static_cast<int>(posLineStart + lengthInsertedTotal +
ll->LineStart(subLine)),
- eol);
- targetEnd += static_cast<int>(strlen(eol));
+ eol, istrlen(eol));
+ targetEnd += lengthInserted;
+ lengthInsertedTotal += lengthInserted;
}
}
lineEnd = pdoc->LineFromPosition(targetEnd);
@@ -1763,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;
@@ -1779,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;
@@ -1793,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;
@@ -1801,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);
@@ -1836,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;
@@ -1892,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.
@@ -1920,18 +1920,18 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
}
// Old code does not know about new markers needed to distinguish all cases
- int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
+ const int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
SC_MARKNUM_FOLDEROPEN);
- int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
+ const int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
SC_MARKNUM_FOLDER);
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rc.bottom) {
PLATFORM_ASSERT(visibleLine < cs.LinesDisplayed());
- int lineDoc = cs.DocFromDisplay(visibleLine);
+ const int lineDoc = cs.DocFromDisplay(visibleLine);
PLATFORM_ASSERT(cs.GetVisible(lineDoc));
- bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc);
- bool lastSubLine = visibleLine == (cs.DisplayFromDoc(lineDoc + 1) - 1);
+ const bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc);
+ const bool lastSubLine = visibleLine == cs.DisplayLastFromDoc(lineDoc);
int marks = pdoc->GetMark(lineDoc);
if (!firstSubLine)
@@ -1941,10 +1941,10 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
if (vs.ms[margin].mask & SC_MASK_FOLDERS) {
// Decide which fold indicator should be displayed
- int level = pdoc->GetLevel(lineDoc);
- int levelNext = pdoc->GetLevel(lineDoc + 1);
- int levelNum = level & SC_FOLDLEVELNUMBERMASK;
- int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK;
+ const int level = pdoc->GetLevel(lineDoc);
+ const int levelNext = pdoc->GetLevel(lineDoc + 1);
+ const int levelNum = level & SC_FOLDLEVELNUMBERMASK;
+ const int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK;
if (level & SC_FOLDLEVELHEADERFLAG) {
if (firstSubLine) {
if (levelNum < levelNextNum) {
@@ -1974,9 +1974,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
}
}
needWhiteClosure = false;
- int firstFollowupLine = cs.DocFromDisplay(cs.DisplayFromDoc(lineDoc + 1));
- int firstFollowupLineLevel = pdoc->GetLevel(firstFollowupLine);
- int secondFollowupLineLevelNum = pdoc->GetLevel(firstFollowupLine + 1) & SC_FOLDLEVELNUMBERMASK;
+ const int firstFollowupLine = cs.DocFromDisplay(cs.DisplayFromDoc(lineDoc + 1));
+ const int firstFollowupLineLevel = pdoc->GetLevel(firstFollowupLine);
+ const int secondFollowupLineLevelNum = pdoc->GetLevel(firstFollowupLine + 1) & SC_FOLDLEVELNUMBERMASK;
if (!cs.GetExpanded(lineDoc)) {
if ((firstFollowupLineLevel & SC_FOLDLEVELWHITEFLAG) &&
(levelNum > secondFollowupLineLevelNum))
@@ -2031,21 +2031,26 @@ 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] = "";
if (lineDoc >= 0)
sprintf(number, "%d", lineDoc + 1);
- if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
- int lev = pdoc->GetLevel(lineDoc);
- sprintf(number, "%c%c %03X %03X",
- (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
- (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
- lev & SC_FOLDLEVELNUMBERMASK,
- lev >> 16
- );
+ if (foldFlags & (SC_FOLDFLAG_LEVELNUMBERS | SC_FOLDFLAG_LINESTATE)) {
+ if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
+ int lev = pdoc->GetLevel(lineDoc);
+ sprintf(number, "%c%c %03X %03X",
+ (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
+ (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
+ lev & SC_FOLDLEVELNUMBERMASK,
+ lev >> 16
+ );
+ } else {
+ int state = pdoc->GetLineState(lineDoc);
+ sprintf(number, "%0X", state);
+ }
}
PRectangle rcNumber = rcMarker;
// Right justify
@@ -2072,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);
}
}
@@ -2121,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);
}
@@ -2218,7 +2223,6 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
ll->edgeColumn = -1;
}
- char styleByte;
const int styleMask = pdoc->stylingBitsMask;
ll->styleBitsSet = 0;
// Fill base line layout
@@ -2228,12 +2232,12 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
int numCharsBeforeEOL = pdoc->LineEnd(line) - posLineStart;
const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL;
for (int styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) {
- styleByte = ll->styles[styleInLine];
+ const unsigned char styleByte = ll->styles[styleInLine];
ll->styleBitsSet |= styleByte;
- ll->styles[styleInLine] = static_cast<char>(styleByte & styleMask);
+ ll->styles[styleInLine] = styleByte & styleMask;
ll->indicators[styleInLine] = static_cast<char>(styleByte & ~styleMask);
}
- styleByte = static_cast<char>(((lineLength > 0) ? ll->styles[lineLength-1] : 0) & styleMask);
+ const unsigned char styleByteLast = ((lineLength > 0) ? ll->styles[lineLength-1] : 0) & styleMask;
if (vstyle.someStylesForceCase) {
for (int charInLine = 0; charInLine<lineLength; charInLine++) {
char chDoc = ll->chars[charInLine];
@@ -2246,7 +2250,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
ll->xHighlightGuide = 0;
// Extra element at the end of the line to hold end x position and act as
ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character
- ll->styles[numCharsInLine] = styleByte; // For eolFilled
+ ll->styles[numCharsInLine] = styleByteLast; // For eolFilled
ll->indicators[numCharsInLine] = 0;
// Layout the line, determining the position of each character,
@@ -2418,8 +2422,8 @@ ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
}
void Editor::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight) {
- Point from(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0);
- PRectangle rcCopyArea(start + 1, rcSegment.top, start + 2, rcSegment.bottom);
+ Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0);
+ PRectangle rcCopyArea = PRectangle::FromInts(start + 1, static_cast<int>(rcSegment.top), start + 2, static_cast<int>(rcSegment.bottom));
surface->Copy(rcCopyArea, from,
highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide);
}
@@ -2429,15 +2433,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;
@@ -2480,8 +2484,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;
@@ -2513,7 +2517,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) {
@@ -2528,8 +2532,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()));
@@ -2551,8 +2557,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;
@@ -2742,23 +2748,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;
}
}
@@ -2777,21 +2783,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));
}
}
}
@@ -2893,7 +2899,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..
@@ -2937,8 +2943,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)) {
@@ -2972,9 +2978,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);
}
@@ -2997,8 +3004,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;
@@ -3029,8 +3036,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)) {
@@ -3058,11 +3065,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));
}
@@ -3075,7 +3082,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 {
@@ -3114,24 +3121,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, 0);
+ 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));
}
@@ -3164,7 +3173,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
@@ -3203,7 +3212,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));
@@ -3234,8 +3243,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
@@ -3352,7 +3363,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
// for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half
// way between the chrome colour and the chrome highlight colour making a nice transition
// between the window chrome and the content area. And it works in low colour depths.
- PRectangle rcPattern(0, 0, patternSize, patternSize);
+ PRectangle rcPattern = PRectangle::FromInts(0, 0, patternSize, patternSize);
// Initialize default colours based on the chrome colour scheme. Typically the highlight is white.
ColourDesired colourFMFill = vs.selbar;
@@ -3377,7 +3388,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
pixmapSelPatternOffset1->FillRectangle(rcPattern, colourFMStripes);
for (int y = 0; y < patternSize; y++) {
for (int x = y % 2; x < patternSize; x+=2) {
- PRectangle rcPixel(x, y, x+1, y+1);
+ PRectangle rcPixel = PRectangle::FromInts(x, y, x + 1, y + 1);
pixmapSelPattern->FillRectangle(rcPixel, colourFMStripes);
pixmapSelPatternOffset1->FillRectangle(rcPixel, colourFMFill);
}
@@ -3388,13 +3399,13 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
// 1 extra pixel in height so can handle odd/even positions and so produce a continuous line
pixmapIndentGuide->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID());
pixmapIndentGuideHighlight->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID());
- PRectangle rcIG(0, 0, 1, vs.lineHeight);
+ PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vs.lineHeight);
pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back);
pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore);
pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back);
pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore);
for (int stripe = 1; stripe < vs.lineHeight + 1; stripe += 2) {
- PRectangle rcPixel(0, stripe, 1, stripe+1);
+ PRectangle rcPixel = PRectangle::FromInts(0, stripe, 1, stripe + 1);
pixmapIndentGuide->FillRectangle(rcPixel, vs.styles[STYLE_INDENTGUIDE].fore);
pixmapIndentGuideHighlight->FillRectangle(rcPixel, vs.styles[STYLE_BRACELIGHT].fore);
}
@@ -3403,10 +3414,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());
}
}
}
@@ -3460,7 +3471,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 */
@@ -3478,7 +3489,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;
@@ -3513,9 +3524,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;
@@ -3646,8 +3657,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)) ||
@@ -3657,7 +3668,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;
@@ -3699,14 +3710,15 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
DrawCarets(surface, vs, lineDoc, xStart, rcLine, ll, subLine);
if (bufferedDraw) {
- Point from(vs.textStart-leftTextOverlap, 0);
- PRectangle rcCopyArea(vs.textStart-leftTextOverlap, yposScreen,
- rcClient.right - vs.rightMarginWidth, yposScreen + vs.lineHeight);
+ Point from = Point::FromInts(vs.textStart-leftTextOverlap, 0);
+ PRectangle rcCopyArea = PRectangle::FromInts(vs.textStart - leftTextOverlap, yposScreen,
+ static_cast<int>(rcClient.right - vs.rightMarginWidth),
+ yposScreen + vs.lineHeight);
surfaceWindow->Copy(rcCopyArea, from, *pixmapLine);
}
lineWidthMaxSeen = Platform::Maximum(
- lineWidthMaxSeen, ll->positions[ll->numCharsInLine]);
+ lineWidthMaxSeen, static_cast<int>(ll->positions[ll->numCharsInLine]));
//durCopy += et.Duration(true);
}
@@ -3725,14 +3737,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);
}
@@ -3834,11 +3846,11 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
vsPrint.rightMarginWidth = 0;
vsPrint.Refresh(*surfaceMeasure, pdoc->tabInChars);
- // Determining width must hapen after fonts have been realised in Refresh
+ // Determining width must happen 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
}
@@ -3886,11 +3898,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 = PRectangle::FromInts(
+ 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
@@ -3920,7 +3932,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);
}
@@ -3932,8 +3944,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;
@@ -3959,7 +3971,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;
}
@@ -3997,7 +4009,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();
@@ -4009,8 +4021,8 @@ void Editor::ChangeSize() {
int Editor::InsertSpace(int position, unsigned int spaces) {
if (spaces > 0) {
std::string spaceText(spaces, ' ');
- pdoc->InsertString(position, spaceText.c_str(), spaces);
- position += spaces;
+ const int lengthInserted = pdoc->InsertString(position, spaceText.c_str(), spaces);
+ position += lengthInserted;
}
return position;
}
@@ -4069,9 +4081,10 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
}
}
positionInsert = InsertSpace(positionInsert, currentSel->caret.VirtualSpace());
- if (pdoc->InsertString(positionInsert, s, len)) {
- currentSel->caret.SetPosition(positionInsert + len);
- currentSel->anchor.SetPosition(positionInsert + len);
+ const int lengthInserted = pdoc->InsertString(positionInsert, s, len);
+ if (lengthInserted > 0) {
+ currentSel->caret.SetPosition(positionInsert + lengthInserted);
+ currentSel->anchor.SetPosition(positionInsert + lengthInserted);
}
currentSel->ClearVirtualSpace();
// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
@@ -4143,11 +4156,13 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
}
}
-void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len) {
+void Editor::InsertPaste(const char *text, int len) {
if (multiPasteMode == SC_MULTIPASTE_ONCE) {
+ SelectionPosition selStart = sel.Start();
selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace()));
- if (pdoc->InsertString(selStart.Position(), text, len)) {
- SetEmptySelection(selStart.Position() + len);
+ const int lengthInserted = pdoc->InsertString(selStart.Position(), text, len);
+ if (lengthInserted > 0) {
+ SetEmptySelection(selStart.Position() + lengthInserted);
}
} else {
// SC_MULTIPASTE_EACH
@@ -4165,9 +4180,10 @@ void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len)
}
}
positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
- if (pdoc->InsertString(positionInsert, text, len)) {
- sel.Range(r).caret.SetPosition(positionInsert + len);
- sel.Range(r).anchor.SetPosition(positionInsert + len);
+ const int lengthInserted = pdoc->InsertString(positionInsert, text, len);
+ if (lengthInserted > 0) {
+ sel.Range(r).caret.SetPosition(positionInsert + lengthInserted);
+ sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted);
}
sel.Range(r).ClearVirtualSpace();
}
@@ -4175,6 +4191,35 @@ void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len)
}
}
+void Editor::InsertPasteShape(const char *text, int len, PasteShape shape) {
+ std::string convertedText;
+ if (convertPastes) {
+ // Convert line endings of the paste into our local line-endings mode
+ convertedText = Document::TransformLineEnds(text, len, pdoc->eolMode);
+ len = static_cast<int>(convertedText.length());
+ text = convertedText.c_str();
+ }
+ if (shape == pasteRectangular) {
+ PasteRectangular(sel.Start(), text, len);
+ } else {
+ if (shape == pasteLine) {
+ int insertPos = pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()));
+ int lengthInserted = pdoc->InsertString(insertPos, text, len);
+ // add the newline if necessary
+ if ((len > 0) && (text[len - 1] != '\n' && text[len - 1] != '\r')) {
+ const char *endline = StringFromEOLMode(pdoc->eolMode);
+ int length = static_cast<int>(strlen(endline));
+ lengthInserted += pdoc->InsertString(insertPos + lengthInserted, endline, length);
+ }
+ if (sel.MainCaret() == insertPos) {
+ SetEmptySelection(sel.MainCaret() + lengthInserted);
+ }
+ } else {
+ InsertPaste(text, len);
+ }
+ }
+}
+
void Editor::ClearSelection(bool retainMultipleSelections) {
if (!sel.IsRectangular() && !retainMultipleSelections)
FilterSelections();
@@ -4263,22 +4308,22 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
line++;
if (line >= pdoc->LinesTotal()) {
if (pdoc->eolMode != SC_EOL_LF)
- pdoc->InsertChar(pdoc->Length(), '\r');
+ pdoc->InsertString(pdoc->Length(), "\r", 1);
if (pdoc->eolMode != SC_EOL_CR)
- pdoc->InsertChar(pdoc->Length(), '\n');
+ pdoc->InsertString(pdoc->Length(), "\n", 1);
}
// Pad the end of lines with spaces if required
sel.RangeMain().caret.SetPosition(PositionFromLineX(line, xInsert));
if ((XFromPosition(sel.MainCaret()) < xInsert) && (i + 1 < len)) {
while (XFromPosition(sel.MainCaret()) < xInsert) {
- pdoc->InsertChar(sel.MainCaret(), ' ');
- sel.RangeMain().caret.Add(1);
+ const int lengthInserted = pdoc->InsertString(sel.MainCaret(), " ", 1);
+ sel.RangeMain().caret.Add(lengthInserted);
}
}
prevCr = ptr[i] == '\r';
} else {
- pdoc->InsertString(sel.MainCaret(), ptr + i, 1);
- sel.RangeMain().caret.Add(1);
+ const int lengthInserted = pdoc->InsertString(sel.MainCaret(), ptr + i, 1);
+ sel.RangeMain().caret.Add(lengthInserted);
prevCr = false;
}
}
@@ -4374,14 +4419,12 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
UndoGroup ugInner(pdoc, !ug.Needed());
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
int indentationStep = pdoc->IndentSize();
- if (indentation % indentationStep == 0) {
- pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
- } else {
- pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep));
- }
+ int indentationChange = indentation % indentationStep;
+ if (indentationChange == 0)
+ indentationChange = indentationStep;
+ const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationChange);
// SetEmptySelection
- sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos),
- pdoc->GetLineIndentPosition(lineCurrentPos));
+ sel.Range(r) = SelectionRange(posSelect);
} else {
pdoc->DelCharBack(sel.Range(r).caret.Position());
}
@@ -4603,8 +4646,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);
}
@@ -4970,17 +5013,17 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {
int topStutterLine = topLine + caretYSlop;
int bottomStutterLine =
pdoc->LineFromPosition(PositionFromLocation(
- Point(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll())))
+ Point::FromInts(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll())))
- caretYSlop - 1;
if (stuttered && (direction < 0 && currentLine > topStutterLine)) {
topLineNew = topLine;
- newPos = SPositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * caretYSlop),
+ newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * caretYSlop),
false, false, UserVirtualSpace());
} else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) {
topLineNew = topLine;
- newPos = SPositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)),
+ newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)),
false, false, UserVirtualSpace());
} else {
@@ -4989,7 +5032,7 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {
topLineNew = Platform::Clamp(
topLine + direction * LinesToScroll(), 0, MaxScrollPos());
newPos = SPositionFromLocation(
- Point(lastXChosen - xOffset, pt.y + direction * (vs.lineHeight * LinesToScroll())),
+ Point::FromInts(lastXChosen - xOffset, static_cast<int>(pt.y) + direction * (vs.lineHeight * LinesToScroll())),
false, false, UserVirtualSpace());
}
@@ -5029,12 +5072,13 @@ void Editor::ChangeCaseOfSelection(int caseMapping) {
pdoc->DeleteChars(
static_cast<int>(currentNoVS.Start().Position() + firstDifference),
static_cast<int>(rangeBytes - firstDifference - endDifferenceText));
- pdoc->InsertString(
+ const int lengthChange = static_cast<int>(lastDifferenceMapped - firstDifference + 1);
+ const int lengthInserted = pdoc->InsertString(
static_cast<int>(currentNoVS.Start().Position() + firstDifference),
sMapped.c_str() + firstDifference,
- static_cast<int>(lastDifferenceMapped - firstDifference + 1));
+ lengthChange);
// Automatic movement changes selection so reset to exactly the same as it was.
- int diffSizes = static_cast<int>(sMapped.size() - sText.size());
+ int diffSizes = static_cast<int>(sMapped.size() - sText.size()) + lengthInserted - lengthChange;
if (diffSizes != 0) {
if (current.anchor > current.caret)
current.anchor.Add(diffSizes);
@@ -5051,19 +5095,23 @@ void Editor::LineTranspose() {
int line = pdoc->LineFromPosition(sel.MainCaret());
if (line > 0) {
UndoGroup ug(pdoc);
- int startPrev = pdoc->LineStart(line - 1);
- int endPrev = pdoc->LineEnd(line - 1);
- int start = pdoc->LineStart(line);
- int end = pdoc->LineEnd(line);
- std::string line1 = RangeText(startPrev, endPrev);
- int len1 = endPrev - startPrev;
- std::string line2 = RangeText(start, end);
- int len2 = end - start;
- pdoc->DeleteChars(start, len2);
- pdoc->DeleteChars(startPrev, len1);
- pdoc->InsertString(startPrev, line2.c_str(), len2);
- pdoc->InsertString(start - len1 + len2, line1.c_str(), len1);
- MovePositionTo(SelectionPosition(start - len1 + len2));
+
+ const int startPrevious = pdoc->LineStart(line - 1);
+ const std::string linePrevious = RangeText(startPrevious, pdoc->LineEnd(line - 1));
+
+ int startCurrent = pdoc->LineStart(line);
+ const std::string lineCurrent = RangeText(startCurrent, pdoc->LineEnd(line));
+
+ pdoc->DeleteChars(startCurrent, static_cast<int>(lineCurrent.length()));
+ pdoc->DeleteChars(startPrevious, static_cast<int>(linePrevious.length()));
+ startCurrent -= static_cast<int>(linePrevious.length());
+
+ startCurrent += pdoc->InsertString(startPrevious, lineCurrent.c_str(),
+ static_cast<int>(lineCurrent.length()));
+ pdoc->InsertString(startCurrent, linePrevious.c_str(),
+ static_cast<int>(linePrevious.length()));
+ // Move caret to start of current line
+ MovePositionTo(SelectionPosition(startCurrent));
}
}
@@ -5087,9 +5135,10 @@ void Editor::Duplicate(bool forLine) {
end = SelectionPosition(pdoc->LineEnd(line));
}
std::string text = RangeText(start.Position(), end.Position());
+ int lengthInserted = eolLen;
if (forLine)
- pdoc->InsertString(end.Position(), eol, eolLen);
- pdoc->InsertString(end.Position() + eolLen, text.c_str(), SelectionRange(end, start).Length());
+ lengthInserted = pdoc->InsertString(end.Position(), eol, eolLen);
+ pdoc->InsertString(end.Position() + lengthInserted, text.c_str(), static_cast<int>(text.length()));
}
if (sel.Count() && sel.IsRectangular()) {
SelectionPosition last = sel.Last();
@@ -5128,12 +5177,12 @@ void Editor::NewLine() {
} else if (pdoc->eolMode == SC_EOL_CR) {
eol = "\r";
} // else SC_EOL_LF -> "\n" already set
- bool inserted = pdoc->InsertCString(sel.MainCaret(), eol);
+ const int insertLength = pdoc->InsertString(sel.MainCaret(), eol, istrlen(eol));
// Want to end undo group before NotifyChar as applications often modify text here
if (needGroupUndo)
pdoc->EndUndoAction();
- if (inserted) {
- SetEmptySelection(sel.MainCaret() + istrlen(eol));
+ if (insertLength > 0) {
+ SetEmptySelection(sel.MainCaret() + insertLength);
while (*eol) {
NotifyChar(*eol);
if (recordingMacro) {
@@ -5168,7 +5217,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);
@@ -5180,9 +5229,9 @@ 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());
+ Point::FromInts(lastXChosen - xOffset, newY), false, false, UserVirtualSpace());
if (direction < 0) {
// Line wrapping may lead to a location on the same line, so
@@ -5771,7 +5820,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;
@@ -5797,21 +5846,22 @@ void Editor::Indent(bool forwards) {
pdoc->tabIndents) {
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
int indentationStep = pdoc->IndentSize();
- pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
- sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos));
+ const int posSelect = pdoc->SetLineIndentation(
+ lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
+ sel.Range(r) = SelectionRange(posSelect);
} else {
if (pdoc->useTabs) {
- pdoc->InsertChar(caretPosition, '\t');
- sel.Range(r) = SelectionRange(caretPosition+1);
+ const int lengthInserted = pdoc->InsertString(caretPosition, "\t", 1);
+ sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
} else {
int numSpaces = (pdoc->tabInChars) -
(pdoc->GetColumn(caretPosition) % (pdoc->tabInChars));
if (numSpaces < 1)
numSpaces = pdoc->tabInChars;
- for (int i = 0; i < numSpaces; i++) {
- pdoc->InsertChar(caretPosition + i, ' ');
- }
- sel.Range(r) = SelectionRange(caretPosition+numSpaces);
+ const std::string spaceText(numSpaces, ' ');
+ const int lengthInserted = pdoc->InsertString(caretPosition, spaceText.c_str(),
+ static_cast<int>(spaceText.length()));
+ sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
}
}
} else {
@@ -5819,8 +5869,8 @@ void Editor::Indent(bool forwards) {
pdoc->tabIndents) {
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
int indentationStep = pdoc->IndentSize();
- pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
- sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos));
+ const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
+ sel.Range(r) = SelectionRange(posSelect);
} else {
int newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) *
pdoc->tabInChars;
@@ -5890,7 +5940,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;
@@ -5936,7 +5986,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,
@@ -5944,7 +5994,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) {
@@ -6098,8 +6148,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;
}
@@ -6150,16 +6200,20 @@ void Editor::DropAt(SelectionPosition position, const char *value, size_t length
}
position = positionAfterDeletion;
+ std::string convertedText = Document::TransformLineEnds(value, lengthValue, pdoc->eolMode);
+
if (rectangular) {
- PasteRectangular(position, value, static_cast<int>(lengthValue));
+ PasteRectangular(position, convertedText.c_str(), static_cast<int>(convertedText.length()));
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position
SetEmptySelection(position);
} else {
position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());
position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace()));
- if (pdoc->InsertString(position.Position(), value, static_cast<int>(lengthValue))) {
+ const int lengthInserted = pdoc->InsertString(
+ position.Position(), convertedText.c_str(), static_cast<int>(convertedText.length()));
+ if (lengthInserted > 0) {
SelectionPosition posAfterInsertion = position;
- posAfterInsertion.Add(static_cast<int>(lengthValue));
+ posAfterInsertion.Add(lengthInserted);
SetSelection(posAfterInsertion, position);
}
}
@@ -6214,8 +6268,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;
@@ -6371,7 +6425,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
doubleClick = true;
} else if (selectionType == selWord) {
// Since we ended up here, we're inside a *triple* click, which should always select
- // whole line irregardless of word wrap being enabled or not.
+ // whole line regardless of word wrap being enabled or not.
selectionType = selWholeLine;
} else {
selectionType = selChar;
@@ -6489,7 +6543,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();
}
@@ -6697,20 +6751,27 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
SelectionPosition selEnd = SelectionEnd();
if (selStart < selEnd) {
if (drag.Length()) {
+ const int length = static_cast<int>(drag.Length());
if (ctrl) {
- if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
- SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
+ const int lengthInserted = pdoc->InsertString(
+ newPos.Position(), drag.Data(), length);
+ if (lengthInserted > 0) {
+ SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else if (newPos < selStart) {
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
- if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
- SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
+ const int lengthInserted = pdoc->InsertString(
+ newPos.Position(), drag.Data(), length);
+ if (lengthInserted > 0) {
+ SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else if (newPos > selEnd) {
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
newPos.Add(-static_cast<int>(drag.Length()));
- if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
- SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
+ const int lengthInserted = pdoc->InsertString(
+ newPos.Position(), drag.Data(), length);
+ if (lengthInserted > 0) {
+ SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else {
SetEmptySelection(newPos.Position());
@@ -6734,7 +6795,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();
}
@@ -6792,7 +6853,7 @@ bool Editor::Idle() {
// Add more idle things to do here, but make sure idleDone is
// set correctly before the function returns. returning
- // false will stop calling this idle funtion until SetIdle() is
+ // false will stop calling this idle function until SetIdle() is
// called again.
idleDone = wrappingDone; // && thatDone && theOtherThingDone...
@@ -6815,7 +6876,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
@@ -6869,7 +6930,7 @@ bool Editor::PaintContainsMargin() {
return false;
}
PRectangle rcSelMargin = GetClientRectangle();
- rcSelMargin.right = vs.textStart;
+ rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart);
return PaintContains(rcSelMargin);
}
@@ -6879,7 +6940,7 @@ void Editor::CheckForChangeOutsidePaint(Range r) {
if (!r.Valid())
return;
- PRectangle rcRange = RectangleFromRange(r.start, r.end);
+ PRectangle rcRange = RectangleFromRange(r);
PRectangle rcText = GetTextRectangle();
if (rcRange.top < rcText.top) {
rcRange.top = rcText.top;
@@ -7258,8 +7319,8 @@ int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) {
if (targetStart != targetEnd)
pdoc->DeleteChars(targetStart, targetEnd - targetStart);
targetEnd = targetStart;
- pdoc->InsertString(targetStart, text, length);
- targetEnd = targetStart + length;
+ const int lengthInserted = pdoc->InsertString(targetStart, text, length);
+ targetEnd = targetStart + lengthInserted;
return length;
}
@@ -7294,16 +7355,16 @@ void Editor::AddStyledText(char *buffer, int appendLength) {
for (i = 0; i < textLength; i++) {
text[i] = buffer[i*2];
}
- pdoc->InsertString(CurrentPosition(), text.c_str(), textLength);
+ const int lengthInserted = pdoc->InsertString(CurrentPosition(), text.c_str(), textLength);
for (i = 0; i < textLength; i++) {
text[i] = buffer[i*2+1];
}
- pdoc->StartStyling(CurrentPosition(), static_cast<char>(0xff));
+ pdoc->StartStyling(CurrentPosition(), static_cast<unsigned char>(0xff));
pdoc->SetStyles(textLength, text.c_str());
- SetEmptySelection(sel.MainCaret() + textLength);
+ SetEmptySelection(sel.MainCaret() + lengthInserted);
}
-static bool ValidMargin(unsigned long wParam) {
+static bool ValidMargin(uptr_t wParam) {
return wParam <= SC_MAX_MARGIN;
}
@@ -7315,16 +7376,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;
@@ -7333,14 +7394,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:
@@ -7350,7 +7411,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:
@@ -7455,7 +7516,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
UndoGroup ug(pdoc);
pdoc->DeleteChars(0, pdoc->Length());
SetEmptySelection(0);
- pdoc->InsertCString(0, CharPtrFromSPtr(lParam));
+ const char *text = CharPtrFromSPtr(lParam);
+ pdoc->InsertString(0, text, istrlen(text));
return 1;
}
@@ -7488,11 +7550,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:
@@ -7525,12 +7587,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;
}
@@ -7587,7 +7649,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)
@@ -7598,14 +7660,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)
@@ -7613,21 +7675,22 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
UndoGroup ug(pdoc);
ClearSelection();
char *replacement = CharPtrFromSPtr(lParam);
- pdoc->InsertCString(sel.MainCaret(), replacement);
- SetEmptySelection(sel.MainCaret() + istrlen(replacement));
+ const int lengthInserted = pdoc->InsertString(
+ sel.MainCaret(), replacement, istrlen(replacement));
+ SetEmptySelection(sel.MainCaret() + lengthInserted);
EnsureCaretVisible();
}
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:
@@ -7645,42 +7708,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();
@@ -7711,17 +7774,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:
@@ -7757,13 +7820,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;
@@ -7772,33 +7835,39 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_ADDTEXT: {
if (lParam == 0)
return 0;
- pdoc->InsertString(CurrentPosition(), CharPtrFromSPtr(lParam), wParam);
- SetEmptySelection(sel.MainCaret() + wParam);
+ const int lengthInserted = pdoc->InsertString(
+ 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();
char *sz = CharPtrFromSPtr(lParam);
- pdoc->InsertCString(insertPos, sz);
+ const int lengthInserted = pdoc->InsertString(insertPos, sz, istrlen(sz));
if (newCurrent > insertPos)
- newCurrent += istrlen(sz);
+ newCurrent += lengthInserted;
SetEmptySelection(newCurrent);
return 0;
}
+ case SCI_CHANGEINSERTION:
+ PLATFORM_ASSERT(lParam);
+ 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:
@@ -7806,7 +7875,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:
@@ -7832,7 +7901,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return caret.period;
case SCI_SETCARETPERIOD:
- caret.period = wParam;
+ CaretSetPeriod(static_cast<int>(wParam));
break;
case SCI_GETWORDCHARS:
@@ -7874,19 +7943,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;
@@ -7895,11 +7964,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;
@@ -7907,32 +7976,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:
@@ -7949,7 +8018,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();
@@ -7981,10 +8050,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:
@@ -8004,27 +8073,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::FromInts(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::FromInts(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::FromInts(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::FromInts(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;
@@ -8052,11 +8121,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());
@@ -8071,17 +8140,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:
@@ -8110,7 +8179,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;
}
@@ -8121,7 +8190,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
@@ -8141,14 +8210,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;
@@ -8165,7 +8234,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;
@@ -8173,13 +8242,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();
@@ -8191,7 +8260,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();
}
@@ -8201,7 +8270,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;
@@ -8210,7 +8279,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();
}
@@ -8220,7 +8289,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();
}
@@ -8230,7 +8299,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:
@@ -8247,7 +8316,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;
@@ -8267,13 +8336,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;
@@ -8292,7 +8361,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;
@@ -8304,10 +8373,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)) {
@@ -8343,7 +8412,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;
@@ -8352,11 +8421,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());
@@ -8381,7 +8450,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();
@@ -8396,13 +8465,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;
@@ -8412,26 +8481,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:
@@ -8439,13 +8508,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;
}
@@ -8462,20 +8531,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();
@@ -8484,7 +8553,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;
@@ -8499,8 +8568,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();
}
}
@@ -8514,7 +8583,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;
@@ -8540,7 +8609,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:
@@ -8595,17 +8664,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();
@@ -8626,114 +8695,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:
@@ -8745,18 +8814,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:
@@ -8764,19 +8833,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;
@@ -8802,7 +8871,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;
@@ -8811,7 +8880,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;
@@ -8827,7 +8896,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;
@@ -8835,13 +8904,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:
@@ -8850,7 +8919,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;
@@ -8860,7 +8929,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;
@@ -8880,7 +8949,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;
@@ -8890,7 +8959,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;
@@ -8899,35 +8968,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:
@@ -9024,13 +9093,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;
@@ -9041,14 +9110,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;
@@ -9059,7 +9128,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;
@@ -9071,7 +9140,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;
@@ -9079,7 +9148,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;
@@ -9087,7 +9156,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;
@@ -9116,25 +9185,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:
@@ -9180,8 +9249,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()) {
@@ -9206,7 +9275,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:
@@ -9220,7 +9289,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;
@@ -9228,7 +9297,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;
@@ -9317,13 +9386,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;
@@ -9331,7 +9400,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;
@@ -9339,7 +9408,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;
@@ -9347,36 +9416,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);
}
@@ -9385,48 +9454,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;
@@ -9438,10 +9507,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:
@@ -9468,7 +9537,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:
@@ -9502,22 +9571,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;
@@ -9525,7 +9594,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;
@@ -9533,14 +9602,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;
@@ -9548,7 +9617,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;
@@ -9556,7 +9625,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;
@@ -9564,7 +9633,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;
@@ -9575,7 +9644,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;
@@ -9587,7 +9656,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;
@@ -9599,7 +9668,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;
@@ -9611,7 +9680,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;
@@ -9620,24 +9689,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;
@@ -9645,7 +9714,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;
@@ -9663,11 +9732,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:
@@ -9681,7 +9750,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);