aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/AutoComplete.cxx2
-rw-r--r--src/CallTip.cxx22
-rw-r--r--src/CaseConvert.cxx8
-rw-r--r--src/CellBuffer.cxx8
-rw-r--r--src/ContractionState.cxx10
-rw-r--r--src/Document.cxx98
-rw-r--r--src/EditView.cxx92
-rw-r--r--src/Editor.cxx200
-rw-r--r--src/Indicator.cxx14
-rw-r--r--src/LineMarker.cxx18
-rw-r--r--src/MarginView.cxx20
-rw-r--r--src/PerLine.cxx8
-rw-r--r--src/PositionCache.cxx20
-rw-r--r--src/ScintillaBase.cxx30
-rw-r--r--src/Selection.cxx4
-rw-r--r--src/ViewStyle.cxx6
-rw-r--r--src/XPM.cxx2
17 files changed, 281 insertions, 281 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index ac8a27c18..a5aa50afe 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -224,7 +224,7 @@ void AutoComplete::Move(int delta) {
}
void AutoComplete::Select(const char *word) {
- size_t lenWord = strlen(word);
+ const size_t lenWord = strlen(word);
int location = -1;
int start = 0; // lower bound of the api array block to search
int end = lb->Length() - 1; // upper bound of the api array block to search
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index b7aaaceb8..3d62dba88 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -108,7 +108,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
int startSeg = 0;
int xEnd;
for (int seg = 0; seg<maxEnd; seg++) {
- int endSeg = ends[seg];
+ const int endSeg = ends[seg];
if (endSeg > startSeg) {
if (IsArrowCharacter(s[startSeg])) {
xEnd = x + widthArrow;
@@ -121,7 +121,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
const int centreX = x + widthArrow / 2 - 1;
const int centreY = static_cast<int>(rcClient.top + rcClient.bottom) / 2;
surface->FillRectangle(rcClient, colourBG);
- PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1,
+ const PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1,
rcClient.right - 2, rcClient.bottom - 1);
surface->FillRectangle(rcClientInner, colourUnSel);
@@ -166,13 +166,13 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
}
int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
- PRectangle rcClientPos = wCallTip.GetClientPosition();
- PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
+ const PRectangle rcClientPos = wCallTip.GetClientPosition();
+ const PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
rcClientPos.bottom - rcClientPos.top);
PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
// To make a nice small call tip window, it is only sized to fit most normal characters without accents
- int ascent = RoundXYPosition(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font));
+ const int ascent = RoundXYPosition(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font));
// For each line...
// Draw the definition in three parts: before highlight, highlighted, after highlight
@@ -219,10 +219,10 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
void CallTip::PaintCT(Surface *surfaceWindow) {
if (val.empty())
return;
- PRectangle rcClientPos = wCallTip.GetClientPosition();
- PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
+ const PRectangle rcClientPos = wCallTip.GetClientPosition();
+ const PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
rcClientPos.bottom - rcClientPos.top);
- PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
+ const PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
surfaceWindow->FillRectangle(rcClient, colourBG);
@@ -265,8 +265,8 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co
endHighlight = 0;
inCallTipMode = true;
posStartCallTip = pos;
- XYPOSITION deviceHeight = static_cast<XYPOSITION>(surfaceMeasure->DeviceHeightFont(size));
- FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet);
+ const XYPOSITION deviceHeight = static_cast<XYPOSITION>(surfaceMeasure->DeviceHeightFont(size));
+ const FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet);
font.Create(fp);
// Look for multiple lines in the text
// Only support \n here - simply means container must avoid \r!
@@ -286,7 +286,7 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co
// The returned
// rectangle is aligned to the right edge of the last arrow encountered in
// the tip text, else to the tip text left edge.
- int height = lineHeight * numLines - static_cast<int>(surfaceMeasure->InternalLeading(font)) + borderHeight * 2;
+ const int height = lineHeight * numLines - static_cast<int>(surfaceMeasure->InternalLeading(font)) + borderHeight * 2;
if (above) {
return PRectangle(pt.x - offsetMain, pt.y - verticalOffset - height, pt.x + width - offsetMain, pt.y - verticalOffset);
} else {
diff --git a/src/CaseConvert.cxx b/src/CaseConvert.cxx
index df293f338..76bc0c652 100644
--- a/src/CaseConvert.cxx
+++ b/src/CaseConvert.cxx
@@ -621,11 +621,11 @@ public:
for (int b=1; b<widthCharBytes; b++) {
bytes[b] = (mixedPos+b < lenMixed) ? mixed[mixedPos+b] : 0;
}
- int classified = UTF8Classify(bytes, widthCharBytes);
+ const int classified = UTF8Classify(bytes, widthCharBytes);
if (!(classified & UTF8MaskInvalid)) {
// valid UTF-8
lenMixedChar = classified & UTF8MaskWidth;
- int character = UnicodeFromUTF8(bytes);
+ const int character = UnicodeFromUTF8(bytes);
caseConverted = Find(character);
}
}
@@ -759,7 +759,7 @@ void SetupConversions(enum CaseConversion conversion) {
sComplex++;
lowerUTF8[i] = 0;
- int character = UnicodeFromUTF8(reinterpret_cast<unsigned char *>(originUTF8));
+ const int character = UnicodeFromUTF8(reinterpret_cast<unsigned char *>(originUTF8));
if (conversion == CaseConversionFold && foldedUTF8[0]) {
caseConvFold.Add(character, foldedUTF8);
@@ -826,7 +826,7 @@ size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixe
std::string CaseConvertString(const std::string &s, enum CaseConversion conversion) {
std::string retMapped(s.length() * maxExpansionCaseConversion, 0);
- size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),
+ const size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),
conversion);
retMapped.resize(lenMapped);
return retMapped;
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index b4a4029f6..744b62967 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -577,10 +577,10 @@ void CellBuffer::ResetLineEnds() {
// Reinitialize line data -- too much work to preserve
lv.Init();
- Sci::Position position = 0;
- Sci::Position length = Length();
+ const Sci::Position position = 0;
+ const Sci::Position length = Length();
Sci::Line lineInsert = 1;
- bool atLineStart = true;
+ const bool atLineStart = true;
lv.InsertText(lineInsert-1, length);
unsigned char chBeforePrev = 0;
unsigned char chPrev = 0;
@@ -626,7 +626,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
}
Sci::Line lineInsert = lv.LineFromPosition(position) + 1;
- bool atLineStart = lv.LineStart(lineInsert-1) == position;
+ const bool atLineStart = lv.LineStart(lineInsert-1) == position;
// Point all the lines after the insertion point further along in the buffer
lv.InsertText(lineInsert-1, insertLength);
unsigned char chBeforePrev = substance.ValueAt(position - 2);
diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx
index 77b717a17..92e18f4ab 100644
--- a/src/ContractionState.cxx
+++ b/src/ContractionState.cxx
@@ -93,7 +93,7 @@ Sci::Line ContractionState::DocFromDisplay(Sci::Line lineDisplay) const {
if (lineDisplay > LinesDisplayed()) {
return displayLines->PartitionFromPosition(LinesDisplayed());
}
- Sci::Line lineDoc = displayLines->PartitionFromPosition(lineDisplay);
+ const Sci::Line lineDoc = displayLines->PartitionFromPosition(lineDisplay);
PLATFORM_ASSERT(GetVisible(lineDoc));
return lineDoc;
}
@@ -111,7 +111,7 @@ void ContractionState::InsertLine(Sci::Line lineDoc) {
heights->SetValueAt(lineDoc, 1);
foldDisplayTexts->InsertSpace(lineDoc, 1);
foldDisplayTexts->SetValueAt(lineDoc, nullptr);
- Sci::Line lineDisplay = DisplayFromDoc(lineDoc);
+ const Sci::Line lineDisplay = DisplayFromDoc(lineDoc);
displayLines->InsertPartition(lineDoc, lineDisplay);
displayLines->InsertText(lineDoc, 1);
}
@@ -166,7 +166,7 @@ bool ContractionState::SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd,
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) {
for (Sci::Line line = lineDocStart; line <= lineDocEnd; line++) {
if (GetVisible(line) != isVisible) {
- int difference = isVisible ? heights->ValueAt(line) : -heights->ValueAt(line);
+ const int difference = isVisible ? heights->ValueAt(line) : -heights->ValueAt(line);
visible->SetValueAt(line, isVisible ? 1 : 0);
displayLines->InsertText(line, difference);
delta += difference;
@@ -243,7 +243,7 @@ Sci::Line ContractionState::ContractedNext(Sci::Line lineDocStart) const {
if (!expanded->ValueAt(lineDocStart)) {
return lineDocStart;
} else {
- Sci::Line lineDocNextChange = expanded->EndRun(lineDocStart);
+ const Sci::Line lineDocNextChange = expanded->EndRun(lineDocStart);
if (lineDocNextChange < LinesInDoc())
return lineDocNextChange;
else
@@ -284,7 +284,7 @@ bool ContractionState::SetHeight(Sci::Line lineDoc, int height) {
}
void ContractionState::ShowAll() {
- Sci::Line lines = LinesInDoc();
+ const Sci::Line lines = LinesInDoc();
Clear();
linesInDocument = lines;
}
diff --git a/src/Document.cxx b/src/Document.cxx
index 41d6b2375..ec3ddbb4a 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -62,10 +62,10 @@ void LexInterface::Colourise(Sci::Position start, Sci::Position end) {
// code looks for child lines which may trigger styling.
performingStyle = true;
- Sci::Position lengthDoc = static_cast<Sci::Position>(pdoc->Length());
+ const Sci::Position lengthDoc = static_cast<Sci::Position>(pdoc->Length());
if (end == -1)
end = lengthDoc;
- Sci::Position len = end - start;
+ const Sci::Position len = end - start;
PLATFORM_ASSERT(len >= 0);
PLATFORM_ASSERT(start + len <= lengthDoc);
@@ -181,7 +181,7 @@ bool Document::SetDBCSCodePage(int dbcsCodePage_) {
bool Document::SetLineEndTypesAllowed(int lineEndBitSet_) {
if (lineEndBitSet != lineEndBitSet_) {
lineEndBitSet = lineEndBitSet_;
- int lineEndBitSetActive = lineEndBitSet & LineEndTypesSupported();
+ const int lineEndBitSetActive = lineEndBitSet & LineEndTypesSupported();
if (lineEndBitSetActive != cb.GetLineEndTypes()) {
ModifiedAt(0);
cb.SetLineEndTypes(lineEndBitSetActive);
@@ -278,7 +278,7 @@ void Document::TentativeUndo() {
linesAdded, action.data.get()));
}
- bool endSavePoint = cb.IsSavePoint();
+ const bool endSavePoint = cb.IsSavePoint();
if (startSavePoint != endSavePoint)
NotifySavePoint(endSavePoint);
@@ -299,7 +299,7 @@ Sci::Line Document::MarkerNext(Sci::Line lineStart, int mask) const {
int Document::AddMark(Sci::Line line, int markerNum) {
if (line >= 0 && line <= LinesTotal()) {
const int prev = Markers()->AddMark(line, markerNum, LinesTotal());
- DocModification mh(SC_MOD_CHANGEMARKER, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0, line);
+ const DocModification mh(SC_MOD_CHANGEMARKER, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0, line);
NotifyModified(mh);
return prev;
} else {
@@ -316,13 +316,13 @@ void Document::AddMarkSet(Sci::Line line, int valueSet) {
if (m & 1)
Markers()->AddMark(line, i, LinesTotal());
}
- DocModification mh(SC_MOD_CHANGEMARKER, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0, line);
+ const DocModification mh(SC_MOD_CHANGEMARKER, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0, line);
NotifyModified(mh);
}
void Document::DeleteMark(Sci::Line line, int markerNum) {
Markers()->DeleteMark(line, markerNum, false);
- DocModification mh(SC_MOD_CHANGEMARKER, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0, line);
+ const DocModification mh(SC_MOD_CHANGEMARKER, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0, line);
NotifyModified(mh);
}
@@ -409,8 +409,8 @@ bool Document::IsPositionInLineEnd(Sci::Position position) const {
}
Sci::Position Document::VCHomePosition(Sci::Position position) const {
- Sci::Line line = static_cast<Sci::Line>(LineFromPosition(position));
- Sci::Position startPosition = static_cast<Sci::Position>(LineStart(line));
+ const Sci::Line line = static_cast<Sci::Line>(LineFromPosition(position));
+ const Sci::Position startPosition = static_cast<Sci::Position>(LineStart(line));
const Sci::Position endLine = static_cast<Sci::Position>(LineEnd(line));
Sci::Position startText = startPosition;
while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t'))
@@ -492,7 +492,7 @@ Sci::Line Document::GetFoldParent(Sci::Line line) const {
void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine) {
const int level = GetLevel(line);
- Sci::Line lookLastLine = std::max(line, lastLine) + 1;
+ const Sci::Line lookLastLine = std::max(line, lastLine) + 1;
Sci::Line lookLine = line;
int lookLineLevel = level;
@@ -580,7 +580,7 @@ int Document::LenChar(Sci::Position pos) {
} else if (SC_CP_UTF8 == dbcsCodePage) {
const unsigned char leadByte = static_cast<unsigned char>(cb.CharAt(pos));
const int widthCharBytes = UTF8BytesOfLead[leadByte];
- Sci::Position lengthDoc = static_cast<Sci::Position>(Length());
+ const Sci::Position lengthDoc = static_cast<Sci::Position>(Length());
if ((pos + widthCharBytes) > lengthDoc)
return lengthDoc - pos;
else
@@ -670,7 +670,7 @@ Sci::Position Document::MovePositionOutsideChar(Sci::Position pos, Sci::Position
// Check from known start of character.
while (posCheck < pos) {
- int mbsize = IsDBCSLeadByte(cb.CharAt(posCheck)) ? 2 : 1;
+ const int mbsize = IsDBCSLeadByte(cb.CharAt(posCheck)) ? 2 : 1;
if (posCheck + mbsize == pos) {
return pos;
} else if (posCheck + mbsize > pos) {
@@ -693,7 +693,7 @@ Sci::Position Document::MovePositionOutsideChar(Sci::Position pos, Sci::Position
// A \r\n pair is treated as two characters.
Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const {
// If out of range, just return minimum/maximum value.
- int increment = (moveDir > 0) ? 1 : -1;
+ const int increment = (moveDir > 0) ? 1 : -1;
if (pos + increment <= 0)
return 0;
if (pos + increment >= Length())
@@ -712,7 +712,7 @@ Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const {
char charBytes[UTF8MaxBytes] = {static_cast<char>(leadByte),0,0,0};
for (int b=1; b<widthCharBytes; b++)
charBytes[b] = cb.CharAt(static_cast<int>(pos+b));
- int utf8status = UTF8Classify(reinterpret_cast<const unsigned char *>(charBytes), widthCharBytes);
+ const int utf8status = UTF8Classify(reinterpret_cast<const unsigned char *>(charBytes), widthCharBytes);
if (utf8status & UTF8MaskInvalid)
pos++;
else
@@ -735,7 +735,7 @@ Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const {
}
} else {
if (moveDir > 0) {
- int mbsize = IsDBCSLeadByte(cb.CharAt(pos)) ? 2 : 1;
+ const int mbsize = IsDBCSLeadByte(cb.CharAt(pos)) ? 2 : 1;
pos += mbsize;
if (pos > Length())
pos = static_cast<Sci::Position>(Length());
@@ -794,7 +794,7 @@ Document::CharacterExtracted Document::CharacterAfter(Sci::Position position) co
unsigned char charBytes[UTF8MaxBytes] = { leadByte, 0, 0, 0 };
for (int b = 1; b<widthCharBytes; b++)
charBytes[b] = static_cast<unsigned char>(cb.CharAt(position + b));
- int utf8status = UTF8Classify(charBytes, widthCharBytes);
+ const int utf8status = UTF8Classify(charBytes, widthCharBytes);
if (utf8status & UTF8MaskInvalid) {
// Treat as invalid and use up just one byte
return CharacterExtracted(unicodeReplacementChar, 1);
@@ -833,7 +833,7 @@ Document::CharacterExtracted Document::CharacterBefore(Sci::Position position) c
unsigned char charBytes[UTF8MaxBytes] = { 0, 0, 0, 0 };
for (int b = 0; b<widthCharBytes; b++)
charBytes[b] = static_cast<unsigned char>(cb.CharAt(startUTF + b));
- int utf8status = UTF8Classify(charBytes, widthCharBytes);
+ const int utf8status = UTF8Classify(charBytes, widthCharBytes);
if (utf8status & UTF8MaskInvalid) {
// Treat as invalid and use up just one byte
return CharacterExtracted(unicodeReplacementChar, 1);
@@ -1059,8 +1059,8 @@ bool Document::DeleteChars(Sci::Position pos, Sci::Position len) {
SC_MOD_BEFOREDELETE | SC_PERFORMED_USER,
pos, len,
0, 0));
- Sci::Line prevLinesTotal = LinesTotal();
- bool startSavePoint = cb.IsSavePoint();
+ const Sci::Line prevLinesTotal = LinesTotal();
+ const bool startSavePoint = cb.IsSavePoint();
bool startSequence = false;
const char *text = cb.DeleteChars(pos, len, startSequence);
if (startSavePoint && cb.IsCollectingUndo())
@@ -1111,8 +1111,8 @@ Sci::Position Document::InsertString(Sci::Position position, const char *s, Sci:
SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
position, insertLength,
0, s));
- Sci::Line prevLinesTotal = LinesTotal();
- bool startSavePoint = cb.IsSavePoint();
+ const Sci::Line prevLinesTotal = LinesTotal();
+ const bool startSavePoint = cb.IsSavePoint();
bool startSequence = false;
const char *text = cb.InsertString(position, s, insertLength, startSequence);
if (startSavePoint && cb.IsCollectingUndo())
@@ -1137,7 +1137,7 @@ void Document::ChangeInsertion(const char *s, Sci::Position length) {
int SCI_METHOD Document::AddData(const char *data, Sci_Position length) {
try {
- Sci::Position position = static_cast<Sci::Position>(Length());
+ const Sci::Position position = static_cast<Sci::Position>(Length());
InsertString(position, data, static_cast<Sci::Position>(length));
} catch (std::bad_alloc &) {
return SC_STATUS_BADALLOC;
@@ -1227,7 +1227,7 @@ Sci::Position Document::Undo() {
linesAdded, action.data.get()));
}
- bool endSavePoint = cb.IsSavePoint();
+ const bool endSavePoint = cb.IsSavePoint();
if (startSavePoint != endSavePoint)
NotifySavePoint(endSavePoint);
}
@@ -1287,7 +1287,7 @@ Sci::Position Document::Redo() {
linesAdded, action.data.get()));
}
- bool endSavePoint = cb.IsSavePoint();
+ const bool endSavePoint = cb.IsSavePoint();
if (startSavePoint != endSavePoint)
NotifySavePoint(endSavePoint);
}
@@ -1306,7 +1306,7 @@ void Document::DelCharBack(Sci::Position pos) {
} else if (IsCrLf(pos - 2)) {
DeleteChars(pos - 2, 2);
} else if (dbcsCodePage) {
- Sci::Position startChar = NextPosition(pos, -1);
+ const Sci::Position startChar = NextPosition(pos, -1);
DeleteChars(startChar, pos - startChar);
} else {
DeleteChars(pos - 1, 1);
@@ -1356,8 +1356,8 @@ Sci::Position Document::SetLineIndentation(Sci::Line line, Sci::Position indent)
indent = 0;
if (indent != indentOfLine) {
std::string linebuf = CreateIndentation(indent, tabInChars, !useTabs);
- Sci::Position thisLineStart = static_cast<Sci::Position>(LineStart(line));
- Sci::Position indentPos = GetLineIndentPosition(line);
+ const Sci::Position thisLineStart = static_cast<Sci::Position>(LineStart(line));
+ const Sci::Position indentPos = GetLineIndentPosition(line);
UndoGroup ug(this);
DeleteChars(thisLineStart, indentPos - thisLineStart);
return thisLineStart + InsertString(thisLineStart, linebuf.c_str(),
@@ -1380,7 +1380,7 @@ Sci::Position Document::GetLineIndentPosition(Sci::Line line) const {
Sci::Position Document::GetColumn(Sci::Position pos) {
Sci::Position column = 0;
- Sci::Line line = static_cast<Sci::Line>(LineFromPosition(pos));
+ const Sci::Line line = static_cast<Sci::Line>(LineFromPosition(pos));
if ((line >= 0) && (line < LinesTotal())) {
for (Sci::Position i = static_cast<Sci::Position>(LineStart(line)); i < pos;) {
const char ch = cb.CharAt(i);
@@ -1456,7 +1456,7 @@ Sci::Position Document::FindColumn(Sci::Line line, Sci::Position column) {
void Document::Indent(bool forwards, Sci::Line lineBottom, Sci::Line lineTop) {
// Dedent - suck white space off the front of the line to dedent by equivalent of a tab
for (Sci::Line line = lineBottom; line >= lineTop; line--) {
- Sci::Position indentOfLine = GetLineIndentation(line);
+ const Sci::Position indentOfLine = GetLineIndentation(line);
if (forwards) {
if (LineStart(line) < LineEnd(line)) {
SetLineIndentation(line, indentOfLine + IndentSize());
@@ -1743,7 +1743,7 @@ Sci::Position Document::NextWordEnd(Sci::Position pos, int delta) const {
}
} else {
while (pos < Length()) {
- CharacterExtracted ce = CharacterAfter(pos);
+ const CharacterExtracted ce = CharacterAfter(pos);
if (WordCharacterClass(ce.character) != CharClassify::ccSpace)
break;
pos += ce.widthBytes;
@@ -1830,7 +1830,7 @@ Document::CharacterExtracted Document::ExtractCharacter(Sci::Position position)
unsigned char charBytes[UTF8MaxBytes] = { leadByte, 0, 0, 0 };
for (int b=1; b<widthCharBytes; b++)
charBytes[b] = static_cast<unsigned char>(cb.CharAt(position + b));
- int utf8status = UTF8Classify(charBytes, widthCharBytes);
+ const int utf8status = UTF8Classify(charBytes, widthCharBytes);
if (utf8status & UTF8MaskInvalid) {
// Treat as invalid and use up just one byte
return CharacterExtracted(unicodeReplacementChar, 1);
@@ -1990,7 +1990,7 @@ long Document::FindText(Sci::Position minPos, Sci::Position maxPos, const char *
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
bool found = (pos + lengthFind) <= limitPos;
for (int indexSearch = 0; (indexSearch < lengthFind) && found; indexSearch++) {
- char ch = CharAt(pos + indexSearch);
+ const char ch = CharAt(pos + indexSearch);
char folded[2];
pcf->Fold(folded, sizeof(folded), &ch, 1);
found = folded[0] == searchThing[indexSearch];
@@ -2039,9 +2039,9 @@ bool SCI_METHOD Document::SetStyleFor(Sci_Position length, char style) {
return false;
} else {
enteredStyling++;
- Sci::Position prevEndStyled = endStyled;
+ const Sci::Position prevEndStyled = endStyled;
if (cb.SetStyleFor(static_cast<Sci::Position>(endStyled), static_cast<Sci::Position>(length), style)) {
- DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
+ const DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
prevEndStyled, static_cast<Sci::Position>(length));
NotifyModified(mh);
}
@@ -2070,7 +2070,7 @@ bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) {
}
}
if (didChange) {
- DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
+ const DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
startMod, endMod - startMod + 1);
NotifyModified(mh);
}
@@ -2083,8 +2083,8 @@ void Document::EnsureStyledTo(Sci::Position pos) {
if ((enteredStyling == 0) && (pos > GetEndStyled())) {
IncrementStyleClock();
if (pli && !pli->UseContainerLexing()) {
- Sci::Line lineEndStyled = static_cast<Sci::Line>(LineFromPosition(GetEndStyled()));
- Sci::Position endStyledTo = static_cast<Sci::Position>(LineStart(lineEndStyled));
+ const Sci::Line lineEndStyled = static_cast<Sci::Line>(LineFromPosition(GetEndStyled()));
+ const Sci::Position endStyledTo = static_cast<Sci::Position>(LineStart(lineEndStyled));
pli->Colourise(endStyledTo, pos);
} else {
// Ask the watchers to style, and stop as soon as one responds.
@@ -2141,7 +2141,7 @@ void Document::SetLexInterface(LexInterface *pLexInterface) {
int SCI_METHOD Document::SetLineState(Sci_Position line, int state) {
const int statePrevious = States()->SetLineState(static_cast<Sci::Line>(line), state);
if (state != statePrevious) {
- DocModification mh(SC_MOD_CHANGELINESTATE, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0,
+ const DocModification mh(SC_MOD_CHANGELINESTATE, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0,
static_cast<Sci::Line>(line));
NotifyModified(mh);
}
@@ -2157,7 +2157,7 @@ Sci::Line Document::GetMaxLineState() const {
}
void SCI_METHOD Document::ChangeLexerState(Sci_Position start, Sci_Position end) {
- DocModification mh(SC_MOD_LEXERSTATE, static_cast<Sci::Position>(start),
+ const DocModification mh(SC_MOD_LEXERSTATE, static_cast<Sci::Position>(start),
static_cast<Sci::Position>(end-start), 0, 0, 0);
NotifyModified(mh);
}
@@ -2170,7 +2170,7 @@ StyledText Document::MarginStyledText(Sci::Line line) const {
void Document::MarginSetText(Sci::Line line, const char *text) {
Margins()->SetText(line, text);
- DocModification mh(SC_MOD_CHANGEMARGIN, static_cast<Sci::Position>(LineStart(line)),
+ const DocModification mh(SC_MOD_CHANGEMARGIN, static_cast<Sci::Position>(LineStart(line)),
0, 0, 0, line);
NotifyModified(mh);
}
@@ -2215,7 +2215,7 @@ void Document::AnnotationSetText(Sci::Line line, const char *text) {
void Document::AnnotationSetStyle(Sci::Line line, int style) {
Annotations()->SetStyle(line, style);
- DocModification mh(SC_MOD_CHANGEANNOTATION, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0, line);
+ const DocModification mh(SC_MOD_CHANGEANNOTATION, static_cast<Sci::Position>(LineStart(line)), 0, 0, 0, line);
NotifyModified(mh);
}
@@ -2249,14 +2249,14 @@ void SCI_METHOD Document::DecorationFillRange(Sci_Position position, int value,
Sci::Position sciPosition = static_cast<Sci::Position>(position);
Sci::Position sciFillLength = static_cast<Sci::Position>(fillLength);
if (decorations.FillRange(sciPosition, value, sciFillLength)) {
- DocModification mh(SC_MOD_CHANGEINDICATOR | SC_PERFORMED_USER,
+ const DocModification mh(SC_MOD_CHANGEINDICATOR | SC_PERFORMED_USER,
sciPosition, sciFillLength);
NotifyModified(mh);
}
}
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
- WatcherWithUserData wwud(watcher, userData);
+ const WatcherWithUserData wwud(watcher, userData);
std::vector<WatcherWithUserData>::iterator it =
std::find(watchers.begin(), watchers.end(), wwud);
if (it != watchers.end())
@@ -2899,7 +2899,7 @@ bool MatchOnLines(const Document *doc, const Regex &regexp, const RESearchRange
for (size_t co = 0; co < match.size(); co++) {
search.bopat[co] = match[co].first.Pos();
search.eopat[co] = match[co].second.PosRoundUp();
- Sci::Position lenMatch = search.eopat[co] - search.bopat[co];
+ const Sci::Position lenMatch = search.eopat[co] - search.bopat[co];
search.pat[co].resize(lenMatch);
for (Sci::Position iPos = 0; iPos < lenMatch; iPos++) {
search.pat[co][iPos] = doc->CharAt(iPos + search.bopat[co]);
@@ -2925,12 +2925,12 @@ Sci::Position Cxx11RegexFindText(Document *doc, Sci::Position minPos, Sci::Posit
bool matched = false;
if (SC_CP_UTF8 == doc->dbcsCodePage) {
- size_t lenS = strlen(s);
+ const size_t lenS = strlen(s);
std::vector<wchar_t> ws(lenS + 1);
#if WCHAR_T_IS_16
- size_t outLen = UTF16FromUTF8(s, lenS, &ws[0], lenS);
+ const size_t outLen = UTF16FromUTF8(s, lenS, &ws[0], lenS);
#else
- size_t outLen = UTF32FromUTF8(s, lenS, reinterpret_cast<unsigned int *>(&ws[0]), lenS);
+ const size_t outLen = UTF32FromUTF8(s, lenS, reinterpret_cast<unsigned int *>(&ws[0]), lenS);
#endif
ws[outLen] = 0;
std::wregex regexp;
@@ -3065,8 +3065,8 @@ const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text,
for (int j = 0; j < *length; j++) {
if (text[j] == '\\') {
if (text[j + 1] >= '0' && text[j + 1] <= '9') {
- unsigned int patNum = text[j + 1] - '0';
- Sci::Position len = search.eopat[patNum] - search.bopat[patNum];
+ const unsigned int patNum = text[j + 1] - '0';
+ const Sci::Position len = search.eopat[patNum] - search.bopat[patNum];
if (!search.pat[patNum].empty()) // Will be null if try for a match that did not occur
substituted.append(search.pat[patNum].c_str(), len);
j++;
diff --git a/src/EditView.cxx b/src/EditView.cxx
index d4cdf4dc8..1feb655b9 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -87,7 +87,7 @@ static int WidthStyledText(Surface *surface, const ViewStyle &vs, int styleOffse
int width = 0;
size_t start = 0;
while (start < len) {
- size_t style = styles[start];
+ const size_t style = styles[start];
size_t endSegment = start;
while ((endSegment + 1 < len) && (static_cast<size_t>(styles[endSegment + 1]) == style))
endSegment++;
@@ -103,7 +103,7 @@ int WidestLineWidth(Surface *surface, const ViewStyle &vs, int styleOffset, cons
int widthMax = 0;
size_t start = 0;
while (start < st.length) {
- size_t lenLine = st.LineLength(start);
+ const size_t lenLine = st.LineLength(start);
int widthSubLine;
if (st.multipleStyles) {
widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine);
@@ -214,7 +214,7 @@ void EditView::ClearAllTabstops() {
}
XYPOSITION EditView::NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const {
- int next = GetNextTabstop(line, static_cast<int>(x + tabWidthMinimumPixels));
+ const int next = GetNextTabstop(line, static_cast<int>(x + tabWidthMinimumPixels));
if (next > 0)
return static_cast<XYPOSITION>(next);
return (static_cast<int>((x + tabWidthMinimumPixels) / tabWidth) + 1) * tabWidth;
@@ -320,13 +320,13 @@ void EditView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewSt
// 1 extra pixel in height so can handle odd/even positions and so produce a continuous line
pixmapIndentGuide->InitPixMap(1, vsDraw.lineHeight + 1, surfaceWindow, wid);
pixmapIndentGuideHighlight->InitPixMap(1, vsDraw.lineHeight + 1, surfaceWindow, wid);
- PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vsDraw.lineHeight);
+ const PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vsDraw.lineHeight);
pixmapIndentGuide->FillRectangle(rcIG, vsDraw.styles[STYLE_INDENTGUIDE].back);
pixmapIndentGuide->PenColour(vsDraw.styles[STYLE_INDENTGUIDE].fore);
pixmapIndentGuideHighlight->FillRectangle(rcIG, vsDraw.styles[STYLE_BRACELIGHT].back);
pixmapIndentGuideHighlight->PenColour(vsDraw.styles[STYLE_BRACELIGHT].fore);
for (int stripe = 1; stripe < vsDraw.lineHeight + 1; stripe += 2) {
- PRectangle rcPixel = PRectangle::FromInts(0, stripe, 1, stripe + 1);
+ const PRectangle rcPixel = PRectangle::FromInts(0, stripe, 1, stripe + 1);
pixmapIndentGuide->FillRectangle(rcPixel, vsDraw.styles[STYLE_INDENTGUIDE].fore);
pixmapIndentGuideHighlight->FillRectangle(rcPixel, vsDraw.styles[STYLE_BRACELIGHT].fore);
}
@@ -334,10 +334,10 @@ void EditView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewSt
}
LineLayout *EditView::RetrieveLineLayout(Sci::Line lineNumber, const EditModel &model) {
- Sci::Position posLineStart = static_cast<Sci::Position>(model.pdoc->LineStart(lineNumber));
- Sci::Position posLineEnd = static_cast<Sci::Position>(model.pdoc->LineStart(lineNumber + 1));
+ const Sci::Position posLineStart = static_cast<Sci::Position>(model.pdoc->LineStart(lineNumber));
+ const Sci::Position posLineEnd = static_cast<Sci::Position>(model.pdoc->LineStart(lineNumber + 1));
PLATFORM_ASSERT(posLineEnd >= posLineStart);
- Sci::Line lineCaret = static_cast<Sci::Line>(model.pdoc->LineFromPosition(model.sel.MainCaret()));
+ const Sci::Line lineCaret = static_cast<Sci::Line>(model.pdoc->LineFromPosition(model.sel.MainCaret()));
return llc.Retrieve(lineNumber, lineCaret,
posLineEnd - posLineStart, model.pdoc->GetStyleClock(),
model.LinesOnScreen() + 1, model.pdoc->LinesTotal());
@@ -354,7 +354,7 @@ void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surfa
PLATFORM_ASSERT(line < model.pdoc->LinesTotal());
PLATFORM_ASSERT(ll->chars != NULL);
- Sci::Position posLineStart = static_cast<Sci::Position>(model.pdoc->LineStart(line));
+ const Sci::Position posLineStart = static_cast<Sci::Position>(model.pdoc->LineStart(line));
Sci::Position posLineEnd = static_cast<Sci::Position>(model.pdoc->LineStart(line + 1));
// If the line is very long, limit the treatment to a length that should fit in the viewport
if (posLineEnd >(posLineStart + ll->maxLineLength)) {
@@ -372,7 +372,7 @@ void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surfa
int styleByte = 0;
int numCharsInLine = 0;
while (numCharsInLine < lineLength) {
- Sci::Position charInDoc = numCharsInLine + posLineStart;
+ const Sci::Position charInDoc = numCharsInLine + posLineStart;
const char chDoc = model.pdoc->CharAt(charInDoc);
styleByte = model.pdoc->StyleIndexAt(charInDoc);
allSame = allSame &&
@@ -786,8 +786,8 @@ static ColourDesired TextBackground(const EditModel &model, const ViewStyle &vsD
}
void EditView::DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, Sci::Position start, PRectangle rcSegment, bool highlight) {
- 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));
+ const Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0);
+ const 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);
}
@@ -875,7 +875,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
rcSegment.right = xEol + xStart + virtualSpace;
surface->FillRectangle(rcSegment, background.isSet ? background : vsDraw.styles[ll->styles[ll->numCharsInLine]].back);
if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) {
- SelectionSegment virtualSpaceRange(SelectionPosition(static_cast<Sci::Position>(model.pdoc->LineEnd(line))),
+ const SelectionSegment virtualSpaceRange(SelectionPosition(static_cast<Sci::Position>(model.pdoc->LineEnd(line))),
SelectionPosition(static_cast<Sci::Position>(model.pdoc->LineEnd(line)),
model.sel.VirtualSpaceFor(static_cast<Sci::Position>(model.pdoc->LineEnd(line)))));
for (size_t r = 0; r<model.sel.Count(); r++) {
@@ -900,7 +900,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
int eolInSelection = 0;
int alpha = SC_ALPHA_NOALPHA;
if (!hideSelection) {
- Sci::Position posAfterLineEnd = static_cast<Sci::Position>(model.pdoc->LineStart(line + 1));
+ const Sci::Position posAfterLineEnd = static_cast<Sci::Position>(model.pdoc->LineStart(line + 1));
eolInSelection = (lastSubLine == true) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0;
alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
}
@@ -915,8 +915,8 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
char hexits[4];
const char *ctrlChar;
const unsigned char chEOL = ll->chars[eolPos];
- int styleMain = ll->styles[eolPos];
- ColourDesired textBack = TextBackground(model, vsDraw, ll, background, eolInSelection, false, styleMain, eolPos);
+ const int styleMain = ll->styles[eolPos];
+ const ColourDesired textBack = TextBackground(model, vsDraw, ll, background, eolInSelection, false, styleMain, eolPos);
if (UTF8IsAscii(chEOL)) {
ctrlChar = ControlCharacterString(chEOL);
} else {
@@ -1017,7 +1017,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
static void DrawIndicator(int indicNum, Sci::Position startPos, Sci::Position endPos, Surface *surface, const ViewStyle &vsDraw,
const LineLayout *ll, int xStart, PRectangle rcLine, Sci::Position secondCharacter, int subLine, Indicator::DrawState drawState, int value) {
const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)];
- PRectangle rcIndic(
+ const PRectangle rcIndic(
ll->positions[startPos] + xStart - subLineStart,
rcLine.top + vsDraw.maxAscent,
ll->positions[endPos] + xStart - subLineStart,
@@ -1070,16 +1070,16 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
(vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACEBAD))) {
const int braceIndicator = (model.bracesMatchStyle == STYLE_BRACELIGHT) ? vsDraw.braceHighlightIndicator : vsDraw.braceBadLightIndicator;
if (under == vsDraw.indicators[braceIndicator].under) {
- Range rangeLine(posLineStart + lineStart, posLineEnd);
+ const Range rangeLine(posLineStart + lineStart, posLineEnd);
if (rangeLine.ContainsCharacter(model.braces[0])) {
- Sci::Position braceOffset = model.braces[0] - posLineStart;
+ const Sci::Position braceOffset = model.braces[0] - posLineStart;
if (braceOffset < ll->numCharsInLine) {
const Sci::Position secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[0] + 1, 1) - posLineStart;
DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1);
}
}
if (rangeLine.ContainsCharacter(model.braces[1])) {
- Sci::Position braceOffset = model.braces[1] - posLineStart;
+ const Sci::Position braceOffset = model.braces[1] - posLineStart;
if (braceOffset < ll->numCharsInLine) {
const Sci::Position secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[1] + 1, 1) - posLineStart;
DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1);
@@ -1107,13 +1107,13 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
int eolInSelection = 0;
int alpha = SC_ALPHA_NOALPHA;
if (!hideSelection) {
- Sci::Position posAfterLineEnd = static_cast<Sci::Position>(model.pdoc->LineStart(line + 1));
+ const Sci::Position posAfterLineEnd = static_cast<Sci::Position>(model.pdoc->LineStart(line + 1));
eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0;
alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
}
const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
- XYPOSITION virtualSpace = model.sel.VirtualSpaceFor(
+ const XYPOSITION virtualSpace = model.sel.VirtualSpaceFor(
static_cast<Sci::Position>(model.pdoc->LineEnd(line))) * spaceWidth;
rcSegment.left = xStart + static_cast<XYPOSITION>(ll->positions[ll->numCharsInLine] - subLineStart) + virtualSpace + vsDraw.aveCharWidth;
rcSegment.right = rcSegment.left + static_cast<XYPOSITION>(widthFoldDisplayText);
@@ -1246,7 +1246,7 @@ void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const Vi
static void DrawBlockCaret(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
int subLine, int xStart, Sci::Position offset, Sci::Position posCaret, PRectangle rcCaret, ColourDesired caretColour) {
- Sci::Position lineStart = ll->LineStart(subLine);
+ const Sci::Position lineStart = ll->LineStart(subLine);
Sci::Position posBefore = posCaret;
Sci::Position posAfter = model.pdoc->MovePositionOutsideChar(posCaret + 1, 1);
Sci::Position numCharsToDraw = posAfter - posCaret;
@@ -1294,14 +1294,14 @@ static void DrawBlockCaret(Surface *surface, const EditModel &model, const ViewS
// Adjust caret position to take into account any word wrapping symbols.
if ((ll->wrapIndent != 0) && (lineStart != 0)) {
- XYPOSITION wordWrapCharWidth = ll->wrapIndent;
+ const XYPOSITION wordWrapCharWidth = ll->wrapIndent;
rcCaret.left += wordWrapCharWidth;
rcCaret.right += wordWrapCharWidth;
}
// This character is where the caret block is, we override the colours
// (inversed) for drawing the caret here.
- int styleMain = ll->styles[offsetFirstChar];
+ const int styleMain = ll->styles[offsetFirstChar];
FontAlias fontText = vsDraw.styles[styleMain].font;
surface->DrawTextClipped(rcCaret, fontText,
rcCaret.top + vsDraw.maxAscent, &ll->chars[offsetFirstChar],
@@ -1386,7 +1386,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
rcCaret.left = static_cast<XYPOSITION>(RoundXYPosition(xposCaret - caretWidthOffset));
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
}
- ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour;
+ const ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour;
if (drawBlockCaret) {
DrawBlockCaret(surface, model, vsDraw, ll, subLine, xStart, offset, posCaret.Position(), rcCaret, caretColour);
} else {
@@ -1488,7 +1488,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
for (int cpos = 0; cpos <= i - ts.start; cpos++) {
if (ll->chars[cpos + ts.start] == ' ') {
if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) {
- PRectangle rcSpace(
+ const PRectangle rcSpace(
ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.top,
ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart),
@@ -1511,7 +1511,7 @@ static void DrawEdgeLine(Surface *surface, const ViewStyle &vsDraw, const LineLa
Range lineRange, int xStart) {
if (vsDraw.edgeState == EDGE_LINE) {
PRectangle rcSegment = rcLine;
- int edgeX = static_cast<int>(vsDraw.theEdge.column * vsDraw.spaceWidth);
+ const int edgeX = static_cast<int>(vsDraw.theEdge.column * vsDraw.spaceWidth);
rcSegment.left = static_cast<XYPOSITION>(edgeX + xStart);
if ((ll->wrapIndent != 0) && (lineRange.start != 0))
rcSegment.left -= ll->wrapIndent;
@@ -1521,7 +1521,7 @@ static void DrawEdgeLine(Surface *surface, const ViewStyle &vsDraw, const LineLa
for (size_t edge = 0; edge < vsDraw.theMultiEdge.size(); edge++) {
if (vsDraw.theMultiEdge[edge].column >= 0) {
PRectangle rcSegment = rcLine;
- int edgeX = static_cast<int>(vsDraw.theMultiEdge[edge].column * vsDraw.spaceWidth);
+ const int edgeX = static_cast<int>(vsDraw.theMultiEdge[edge].column * vsDraw.spaceWidth);
rcSegment.left = static_cast<XYPOSITION>(edgeX + xStart);
if ((ll->wrapIndent != 0) && (lineRange.start != 0))
rcSegment.left -= ll->wrapIndent;
@@ -1648,7 +1648,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
// 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)) {
- int styleMain = ll->styles[i];
+ const int styleMain = ll->styles[i];
ColourDesired textFore = vsDraw.styles[styleMain].fore;
FontAlias textFont = vsDraw.styles[styleMain].font;
//hotspot foreground
@@ -1699,7 +1699,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth;
indentCount++) {
if (indentCount > 0) {
- int xIndent = static_cast<int>(indentCount * indentWidth);
+ const int xIndent = static_cast<int>(indentCount * indentWidth);
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
(ll->xHighlightGuide == xIndent));
}
@@ -1710,7 +1710,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (vsDraw.whitespaceColours.fore.isSet)
textFore = vsDraw.whitespaceColours.fore;
surface->PenColour(textFore);
- PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowHeight,
+ const PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowHeight,
rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
if (customDrawTabArrow == NULL)
DrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2), vsDraw);
@@ -1725,7 +1725,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
// the box goes around the characters tightly. Seems to be no way to work out what height
// is taken by an individual character - internal leading gives varying results.
FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font;
- char cc[2] = { static_cast<char>(vsDraw.controlCharSymbol), '\0' };
+ const char cc[2] = { static_cast<char>(vsDraw.controlCharSymbol), '\0' };
surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
rcSegment.top + vsDraw.maxAscent,
cc, 1, textBack, textFore);
@@ -1755,10 +1755,10 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (vsDraw.whitespaceColours.fore.isSet)
textFore = vsDraw.whitespaceColours.fore;
if (vsDraw.WhiteSpaceVisible(inIndentation)) {
- XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2;
+ const XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2;
if ((phasesDraw == phasesOne) && drawWhitespaceBackground) {
textBack = vsDraw.whitespaceColours.back;
- PRectangle rcSpace(
+ const PRectangle rcSpace(
ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.top,
ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart),
@@ -1778,7 +1778,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth;
indentCount++) {
if (indentCount > 0) {
- int xIndent = static_cast<int>(indentCount * indentWidth);
+ const int xIndent = static_cast<int>(indentCount * indentWidth);
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
(ll->xHighlightGuide == xIndent));
}
@@ -1855,7 +1855,7 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode
}
for (int indentPos = model.pdoc->IndentSize(); indentPos < indentSpace; indentPos += model.pdoc->IndentSize()) {
- int xIndent = static_cast<int>(indentPos * vsDraw.spaceWidth);
+ const int xIndent = static_cast<int>(indentPos * vsDraw.spaceWidth);
if (xIndent < xStartText) {
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcLine,
(ll->xHighlightGuide == xIndent));
@@ -2059,7 +2059,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
rcLine.top = static_cast<XYPOSITION>(ypos);
rcLine.bottom = static_cast<XYPOSITION>(ypos + vsDraw.lineHeight);
- Range rangeLine(static_cast<Sci::Position>(model.pdoc->LineStart(lineDoc)),
+ const Range rangeLine(static_cast<Sci::Position>(model.pdoc->LineStart(lineDoc)),
static_cast<Sci::Position>(model.pdoc->LineStart(lineDoc + 1)));
// Highlight the current braces if any
@@ -2089,8 +2089,8 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
}
if (bufferedDraw) {
- Point from = Point::FromInts(vsDraw.textStart - leftTextOverlap, 0);
- PRectangle rcCopyArea = PRectangle::FromInts(vsDraw.textStart - leftTextOverlap, yposScreen,
+ const Point from = Point::FromInts(vsDraw.textStart - leftTextOverlap, 0);
+ const PRectangle rcCopyArea = PRectangle::FromInts(vsDraw.textStart - leftTextOverlap, yposScreen,
static_cast<int>(rcClient.right - vsDraw.rightMarginWidth),
yposScreen + vsDraw.lineHeight);
surfaceWindow->Copy(rcCopyArea, from, *pixmapLine);
@@ -2121,14 +2121,14 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
if (rcBeyondEOF.top < rcBeyondEOF.bottom) {
surfaceWindow->FillRectangle(rcBeyondEOF, vsDraw.styles[STYLE_DEFAULT].back);
if (vsDraw.edgeState == EDGE_LINE) {
- int edgeX = static_cast<int>(vsDraw.theEdge.column * vsDraw.spaceWidth);
+ const int edgeX = static_cast<int>(vsDraw.theEdge.column * vsDraw.spaceWidth);
rcBeyondEOF.left = static_cast<XYPOSITION>(edgeX + xStart);
rcBeyondEOF.right = rcBeyondEOF.left + 1;
surfaceWindow->FillRectangle(rcBeyondEOF, vsDraw.theEdge.colour);
} else if (vsDraw.edgeState == EDGE_MULTILINE) {
for (size_t edge = 0; edge < vsDraw.theMultiEdge.size(); edge++) {
if (vsDraw.theMultiEdge[edge].column >= 0) {
- int edgeX = static_cast<int>(vsDraw.theMultiEdge[edge].column * vsDraw.spaceWidth);
+ const int edgeX = static_cast<int>(vsDraw.theMultiEdge[edge].column * vsDraw.spaceWidth);
rcBeyondEOF.left = static_cast<XYPOSITION>(edgeX + xStart);
rcBeyondEOF.right = rcBeyondEOF.left + 1;
surfaceWindow->FillRectangle(rcBeyondEOF, vsDraw.theMultiEdge[edge].colour);
@@ -2149,7 +2149,7 @@ void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const
int eolInSelection = 0;
int alpha = SC_ALPHA_NOALPHA;
if (!hideSelection) {
- Sci::Position posAfterLineEnd = static_cast<Sci::Position>(model.pdoc->LineStart(line + 1));
+ const Sci::Position posAfterLineEnd = static_cast<Sci::Position>(model.pdoc->LineStart(line + 1));
eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0;
alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
}
@@ -2258,12 +2258,12 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface,
vsPrint.Refresh(*surfaceMeasure, model.pdoc->tabInChars); // Recalculate fixedColumnWidth
}
- Sci::Line linePrintStart = static_cast<Sci::Line>(
+ const Sci::Line linePrintStart = static_cast<Sci::Line>(
model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMin)));
Sci::Line linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1;
if (linePrintLast < linePrintStart)
linePrintLast = linePrintStart;
- Sci::Line linePrintMax = static_cast<Sci::Line>(
+ const Sci::Line linePrintMax = static_cast<Sci::Line>(
model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMax)));
if (linePrintLast > linePrintMax)
linePrintLast = linePrintMax;
@@ -2277,7 +2277,7 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface,
// Ensure we are styled to where we are formatting.
model.pdoc->EnsureStyledTo(endPosPrint);
- int xStart = vsPrint.fixedColumnWidth + pfr->rc.left;
+ const int xStart = vsPrint.fixedColumnWidth + pfr->rc.left;
int ypos = pfr->rc.top;
Sci::Line lineDoc = linePrintStart;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index a516fc151..db2a75160 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -212,7 +212,7 @@ void Editor::SetRepresentations() {
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"
};
for (size_t j=0; j < ELEMENTS(reps); j++) {
- char c[2] = { static_cast<char>(j), 0 };
+ const char c[2] = { static_cast<char>(j), 0 };
reprs.SetRepresentation(c, reps[j]);
}
@@ -226,7 +226,7 @@ void Editor::SetRepresentations() {
"SOS", "SGCI", "SCI", "CSI", "ST", "OSC", "PM", "APC"
};
for (size_t j=0; j < ELEMENTS(repsC1); j++) {
- char c1[3] = { '\xc2', static_cast<char>(0x80+j), 0 };
+ const char c1[3] = { '\xc2', static_cast<char>(0x80+j), 0 };
reprs.SetRepresentation(c1, repsC1[j]);
}
reprs.SetRepresentation("\xe2\x80\xa8", "LS");
@@ -236,7 +236,7 @@ void Editor::SetRepresentations() {
// UTF-8 invalid bytes
if (IsUnicodeMode()) {
for (int k=0x80; k < 0x100; k++) {
- char hiByte[2] = { static_cast<char>(k), 0 };
+ const char hiByte[2] = { static_cast<char>(k), 0 };
char hexits[5]; // Really only needs 4 but that causes warning from gcc 7.1
sprintf(hexits, "x%2X", k);
reprs.SetRepresentation(hiByte, hexits);
@@ -329,7 +329,7 @@ Sci::Line Editor::LinesOnScreen() const {
}
Sci::Line Editor::LinesToScroll() const {
- Sci::Line retVal = LinesOnScreen() - 1;
+ const Sci::Line retVal = LinesOnScreen() - 1;
if (retVal < 1)
return 1;
else
@@ -376,12 +376,12 @@ Point Editor::LocationFromPosition(Sci::Position pos, PointEnd pe) {
}
int Editor::XFromPosition(Sci::Position pos) {
- Point pt = LocationFromPosition(pos);
+ const Point pt = LocationFromPosition(pos);
return static_cast<int>(pt.x) - vs.textStart + xOffset;
}
int Editor::XFromPosition(SelectionPosition sp) {
- Point pt = LocationFromPosition(sp);
+ const Point pt = LocationFromPosition(sp);
return static_cast<int>(pt.x) - vs.textStart + xOffset;
}
@@ -392,7 +392,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
if (canReturnInvalid) {
PRectangle rcClient = GetTextRectangle();
// May be in scroll view coordinates so translate back to main view
- Point ptOrigin = GetVisibleOriginInMain();
+ const Point ptOrigin = GetVisibleOriginInMain();
rcClient.Move(-ptOrigin.x, -ptOrigin.y);
if (!rcClient.Contains(pt))
return SelectionPosition(INVALID_POSITION);
@@ -401,7 +401,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
if (pt.y < 0)
return SelectionPosition(INVALID_POSITION);
}
- PointDocument ptdoc = DocumentPointFromView(pt);
+ const PointDocument ptdoc = DocumentPointFromView(pt);
return view.SPositionFromLocation(surface, *this, ptdoc, canReturnInvalid, charPosition, virtualSpace, vs);
}
@@ -454,7 +454,7 @@ void Editor::RedrawRect(PRectangle rc) {
//Platform::DebugPrintf("Redraw %0d,%0d - %0d,%0d\n", rc.left, rc.top, rc.right, rc.bottom);
// Clip the redraw rectangle into the client area
- PRectangle rcClient = GetClientRectangle();
+ const PRectangle rcClient = GetClientRectangle();
if (rc.top < rcClient.top)
rc.top = rcClient.top;
if (rc.bottom > rcClient.bottom)
@@ -475,7 +475,7 @@ void Editor::DiscardOverdraw() {
void Editor::Redraw() {
//Platform::DebugPrintf("Redraw all\n");
- PRectangle rcClient = GetClientRectangle();
+ const PRectangle rcClient = GetClientRectangle();
wMain.InvalidateRectangle(rcClient);
if (wMargin.GetID())
wMargin.InvalidateAll();
@@ -503,7 +503,7 @@ void Editor::RedrawSelMargin(Sci::Line line, bool allAfter) {
// Inflate line rectangle if there are image markers with height larger than line height
if (vs.largestMarkerHeight > vs.lineHeight) {
- int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2;
+ const int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2;
rcLine.top -= delta;
rcLine.bottom += delta;
if (rcLine.top < rcMarkers.top)
@@ -519,7 +519,7 @@ void Editor::RedrawSelMargin(Sci::Line line, bool allAfter) {
return;
}
if (wMargin.GetID()) {
- Point ptOrigin = GetVisibleOriginInMain();
+ const Point ptOrigin = GetVisibleOriginInMain();
rcMarkers.Move(-ptOrigin.x, -ptOrigin.y);
wMargin.InvalidateRectangle(rcMarkers);
} else {
@@ -646,7 +646,7 @@ SelectionRange Editor::LineSelectionRange(SelectionPosition currentPos_, Selecti
void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) {
currentPos_ = ClampPositionIntoDocument(currentPos_);
anchor_ = ClampPositionIntoDocument(anchor_);
- Sci::Line currentLine = static_cast<Sci::Line>(pdoc->LineFromPosition(currentPos_.Position()));
+ const Sci::Line currentLine = static_cast<Sci::Line>(pdoc->LineFromPosition(currentPos_.Position()));
SelectionRange rangeNew(currentPos_, anchor_);
if (sel.selType == Selection::selLines) {
rangeNew = LineSelectionRange(currentPos_, anchor_);
@@ -672,7 +672,7 @@ void Editor::SetSelection(Sci::Position currentPos_, Sci::Position anchor_) {
// Just move the caret on the main selection
void Editor::SetSelection(SelectionPosition currentPos_) {
currentPos_ = ClampPositionIntoDocument(currentPos_);
- Sci::Line currentLine = static_cast<Sci::Line>(pdoc->LineFromPosition(currentPos_.Position()));
+ const Sci::Line currentLine = static_cast<Sci::Line>(pdoc->LineFromPosition(currentPos_.Position()));
if (sel.Count() > 1 || !(sel.RangeMain().caret == currentPos_)) {
InvalidateSelection(SelectionRange(currentPos_));
}
@@ -700,7 +700,7 @@ void Editor::SetSelection(int currentPos_) {
}
void Editor::SetEmptySelection(SelectionPosition currentPos_) {
- Sci::Line currentLine = static_cast<Sci::Line>(
+ const Sci::Line currentLine = static_cast<Sci::Line>(
pdoc->LineFromPosition(currentPos_.Position()));
SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_));
if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) {
@@ -758,7 +758,7 @@ void Editor::MultipleSelectAdd(AddNumber addNumber) {
const Sci::Position searchEnd = it->end;
for (;;) {
Sci::Position lengthFound = static_cast<Sci::Position>(selectedText.length());
- Sci::Position pos = static_cast<Sci::Position>(pdoc->FindText(searchStart, searchEnd,
+ const Sci::Position pos = static_cast<Sci::Position>(pdoc->FindText(searchStart, searchEnd,
selectedText.c_str(), searchFlags, &lengthFound));
if (pos >= 0) {
sel.AddSelection(SelectionRange(pos + lengthFound, pos));
@@ -778,7 +778,7 @@ void Editor::MultipleSelectAdd(AddNumber addNumber) {
bool Editor::RangeContainsProtected(Sci::Position start, Sci::Position end) const {
if (vs.ProtectionActive()) {
if (start > end) {
- Sci::Position t = start;
+ const Sci::Position t = start;
start = end;
end = t;
}
@@ -808,7 +808,7 @@ Sci::Position Editor::MovePositionOutsideChar(Sci::Position pos, Sci::Position m
}
SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, Sci::Position moveDir, bool checkLineEnd) const {
- Sci::Position posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd);
+ const Sci::Position posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd);
if (posMoved != pos.Position())
pos.SetPosition(posMoved);
if (vs.ProtectionActive()) {
@@ -839,7 +839,7 @@ void Editor::MovedCaret(SelectionPosition newPos, SelectionPosition previousPos,
Redraw();
}
}
- XYScrollPosition newXY = XYScrollToMakeVisible(
+ const XYScrollPosition newXY = XYScrollToMakeVisible(
SelectionRange(posDrag.IsValid() ? posDrag : newPos), xysDefault);
if (previousPos.IsValid() && (newXY.xOffset == xOffset)) {
// simple vertical scroll then invalidate
@@ -866,7 +866,7 @@ void Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt,
const SelectionPosition spCaret = ((sel.Count() == 1) && sel.Empty()) ?
sel.Last() : SelectionPosition(INVALID_POSITION);
- Sci::Position delta = newPos.Position() - sel.MainCaret();
+ const Sci::Position delta = newPos.Position() - sel.MainCaret();
newPos = ClampPositionIntoDocument(newPos);
newPos = MovePositionOutsideChar(newPos, delta);
if (!multipleSelection && sel.IsRectangular() && (selt == Selection::selStream)) {
@@ -900,7 +900,7 @@ void Editor::MovePositionTo(Sci::Position newPos, Selection::selTypes selt, bool
SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveDir) {
pos = ClampPositionIntoDocument(pos);
pos = MovePositionOutsideChar(pos, moveDir);
- Sci::Line lineDoc = static_cast<Sci::Line>(pdoc->LineFromPosition(pos.Position()));
+ const Sci::Line lineDoc = static_cast<Sci::Line>(pdoc->LineFromPosition(pos.Position()));
if (cs.GetVisible(lineDoc)) {
return pos;
} else {
@@ -931,7 +931,7 @@ Point Editor::PointMainCaret() {
* as it moves up and down.
*/
void Editor::SetLastXChosen() {
- Point pt = PointMainCaret();
+ const Point pt = PointMainCaret();
lastXChosen = static_cast<Sci::Position>(pt.x) + xOffset;
}
@@ -1041,8 +1041,8 @@ void Editor::MoveSelectedLines(int lineDelta) {
CopySelectionRange(&selectedText);
Sci::Position selectionLength = SelectionRange(selectionStart, selectionEnd).Length();
- Point currentLocation = LocationFromPosition(CurrentPosition());
- Sci::Line currentLine = LineFromLocation(currentLocation);
+ const Point currentLocation = LocationFromPosition(CurrentPosition());
+ const Sci::Line currentLine = LineFromLocation(currentLocation);
if (appendEol)
SetSelection(pdoc->MovePositionOutsideChar(selectionStart - 1, -1), selectionEnd);
@@ -1070,15 +1070,15 @@ void Editor::MoveSelectedLinesDown() {
}
void Editor::MoveCaretInsideView(bool ensureVisible) {
- PRectangle rcClient = GetTextRectangle();
- Point pt = PointMainCaret();
+ const PRectangle rcClient = GetTextRectangle();
+ const Point pt = PointMainCaret();
if (pt.y < rcClient.top) {
MovePositionTo(SPositionFromLocation(
Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top)),
false, false, UserVirtualSpace()),
Selection::noSel, ensureVisible);
} else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) {
- Sci::Position yOfLastLineFullyDisplayed = static_cast<Sci::Position>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight;
+ const Sci::Position yOfLastLineFullyDisplayed = static_cast<Sci::Position>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight;
MovePositionTo(SPositionFromLocation(
Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top) + yOfLastLineFullyDisplayed),
false, false, UserVirtualSpace()),
@@ -1616,7 +1616,7 @@ void Editor::LinesSplit(int pixelWidth) {
const PRectangle rcText = GetTextRectangle();
pixelWidth = static_cast<int>(rcText.Width());
}
- Sci::Line lineStart = static_cast<Sci::Line>(pdoc->LineFromPosition(targetStart));
+ const Sci::Line lineStart = static_cast<Sci::Line>(pdoc->LineFromPosition(targetStart));
Sci::Line lineEnd = static_cast<Sci::Line>(pdoc->LineFromPosition(targetEnd));
const char *eol = StringFromEOLMode(pdoc->eolMode);
UndoGroup ug(pdoc);
@@ -1624,7 +1624,7 @@ void Editor::LinesSplit(int pixelWidth) {
AutoSurface surface(this);
AutoLineLayout ll(view.llc, view.RetrieveLineLayout(line, *this));
if (surface && ll) {
- Sci::Position posLineStart = static_cast<Sci::Position>(pdoc->LineStart(line));
+ const Sci::Position posLineStart = static_cast<Sci::Position>(pdoc->LineStart(line));
view.LayoutLine(*this, line, surface, vs, ll, pixelWidth);
Sci::Position lengthInsertedTotal = 0;
for (int subLine = 1; subLine < ll->lines; subLine++) {
@@ -1657,7 +1657,7 @@ void Editor::PaintSelMargin(Surface *surfaceWindow, PRectangle &rc) {
}
PRectangle rcMargin = GetClientRectangle();
- Point ptOrigin = GetVisibleOriginInMain();
+ const Point ptOrigin = GetVisibleOriginInMain();
rcMargin.Move(0, -ptOrigin.y);
rcMargin.left = 0;
rcMargin.right = static_cast<XYPOSITION>(vs.fixedColumnWidth);
@@ -1716,7 +1716,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
StyleAreaBounded(rcArea, false);
- PRectangle rcClient = GetClientRectangle();
+ const PRectangle rcClient = GetClientRectangle();
//Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n",
// rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
@@ -1987,7 +1987,7 @@ void Editor::ClearBeforeTentativeStart() {
for (size_t r = 0; r<sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
- Sci::Position positionInsert = sel.Range(r).Start().Position();
+ const Sci::Position positionInsert = sel.Range(r).Start().Position();
if (!sel.Range(r).Empty()) {
if (sel.Range(r).Length()) {
pdoc->DeleteChars(positionInsert, sel.Range(r).Length());
@@ -2050,13 +2050,13 @@ void Editor::InsertPasteShape(const char *text, int len, PasteShape shape) {
PasteRectangular(sel.Start(), text, len);
} else {
if (shape == pasteLine) {
- Sci::Position insertPos = static_cast<Sci::Position>(
+ const Sci::Position insertPos = static_cast<Sci::Position>(
pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())));
Sci::Position 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));
+ const int length = static_cast<int>(strlen(endline));
lengthInserted += pdoc->InsertString(insertPos + lengthInserted, endline, length);
}
if (sel.MainCaret() == insertPos) {
@@ -2141,7 +2141,7 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, Sci::Posit
Sci::Line line = static_cast<Sci::Line>(pdoc->LineFromPosition(sel.MainCaret()));
UndoGroup ug(pdoc);
sel.RangeMain().caret = RealizeVirtualSpace(sel.RangeMain().caret);
- int xInsert = XFromPosition(sel.RangeMain().caret);
+ const int xInsert = XFromPosition(sel.RangeMain().caret);
bool prevCr = false;
while ((len > 0) && IsEOLChar(ptr[len-1]))
len--;
@@ -2220,7 +2220,7 @@ void Editor::SelectAll() {
void Editor::Undo() {
if (pdoc->CanUndo()) {
InvalidateCaret();
- Sci::Position newPos = pdoc->Undo();
+ const Sci::Position newPos = pdoc->Undo();
if (newPos >= 0)
SetEmptySelection(newPos);
EnsureCaretVisible();
@@ -2229,7 +2229,7 @@ void Editor::Undo() {
void Editor::Redo() {
if (pdoc->CanRedo()) {
- Sci::Position newPos = pdoc->Redo();
+ const Sci::Position newPos = pdoc->Redo();
if (newPos >= 0)
SetEmptySelection(newPos);
EnsureCaretVisible();
@@ -2250,7 +2250,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
sel.Range(r).caret.SetVirtualSpace(sel.Range(r).caret.VirtualSpace() - 1);
sel.Range(r).anchor.SetVirtualSpace(sel.Range(r).caret.VirtualSpace());
} else {
- Sci::Line lineCurrentPos = static_cast<Sci::Line>(
+ const Sci::Line lineCurrentPos = static_cast<Sci::Line>(
pdoc->LineFromPosition(sel.Range(r).caret.Position()));
if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != sel.Range(r).caret.Position())) {
if (pdoc->GetColumn(sel.Range(r).caret.Position()) <= pdoc->GetLineIndentation(lineCurrentPos) &&
@@ -2409,15 +2409,15 @@ void Editor::NotifyIndicatorClick(bool click, Sci::Position position, int modifi
bool Editor::NotifyMarginClick(Point pt, int modifiers) {
const int marginClicked = vs.MarginFromLocation(pt);
if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) {
- Sci::Position position = static_cast<Sci::Position>(pdoc->LineStart(LineFromLocation(pt)));
+ const Sci::Position position = static_cast<Sci::Position>(pdoc->LineStart(LineFromLocation(pt)));
if ((vs.ms[marginClicked].mask & SC_MASK_FOLDERS) && (foldAutomatic & SC_AUTOMATICFOLD_CLICK)) {
const bool ctrl = (modifiers & SCI_CTRL) != 0;
const bool shift = (modifiers & SCI_SHIFT) != 0;
- Sci::Line lineClick = static_cast<Sci::Line>(pdoc->LineFromPosition(position));
+ const Sci::Line lineClick = static_cast<Sci::Line>(pdoc->LineFromPosition(position));
if (shift && ctrl) {
FoldAll(SC_FOLDACTION_TOGGLE);
} else {
- int levelClick = pdoc->GetLevel(lineClick);
+ const int levelClick = pdoc->GetLevel(lineClick);
if (levelClick & SC_FOLDLEVELHEADERFLAG) {
if (shift) {
// Ensure all children visible
@@ -2445,9 +2445,9 @@ bool Editor::NotifyMarginClick(Point pt, int modifiers) {
}
bool Editor::NotifyMarginRightClick(Point pt, int modifiers) {
- int marginRightClicked = vs.MarginFromLocation(pt);
+ const int marginRightClicked = vs.MarginFromLocation(pt);
if ((marginRightClicked >= 0) && vs.ms[marginRightClicked].sensitive) {
- Sci::Position position = static_cast<Sci::Position>(pdoc->LineStart(LineFromLocation(pt)));
+ const Sci::Position position = static_cast<Sci::Position>(pdoc->LineStart(LineFromLocation(pt)));
SCNotification scn = {};
scn.nmhdr.code = SCN_MARGINRIGHTCLICK;
scn.modifiers = modifiers;
@@ -2497,8 +2497,8 @@ void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) {
void Editor::CheckModificationForWrap(DocModification mh) {
if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
view.llc.Invalidate(LineLayout::llCheckTextAndStyle);
- Sci::Line lineDoc = static_cast<Sci::Line>(pdoc->LineFromPosition(mh.position));
- Sci::Line lines = std::max(static_cast<Sci::Line>(0), mh.linesAdded);
+ const Sci::Line lineDoc = static_cast<Sci::Line>(pdoc->LineFromPosition(mh.position));
+ const Sci::Line lines = std::max(static_cast<Sci::Line>(0), mh.linesAdded);
if (Wrapping()) {
NeedWrapping(lineDoc, lineDoc + lines + 1);
}
@@ -2618,7 +2618,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
view.LinesAddedOrRemoved(lineOfPos, mh.linesAdded);
}
if (mh.modificationType & SC_MOD_CHANGEANNOTATION) {
- Sci::Line lineDoc = static_cast<Sci::Line>(pdoc->LineFromPosition(mh.position));
+ const Sci::Line lineDoc = static_cast<Sci::Line>(pdoc->LineFromPosition(mh.position));
if (vs.annotationVisible) {
if (cs.SetHeight(lineDoc, cs.GetHeight(lineDoc) + mh.annotationLinesAdded)) {
SetScrollBars();
@@ -2630,7 +2630,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
if (mh.linesAdded != 0) {
// Avoid scrolling of display if change before current display
if (mh.position < posTopLine && !CanDeferToLastStep(mh)) {
- Sci::Line newTop = std::clamp(topLine + mh.linesAdded, static_cast<Sci::Line>(0), MaxScrollPos());
+ const Sci::Line newTop = std::clamp(topLine + mh.linesAdded, static_cast<Sci::Line>(0), MaxScrollPos());
if (newTop != topLine) {
SetTopLine(newTop);
SetVerticalScrollPos();
@@ -2864,7 +2864,7 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {
false, false, UserVirtualSpace());
} else {
- Point pt = LocationFromPosition(sel.MainCaret());
+ const Point pt = LocationFromPosition(sel.MainCaret());
topLineNew = std::clamp(
topLine + direction * LinesToScroll(), static_cast<Sci::Line>(0), MaxScrollPos());
@@ -2889,7 +2889,7 @@ void Editor::ChangeCaseOfSelection(int caseMapping) {
SelectionRange current = sel.Range(r);
SelectionRange currentNoVS = current;
currentNoVS.ClearVirtualSpace();
- size_t rangeBytes = currentNoVS.Length();
+ const size_t rangeBytes = currentNoVS.Length();
if (rangeBytes > 0) {
std::string sText = RangeText(currentNoVS.Start().Position(), currentNoVS.End().Position());
@@ -2905,7 +2905,7 @@ void Editor::ChangeCaseOfSelection(int caseMapping) {
lastDifferenceText--;
lastDifferenceMapped--;
}
- size_t endDifferenceText = sText.size() - 1 - lastDifferenceText;
+ const size_t endDifferenceText = sText.size() - 1 - lastDifferenceText;
pdoc->DeleteChars(
static_cast<Sci::Position>(currentNoVS.Start().Position() + firstDifference),
static_cast<Sci::Position>(rangeBytes - firstDifference - endDifferenceText));
@@ -2915,7 +2915,7 @@ void Editor::ChangeCaseOfSelection(int caseMapping) {
sMapped.c_str() + firstDifference,
lengthChange);
// Automatic movement changes selection so reset to exactly the same as it was.
- Sci::Position diffSizes = static_cast<Sci::Position>(sMapped.size() - sText.size()) + lengthInserted - lengthChange;
+ const Sci::Position diffSizes = static_cast<Sci::Position>(sMapped.size() - sText.size()) + lengthInserted - lengthChange;
if (diffSizes != 0) {
if (current.anchor > current.caret)
current.anchor.Add(diffSizes);
@@ -2929,7 +2929,7 @@ void Editor::ChangeCaseOfSelection(int caseMapping) {
}
void Editor::LineTranspose() {
- Sci::Line line = static_cast<Sci::Line>(pdoc->LineFromPosition(sel.MainCaret()));
+ const Sci::Line line = static_cast<Sci::Line>(pdoc->LineFromPosition(sel.MainCaret()));
if (line > 0) {
UndoGroup ug(pdoc);
@@ -2998,7 +2998,7 @@ void Editor::Duplicate(bool forLine) {
SelectionPosition start = sel.Range(r).Start();
SelectionPosition end = sel.Range(r).End();
if (forLine) {
- Sci::Line line = static_cast<Sci::Line>(pdoc->LineFromPosition(sel.Range(r).caret.Position()));
+ const Sci::Line line = static_cast<Sci::Line>(pdoc->LineFromPosition(sel.Range(r).caret.Position()));
start = SelectionPosition(static_cast<Sci::Position>(pdoc->LineStart(line)));
end = SelectionPosition(static_cast<Sci::Position>(pdoc->LineEnd(line)));
}
@@ -3011,7 +3011,7 @@ void Editor::Duplicate(bool forLine) {
if (sel.Count() && sel.IsRectangular()) {
SelectionPosition last = sel.Last();
if (forLine) {
- Sci::Line line = static_cast<Sci::Line>(pdoc->LineFromPosition(last.Position()));
+ const Sci::Line line = static_cast<Sci::Line>(pdoc->LineFromPosition(last.Position()));
last = SelectionPosition(last.Position() +
static_cast<Sci::Position>(pdoc->LineStart(line+1) - pdoc->LineStart(line)));
}
@@ -3175,7 +3175,7 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) {
Sci::Line lineDoc;
- Sci::Position savedPos = sel.MainCaret();
+ const Sci::Position savedPos = sel.MainCaret();
do {
MovePositionTo(SelectionPosition(direction > 0 ? pdoc->ParaDown(sel.MainCaret()) : pdoc->ParaUp(sel.MainCaret())), selt);
lineDoc = static_cast<Sci::Line>(pdoc->LineFromPosition(sel.MainCaret()));
@@ -3199,7 +3199,7 @@ Range Editor::RangeDisplayLine(Sci::Line lineVisible) {
Sci::Position Editor::StartEndDisplayLine(Sci::Position pos, bool start) {
RefreshStyleData();
AutoSurface surface(this);
- Sci::Position posRet = view.StartEndDisplayLine(surface, *this, pos, start, vs);
+ const Sci::Position posRet = view.StartEndDisplayLine(surface, *this, pos, start, vs);
if (posRet == INVALID_POSITION) {
return pos;
} else {
@@ -3904,7 +3904,7 @@ int Editor::KeyDefault(int, int) {
int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) {
DwellEnd(false);
- int msg = kmap.Find(key, modifiers);
+ const int msg = kmap.Find(key, modifiers);
if (msg) {
if (consumed)
*consumed = true;
@@ -3919,18 +3919,18 @@ int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) {
void Editor::Indent(bool forwards) {
UndoGroup ug(pdoc);
for (size_t r=0; r<sel.Count(); r++) {
- Sci::Line lineOfAnchor = static_cast<Sci::Line>(
+ const Sci::Line lineOfAnchor = static_cast<Sci::Line>(
pdoc->LineFromPosition(sel.Range(r).anchor.Position()));
Sci::Position caretPosition = sel.Range(r).caret.Position();
- Sci::Line lineCurrentPos = static_cast<Sci::Line>(pdoc->LineFromPosition(caretPosition));
+ const Sci::Line lineCurrentPos = static_cast<Sci::Line>(pdoc->LineFromPosition(caretPosition));
if (lineOfAnchor == lineCurrentPos) {
if (forwards) {
pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length());
caretPosition = sel.Range(r).caret.Position();
if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) &&
pdoc->tabIndents) {
- int indentation = pdoc->GetLineIndentation(lineCurrentPos);
- int indentationStep = pdoc->IndentSize();
+ const int indentation = pdoc->GetLineIndentation(lineCurrentPos);
+ const int indentationStep = pdoc->IndentSize();
const Sci::Position posSelect = pdoc->SetLineIndentation(
lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
sel.Range(r) = SelectionRange(posSelect);
@@ -4027,7 +4027,7 @@ long Editor::FindText(
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
- long pos = pdoc->FindText(
+ const long pos = pdoc->FindText(
static_cast<Sci::Position>(ft->chrg.cpMin),
static_cast<Sci::Position>(ft->chrg.cpMax),
ft->lpstrText,
@@ -4123,7 +4123,7 @@ long Editor::SearchInTarget(const char *text, Sci::Position length) {
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
- long pos = pdoc->FindText(targetStart, targetEnd, text,
+ const long pos = pdoc->FindText(targetStart, targetEnd, text,
searchFlags,
&lengthFound);
if (pos != -1) {
@@ -4157,7 +4157,7 @@ static bool Close(Point pt1, Point pt2, Point threshold) {
std::string Editor::RangeText(Sci::Position start, Sci::Position end) const {
if (start < end) {
- Sci::Position len = end - start;
+ const Sci::Position len = end - start;
std::string ret(len, '\0');
for (int i = 0; i < len; i++) {
ret[i] = pdoc->CharAt(start + i);
@@ -4170,9 +4170,9 @@ std::string Editor::RangeText(Sci::Position start, Sci::Position end) const {
void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
if (sel.Empty()) {
if (allowLineCopy) {
- Sci::Line currentLine = static_cast<Sci::Line>(pdoc->LineFromPosition(sel.MainCaret()));
- Sci::Position start = static_cast<Sci::Position>(pdoc->LineStart(currentLine));
- Sci::Position end = static_cast<Sci::Position>(pdoc->LineEnd(currentLine));
+ const Sci::Line currentLine = static_cast<Sci::Line>(pdoc->LineFromPosition(sel.MainCaret()));
+ const Sci::Position start = static_cast<Sci::Position>(pdoc->LineStart(currentLine));
+ const Sci::Position end = static_cast<Sci::Position>(pdoc->LineEnd(currentLine));
std::string text = RangeText(start, end);
if (pdoc->eolMode != SC_EOL_LF)
@@ -4267,8 +4267,8 @@ void Editor::DropAt(SelectionPosition position, const char *value, size_t length
if ((inDragDrop != ddDragging) || !(positionWasInSelection) ||
(positionOnEdgeOfSelection && !moving)) {
- SelectionPosition selStart = SelectionStart();
- SelectionPosition selEnd = SelectionEnd();
+ const SelectionPosition selStart = SelectionStart();
+ const SelectionPosition selEnd = SelectionEnd();
UndoGroup ug(pdoc);
@@ -4390,8 +4390,8 @@ void Editor::TrimAndSetSelection(Sci::Position currentPos_, Sci::Position anchor
void Editor::LineSelection(Sci::Position lineCurrentPos_, Sci::Position lineAnchorPos_, bool wholeLine) {
Sci::Position selCurrentPos, selAnchorPos;
if (wholeLine) {
- Sci::Line lineCurrent_ = static_cast<Sci::Line>(pdoc->LineFromPosition(lineCurrentPos_));
- Sci::Line lineAnchor_ = static_cast<Sci::Line>(pdoc->LineFromPosition(lineAnchorPos_));
+ const Sci::Line lineCurrent_ = static_cast<Sci::Line>(pdoc->LineFromPosition(lineCurrentPos_));
+ const Sci::Line lineAnchor_ = static_cast<Sci::Line>(pdoc->LineFromPosition(lineAnchorPos_));
if (lineAnchorPos_ < lineCurrentPos_) {
selCurrentPos = static_cast<Sci::Position>(pdoc->LineStart(lineCurrent_ + 1));
selAnchorPos = static_cast<Sci::Position>(pdoc->LineStart(lineAnchor_));
@@ -4618,7 +4618,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
SetDragPosition(SelectionPosition(Sci::invalidPosition));
if (!shift) {
if (ctrl && multipleSelection) {
- SelectionRange range(newPos);
+ const SelectionRange range(newPos);
sel.TentativeSelection(range);
InvalidateSelection(range, true);
} else {
@@ -4659,7 +4659,7 @@ bool Editor::PositionIsHotspot(Sci::Position position) const {
}
bool Editor::PointIsHotspot(Point pt) {
- Sci::Position pos = PositionFromLocation(pt, true, true);
+ const Sci::Position pos = PositionFromLocation(pt, true, true);
if (pos == INVALID_POSITION)
return false;
return PositionIsHotspot(pos);
@@ -4694,7 +4694,7 @@ void Editor::SetHoverIndicatorPoint(Point pt) {
void Editor::SetHotSpotRange(const Point *pt) {
if (pt) {
- Sci::Position pos = PositionFromLocation(*pt, false, true);
+ const Sci::Position pos = PositionFromLocation(*pt, false, true);
// If we don't limit this to word characters then the
// range can encompass more than the run range and then
@@ -4745,7 +4745,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {
ptMouseLast = pt;
PRectangle rcClient = GetClientRectangle();
- Point ptOrigin = GetVisibleOriginInMain();
+ const Point ptOrigin = GetVisibleOriginInMain();
rcClient.Move(0, -ptOrigin.y);
if ((dwellDelay < SC_TIME_FOREVER) && rcClient.Contains(pt)) {
FineTickerStart(tickDwell, dwellDelay, dwellDelay/10);
@@ -4772,7 +4772,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {
SetSelection(movePos, sel.RangeMain().anchor);
} else if (sel.Count() > 1) {
InvalidateSelection(sel.RangeMain(), false);
- SelectionRange range(movePos, sel.RangeMain().anchor);
+ const SelectionRange range(movePos, sel.RangeMain().anchor);
sel.TentativeSelection(range);
InvalidateSelection(range, true);
} else {
@@ -4801,7 +4801,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {
}
// Autoscroll
- Sci::Line lineMove = DisplayFromPosition(movePos.Position());
+ const Sci::Line lineMove = DisplayFromPosition(movePos.Position());
if (pt.y > rcClient.bottom) {
ScrollTo(lineMove - LinesOnScreen() + 1);
Redraw();
@@ -4879,8 +4879,8 @@ void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers
FineTickerCancel(tickScroll);
NotifyIndicatorClick(false, newPos.Position(), 0);
if (inDragDrop == ddDragging) {
- SelectionPosition selStart = SelectionStart();
- SelectionPosition selEnd = SelectionEnd();
+ const SelectionPosition selStart = SelectionStart();
+ const SelectionPosition selEnd = SelectionEnd();
if (selStart < selEnd) {
if (drag.Length()) {
const int length = static_cast<int>(drag.Length());
@@ -5020,7 +5020,7 @@ Sci::Position 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
- Sci::Line lineAfter = TopLineOfMain() + static_cast<Sci::Line>(rcArea.bottom - 1) / vs.lineHeight + 1;
+ const Sci::Line lineAfter = TopLineOfMain() + static_cast<Sci::Line>(rcArea.bottom - 1) / vs.lineHeight + 1;
if (lineAfter < cs.LinesDisplayed())
return static_cast<Sci::Position>(pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1));
else
@@ -5144,7 +5144,7 @@ void Editor::CheckForChangeOutsidePaint(Range r) {
return;
PRectangle rcRange = RectangleFromRange(r, 0);
- PRectangle rcText = GetTextRectangle();
+ const PRectangle rcText = GetTextRectangle();
if (rcRange.top < rcText.top) {
rcRange.top = rcText.top;
}
@@ -5246,9 +5246,9 @@ void Editor::SetAnnotationVisible(int visible) {
const bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0));
vs.annotationVisible = visible;
if (changedFromOrToHidden) {
- int dir = vs.annotationVisible ? 1 : -1;
+ const int dir = vs.annotationVisible ? 1 : -1;
for (Sci::Line line=0; line<pdoc->LinesTotal(); line++) {
- int annotationLines = pdoc->AnnotationLines(line);
+ const int annotationLines = pdoc->AnnotationLines(line);
if (annotationLines > 0) {
cs.SetHeight(line, cs.GetHeight(line) + annotationLines * dir);
}
@@ -5263,7 +5263,7 @@ void Editor::SetAnnotationVisible(int visible) {
* Recursively expand a fold, making lines visible except where they have an unexpanded parent.
*/
Sci::Line Editor::ExpandLine(Sci::Line line) {
- Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
+ const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
line++;
while (line <= lineMaxSubord) {
cs.SetVisible(line, line, true);
@@ -5337,7 +5337,7 @@ void Editor::FoldExpand(Sci::Line line, int action, int level) {
if (expanding && (cs.HiddenLines() == 0))
// Nothing to do
return;
- Sci::Line lineMaxSubord = pdoc->GetLastChild(line, LevelNumber(level));
+ const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, LevelNumber(level));
line++;
cs.SetVisible(line, lineMaxSubord, expanding);
while (line <= lineMaxSubord) {
@@ -5424,7 +5424,7 @@ void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {
void Editor::FoldAll(int action) {
pdoc->EnsureStyledTo(static_cast<Sci::Position>(pdoc->Length()));
- Sci::Line maxLine = pdoc->LinesTotal();
+ const Sci::Line maxLine = pdoc->LinesTotal();
bool expanding = action == SC_FOLDACTION_EXPAND;
if (action == SC_FOLDACTION_TOGGLE) {
// Discover current state
@@ -5449,7 +5449,7 @@ void Editor::FoldAll(int action) {
if ((level & SC_FOLDLEVELHEADERFLAG) &&
(SC_FOLDLEVELBASE == LevelNumber(level))) {
SetFoldExpanded(line, false);
- Sci::Line lineMaxSubord = pdoc->GetLastChild(line, -1);
+ const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, -1);
if (lineMaxSubord > line) {
cs.SetVisible(line + 1, lineMaxSubord, false);
}
@@ -5491,7 +5491,7 @@ void Editor::FoldChanged(Sci::Line line, int levelNow, int levelPrev) {
(LevelNumber(levelPrev) > LevelNumber(levelNow))) {
if (cs.HiddenLines()) {
// See if should still be hidden
- Sci::Line parentLine = pdoc->GetFoldParent(line);
+ const Sci::Line parentLine = pdoc->GetFoldParent(line);
if ((parentLine < 0) || (cs.GetExpanded(parentLine) && cs.GetVisible(parentLine))) {
cs.SetVisible(line, line, true);
SetScrollBars();
@@ -5583,7 +5583,7 @@ int Editor::WrapCount(int line) {
void Editor::AddStyledText(char *buffer, Sci::Position appendLength) {
// The buffer consists of alternating character bytes and style bytes
- Sci::Position textLength = appendLength / 2;
+ const Sci::Position textLength = appendLength / 2;
std::string text(textLength, '\0');
Sci::Position i;
for (i = 0; i < textLength; i++) {
@@ -5858,9 +5858,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETLINE: { // Risk of overwriting the end of the buffer
- Sci::Position lineStart = static_cast<Sci::Position>(
+ const Sci::Position lineStart = static_cast<Sci::Position>(
pdoc->LineStart(static_cast<Sci::Line>(wParam)));
- Sci::Position lineEnd = static_cast<Sci::Position>(
+ const Sci::Position lineEnd = static_cast<Sci::Position>(
pdoc->LineStart(static_cast<Sci::Line>(wParam + 1)));
if (lParam == 0) {
return lineEnd - lineStart;
@@ -5943,7 +5943,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return 0;
UndoGroup ug(pdoc);
ClearSelection();
- char *replacement = CharPtrFromSPtr(lParam);
+ const char *replacement = CharPtrFromSPtr(lParam);
const Sci::Position lengthInserted = pdoc->InsertString(
sel.MainCaret(), replacement, istrlen(replacement));
SetEmptySelection(sel.MainCaret() + lengthInserted);
@@ -6059,7 +6059,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (lParam < 0) {
return 0;
} else {
- Point pt = LocationFromPosition(static_cast<int>(lParam));
+ const Point pt = LocationFromPosition(static_cast<int>(lParam));
// Convert to view-relative
return static_cast<int>(pt.x) - vs.textStart + vs.fixedColumnWidth;
}
@@ -6068,7 +6068,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (lParam < 0) {
return 0;
} else {
- Point pt = LocationFromPosition(static_cast<int>(lParam));
+ const Point pt = LocationFromPosition(static_cast<int>(lParam));
return static_cast<int>(pt.y);
}
@@ -6138,7 +6138,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (static_cast<int>(wParam) == -1)
insertPos = CurrentPosition();
Sci::Position newCurrent = CurrentPosition();
- char *sz = CharPtrFromSPtr(lParam);
+ const char *sz = CharPtrFromSPtr(lParam);
const Sci::Position lengthInserted = pdoc->InsertString(insertPos, sz, istrlen(sz));
if (newCurrent > insertPos)
newCurrent += lengthInserted;
@@ -6498,14 +6498,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_CLEARTABSTOPS:
if (view.ClearTabstops(static_cast<int>(wParam))) {
- DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, 0, static_cast<int>(wParam));
+ const DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, 0, static_cast<int>(wParam));
NotifyModified(pdoc, mh, NULL);
}
break;
case SCI_ADDTABSTOP:
if (view.AddTabstop(static_cast<int>(wParam), static_cast<int>(lParam))) {
- DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, 0, static_cast<int>(wParam));
+ const DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, 0, static_cast<int>(wParam));
NotifyModified(pdoc, mh, NULL);
}
break;
@@ -6831,7 +6831,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateStyleRedraw();
break;
case SCI_MARKERADD: {
- int markerID = pdoc->AddMark(static_cast<int>(wParam), static_cast<int>(lParam));
+ const int markerID = pdoc->AddMark(static_cast<int>(wParam), static_cast<int>(lParam));
return markerID;
}
case SCI_MARKERADDSET:
@@ -7086,7 +7086,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return WrapCount(static_cast<int>(wParam));
case SCI_SETFOLDLEVEL: {
- int prev = pdoc->SetLevel(static_cast<int>(wParam), static_cast<int>(lParam));
+ const int prev = pdoc->SetLevel(static_cast<int>(wParam), static_cast<int>(lParam));
if (prev != static_cast<int>(lParam))
RedrawSelMargin();
return prev;
@@ -7683,7 +7683,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.MoveExtends();
case SCI_GETLINESELSTARTPOSITION:
case SCI_GETLINESELENDPOSITION: {
- SelectionSegment segmentLine(
+ const SelectionSegment segmentLine(
SelectionPosition(static_cast<Sci::Position>(pdoc->LineStart(static_cast<int>(wParam)))),
SelectionPosition(static_cast<Sci::Position>(pdoc->LineEnd(static_cast<int>(wParam)))));
for (size_t r=0; r<sel.Count(); r++) {
diff --git a/src/Indicator.cxx b/src/Indicator.cxx
index e8702b17c..3551e7202 100644
--- a/src/Indicator.cxx
+++ b/src/Indicator.cxx
@@ -34,7 +34,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
sacDraw = sacHover;
}
surface->PenColour(sacDraw.fore);
- int ymid = static_cast<int>(rc.bottom + rc.top) / 2;
+ const int ymid = static_cast<int>(rc.bottom + rc.top) / 2;
if (sacDraw.style == INDIC_SQUIGGLE) {
int x = static_cast<int>(rc.left+0.5);
const int xLast = static_cast<int>(rc.right+0.5);
@@ -52,9 +52,9 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
surface->LineTo(x, static_cast<int>(rc.top) + y);
}
} else if (sacDraw.style == INDIC_SQUIGGLEPIXMAP) {
- PRectangle rcSquiggle = PixelGridAlign(rc);
+ const PRectangle rcSquiggle = PixelGridAlign(rc);
- int width = std::min(4000, static_cast<int>(rcSquiggle.Width()));
+ const int width = std::min(4000, static_cast<int>(rcSquiggle.Width()));
RGBAImage image(width, 3, 1.0, 0);
enum { alphaFull = 0xff, alphaSide = 0x2f, alphaSide2=0x5f };
for (int x = 0; x < width; x++) {
@@ -136,7 +136,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
rcBox.top = rcLine.top + 1;
rcBox.bottom = rcLine.bottom;
// Cap width at 4000 to avoid large allocations when mistakes made
- int width = std::min(static_cast<int>(rcBox.Width()), 4000);
+ const int width = std::min(static_cast<int>(rcBox.Width()), 4000);
RGBAImage image(width, static_cast<int>(rcBox.Height()), 1.0, 0);
// Draw horizontal lines top and bottom
for (int x=0; x<width; x++) {
@@ -161,15 +161,15 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
} else if (sacDraw.style == INDIC_DOTS) {
int x = static_cast<int>(rc.left);
while (x < static_cast<int>(rc.right)) {
- PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1);
+ const PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1);
surface->FillRectangle(rcDot, sacDraw.fore);
x += 2;
}
} else if (sacDraw.style == INDIC_COMPOSITIONTHICK) {
- PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom);
+ const PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom);
surface->FillRectangle(rcComposition, sacDraw.fore);
} else if (sacDraw.style == INDIC_COMPOSITIONTHIN) {
- PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom-1);
+ const PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom-1);
surface->FillRectangle(rcComposition, sacDraw.fore);
} else if (sacDraw.style == INDIC_POINT || sacDraw.style == INDIC_POINTCHARACTER) {
if (rcCharacter.Width() >= 0.1) {
diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx
index e3c2c6713..261916e11 100644
--- a/src/LineMarker.cxx
+++ b/src/LineMarker.cxx
@@ -40,7 +40,7 @@ void LineMarker::SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned c
}
static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) {
- PRectangle rc = PRectangle::FromInts(
+ const PRectangle rc = PRectangle::FromInts(
centreX - armSize,
centreY - armSize,
centreX + armSize + 1,
@@ -49,7 +49,7 @@ static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Col
}
static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) {
- PRectangle rcCircle = PRectangle::FromInts(
+ const PRectangle rcCircle = PRectangle::FromInts(
centreX - armSize,
centreY - armSize,
centreX + armSize + 1,
@@ -58,14 +58,14 @@ static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize,
}
static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) {
- PRectangle rcV = PRectangle::FromInts(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
+ const PRectangle rcV = PRectangle::FromInts(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
surface->FillRectangle(rcV, fore);
- PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1);
+ const PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1);
surface->FillRectangle(rcH, fore);
}
static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) {
- PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1);
+ const PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1);
surface->FillRectangle(rcH, fore);
}
@@ -122,7 +122,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
const int centreY = static_cast<int>(floor((rc.bottom + rc.top) / 2.0));
const int dimOn2 = minDim / 2;
const int dimOn4 = minDim / 4;
- int blobSize = dimOn2-1;
+ const int blobSize = dimOn2-1;
const int armSize = dimOn2-2;
if (marginStyle == SC_MARGIN_NUMBER || marginStyle == SC_MARGIN_TEXT || marginStyle == SC_MARGIN_RTEXT) {
// On textual margins move marker to the left to try to avoid overlapping the text
@@ -134,7 +134,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
rcRounded.right = rc.right - 1;
surface->RoundedRectangle(rcRounded, fore, back);
} else if (markType == SC_MARK_CIRCLE) {
- PRectangle rcCircle = PRectangle::FromInts(
+ const PRectangle rcCircle = PRectangle::FromInts(
centreX - dimOn2,
centreY - dimOn2,
centreX + dimOn2,
@@ -340,7 +340,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType >= SC_MARK_CHARACTER) {
char character[1];
character[0] = static_cast<char>(markType - SC_MARK_CHARACTER);
- XYPOSITION width = surface->WidthText(fontForCharacter, character, 1);
+ const XYPOSITION width = surface->WidthText(fontForCharacter, character, 1);
rc.left += (rc.Width() - width) / 2;
rc.right = rc.left + width;
surface->DrawTextClipped(rc, fontForCharacter, rc.bottom - 2,
@@ -349,7 +349,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType == SC_MARK_DOTDOTDOT) {
XYPOSITION right = static_cast<XYPOSITION>(centreX - 6);
for (int b=0; b<3; b++) {
- PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom-2);
+ const PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom-2);
surface->FillRectangle(rcBlob, fore);
right += 5.0f;
}
diff --git a/src/MarginView.cxx b/src/MarginView.cxx
index 121f7ecf6..ff19840c4 100644
--- a/src/MarginView.cxx
+++ b/src/MarginView.cxx
@@ -60,15 +60,15 @@ void DrawWrapMarker(Surface *surface, PRectangle rcPlace,
surface->PenColour(wrapColour);
enum { xa = 1 }; // gap before start
- int w = static_cast<int>(rcPlace.right - rcPlace.left) - xa - 1;
+ const int w = static_cast<int>(rcPlace.right - rcPlace.left) - xa - 1;
const bool xStraight = isEndMarker; // x-mirrored symbol for start marker
const int x0 = static_cast<int>(xStraight ? rcPlace.left : rcPlace.right - 1);
const int y0 = static_cast<int>(rcPlace.top);
- int dy = static_cast<int>(rcPlace.bottom - rcPlace.top) / 5;
- int y = static_cast<int>(rcPlace.bottom - rcPlace.top) / 2 + dy;
+ const int dy = static_cast<int>(rcPlace.bottom - rcPlace.top) / 5;
+ const int y = static_cast<int>(rcPlace.bottom - rcPlace.top) / 2 + dy;
struct Relative {
Surface *surface;
@@ -137,7 +137,7 @@ void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const View
// 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 = PRectangle::FromInts(0, 0, patternSize, patternSize);
+ const PRectangle rcPattern = PRectangle::FromInts(0, 0, patternSize, patternSize);
// Initialize default colours based on the chrome colour scheme. Typically the highlight is white.
ColourDesired colourFMFill = vsDraw.selbar;
@@ -162,7 +162,7 @@ void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const View
pixmapSelPatternOffset1->FillRectangle(rcPattern, colourFMStripes);
for (int y = 0; y < patternSize; y++) {
for (int x = y % 2; x < patternSize; x += 2) {
- PRectangle rcPixel = PRectangle::FromInts(x, y, x + 1, y + 1);
+ const PRectangle rcPixel = PRectangle::FromInts(x, y, x + 1, y + 1);
pixmapSelPattern->FillRectangle(rcPixel, colourFMStripes);
pixmapSelPatternOffset1->FillRectangle(rcPixel, colourFMFill);
}
@@ -184,7 +184,7 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
if (rcSelMargin.bottom < rc.bottom)
rcSelMargin.bottom = rc.bottom;
- Point ptOrigin = model.GetVisibleOriginInMain();
+ const Point ptOrigin = model.GetVisibleOriginInMain();
FontAlias fontLineNumber = vs.styles[STYLE_LINENUMBER].font;
for (size_t margin = 0; margin < vs.ms.size(); margin++) {
if (vs.ms[margin].width > 0) {
@@ -244,7 +244,7 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
}
}
if (highlightDelimiter.isEnabled) {
- Sci::Line lastLine = model.cs.DocFromDisplay(topLine + model.LinesOnScreen()) + 1;
+ const Sci::Line lastLine = model.cs.DocFromDisplay(topLine + model.LinesOnScreen()) + 1;
model.pdoc->GetHighlightDelimiters(highlightDelimiter,
static_cast<Sci::Line>(model.pdoc->LineFromPosition(model.sel.MainCaret())), lastLine);
}
@@ -387,8 +387,8 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
}
PRectangle rcNumber = rcMarker;
// Right justify
- XYPOSITION width = surface->WidthText(fontLineNumber, number, static_cast<int>(strlen(number)));
- XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding;
+ const XYPOSITION width = surface->WidthText(fontLineNumber, number, static_cast<int>(strlen(number)));
+ const XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding;
rcNumber.left = xpos;
DrawTextNoClipPhase(surface, rcNumber, vs.styles[STYLE_LINENUMBER],
rcNumber.top + vs.maxAscent, number, static_cast<int>(strlen(number)), drawAll);
@@ -409,7 +409,7 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
surface->FillRectangle(rcMarker,
vs.styles[stMargin.StyleAt(0) + vs.marginStyleOffset].back);
if (vs.ms[margin].style == SC_MARGIN_RTEXT) {
- int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin);
+ const int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin);
rcMarker.left = rcMarker.right - width - 3;
}
DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker,
diff --git a/src/PerLine.cxx b/src/PerLine.cxx
index 6785ef81b..68677ab22 100644
--- a/src/PerLine.cxx
+++ b/src/PerLine.cxx
@@ -179,7 +179,7 @@ bool LineMarkers::DeleteMark(Sci::Line line, int markerNum, bool all) {
}
void LineMarkers::DeleteMarkFromHandle(int markerHandle) {
- Sci::Line line = LineFromHandle(markerHandle);
+ const Sci::Line line = LineFromHandle(markerHandle);
if (line >= 0) {
markers[line]->RemoveHandle(markerHandle);
if (markers[line]->Empty()) {
@@ -197,7 +197,7 @@ void LineLevels::Init() {
void LineLevels::InsertLine(Sci::Line line) {
if (levels.Length()) {
- int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE;
+ const int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE;
levels.InsertValue(line, 1, level);
}
}
@@ -255,7 +255,7 @@ void LineState::Init() {
void LineState::InsertLine(Sci::Line line) {
if (lineStates.Length()) {
lineStates.EnsureLength(line);
- int val = (line < lineStates.Length()) ? lineStates[line] : 0;
+ const int val = (line < lineStates.Length()) ? lineStates[line] : 0;
lineStates.Insert(line, val);
}
}
@@ -401,7 +401,7 @@ void LineAnnotation::SetStyles(Sci::Line line, const unsigned char *styles) {
if (!annotations[line]) {
annotations[line] = AllocateAnnotation(0, IndividualStyles);
} else {
- AnnotationHeader *pahSource = reinterpret_cast<AnnotationHeader *>(annotations[line].get());
+ const AnnotationHeader *pahSource = reinterpret_cast<AnnotationHeader *>(annotations[line].get());
if (pahSource->style != IndividualStyles) {
std::unique_ptr<char[]>allocation = AllocateAnnotation(pahSource->length, IndividualStyles);
AnnotationHeader *pahAlloc = reinterpret_cast<AnnotationHeader *>(allocation.get());
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 273875e4e..5ebb0bcf4 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -143,14 +143,14 @@ void LineLayout::SetLineStart(int line, int start) {
void LineLayout::SetBracesHighlight(Range rangeLine, const Sci::Position braces[],
char bracesMatchStyle, int xHighlight, bool ignoreStyle) {
if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {
- int braceOffset = braces[0] - rangeLine.start;
+ const int braceOffset = braces[0] - rangeLine.start;
if (braceOffset < numCharsInLine) {
bracePreviousStyles[0] = styles[braceOffset];
styles[braceOffset] = bracesMatchStyle;
}
}
if (!ignoreStyle && rangeLine.ContainsCharacter(braces[1])) {
- int braceOffset = braces[1] - rangeLine.start;
+ const int braceOffset = braces[1] - rangeLine.start;
if (braceOffset < numCharsInLine) {
bracePreviousStyles[1] = styles[braceOffset];
styles[braceOffset] = bracesMatchStyle;
@@ -164,13 +164,13 @@ void LineLayout::SetBracesHighlight(Range rangeLine, const Sci::Position braces[
void LineLayout::RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle) {
if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {
- int braceOffset = braces[0] - rangeLine.start;
+ const int braceOffset = braces[0] - rangeLine.start;
if (braceOffset < numCharsInLine) {
styles[braceOffset] = bracePreviousStyles[0];
}
}
if (!ignoreStyle && rangeLine.ContainsCharacter(braces[1])) {
- int braceOffset = braces[1] - rangeLine.start;
+ const int braceOffset = braces[1] - rangeLine.start;
if (braceOffset < numCharsInLine) {
styles[braceOffset] = bracePreviousStyles[1];
}
@@ -180,7 +180,7 @@ void LineLayout::RestoreBracesHighlight(Range rangeLine, const Sci::Position bra
int LineLayout::FindBefore(XYPOSITION x, int lower, int upper) const {
do {
- int middle = (upper + lower + 1) / 2; // Round high
+ const int middle = (upper + lower + 1) / 2; // Round high
const XYPOSITION posMiddle = positions[middle];
if (x < posMiddle) {
upper = middle - 1;
@@ -491,7 +491,7 @@ BreakFinder::~BreakFinder() {
TextSegment BreakFinder::Next() {
if (subBreak == -1) {
- int prev = nextBreak;
+ const int prev = nextBreak;
while (nextBreak < lineRange.end) {
int charWidth = 1;
if (encodingFamily == efUnicode)
@@ -529,7 +529,7 @@ TextSegment BreakFinder::Next() {
}
// Splitting up a long run from prev to nextBreak in lots of approximately lengthEachSubdivision.
// For very long runs add extra breaks after spaces or if no spaces before low punctuation.
- int startSegment = subBreak;
+ const int startSegment = subBreak;
if ((nextBreak - subBreak) <= lengthEachSubdivision) {
subBreak = -1;
return TextSegment(startSegment, nextBreak - startSegment);
@@ -659,12 +659,12 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns
// long comments with only a single comment.
// Two way associative: try two probe positions.
- unsigned int hashValue = PositionCacheEntry::Hash(styleNumber, s, len);
+ const unsigned int hashValue = PositionCacheEntry::Hash(styleNumber, s, len);
probe = hashValue % pces.size();
if (pces[probe].Retrieve(styleNumber, s, len, positions)) {
return;
}
- unsigned int probe2 = (hashValue * 37) % pces.size();
+ const unsigned int probe2 = (hashValue * 37) % pces.size();
if (pces[probe2].Retrieve(styleNumber, s, len, positions)) {
return;
}
@@ -678,7 +678,7 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns
unsigned int startSegment = 0;
XYPOSITION xStartSegment = 0;
while (startSegment < len) {
- unsigned int lenSegment = pdoc->SafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision);
+ const unsigned int lenSegment = pdoc->SafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision);
FontAlias fontStyle = vstyle.styles[styleNumber].font;
surface->MeasureWidths(fontStyle, s + startSegment, lenSegment, positions + startSegment);
for (unsigned int inSeg = 0; inSeg < lenSegment; inSeg++) {
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 8f9da7fa6..86158bcfb 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -247,7 +247,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
if (ac.chooseSingle && (listType == 0)) {
if (list && !strchr(list, ac.GetSeparator())) {
const char *typeSep = strchr(list, ac.GetTypesep());
- int lenInsert = typeSep ?
+ const int lenInsert = typeSep ?
static_cast<int>(typeSep-list) : static_cast<int>(strlen(list));
if (ac.ignoreCase) {
// May need to convert the case before invocation, so remove lenEntered characters
@@ -262,7 +262,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(),
lenEntered, vs.lineHeight, IsUnicodeMode(), technology);
- PRectangle rcClient = GetClientRectangle();
+ const PRectangle rcClient = GetClientRectangle();
Point pt = LocationFromPosition(sel.MainCaret() - lenEntered);
PRectangle rcPopupBounds = wMain.GetMonitorRect(pt);
if (rcPopupBounds.Height() == 0)
@@ -276,7 +276,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
pt = PointMainCaret();
}
if (wMargin.GetID()) {
- Point ptOrigin = GetVisibleOriginInMain();
+ const Point ptOrigin = GetVisibleOriginInMain();
pt.x += ptOrigin.x;
pt.y += ptOrigin.y;
}
@@ -296,7 +296,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
rcac.bottom = static_cast<XYPOSITION>(std::min(static_cast<int>(rcac.top) + heightLB, static_cast<int>(rcPopupBounds.bottom)));
ac.lb->SetPositionRelative(rcac, wMain);
ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);
- unsigned int aveCharWidth = static_cast<unsigned int>(vs.styles[STYLE_DEFAULT].aveCharWidth);
+ const unsigned int aveCharWidth = static_cast<unsigned int>(vs.styles[STYLE_DEFAULT].aveCharWidth);
ac.lb->SetAverageCharWidth(aveCharWidth);
ac.lb->SetDelegate(this);
@@ -304,7 +304,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
// Fiddle the position of the list so it is right next to the target and wide enough for all its strings
PRectangle rcList = ac.lb->GetDesiredRect();
- int heightAlloced = static_cast<int>(rcList.bottom - rcList.top);
+ const int heightAlloced = static_cast<int>(rcList.bottom - rcList.top);
widthLB = std::max(widthLB, static_cast<int>(rcList.right - rcList.left));
if (maxListWidth != 0)
widthLB = std::min(widthLB, static_cast<int>(aveCharWidth)*maxListWidth);
@@ -346,7 +346,7 @@ void ScintillaBase::AutoCompleteMoveToCurrentWord() {
}
void ScintillaBase::AutoCompleteSelection() {
- int item = ac.GetSelection();
+ const int item = ac.GetSelection();
std::string selected;
if (item != -1) {
selected = ac.GetValue(item);
@@ -357,7 +357,7 @@ void ScintillaBase::AutoCompleteSelection() {
scn.message = 0;
scn.wParam = listType;
scn.listType = listType;
- Sci::Position firstPos = ac.posStart - ac.startLen;
+ const Sci::Position firstPos = ac.posStart - ac.startLen;
scn.position = firstPos;
scn.lParam = firstPos;
scn.text = selected.c_str();
@@ -406,7 +406,7 @@ void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod
scn.listCompletionMethod = completionMethod;
scn.wParam = listType;
scn.listType = listType;
- Sci::Position firstPos = ac.posStart - ac.startLen;
+ const Sci::Position firstPos = ac.posStart - ac.startLen;
scn.position = firstPos;
scn.lParam = firstPos;
scn.text = selected.c_str();
@@ -458,12 +458,12 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
// If container knows about STYLE_CALLTIP then use it in place of the
// STYLE_DEFAULT for the face name, size and character set. Also use it
// for the foreground and background colour.
- int ctStyle = ct.UseStyleCallTip() ? STYLE_CALLTIP : STYLE_DEFAULT;
+ const int ctStyle = ct.UseStyleCallTip() ? STYLE_CALLTIP : STYLE_DEFAULT;
if (ct.UseStyleCallTip()) {
ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back);
}
if (wMargin.GetID()) {
- Point ptOrigin = GetVisibleOriginInMain();
+ const Point ptOrigin = GetVisibleOriginInMain();
pt.x += ptOrigin.x;
pt.y += ptOrigin.y;
}
@@ -479,7 +479,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
// If the call-tip window would be out of the client
// space
const PRectangle rcClient = GetClientRectangle();
- int offset = vs.lineHeight + static_cast<int>(rc.Height());
+ const int offset = vs.lineHeight + static_cast<int>(rc.Height());
// adjust so it displays above the text.
if (rc.bottom > rcClient.bottom && rc.Height() < rcClient.Height()) {
rc.top -= offset;
@@ -655,7 +655,7 @@ const char *LexState::DescribeWordListSets() {
void LexState::SetWordList(int n, const char *wl) {
if (instance) {
- Sci_Position firstModification = instance->WordListSet(n, wl);
+ const Sci_Position firstModification = instance->WordListSet(n, wl);
if (firstModification >= 0) {
pdoc->ModifiedAt(static_cast<Sci::Position>(firstModification));
}
@@ -701,7 +701,7 @@ const char *LexState::DescribeProperty(const char *name) {
void LexState::PropSet(const char *key, const char *val) {
props.Set(key, val);
if (instance) {
- Sci_Position firstModification = instance->PropertySet(key, val);
+ const Sci_Position firstModification = instance->PropertySet(key, val);
if (firstModification >= 0) {
pdoc->ModifiedAt(static_cast<Sci::Position>(firstModification));
}
@@ -826,9 +826,9 @@ const char *LexState::DescriptionOfStyle(int style) {
void ScintillaBase::NotifyStyleToNeeded(Sci::Position endStyleNeeded) {
#ifdef SCI_LEXER
if (DocumentLexState()->lexLanguage != SCLEX_CONTAINER) {
- Sci::Line lineEndStyled = static_cast<Sci::Line>(
+ const Sci::Line lineEndStyled = static_cast<Sci::Line>(
pdoc->LineFromPosition(pdoc->GetEndStyled()));
- Sci::Position endStyled = static_cast<Sci::Position>(
+ const Sci::Position endStyled = static_cast<Sci::Position>(
pdoc->LineStart(lineEndStyled));
DocumentLexState()->Colourise(endStyled, endStyleNeeded);
return;
diff --git a/src/Selection.cxx b/src/Selection.cxx
index 2e2680ad8..a45adcf51 100644
--- a/src/Selection.cxx
+++ b/src/Selection.cxx
@@ -23,7 +23,7 @@ using namespace Scintilla;
void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length) {
if (insertion) {
if (position == startChange) {
- Sci::Position virtualLengthRemove = std::min(length, virtualSpace);
+ const Sci::Position virtualLengthRemove = std::min(length, virtualSpace);
virtualSpace -= virtualLengthRemove;
position += virtualLengthRemove;
} else if (position > startChange) {
@@ -108,7 +108,7 @@ bool SelectionRange::ContainsCharacter(Sci::Position posCharacter) const {
}
SelectionSegment SelectionRange::Intersect(SelectionSegment check) const {
- SelectionSegment inOrder(caret, anchor);
+ const SelectionSegment inOrder(caret, anchor);
if ((inOrder.start <= check.end) || (inOrder.end >= check.start)) {
SelectionSegment portion = check;
if (portion.start < inOrder.start)
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index 1c4f6d690..9635ed6e7 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -71,8 +71,8 @@ void FontRealised::Realise(Surface &surface, int zoomLevel, int technology, cons
if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1
sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER;
- float deviceHeight = static_cast<float>(surface.DeviceHeightFont(sizeZoomed));
- FontParameters fp(fs.fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, fs.weight, fs.italic, fs.extraFontFlag, technology, fs.characterSet);
+ const float deviceHeight = static_cast<float>(surface.DeviceHeightFont(sizeZoomed));
+ const FontParameters fp(fs.fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, fs.weight, fs.italic, fs.extraFontFlag, technology, fs.characterSet);
font.Create(fp);
ascent = static_cast<unsigned int>(surface.Ascent(font));
@@ -377,7 +377,7 @@ void ViewStyle::ReleaseAllExtendedStyles() {
}
int ViewStyle::AllocateExtendedStyles(int numberStyles) {
- int startRange = static_cast<int>(nextExtendedStyle);
+ const int startRange = static_cast<int>(nextExtendedStyle);
nextExtendedStyle += numberStyles;
EnsureStyle(nextExtendedStyle);
for (size_t i=startRange; i<nextExtendedStyle; i++) {
diff --git a/src/XPM.cxx b/src/XPM.cxx
index 35bfc79aa..a446724fb 100644
--- a/src/XPM.cxx
+++ b/src/XPM.cxx
@@ -49,7 +49,7 @@ ColourDesired XPM::ColourFromCode(int ch) const {
void XPM::FillRun(Surface *surface, int code, int startX, int y, int x) const {
if ((code != codeTransparent) && (startX != x)) {
- PRectangle rc = PRectangle::FromInts(startX, y, x, y + 1);
+ const PRectangle rc = PRectangle::FromInts(startX, y, x, y + 1);
surface->FillRectangle(rc, ColourFromCode(code));
}
}