aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2017-04-06 21:04:37 +1000
committerNeil <nyamatongwe@gmail.com>2017-04-06 21:04:37 +1000
commitcda15af9657880e91ccf65603e109b202d9e78bf (patch)
treeeb730cdcc810842ce2255c3d2af9872041583a74 /src
parentdba2fe55b8a4ab4ac34795fe4a4b30a729c77016 (diff)
downloadscintilla-mirror-cda15af9657880e91ccf65603e109b202d9e78bf.tar.gz
Added const where possible.
Diffstat (limited to 'src')
-rw-r--r--src/AutoComplete.cxx8
-rw-r--r--src/CallTip.cxx10
-rw-r--r--src/CaseConvert.cxx12
-rw-r--r--src/CellBuffer.cxx32
-rw-r--r--src/Decoration.cxx8
-rw-r--r--src/Document.cxx94
-rw-r--r--src/EditView.cxx72
-rw-r--r--src/Editor.cxx142
-rw-r--r--src/ExternalLexer.cxx2
-rw-r--r--src/Indicator.cxx2
-rw-r--r--src/LineMarker.cxx10
-rw-r--r--src/MarginView.cxx14
-rw-r--r--src/Partitioning.h6
-rw-r--r--src/PerLine.cxx10
-rw-r--r--src/PositionCache.cxx12
-rw-r--r--src/PositionCache.h2
-rw-r--r--src/RESearch.cxx8
-rw-r--r--src/RunStyles.cxx10
-rw-r--r--src/ScintillaBase.cxx10
-rw-r--r--src/Selection.cxx6
-rw-r--r--src/SplitVector.h2
-rw-r--r--src/UniConversion.cxx10
-rw-r--r--src/ViewStyle.cxx10
-rw-r--r--src/XPM.cxx10
-rw-r--r--src/XPM.h2
25 files changed, 252 insertions, 252 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index a7b4a8b00..3de39bfcc 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -131,9 +131,9 @@ struct Sorter {
}
bool operator()(int a, int b) {
- int lenA = indices[a * 2 + 1] - indices[a * 2];
- int lenB = indices[b * 2 + 1] - indices[b * 2];
- int len = std::min(lenA, lenB);
+ const int lenA = indices[a * 2 + 1] - indices[a * 2];
+ const int lenB = indices[b * 2 + 1] - indices[b * 2];
+ const int len = std::min(lenA, lenB);
int cmp;
if (ac->ignoreCase)
cmp = CompareNCaseInsensitive(list + indices[a * 2], list + indices[b * 2], len);
@@ -217,7 +217,7 @@ void AutoComplete::Cancel() {
void AutoComplete::Move(int delta) {
- int count = lb->Length();
+ const int count = lb->Length();
int current = lb->GetSelection();
current += delta;
if (current >= count)
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index 1609bab0a..c3d1ca767 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -90,7 +90,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
int posStart, int posEnd, int ytext, PRectangle rcClient,
bool highlight, bool draw) {
s += posStart;
- int len = posEnd - posStart;
+ const int len = posEnd - posStart;
// Divide the text into sections that are all text, or that are
// single arrows or single tab characters (if tabSize > 0).
@@ -113,7 +113,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
if (endSeg > startSeg) {
if (IsArrowCharacter(s[startSeg])) {
xEnd = x + widthArrow;
- bool upArrow = s[startSeg] == '\001';
+ const bool upArrow = s[startSeg] == '\001';
rcClient.left = static_cast<XYPOSITION>(x);
rcClient.right = static_cast<XYPOSITION>(xEnd);
if (draw) {
@@ -189,9 +189,9 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
chunkEnd = chunkVal + strlen(chunkVal);
moreChunks = false;
}
- int chunkOffset = static_cast<int>(chunkVal - val.c_str());
- int chunkLength = static_cast<int>(chunkEnd - chunkVal);
- int chunkEndOffset = chunkOffset + chunkLength;
+ const int chunkOffset = static_cast<int>(chunkVal - val.c_str());
+ const int chunkLength = static_cast<int>(chunkEnd - chunkVal);
+ const int chunkEndOffset = chunkOffset + chunkLength;
int thisStartHighlight = std::max(startHighlight, chunkOffset);
thisStartHighlight = std::min(thisStartHighlight, chunkEndOffset);
thisStartHighlight -= chunkOffset;
diff --git a/src/CaseConvert.cxx b/src/CaseConvert.cxx
index c39d42840..4d0e5e271 100644
--- a/src/CaseConvert.cxx
+++ b/src/CaseConvert.cxx
@@ -708,18 +708,18 @@ void AddSymmetric(enum CaseConversion conversion, int lower,int upper) {
void SetupConversions(enum CaseConversion conversion) {
// First initialize for the symmetric ranges
for (size_t i=0; i<ELEMENTS(symmetricCaseConversionRanges);) {
- int lower = symmetricCaseConversionRanges[i++];
- int upper = symmetricCaseConversionRanges[i++];
- int length = symmetricCaseConversionRanges[i++];
- int pitch = symmetricCaseConversionRanges[i++];
+ const int lower = symmetricCaseConversionRanges[i++];
+ const int upper = symmetricCaseConversionRanges[i++];
+ const int length = symmetricCaseConversionRanges[i++];
+ const int pitch = symmetricCaseConversionRanges[i++];
for (int j=0; j<length*pitch; j+=pitch) {
AddSymmetric(conversion, lower+j, upper+j);
}
}
// Add the symmetric singletons
for (size_t i=0; i<ELEMENTS(symmetricCaseConversions);) {
- int lower = symmetricCaseConversions[i++];
- int upper = symmetricCaseConversions[i++];
+ const int lower = symmetricCaseConversions[i++];
+ const int upper = symmetricCaseConversions[i++];
AddSymmetric(conversion, lower, upper);
}
// Add the complex cases
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index f437cc335..1c4e920bf 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -162,7 +162,7 @@ void UndoHistory::EnsureUndoRoom() {
// as two actions may be created by the calling function
if (currentAction >= (lenActions - 2)) {
// Run out of undo nodes so extend the array
- int lenActionsNew = lenActions * 2;
+ const int lenActionsNew = lenActions * 2;
Action *actionsNew = new Action[lenActionsNew];
for (int act = 0; act <= currentAction; act++)
actionsNew[act].Grab(&actions[act]);
@@ -240,7 +240,7 @@ const char *UndoHistory::AppendAction(actionType at, Sci::Position position, con
currentAction++;
}
startSequence = oldCurrentAction != currentAction;
- int actionWithData = currentAction;
+ const int actionWithData = currentAction;
actions[currentAction].Create(at, position, data, lengthData, mayCoalesce);
currentAction++;
actions[currentAction].Create(startAction);
@@ -439,7 +439,7 @@ const char *CellBuffer::InsertString(Sci::Position position, const char *s, Sci:
}
bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) {
- char curVal = style.ValueAt(position);
+ const char curVal = style.ValueAt(position);
if (curVal != styleValue) {
style.SetValueAt(position, styleValue);
return true;
@@ -453,7 +453,7 @@ bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle,
PLATFORM_ASSERT(lengthStyle == 0 ||
(lengthStyle > 0 && lengthStyle + position <= style.Length()));
while (lengthStyle--) {
- char curVal = style.ValueAt(position);
+ const char curVal = style.ValueAt(position);
if (curVal != styleValue) {
style.SetValueAt(position, styleValue);
changed = true;
@@ -505,7 +505,7 @@ bool CellBuffer::ContainsLineEnd(const char *s, Sci::Position length) const {
if ((ch == '\r') || (ch == '\n')) {
return true;
} else if (utf8LineEnds) {
- unsigned char back3[3] = { chBeforePrev, chPrev, ch };
+ const unsigned char back3[3] = { chBeforePrev, chPrev, ch };
if (UTF8IsSeparator(back3) || UTF8IsNEL(back3 + 1)) {
return true;
}
@@ -576,7 +576,7 @@ void CellBuffer::RemoveLine(Sci::Line line) {
}
bool CellBuffer::UTF8LineEndOverlaps(Sci::Position position) const {
- unsigned char bytes[] = {
+ const unsigned char bytes[] = {
static_cast<unsigned char>(substance.ValueAt(position-2)),
static_cast<unsigned char>(substance.ValueAt(position-1)),
static_cast<unsigned char>(substance.ValueAt(position)),
@@ -597,7 +597,7 @@ void CellBuffer::ResetLineEnds() {
unsigned char chBeforePrev = 0;
unsigned char chPrev = 0;
for (Sci::Position i = 0; i < length; i++) {
- unsigned char ch = substance.ValueAt(position + i);
+ const unsigned char ch = substance.ValueAt(position + i);
if (ch == '\r') {
InsertLine(lineInsert, (position + i) + 1, atLineStart);
lineInsert++;
@@ -610,7 +610,7 @@ void CellBuffer::ResetLineEnds() {
lineInsert++;
}
} else if (utf8LineEnds) {
- unsigned char back3[3] = {chBeforePrev, chPrev, ch};
+ const unsigned char back3[3] = {chBeforePrev, chPrev, ch};
if (UTF8IsSeparator(back3) || UTF8IsNEL(back3+1)) {
InsertLine(lineInsert, (position + i) + 1, atLineStart);
lineInsert++;
@@ -626,7 +626,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
return;
PLATFORM_ASSERT(insertLength > 0);
- unsigned char chAfter = substance.ValueAt(position);
+ const unsigned char chAfter = substance.ValueAt(position);
bool breakingUTF8LineEnd = false;
if (utf8LineEnds && UTF8IsTrailByte(chAfter)) {
breakingUTF8LineEnd = UTF8LineEndOverlaps(position);
@@ -664,7 +664,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
lineInsert++;
}
} else if (utf8LineEnds) {
- unsigned char back3[3] = {chBeforePrev, chPrev, ch};
+ const unsigned char back3[3] = {chBeforePrev, chPrev, ch};
if (UTF8IsSeparator(back3) || UTF8IsNEL(back3+1)) {
InsertLine(lineInsert, (position + i) + 1, atLineStart);
lineInsert++;
@@ -682,8 +682,8 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
} else if (utf8LineEnds && !UTF8IsAscii(chAfter)) {
// May have end of UTF-8 line end in buffer and start in insertion
for (int j = 0; j < UTF8SeparatorLength-1; j++) {
- unsigned char chAt = substance.ValueAt(position + insertLength + j);
- unsigned char back3[3] = {chBeforePrev, chPrev, chAt};
+ const unsigned char chAt = substance.ValueAt(position + insertLength + j);
+ const unsigned char back3[3] = {chBeforePrev, chPrev, chAt};
if (UTF8IsSeparator(back3)) {
InsertLine(lineInsert, (position + insertLength + j) + 1, atLineStart);
lineInsert++;
@@ -712,8 +712,8 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
Sci::Line lineRemove = lv.LineFromPosition(position) + 1;
lv.InsertText(lineRemove-1, - (deleteLength));
- unsigned char chPrev = substance.ValueAt(position - 1);
- unsigned char chBefore = chPrev;
+ const unsigned char chPrev = substance.ValueAt(position - 1);
+ const unsigned char chBefore = chPrev;
unsigned char chNext = substance.ValueAt(position);
bool ignoreNL = false;
if (chPrev == '\r' && chNext == '\n') {
@@ -743,7 +743,7 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
}
} else if (utf8LineEnds) {
if (!UTF8IsAscii(ch)) {
- unsigned char next3[3] = {ch, chNext,
+ const unsigned char next3[3] = {ch, chNext,
static_cast<unsigned char>(substance.ValueAt(position + i + 2))};
if (UTF8IsSeparator(next3) || UTF8IsNEL(next3)) {
RemoveLine(lineRemove);
@@ -755,7 +755,7 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
}
// May have to fix up end if last deletion causes cr to be next to lf
// or removes one of a crlf pair
- char chAfter = substance.ValueAt(position + deleteLength);
+ const char chAfter = substance.ValueAt(position + deleteLength);
if (chBefore == '\r' && chAfter == '\n') {
// Using lineRemove-1 as cr ended line before start of deletion
RemoveLine(lineRemove - 1);
diff --git a/src/Decoration.cxx b/src/Decoration.cxx
index 4c85cc60c..a415711ed 100644
--- a/src/Decoration.cxx
+++ b/src/Decoration.cxx
@@ -125,7 +125,7 @@ bool DecorationList::FillRange(int &position, int value, int &fillLength) {
current = Create(currentIndicator, lengthDocument);
}
}
- bool changed = current->rs.FillRange(position, value, fillLength);
+ const bool changed = current->rs.FillRange(position, value, fillLength);
if (current->Empty()) {
Delete(currentIndicator);
}
@@ -177,7 +177,7 @@ int DecorationList::AllOnFor(int position) const {
}
int DecorationList::ValueAt(int indicator, int position) {
- Decoration *deco = DecorationFromIndicator(indicator);
+ const Decoration *deco = DecorationFromIndicator(indicator);
if (deco) {
return deco->rs.ValueAt(position);
}
@@ -185,7 +185,7 @@ int DecorationList::ValueAt(int indicator, int position) {
}
int DecorationList::Start(int indicator, int position) {
- Decoration *deco = DecorationFromIndicator(indicator);
+ const Decoration *deco = DecorationFromIndicator(indicator);
if (deco) {
return deco->rs.StartRun(position);
}
@@ -193,7 +193,7 @@ int DecorationList::Start(int indicator, int position) {
}
int DecorationList::End(int indicator, int position) {
- Decoration *deco = DecorationFromIndicator(indicator);
+ const Decoration *deco = DecorationFromIndicator(indicator);
if (deco) {
return deco->rs.EndRun(position);
}
diff --git a/src/Document.cxx b/src/Document.cxx
index e3b2a4be9..d8fdc1153 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -84,7 +84,7 @@ void LexInterface::Colourise(Sci::Position start, Sci::Position end) {
int LexInterface::LineEndTypesSupported() {
if (instance) {
- int interfaceVersion = instance->Version();
+ const int interfaceVersion = instance->Version();
if (interfaceVersion >= lvSubStyles) {
ILexerWithSubStyles *ssinstance = static_cast<ILexerWithSubStyles *>(instance);
return ssinstance->LineEndTypesSupported();
@@ -211,7 +211,7 @@ int Document::AddRef() {
// Decrease reference count and return its previous value.
// Delete the document if reference count reaches zero.
int SCI_METHOD Document::Release() {
- int curRefCount = --refCount;
+ const int curRefCount = --refCount;
if (curRefCount == 0)
delete this;
return curRefCount;
@@ -229,9 +229,9 @@ void Document::TentativeUndo() {
if (enteredModification == 0) {
enteredModification++;
if (!cb.IsReadOnly()) {
- bool startSavePoint = cb.IsSavePoint();
+ const bool startSavePoint = cb.IsSavePoint();
bool multiLine = false;
- int steps = cb.TentativeSteps();
+ const int steps = cb.TentativeSteps();
//Platform::DebugPrintf("Steps=%d\n", steps);
for (int step = 0; step < steps; step++) {
const Sci::Line prevLinesTotal = LinesTotal();
@@ -293,7 +293,7 @@ Sci::Line Document::MarkerNext(Sci::Line lineStart, int mask) const {
int Document::AddMark(Sci::Line line, int markerNum) {
if (line >= 0 && line <= LinesTotal()) {
- int prev = static_cast<LineMarkers *>(perLineData[ldMarkers])->
+ const int prev = static_cast<LineMarkers *>(perLineData[ldMarkers])->
AddMark(line, markerNum, LinesTotal());
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
NotifyModified(mh);
@@ -360,7 +360,7 @@ Sci_Position SCI_METHOD Document::LineEnd(Sci_Position line) const {
} else {
Sci::Position position = LineStart(line + 1);
if (SC_CP_UTF8 == dbcsCodePage) {
- unsigned char bytes[] = {
+ const unsigned char bytes[] = {
static_cast<unsigned char>(cb.CharAt(position-3)),
static_cast<unsigned char>(cb.CharAt(position-2)),
static_cast<unsigned char>(cb.CharAt(position-1)),
@@ -407,7 +407,7 @@ bool Document::IsPositionInLineEnd(Sci::Position position) const {
Sci::Position Document::VCHomePosition(Sci::Position position) const {
Sci::Line line = LineFromPosition(position);
Sci::Position startPosition = LineStart(line);
- Sci::Position endLine = LineEnd(line);
+ const Sci::Position endLine = LineEnd(line);
Sci::Position startText = startPosition;
while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t'))
startText++;
@@ -418,7 +418,7 @@ Sci::Position Document::VCHomePosition(Sci::Position position) const {
}
int SCI_METHOD Document::SetLevel(Sci_Position line, int level) {
- int prev = static_cast<LineLevels *>(perLineData[ldLevels])->SetLevel(line, level, LinesTotal());
+ const int prev = static_cast<LineLevels *>(perLineData[ldLevels])->SetLevel(line, level, LinesTotal());
if (prev != level) {
DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER,
LineStart(line), 0, 0, 0, line);
@@ -447,8 +447,8 @@ static bool IsSubordinate(int levelStart, int levelTry) {
Sci::Line Document::GetLastChild(Sci::Line lineParent, int level, Sci::Line lastLine) {
if (level == -1)
level = LevelNumber(GetLevel(lineParent));
- Sci::Line maxLine = LinesTotal();
- Sci::Line lookLastLine = (lastLine != -1) ? std::min(LinesTotal() - 1, lastLine) : -1;
+ const Sci::Line maxLine = LinesTotal();
+ const Sci::Line lookLastLine = (lastLine != -1) ? std::min(LinesTotal() - 1, lastLine) : -1;
Sci::Line lineMaxSubord = lineParent;
while (lineMaxSubord < maxLine - 1) {
EnsureStyledTo(LineStart(lineMaxSubord + 2));
@@ -470,7 +470,7 @@ Sci::Line Document::GetLastChild(Sci::Line lineParent, int level, Sci::Line last
}
Sci::Line Document::GetFoldParent(Sci::Line line) const {
- int level = LevelNumber(GetLevel(line));
+ const int level = LevelNumber(GetLevel(line));
Sci::Line lineLook = line - 1;
while ((lineLook > 0) && (
(!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) ||
@@ -487,7 +487,7 @@ Sci::Line Document::GetFoldParent(Sci::Line line) const {
}
void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine) {
- int level = GetLevel(line);
+ const int level = GetLevel(line);
Sci::Line lookLastLine = std::max(line, lastLine) + 1;
Sci::Line lookLine = line;
@@ -599,15 +599,15 @@ bool Document::InGoodUTF8(Sci::Position pos, Sci::Position &start, Sci::Position
if (widthCharBytes == 1) {
return false;
} else {
- int trailBytes = widthCharBytes - 1;
- Sci::Position len = pos - start;
+ const int trailBytes = widthCharBytes - 1;
+ const Sci::Position len = pos - start;
if (len > trailBytes)
// pos too far from lead
return false;
char charBytes[UTF8MaxBytes] = {static_cast<char>(leadByte),0,0,0};
for (int b=1; b<widthCharBytes && ((start+b) < Length()); b++)
charBytes[b] = cb.CharAt(static_cast<Sci::Position>(start+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)
return false;
end = start + widthCharBytes;
@@ -638,7 +638,7 @@ Sci::Position Document::MovePositionOutsideChar(Sci::Position pos, Sci::Position
if (dbcsCodePage) {
if (SC_CP_UTF8 == dbcsCodePage) {
- unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
+ const unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
// If ch is not a trail byte then pos is valid intercharacter position
if (UTF8IsTrailByte(ch)) {
Sci::Position startUTF = pos;
@@ -655,7 +655,7 @@ Sci::Position Document::MovePositionOutsideChar(Sci::Position pos, Sci::Position
} else {
// Anchor DBCS calculations at start of line because start of line can
// not be a DBCS trail byte.
- Sci::Position posStartLine = LineStart(LineFromPosition(pos));
+ const Sci::Position posStartLine = LineStart(LineFromPosition(pos));
if (pos == posStartLine)
return pos;
@@ -717,7 +717,7 @@ Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const {
} else {
// Examine byte before position
pos--;
- unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
+ const unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
// If ch is not a trail byte then pos is valid intercharacter position
if (UTF8IsTrailByte(ch)) {
// If ch is a trail byte in a valid UTF-8 character then return start of character
@@ -738,7 +738,7 @@ Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const {
} else {
// Anchor DBCS calculations at start of line because start of line can
// not be a DBCS trail byte.
- Sci::Position posStartLine = LineStart(LineFromPosition(pos));
+ const Sci::Position posStartLine = LineStart(LineFromPosition(pos));
// See http://msdn.microsoft.com/en-us/library/cc194792%28v=MSDN.10%29.aspx
// http://msdn.microsoft.com/en-us/library/cc194790.aspx
if ((pos - 1) <= posStartLine) {
@@ -902,7 +902,7 @@ int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Positio
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) {
// Report as singleton surrogate values which are invalid Unicode
character = 0xDC80 + leadByte;
@@ -934,7 +934,7 @@ int SCI_METHOD Document::CodePage() const {
bool SCI_METHOD Document::IsDBCSLeadByte(char ch) const {
// Byte ranges found in Wikipedia articles with relevant search strings in each case
- unsigned char uch = static_cast<unsigned char>(ch);
+ const unsigned char uch = static_cast<unsigned char>(ch);
switch (dbcsCodePage) {
case 932:
// Shift_jis
@@ -982,7 +982,7 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const
int lastPunctuationBreak = -1;
int lastEncodingAllowedBreak = 0;
for (int j=0; j < lengthSegment;) {
- unsigned char ch = static_cast<unsigned char>(text[j]);
+ const unsigned char ch = static_cast<unsigned char>(text[j]);
if (j > 0) {
if (IsSpaceOrTab(text[j - 1]) && !IsSpaceOrTab(text[j])) {
lastSpaceBreak = j;
@@ -1150,9 +1150,9 @@ Sci::Position Document::Undo() {
if ((enteredModification == 0) && (cb.IsCollectingUndo())) {
enteredModification++;
if (!cb.IsReadOnly()) {
- bool startSavePoint = cb.IsSavePoint();
+ const bool startSavePoint = cb.IsSavePoint();
bool multiLine = false;
- int steps = cb.StartUndo();
+ const int steps = cb.StartUndo();
//Platform::DebugPrintf("Steps=%d\n", steps);
Sci::Position coalescedRemovePos = -1;
Sci::Position coalescedRemoveLen = 0;
@@ -1235,9 +1235,9 @@ Sci::Position Document::Redo() {
if ((enteredModification == 0) && (cb.IsCollectingUndo())) {
enteredModification++;
if (!cb.IsReadOnly()) {
- bool startSavePoint = cb.IsSavePoint();
+ const bool startSavePoint = cb.IsSavePoint();
bool multiLine = false;
- int steps = cb.StartRedo();
+ const int steps = cb.StartRedo();
for (int step = 0; step < steps; step++) {
const Sci::Line prevLinesTotal = LinesTotal();
const Action &action = cb.GetRedoStep();
@@ -1328,10 +1328,10 @@ static std::string CreateIndentation(Sci::Position indent, int tabSize, bool ins
int SCI_METHOD Document::GetLineIndentation(Sci_Position line) {
int indent = 0;
if ((line >= 0) && (line < LinesTotal())) {
- Sci::Position lineStart = LineStart(line);
- Sci::Position length = Length();
+ const Sci::Position lineStart = LineStart(line);
+ const Sci::Position length = Length();
for (Sci::Position i = lineStart; i < length; i++) {
- char ch = cb.CharAt(i);
+ const char ch = cb.CharAt(i);
if (ch == ' ')
indent++;
else if (ch == '\t')
@@ -1344,7 +1344,7 @@ int SCI_METHOD Document::GetLineIndentation(Sci_Position line) {
}
Sci::Position Document::SetLineIndentation(Sci::Line line, Sci::Position indent) {
- int indentOfLine = GetLineIndentation(line);
+ const int indentOfLine = GetLineIndentation(line);
if (indent < 0)
indent = 0;
if (indent != indentOfLine) {
@@ -1364,7 +1364,7 @@ Sci::Position Document::GetLineIndentPosition(Sci::Line line) const {
if (line < 0)
return 0;
Sci::Position pos = LineStart(line);
- Sci::Position length = Length();
+ const Sci::Position length = Length();
while ((pos < length) && IsSpaceOrTab(cb.CharAt(pos))) {
pos++;
}
@@ -1376,7 +1376,7 @@ Sci::Position Document::GetColumn(Sci::Position pos) {
Sci::Line line = LineFromPosition(pos);
if ((line >= 0) && (line < LinesTotal())) {
for (Sci::Position i = LineStart(line); i < pos;) {
- char ch = cb.CharAt(i);
+ const char ch = cb.CharAt(i);
if (ch == '\t') {
column = NextTab(column, tabInChars);
i++;
@@ -1427,7 +1427,7 @@ Sci::Position Document::FindColumn(Sci::Line line, Sci::Position column) {
if ((line >= 0) && (line < LinesTotal())) {
Sci::Position columnCurrent = 0;
while ((columnCurrent < column) && (position < Length())) {
- char ch = cb.CharAt(position);
+ const char ch = cb.CharAt(position);
if (ch == '\t') {
columnCurrent = NextTab(columnCurrent, tabInChars);
if (columnCurrent > column)
@@ -1524,7 +1524,7 @@ void Document::ConvertLineEnds(int eolModeSet) {
bool Document::IsWhiteLine(Sci::Line line) const {
Sci::Position currentChar = LineStart(line);
- Sci::Position endLine = LineEnd(line);
+ const Sci::Position endLine = LineEnd(line);
while (currentChar < endLine) {
if (cb.CharAt(currentChar) != ' ' && cb.CharAt(currentChar) != '\t') {
return false;
@@ -1718,7 +1718,7 @@ Sci::Position Document::NextWordEnd(Sci::Position pos, int delta) const {
if (delta < 0) {
if (pos > 0) {
CharacterExtracted ce = CharacterBefore(pos);
- CharClassify::cc ccStart = WordCharacterClass(ce.character);
+ const CharClassify::cc ccStart = WordCharacterClass(ce.character);
if (ccStart != CharClassify::ccSpace) {
while (pos > 0) {
ce = CharacterBefore(pos);
@@ -1743,7 +1743,7 @@ Sci::Position Document::NextWordEnd(Sci::Position pos, int delta) const {
}
if (pos < Length()) {
CharacterExtracted ce = CharacterAfter(pos);
- CharClassify::cc ccStart = WordCharacterClass(ce.character);
+ const CharClassify::cc ccStart = WordCharacterClass(ce.character);
while (pos < Length()) {
ce = CharacterAfter(pos);
if (WordCharacterClass(ce.character) != ccStart)
@@ -2125,7 +2125,7 @@ void Document::LexerChanged() {
}
int SCI_METHOD Document::SetLineState(Sci_Position line, int state) {
- int statePrevious = static_cast<LineState *>(perLineData[ldState])->SetLineState(line, state);
+ const int statePrevious = static_cast<LineState *>(perLineData[ldState])->SetLineState(line, state);
if (state != statePrevious) {
DocModification mh(SC_MOD_CHANGELINESTATE, LineStart(line), 0, 0, 0, line);
NotifyModified(mh);
@@ -2147,7 +2147,7 @@ void SCI_METHOD Document::ChangeLexerState(Sci_Position start, Sci_Position end)
}
StyledText Document::MarginStyledText(Sci::Line line) const {
- LineAnnotation *pla = static_cast<LineAnnotation *>(perLineData[ldMargin]);
+ const LineAnnotation *pla = static_cast<LineAnnotation *>(perLineData[ldMargin]);
return StyledText(pla->Length(line), pla->Text(line),
pla->MultipleStyles(line), pla->Style(line), pla->Styles(line));
}
@@ -2169,7 +2169,7 @@ void Document::MarginSetStyles(Sci::Line line, const unsigned char *styles) {
}
void Document::MarginClearAll() {
- Sci::Line maxEditorLine = LinesTotal();
+ const Sci::Line maxEditorLine = LinesTotal();
for (Sci::Line l=0; l<maxEditorLine; l++)
MarginSetText(l, 0);
// Free remaining data
@@ -2177,7 +2177,7 @@ void Document::MarginClearAll() {
}
StyledText Document::AnnotationStyledText(Sci::Line line) const {
- LineAnnotation *pla = static_cast<LineAnnotation *>(perLineData[ldAnnotation]);
+ const LineAnnotation *pla = static_cast<LineAnnotation *>(perLineData[ldAnnotation]);
return StyledText(pla->Length(line), pla->Text(line),
pla->MultipleStyles(line), pla->Style(line), pla->Styles(line));
}
@@ -2210,7 +2210,7 @@ int Document::AnnotationLines(Sci::Line line) const {
}
void Document::AnnotationClearAll() {
- Sci::Line maxEditorLine = LinesTotal();
+ const Sci::Line maxEditorLine = LinesTotal();
for (Sci::Line l=0; l<maxEditorLine; l++)
AnnotationSetText(l, 0);
// Free remaining data
@@ -2416,7 +2416,7 @@ static bool IsLineEndChar(char c) {
}
Sci::Position Document::ExtendStyleRange(Sci::Position pos, int delta, bool singleLine) {
- int sStart = cb.StyleAt(pos);
+ const int sStart = cb.StyleAt(pos);
if (delta < 0) {
while (pos > 0 && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))))
pos--;
@@ -2453,8 +2453,8 @@ static char BraceOpposite(char ch) {
// TODO: should be able to extend styled region to find matching brace
Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxReStyle*/) {
- char chBrace = CharAt(position);
- char chSeek = BraceOpposite(chBrace);
+ const char chBrace = CharAt(position);
+ const char chSeek = BraceOpposite(chBrace);
if (chSeek == '\0')
return - 1;
const int styBrace = StyleIndexAt(position);
@@ -2464,7 +2464,7 @@ Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxRe
int depth = 1;
position = NextPosition(position, direction);
while ((position >= 0) && (position < Length())) {
- char chAtPos = CharAt(position);
+ const char chAtPos = CharAt(position);
const int styAtPos = StyleIndexAt(position);
if ((position > GetEndStyled()) || (styAtPos == styBrace)) {
if (chAtPos == chBrace)
@@ -2474,7 +2474,7 @@ Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxRe
if (depth == 0)
return position;
}
- Sci::Position positionBeforeMove = position;
+ const Sci::Position positionBeforeMove = position;
position = NextPosition(position, direction);
if (position == positionBeforeMove)
break;
@@ -2740,7 +2740,7 @@ public:
}
private:
void ReadCharacter() {
- Document::CharacterExtracted charExtracted = doc->ExtractCharacter(position);
+ const Document::CharacterExtracted charExtracted = doc->ExtractCharacter(position);
lenBytes = charExtracted.widthBytes;
if (charExtracted.character == unicodeReplacementChar) {
lenCharacters = 1;
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 4301836db..e2fe664a7 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -244,7 +244,7 @@ bool EditView::AddTabstop(Sci::Line line, int x) {
}
int EditView::GetNextTabstop(Sci::Line line, int x) const {
- LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops);
+ const LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops);
if (lt) {
return lt->GetNextTabstop(line, x);
} else {
@@ -386,7 +386,7 @@ void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surfa
int numCharsInLine = 0;
while (numCharsInLine < lineLength) {
Sci::Position charInDoc = numCharsInLine + posLineStart;
- char chDoc = model.pdoc->CharAt(charInDoc);
+ const char chDoc = model.pdoc->CharAt(charInDoc);
styleByte = model.pdoc->StyleIndexAt(charInDoc);
allSame = allSame &&
(ll->styles[numCharsInLine] == styleByte);
@@ -435,7 +435,7 @@ void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surfa
const int lineLength = posLineEnd - posLineStart;
model.pdoc->GetCharRange(ll->chars, posLineStart, lineLength);
model.pdoc->GetStyleRange(ll->styles, posLineStart, lineLength);
- int numCharsBeforeEOL = model.pdoc->LineEnd(line) - posLineStart;
+ const int numCharsBeforeEOL = model.pdoc->LineEnd(line) - posLineStart;
const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL;
for (Sci::Position styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) {
const unsigned char styleByte = ll->styles[styleInLine];
@@ -444,7 +444,7 @@ void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surfa
const unsigned char styleByteLast = (lineLength > 0) ? ll->styles[lineLength - 1] : 0;
if (vstyle.someStylesForceCase) {
for (int charInLine = 0; charInLine<lineLength; charInLine++) {
- char chDoc = ll->chars[charInLine];
+ const char chDoc = ll->chars[charInLine];
if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseUpper)
ll->chars[charInLine] = static_cast<char>(MakeUpperCase(chDoc));
else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseLower)
@@ -721,13 +721,13 @@ SelectionPosition EditView::SPositionFromLineX(Surface *surface, const EditModel
}
Sci::Line EditView::DisplayFromPosition(Surface *surface, const EditModel &model, Sci::Position pos, const ViewStyle &vs) {
- Sci::Line lineDoc = model.pdoc->LineFromPosition(pos);
+ const Sci::Line lineDoc = model.pdoc->LineFromPosition(pos);
Sci::Line lineDisplay = model.cs.DisplayFromDoc(lineDoc);
AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model));
if (surface && ll) {
LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth);
- Sci::Position posLineStart = model.pdoc->LineStart(lineDoc);
- Sci::Position posInLine = pos - posLineStart;
+ const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc);
+ const Sci::Position posInLine = pos - posLineStart;
lineDisplay--; // To make up for first increment ahead.
for (int subLine = 0; subLine < ll->lines; subLine++) {
if (posInLine >= ll->LineStart(subLine)) {
@@ -739,13 +739,13 @@ Sci::Line EditView::DisplayFromPosition(Surface *surface, const EditModel &model
}
Sci::Position EditView::StartEndDisplayLine(Surface *surface, const EditModel &model, Sci::Position pos, bool start, const ViewStyle &vs) {
- Sci::Line line = model.pdoc->LineFromPosition(pos);
+ const Sci::Line line = model.pdoc->LineFromPosition(pos);
AutoLineLayout ll(llc, RetrieveLineLayout(line, model));
Sci::Position posRet = INVALID_POSITION;
if (surface && ll) {
- Sci::Position posLineStart = model.pdoc->LineStart(line);
+ const Sci::Position posLineStart = model.pdoc->LineStart(line);
LayoutLine(model, line, surface, vs, ll, model.wrapWidth);
- Sci::Position posInLine = pos - posLineStart;
+ const Sci::Position posInLine = pos - posLineStart;
if (posInLine <= ll->maxLineLength) {
for (int subLine = 0; subLine < ll->lines; subLine++) {
if ((posInLine >= ll->LineStart(subLine)) &&
@@ -880,7 +880,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
virtualSpace = model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line)) * spaceWidth;
}
- XYPOSITION xEol = static_cast<XYPOSITION>(ll->positions[lineEnd] - subLineStart);
+ const XYPOSITION xEol = static_cast<XYPOSITION>(ll->positions[lineEnd] - subLineStart);
// Fill the virtual space and show selections within it
if (virtualSpace > 0.0f) {
@@ -890,9 +890,9 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) {
SelectionSegment virtualSpaceRange(SelectionPosition(model.pdoc->LineEnd(line)), SelectionPosition(model.pdoc->LineEnd(line), model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line))));
for (size_t r = 0; r<model.sel.Count(); r++) {
- int alpha = (r == model.sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
+ const int alpha = (r == model.sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
if (alpha == SC_ALPHA_NOALPHA) {
- SelectionSegment portion = model.sel.Range(r).Intersect(virtualSpaceRange);
+ const SelectionSegment portion = model.sel.Range(r).Intersect(virtualSpaceRange);
if (!portion.Empty()) {
const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] -
@@ -925,7 +925,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
blobsWidth += rcSegment.Width();
char hexits[4];
const char *ctrlChar;
- unsigned char chEOL = ll->chars[eolPos];
+ const unsigned char chEOL = ll->chars[eolPos];
int styleMain = ll->styles[eolPos];
ColourDesired textBack = TextBackground(model, vsDraw, ll, background, eolInSelection, false, styleMain, eolPos);
if (UTF8IsAscii(chEOL)) {
@@ -986,7 +986,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
rcSegment.left = rcLine.left;
rcSegment.right = rcLine.right;
- bool fillRemainder = !lastSubLine || model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_HIDDEN || !model.cs.GetFoldDisplayTextShown(line);
+ const bool fillRemainder = !lastSubLine || model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_HIDDEN || !model.cs.GetFoldDisplayTextShown(line);
if (fillRemainder) {
// Fill the remainder of the line
FillLineRemainder(surface, model, vsDraw, ll, line, rcSegment, subLine);
@@ -1064,7 +1064,7 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
const bool hover = vsDraw.indicators[deco->Indicator()].IsDynamic() &&
rangeRun.ContainsCharacter(hoverIndicatorPos);
const int value = deco->rs.ValueAt(startPos);
- Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal;
+ const Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal;
const Sci::Position posSecond = model.pdoc->MovePositionOutsideChar(rangeRun.First() + 1, 1);
DrawIndicator(deco->Indicator(), startPos - posLineStart, endPos - posLineStart,
surface, vsDraw, ll, xStart, rcLine, posSecond - posLineStart, subLine, drawState, value);
@@ -1079,7 +1079,7 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
// Use indicators to highlight matching braces
if ((vsDraw.braceHighlightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACELIGHT)) ||
(vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACEBAD))) {
- int braceIndicator = (model.bracesMatchStyle == STYLE_BRACELIGHT) ? vsDraw.braceHighlightIndicator : vsDraw.braceBadLightIndicator;
+ const int braceIndicator = (model.bracesMatchStyle == STYLE_BRACELIGHT) ? vsDraw.braceHighlightIndicator : vsDraw.braceBadLightIndicator;
if (under == vsDraw.indicators[braceIndicator].under) {
Range rangeLine(posLineStart + lineStart, posLineEnd);
if (rangeLine.ContainsCharacter(model.braces[0])) {
@@ -1128,13 +1128,13 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
rcSegment.left = xStart + static_cast<XYPOSITION>(ll->positions[ll->numCharsInLine] - subLineStart) + virtualSpace + vsDraw.aveCharWidth;
rcSegment.right = rcSegment.left + static_cast<XYPOSITION>(widthFoldDisplayText);
- ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
+ const ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
FontAlias textFont = vsDraw.styles[STYLE_FOLDDISPLAYTEXT].font;
ColourDesired textFore = vsDraw.styles[STYLE_FOLDDISPLAYTEXT].fore;
if (eolInSelection && (vsDraw.selColours.fore.isSet)) {
textFore = (eolInSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground;
}
- ColourDesired textBack = TextBackground(model, vsDraw, ll, background, eolInSelection,
+ const ColourDesired textBack = TextBackground(model, vsDraw, ll, background, eolInSelection,
false, STYLE_FOLDDISPLAYTEXT, -1);
if (model.trackLineWidth) {
@@ -1198,9 +1198,9 @@ static bool AnnotationBoxedOrIndented(int annotationVisible) {
void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
Sci::Line line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) {
- int indent = static_cast<int>(model.pdoc->GetLineIndentation(line) * vsDraw.spaceWidth);
+ const int indent = static_cast<int>(model.pdoc->GetLineIndentation(line) * vsDraw.spaceWidth);
PRectangle rcSegment = rcLine;
- int annotationLine = subLine - ll->lines;
+ const int annotationLine = subLine - ll->lines;
const StyledText stAnnotation = model.pdoc->AnnotationStyledText(line);
if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) {
if (phase & drawBack) {
@@ -1322,7 +1322,7 @@ static void DrawBlockCaret(Surface *surface, const EditModel &model, const ViewS
void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
Sci::Line lineDoc, int xStart, PRectangle rcLine, int subLine) const {
// When drag is active it is the only caret drawn
- bool drawDrag = model.posDrag.IsValid();
+ const bool drawDrag = model.posDrag.IsValid();
if (hideSelection && !drawDrag)
return;
const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc);
@@ -1342,12 +1342,12 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
if (ll->InLine(offset, subLine) && offset <= ll->numCharsBeforeEOL) {
XYPOSITION xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)];
if (ll->wrapIndent != 0) {
- Sci::Position lineStart = ll->LineStart(subLine);
+ const Sci::Position lineStart = ll->LineStart(subLine);
if (lineStart != 0) // Wrapped
xposCaret += ll->wrapIndent;
}
- bool caretBlinkState = (model.caret.active && model.caret.on) || (!additionalCaretsBlink && !mainCaret);
- bool caretVisibleState = additionalCaretsVisible || mainCaret;
+ const bool caretBlinkState = (model.caret.active && model.caret.on) || (!additionalCaretsBlink && !mainCaret);
+ const bool caretVisibleState = additionalCaretsVisible || mainCaret;
if ((xposCaret >= 0) && (vsDraw.caretWidth > 0) && (vsDraw.caretStyle != CARETSTYLE_INVISIBLE) &&
((model.posDrag.IsValid()) || (caretBlinkState && caretVisibleState))) {
bool caretAtEOF = false;
@@ -1566,13 +1566,13 @@ static void DrawTranslucentSelection(Surface *surface, const EditModel &model, c
if (subLine == (ll->lines - 1)) {
virtualSpaces = model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line));
}
- SelectionPosition posStart(posLineStart + lineRange.start);
- SelectionPosition posEnd(posLineStart + lineRange.end, virtualSpaces);
- SelectionSegment virtualSpaceRange(posStart, posEnd);
+ const SelectionPosition posStart(posLineStart + lineRange.start);
+ const SelectionPosition posEnd(posLineStart + lineRange.end, virtualSpaces);
+ const SelectionSegment virtualSpaceRange(posStart, posEnd);
for (size_t r = 0; r < model.sel.Count(); r++) {
- int alpha = (r == model.sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
+ const int alpha = (r == model.sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
if (alpha != SC_ALPHA_NOALPHA) {
- SelectionSegment portion = model.sel.Range(r).Intersect(virtualSpaceRange);
+ const SelectionSegment portion = model.sel.Range(r).Intersect(virtualSpaceRange);
if (!portion.Empty()) {
const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth;
PRectangle rcSegment = rcLine;
@@ -1838,7 +1838,7 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode
xStartText = 100000; // Don't limit to visible indentation on empty line
// This line is empty, so use indentation of last line with text
int indentLastWithText = model.pdoc->GetLineIndentation(lineLastWithText);
- int isFoldHeader = model.pdoc->GetLevel(lineLastWithText) & SC_FOLDLEVELHEADERFLAG;
+ const int isFoldHeader = model.pdoc->GetLevel(lineLastWithText) & SC_FOLDLEVELHEADERFLAG;
if (isFoldHeader) {
// Level is one more level than parent
indentLastWithText += model.pdoc->IndentSize();
@@ -1950,7 +1950,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
}
static void DrawFoldLines(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, Sci::Line line, PRectangle rcLine) {
- bool expanded = model.cs.GetExpanded(line);
+ const bool expanded = model.cs.GetExpanded(line);
const int level = model.pdoc->GetLevel(line);
const int levelNext = model.pdoc->GetLevel(line + 1);
if ((level & SC_FOLDLEVELHEADERFLAG) &&
@@ -2163,7 +2163,7 @@ void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const
alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
}
- ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
+ const ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
surface->FillRectangle(rcArea, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection));
@@ -2188,8 +2188,8 @@ static ColourDesired InvertedLight(ColourDesired orig) {
unsigned int r = orig.GetRed();
unsigned int g = orig.GetGreen();
unsigned int b = orig.GetBlue();
- unsigned int l = (r + g + b) / 3; // There is a better calculation for this that matches human eye
- unsigned int il = 0xff - l;
+ const unsigned int l = (r + g + b) / 3; // There is a better calculation for this that matches human eye
+ const unsigned int il = 0xff - l;
if (l == 0)
return ColourDesired(0xff, 0xff, 0xff);
r = r * il / l;
@@ -2320,7 +2320,7 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface,
// to start printing from to ensure a particular position is on the first
// line of the page.
if (visibleLine == 0) {
- Sci::Position startWithinLine = nPrintPos - model.pdoc->LineStart(lineDoc);
+ const Sci::Position startWithinLine = nPrintPos - model.pdoc->LineStart(lineDoc);
for (int iwl = 0; iwl < ll.lines - 1; iwl++) {
if (ll.LineStart(iwl) <= startWithinLine && ll.LineStart(iwl + 1) >= startWithinLine) {
visibleLine = -iwl;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 3a4b3c744..6a6e7c7d7 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -287,7 +287,7 @@ Point Editor::GetVisibleOriginInMain() const {
PointDocument Editor::DocumentPointFromView(Point ptView) const {
PointDocument ptDocument(ptView);
if (wMargin.GetID()) {
- Point ptOrigin = GetVisibleOriginInMain();
+ const Point ptOrigin = GetVisibleOriginInMain();
ptDocument.x += ptOrigin.x;
ptDocument.y += ptOrigin.y;
} else {
@@ -321,8 +321,8 @@ PRectangle Editor::GetTextRectangle() const {
}
Sci::Line Editor::LinesOnScreen() const {
- PRectangle rcClient = GetClientRectangle();
- int htClient = static_cast<int>(rcClient.bottom - rcClient.top);
+ const PRectangle rcClient = GetClientRectangle();
+ const int htClient = static_cast<int>(rcClient.bottom - rcClient.top);
//Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1);
return htClient / vs.lineHeight;
}
@@ -565,14 +565,14 @@ SelectionPosition Editor::SelectionEnd() {
void Editor::SetRectangularRange() {
if (sel.IsRectangular()) {
- int xAnchor = XFromPosition(sel.Rectangular().anchor);
+ const int xAnchor = XFromPosition(sel.Rectangular().anchor);
int xCaret = XFromPosition(sel.Rectangular().caret);
if (sel.selType == Selection::selThin) {
xCaret = xAnchor;
}
- Sci::Line lineAnchorRect = pdoc->LineFromPosition(sel.Rectangular().anchor.Position());
- Sci::Line lineCaret = pdoc->LineFromPosition(sel.Rectangular().caret.Position());
- int increment = (lineCaret > lineAnchorRect) ? 1 : -1;
+ const Sci::Line lineAnchorRect = pdoc->LineFromPosition(sel.Rectangular().anchor.Position());
+ const Sci::Line lineCaret = pdoc->LineFromPosition(sel.Rectangular().caret.Position());
+ const int increment = (lineCaret > lineAnchorRect) ? 1 : -1;
for (Sci::Line line=lineAnchorRect; line != lineCaret+increment; line += increment) {
SelectionRange range(SPositionFromLineX(line, xCaret), SPositionFromLineX(line, xAnchor));
if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) == 0)
@@ -913,12 +913,12 @@ void Editor::SetLastXChosen() {
}
void Editor::ScrollTo(Sci::Line line, bool moveThumb) {
- Sci::Line topLineNew = Platform::Clamp(line, 0, MaxScrollPos());
+ const Sci::Line topLineNew = Platform::Clamp(line, 0, MaxScrollPos());
if (topLineNew != topLine) {
// Try to optimise small scrolls
#ifndef UNDER_CE
- Sci::Line linesToMove = topLine - topLineNew;
- bool performBlit = (abs(linesToMove) <= 10) && (paintState == notPainting);
+ const Sci::Line linesToMove = topLine - topLineNew;
+ const bool performBlit = (abs(linesToMove) <= 10) && (paintState == notPainting);
willRedrawAll = !performBlit;
#endif
SetTopLine(topLineNew);
@@ -960,9 +960,9 @@ void Editor::HorizontalScrollTo(int xPos) {
}
void Editor::VerticalCentreCaret() {
- Sci::Line lineDoc = pdoc->LineFromPosition(sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret());
- Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
- Sci::Line newTop = lineDisplay - (LinesOnScreen() / 2);
+ const Sci::Line lineDoc = pdoc->LineFromPosition(sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret());
+ const Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
+ const Sci::Line newTop = lineDisplay - (LinesOnScreen() / 2);
if (topLine != newTop) {
SetTopLine(newTop > 0 ? newTop : 0);
RedrawRect(GetClientRectangle());
@@ -979,15 +979,15 @@ void Editor::MoveSelectedLines(int lineDelta) {
// if selection doesn't start at the beginning of the line, set the new start
Sci::Position selectionStart = SelectionStart().Position();
- Sci::Line startLine = pdoc->LineFromPosition(selectionStart);
- Sci::Position beginningOfStartLine = pdoc->LineStart(startLine);
+ const Sci::Line startLine = pdoc->LineFromPosition(selectionStart);
+ const Sci::Position beginningOfStartLine = pdoc->LineStart(startLine);
selectionStart = beginningOfStartLine;
// if selection doesn't end at the beginning of a line greater than that of the start,
// then set it at the beginning of the next one
Sci::Position selectionEnd = SelectionEnd().Position();
- Sci::Line endLine = pdoc->LineFromPosition(selectionEnd);
- Sci::Position beginningOfEndLine = pdoc->LineStart(endLine);
+ const Sci::Line endLine = pdoc->LineFromPosition(selectionEnd);
+ const Sci::Position beginningOfEndLine = pdoc->LineStart(endLine);
bool appendEol = false;
if (selectionEnd > beginningOfEndLine
|| selectionStart == selectionEnd) {
@@ -1114,7 +1114,7 @@ slop | strict | jumps | even | Caret can go to the margin | When
*/
Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &range, const XYScrollOptions options) {
- PRectangle rcClient = GetTextRectangle();
+ const PRectangle rcClient = GetTextRectangle();
Point pt = LocationFromPosition(range.caret);
Point ptAnchor = LocationFromPosition(range.anchor);
const Point ptOrigin = GetVisibleOriginInMain();
@@ -1334,14 +1334,14 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
if (!(range.caret == range.anchor)) {
if (ptAnchor.x < pt.x) {
// Shift to left to show anchor or as much of range as possible
- int maxOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.left) - 1;
- int minOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 1;
+ const int maxOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.left) - 1;
+ const int minOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 1;
newXY.xOffset = std::min(newXY.xOffset, maxOffset);
newXY.xOffset = std::max(newXY.xOffset, minOffset);
} else {
// Shift to right to show anchor or as much of range as possible
- int minOffset = static_cast<Sci::Position>(ptAnchor.x + xOffset - rcClient.right) + 1;
- int maxOffset = static_cast<Sci::Position>(pt.x + xOffset - rcClient.left) - 1;
+ const int minOffset = static_cast<Sci::Position>(ptAnchor.x + xOffset - rcClient.right) + 1;
+ const int maxOffset = static_cast<Sci::Position>(pt.x + xOffset - rcClient.left) - 1;
newXY.xOffset = std::max(newXY.xOffset, minOffset);
newXY.xOffset = std::min(newXY.xOffset, maxOffset);
}
@@ -1364,7 +1364,7 @@ void Editor::SetXYScroll(XYScrollPosition newXY) {
xOffset = newXY.xOffset;
ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
if (newXY.xOffset > 0) {
- PRectangle rcText = GetTextRectangle();
+ const PRectangle rcText = GetTextRectangle();
if (horizontalScrollBarVisible &&
rcText.Width() + xOffset > scrollWidth) {
scrollWidth = xOffset + static_cast<Sci::Position>(rcText.Width());
@@ -1599,7 +1599,7 @@ const char *Editor::StringFromEOLMode(int eolMode) {
void Editor::LinesSplit(int pixelWidth) {
if (!RangeContainsProtected(targetStart, targetEnd)) {
if (pixelWidth == 0) {
- PRectangle rcText = GetTextRectangle();
+ const PRectangle rcText = GetTextRectangle();
pixelWidth = static_cast<int>(rcText.Width());
}
Sci::Line lineStart = pdoc->LineFromPosition(targetStart);
@@ -1675,7 +1675,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
view.RefreshPixMaps(surfaceWindow, wMain.GetID(), vs);
marginView.RefreshPixMaps(surfaceWindow, wMain.GetID(), vs);
if (view.bufferedDraw) {
- PRectangle rcClient = GetClientRectangle();
+ const PRectangle rcClient = GetClientRectangle();
if (!view.pixmapLine->Initialised()) {
view.pixmapLine->InitPixMap(static_cast<int>(rcClient.Width()), vs.lineHeight,
@@ -1804,9 +1804,9 @@ void Editor::ReconfigureScrollBars() {}
void Editor::SetScrollBars() {
RefreshStyleData();
- Sci::Line nMax = MaxScrollPos();
- Sci::Line nPage = LinesOnScreen();
- bool modified = ModifyScrollBars(nMax + nPage - 1, nPage);
+ const Sci::Line nMax = MaxScrollPos();
+ const Sci::Line nPage = LinesOnScreen();
+ const bool modified = ModifyScrollBars(nMax + nPage - 1, nPage);
if (modified) {
DwellEnd(true);
}
@@ -2251,8 +2251,8 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
if (pdoc->GetColumn(sel.Range(r).caret.Position()) <= pdoc->GetLineIndentation(lineCurrentPos) &&
pdoc->GetColumn(sel.Range(r).caret.Position()) > 0 && pdoc->backspaceUnindents) {
UndoGroup ugInner(pdoc, !ug.Needed());
- int indentation = pdoc->GetLineIndentation(lineCurrentPos);
- int indentationStep = pdoc->IndentSize();
+ const int indentation = pdoc->GetLineIndentation(lineCurrentPos);
+ const int indentationStep = pdoc->IndentSize();
int indentationChange = indentation % indentationStep;
if (indentationChange == 0)
indentationChange = indentationStep;
@@ -2406,7 +2406,7 @@ void Editor::NotifyPainted() {
}
void Editor::NotifyIndicatorClick(bool click, Sci::Position position, int modifiers) {
- int mask = pdoc->decorations.AllOnFor(position);
+ const int mask = pdoc->decorations.AllOnFor(position);
if ((click && mask) || pdoc->decorations.ClickNotified()) {
SCNotification scn = {};
pdoc->decorations.SetClickNotified(click);
@@ -2539,7 +2539,7 @@ static inline Sci::Position MovePositionForInsertion(Sci::Position position, Sci
// character is still present else after the previous surviving character.
static inline Sci::Position MovePositionForDeletion(Sci::Position position, Sci::Position startDeletion, Sci::Position length) {
if (position > startDeletion) {
- Sci::Position endDeletion = startDeletion + length;
+ const Sci::Position endDeletion = startDeletion + length;
if (position > endDeletion) {
return position - length;
} else {
@@ -2862,9 +2862,9 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {
Sci::Line topLineNew;
SelectionPosition newPos;
- Sci::Line currentLine = pdoc->LineFromPosition(sel.MainCaret());
- Sci::Line topStutterLine = topLine + caretYSlop;
- Sci::Line bottomStutterLine =
+ const Sci::Line currentLine = pdoc->LineFromPosition(sel.MainCaret());
+ const Sci::Line topStutterLine = topLine + caretYSlop;
+ const Sci::Line bottomStutterLine =
pdoc->LineFromPosition(PositionFromLocation(
Point::FromInts(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll())))
- caretYSlop - 1;
@@ -3810,26 +3810,26 @@ int Editor::KeyCommand(unsigned int iMessage) {
return DelWordOrLine(iMessage);
case SCI_LINECOPY: {
- Sci::Line lineStart = pdoc->LineFromPosition(SelectionStart().Position());
- Sci::Line lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
+ const Sci::Line lineStart = pdoc->LineFromPosition(SelectionStart().Position());
+ const Sci::Line lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
CopyRangeToClipboard(pdoc->LineStart(lineStart),
pdoc->LineStart(lineEnd + 1));
}
break;
case SCI_LINECUT: {
- Sci::Line lineStart = pdoc->LineFromPosition(SelectionStart().Position());
- Sci::Line lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
- Sci::Position start = pdoc->LineStart(lineStart);
- Sci::Position end = pdoc->LineStart(lineEnd + 1);
+ const Sci::Line lineStart = pdoc->LineFromPosition(SelectionStart().Position());
+ const Sci::Line lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
+ const Sci::Position start = pdoc->LineStart(lineStart);
+ const Sci::Position end = pdoc->LineStart(lineEnd + 1);
SetSelection(start, end);
Cut();
SetLastXChosen();
}
break;
case SCI_LINEDELETE: {
- Sci::Line line = pdoc->LineFromPosition(sel.MainCaret());
- Sci::Position start = pdoc->LineStart(line);
- Sci::Position end = pdoc->LineStart(line + 1);
+ const Sci::Line line = pdoc->LineFromPosition(sel.MainCaret());
+ const Sci::Position start = pdoc->LineStart(line);
+ const Sci::Position end = pdoc->LineStart(line + 1);
pdoc->DeleteChars(start, end - start);
}
break;
@@ -3918,8 +3918,8 @@ void Editor::Indent(bool forwards) {
} else {
if (pdoc->GetColumn(caretPosition) <= pdoc->GetLineIndentation(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);
sel.Range(r) = SelectionRange(posSelect);
} else {
@@ -3934,10 +3934,10 @@ void Editor::Indent(bool forwards) {
}
}
} else { // Multiline
- Sci::Position anchorPosOnLine = sel.Range(r).anchor.Position() - pdoc->LineStart(lineOfAnchor);
- Sci::Position currentPosPosOnLine = caretPosition - pdoc->LineStart(lineCurrentPos);
+ const Sci::Position anchorPosOnLine = sel.Range(r).anchor.Position() - pdoc->LineStart(lineOfAnchor);
+ const Sci::Position currentPosPosOnLine = caretPosition - pdoc->LineStart(lineCurrentPos);
// Multiple lines selected so indent / dedent
- Sci::Line lineTopSel = std::min(lineOfAnchor, lineCurrentPos);
+ const Sci::Line lineTopSel = std::min(lineOfAnchor, lineCurrentPos);
Sci::Line lineBottomSel = std::max(lineOfAnchor, lineCurrentPos);
if (pdoc->LineStart(lineBottomSel) == sel.Range(r).anchor.Position() || pdoc->LineStart(lineBottomSel) == caretPosition)
lineBottomSel--; // If not selecting any characters on a line, do not indent
@@ -4148,7 +4148,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
if (sel.selType == Selection::selRectangle)
std::sort(rangesInOrder.begin(), rangesInOrder.end());
for (size_t r=0; r<rangesInOrder.size(); r++) {
- SelectionRange current = rangesInOrder[r];
+ const SelectionRange current = rangesInOrder[r];
text.append(RangeText(current.Start().Position(), current.End().Position()));
if (sel.selType == Selection::selRectangle) {
if (pdoc->eolMode != SC_EOL_LF)
@@ -4207,9 +4207,9 @@ void Editor::DisplayCursor(Window::Cursor c) {
}
bool Editor::DragThreshold(Point ptStart, Point ptNow) {
- int xMove = static_cast<int>(ptStart.x - ptNow.x);
- int yMove = static_cast<int>(ptStart.y - ptNow.y);
- int distanceSquared = xMove * xMove + yMove * yMove;
+ const int xMove = static_cast<int>(ptStart.x - ptNow.x);
+ const int yMove = static_cast<int>(ptStart.y - ptNow.y);
+ const int distanceSquared = xMove * xMove + yMove * yMove;
return distanceSquared > 16;
}
@@ -4224,9 +4224,9 @@ void Editor::DropAt(SelectionPosition position, const char *value, size_t length
if (inDragDrop == ddDragging)
dropWentOutside = false;
- bool positionWasInSelection = PositionInSelection(position.Position());
+ const bool positionWasInSelection = PositionInSelection(position.Position());
- bool positionOnEdgeOfSelection =
+ const bool positionOnEdgeOfSelection =
(position == SelectionStart()) || (position == SelectionEnd());
if ((inDragDrop != ddDragging) || !(positionWasInSelection) ||
@@ -4298,10 +4298,10 @@ bool Editor::PositionInSelection(Sci::Position pos) {
}
bool Editor::PointInSelection(Point pt) {
- SelectionPosition pos = SPositionFromLocation(pt, false, true);
- Point ptPos = LocationFromPosition(pos);
+ const SelectionPosition pos = SPositionFromLocation(pt, false, true);
+ const Point ptPos = LocationFromPosition(pos);
for (size_t r=0; r<sel.Count(); r++) {
- SelectionRange range = sel.Range(r);
+ const SelectionRange range = sel.Range(r);
if (range.Contains(pos)) {
bool hit = true;
if (pos == range.Start()) {
@@ -4456,7 +4456,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
NotifyIndicatorClick(true, newPos.Position(), modifiers);
- bool inSelMargin = PointInSelMargin(pt);
+ const bool inSelMargin = PointInSelMargin(pt);
// In margin ctrl+(double)click should always select everything
if (ctrl && inSelMargin) {
SelectAll();
@@ -4647,7 +4647,7 @@ bool Editor::PointIsHotspot(Point pt) {
}
void Editor::SetHoverIndicatorPosition(Sci::Position position) {
- Sci::Position hoverIndicatorPosPrev = hoverIndicatorPos;
+ const Sci::Position hoverIndicatorPosPrev = hoverIndicatorPos;
hoverIndicatorPos = INVALID_POSITION;
if (vs.indicatorsDynamic == 0)
return;
@@ -5276,7 +5276,7 @@ void Editor::SetDocPointer(Document *document) {
void Editor::SetAnnotationVisible(int visible) {
if (vs.annotationVisible != visible) {
- bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0));
+ const bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0));
vs.annotationVisible = visible;
if (changedFromOrToHidden) {
int dir = vs.annotationVisible ? 1 : -1;
@@ -5299,7 +5299,7 @@ Sci::Line Editor::ExpandLine(Sci::Line line) {
line++;
while (line <= lineMaxSubord) {
cs.SetVisible(line, line, true);
- int level = pdoc->GetLevel(line);
+ const int level = pdoc->GetLevel(line);
if (level & SC_FOLDLEVELHEADERFLAG) {
if (cs.GetExpanded(line)) {
line = ExpandLine(line);
@@ -5330,12 +5330,12 @@ void Editor::FoldLine(Sci::Line line, int action) {
}
if (action == SC_FOLDACTION_CONTRACT) {
- Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
+ const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
if (lineMaxSubord > line) {
cs.SetExpanded(line, 0);
cs.SetVisible(line + 1, lineMaxSubord, false);
- Sci::Line lineCurrent = pdoc->LineFromPosition(sel.MainCaret());
+ const Sci::Line lineCurrent = pdoc->LineFromPosition(sel.MainCaret());
if (lineCurrent > line && lineCurrent <= lineMaxSubord) {
// This does not re-expand the fold
EnsureCaretVisible();
@@ -5372,7 +5372,7 @@ void Editor::FoldExpand(Sci::Line line, int action, int level) {
line++;
cs.SetVisible(line, lineMaxSubord, expanding);
while (line <= lineMaxSubord) {
- int levelLine = pdoc->GetLevel(line);
+ const int levelLine = pdoc->GetLevel(line);
if (levelLine & SC_FOLDLEVELHEADERFLAG) {
SetFoldExpanded(line, expanding);
}
@@ -5428,7 +5428,7 @@ void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {
Redraw();
}
if (enforcePolicy) {
- Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
+ const Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
if (visiblePolicy & VISIBLE_SLOP) {
if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) {
SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos()));
@@ -5466,14 +5466,14 @@ void Editor::FoldAll(int action) {
if (expanding) {
cs.SetVisible(0, maxLine-1, true);
for (int line = 0; line < maxLine; line++) {
- int levelLine = pdoc->GetLevel(line);
+ const int levelLine = pdoc->GetLevel(line);
if (levelLine & SC_FOLDLEVELHEADERFLAG) {
SetFoldExpanded(line, true);
}
}
} else {
for (int line = 0; line < maxLine; line++) {
- int level = pdoc->GetLevel(line);
+ const int level = pdoc->GetLevel(line);
if ((level & SC_FOLDLEVELHEADERFLAG) &&
(SC_FOLDLEVELBASE == LevelNumber(level))) {
SetFoldExpanded(line, false);
@@ -5540,8 +5540,8 @@ void Editor::FoldChanged(Sci::Line line, int levelNow, int levelPrev) {
void Editor::NeedShown(Sci::Position pos, Sci::Position len) {
if (foldAutomatic & SC_AUTOMATICFOLD_SHOW) {
- Sci::Line lineStart = pdoc->LineFromPosition(pos);
- Sci::Line lineEnd = pdoc->LineFromPosition(pos+len);
+ const Sci::Line lineStart = pdoc->LineFromPosition(pos);
+ const Sci::Line lineEnd = pdoc->LineFromPosition(pos+len);
for (Sci::Line line = lineStart; line <= lineEnd; line++) {
EnsureLineVisible(line, false);
}
@@ -7693,7 +7693,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(static_cast<int>(wParam))),
SelectionPosition(pdoc->LineEnd(static_cast<int>(wParam))));
for (size_t r=0; r<sel.Count(); r++) {
- SelectionSegment portion = sel.Range(r).Intersect(segmentLine);
+ const SelectionSegment portion = sel.Range(r).Intersect(segmentLine);
if (portion.start.IsValid()) {
return (iMessage == SCI_GETLINESELSTARTPOSITION) ? portion.start.Position() : portion.end.Position();
}
diff --git a/src/ExternalLexer.cxx b/src/ExternalLexer.cxx
index 2d3501f5b..8710e0cdd 100644
--- a/src/ExternalLexer.cxx
+++ b/src/ExternalLexer.cxx
@@ -65,7 +65,7 @@ LexerLibrary::LexerLibrary(const char *ModuleName) {
GetLexerNameFn GetLexerName = (GetLexerNameFn)(sptr_t)lib->FindFunction("GetLexerName");
GetLexerFactoryFunction fnFactory = (GetLexerFactoryFunction)(sptr_t)lib->FindFunction("GetLexerFactory");
- int nl = GetLexerCount();
+ const int nl = GetLexerCount();
for (int i = 0; i < nl; i++) {
// Assign a buffer for the lexer name.
diff --git a/src/Indicator.cxx b/src/Indicator.cxx
index c23ae4e17..4a2d43895 100644
--- a/src/Indicator.cxx
+++ b/src/Indicator.cxx
@@ -36,7 +36,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
int ymid = static_cast<int>(rc.bottom + rc.top) / 2;
if (sacDraw.style == INDIC_SQUIGGLE) {
int x = int(rc.left+0.5);
- int xLast = int(rc.right+0.5);
+ const int xLast = int(rc.right+0.5);
int y = 0;
surface->MoveTo(x, static_cast<int>(rc.top) + y);
while (x < xLast) {
diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx
index 53d9617c4..e2de5d97e 100644
--- a/src/LineMarker.cxx
+++ b/src/LineMarker.cxx
@@ -122,11 +122,11 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
int minDim = Platform::Minimum(static_cast<int>(rc.Width()), static_cast<int>(rc.Height()));
minDim--; // Ensure does not go beyond edge
int centreX = static_cast<int>(floor((rc.right + rc.left) / 2.0));
- int centreY = static_cast<int>(floor((rc.bottom + rc.top) / 2.0));
- int dimOn2 = minDim / 2;
- int dimOn4 = minDim / 4;
+ 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;
- int armSize = dimOn2-2;
+ 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
centreX = static_cast<int>(rc.left) + dimOn2 + 1;
@@ -384,7 +384,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
rcLeft.right = rcLeft.left + 4;
surface->FillRectangle(rcLeft, back);
} else if (markType == SC_MARK_BOOKMARK) {
- int halfHeight = minDim / 3;
+ const int halfHeight = minDim / 3;
Point pts[] = {
Point::FromInts(static_cast<int>(rc.left), centreY-halfHeight),
Point::FromInts(static_cast<int>(rc.right) - 3, centreY - halfHeight),
diff --git a/src/MarginView.cxx b/src/MarginView.cxx
index be743213d..27bf1e10d 100644
--- a/src/MarginView.cxx
+++ b/src/MarginView.cxx
@@ -64,10 +64,10 @@ void DrawWrapMarker(Surface *surface, PRectangle rcPlace,
enum { xa = 1 }; // gap before start
int w = static_cast<int>(rcPlace.right - rcPlace.left) - xa - 1;
- bool xStraight = isEndMarker; // x-mirrored symbol for start marker
+ const bool xStraight = isEndMarker; // x-mirrored symbol for start marker
- int x0 = static_cast<int>(xStraight ? rcPlace.left : rcPlace.right - 1);
- int y0 = static_cast<int>(rcPlace.top);
+ 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;
@@ -205,7 +205,7 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
// Required because of special way brush is created for selection margin
// Ensure patterns line up when scrolling with separate margin view
// by choosing correctly aligned variant.
- bool invertPhase = static_cast<int>(ptOrigin.y) & 1;
+ const bool invertPhase = static_cast<int>(ptOrigin.y) & 1;
surface->FillRectangle(rcSelMargin,
invertPhase ? *pixmapSelPattern : *pixmapSelPatternOffset1);
} else {
@@ -238,7 +238,7 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
// be displayed until the last of a sequence of whitespace.
bool needWhiteClosure = false;
if (vs.ms[margin].mask & SC_MASK_FOLDERS) {
- int level = model.pdoc->GetLevel(model.cs.DocFromDisplay(visibleLine));
+ const int level = model.pdoc->GetLevel(model.cs.DocFromDisplay(visibleLine));
if (level & SC_FOLDLEVELWHITEFLAG) {
Sci::Line lineBack = model.cs.DocFromDisplay(visibleLine);
int levelPrev = level;
@@ -380,7 +380,7 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
sprintf(number, "%d", lineDoc + 1);
if (model.foldFlags & (SC_FOLDFLAG_LEVELNUMBERS | SC_FOLDFLAG_LINESTATE)) {
if (model.foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
- int lev = model.pdoc->GetLevel(lineDoc);
+ const int lev = model.pdoc->GetLevel(lineDoc);
sprintf(number, "%c%c %03X %03X",
(lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
(lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
@@ -388,7 +388,7 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
lev >> 16
);
} else {
- int state = model.pdoc->GetLineState(lineDoc);
+ const int state = model.pdoc->GetLineState(lineDoc);
sprintf(number, "%0X", state);
}
}
diff --git a/src/Partitioning.h b/src/Partitioning.h
index 688b38d7d..2c82cfac9 100644
--- a/src/Partitioning.h
+++ b/src/Partitioning.h
@@ -27,9 +27,9 @@ public:
void RangeAddDelta(int start, int end, int delta) {
// end is 1 past end, so end-start is number of elements to change
int i = 0;
- int rangeLength = end - start;
+ const int rangeLength = end - start;
int range1Length = rangeLength;
- int part1Left = part1Length - start;
+ const int part1Left = part1Length - start;
if (range1Length > part1Left)
range1Length = part1Left;
while (i < range1Length) {
@@ -170,7 +170,7 @@ public:
int lower = 0;
int upper = body->Length()-1;
do {
- int middle = (upper + lower + 1) / 2; // Round high
+ const int middle = (upper + lower + 1) / 2; // Round high
int posMiddle = body->ValueAt(middle);
if (middle > stepPartition)
posMiddle += stepLength;
diff --git a/src/PerLine.cxx b/src/PerLine.cxx
index ceace09f4..abe2230e6 100644
--- a/src/PerLine.cxx
+++ b/src/PerLine.cxx
@@ -181,9 +181,9 @@ int LineMarkers::MarkValue(Sci::Line line) {
Sci::Line LineMarkers::MarkerNext(Sci::Line lineStart, int mask) const {
if (lineStart < 0)
lineStart = 0;
- Sci::Line length = markers.Length();
+ const Sci::Line length = markers.Length();
for (Sci::Line iLine = lineStart; iLine < length; iLine++) {
- MarkerHandleSet *onLine = markers[iLine];
+ const MarkerHandleSet *onLine = markers[iLine];
if (onLine && ((onLine->MarkValue() & mask) != 0))
//if ((pdoc->GetMark(iLine) & lParam) != 0)
return iLine;
@@ -318,7 +318,7 @@ void LineState::RemoveLine(Sci::Line line) {
int LineState::SetLineState(Sci::Line line, int state) {
lineStates.EnsureLength(line + 1);
- int stateOld = lineStates[line];
+ const int stateOld = lineStates[line];
lineStates[line] = state;
return stateOld;
}
@@ -410,7 +410,7 @@ const unsigned char *LineAnnotation::Styles(Sci::Line line) const {
}
static char *AllocateAnnotation(int length, int style) {
- size_t len = sizeof(AnnotationHeader) + length + ((style == IndividualStyles) ? length : 0);
+ const size_t len = sizeof(AnnotationHeader) + length + ((style == IndividualStyles) ? length : 0);
char *ret = new char[len]();
return ret;
}
@@ -418,7 +418,7 @@ static char *AllocateAnnotation(int length, int style) {
void LineAnnotation::SetText(Sci::Line line, const char *text) {
if (text && (line >= 0)) {
annotations.EnsureLength(line+1);
- int style = Style(line);
+ const int style = Style(line);
if (annotations[line]) {
delete []annotations[line];
}
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 2850e4fbd..1572f2beb 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -189,7 +189,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
- XYPOSITION posMiddle = positions[middle];
+ const XYPOSITION posMiddle = positions[middle];
if (x < posMiddle) {
upper = middle - 1;
} else {
@@ -469,11 +469,11 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin
}
if (breakForSelection) {
- SelectionPosition posStart(posLineStart);
- SelectionPosition posEnd(posLineStart + lineRange.end);
- SelectionSegment segmentLine(posStart, posEnd);
+ const SelectionPosition posStart(posLineStart);
+ const SelectionPosition posEnd(posLineStart + lineRange.end);
+ const SelectionSegment segmentLine(posStart, posEnd);
for (size_t r=0; r<psel->Count(); r++) {
- SelectionSegment portion = psel->Range(r).Intersect(segmentLine);
+ const SelectionSegment portion = psel->Range(r).Intersect(segmentLine);
if (!(portion.start == portion.end)) {
if (portion.start.IsValid())
Insert(portion.start.Position() - posLineStart);
@@ -653,7 +653,7 @@ void PositionCache::SetSize(size_t size_) {
}
void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber,
- const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc) {
+ const char *s, unsigned int len, XYPOSITION *positions, const Document *pdoc) {
allClear = false;
size_t probe = pces.size(); // Out of bounds
diff --git a/src/PositionCache.h b/src/PositionCache.h
index 8c6f0f2e1..b80edd880 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -214,7 +214,7 @@ public:
void SetSize(size_t size_);
size_t GetSize() const { return pces.size(); }
void MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber,
- const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc);
+ const char *s, unsigned int len, XYPOSITION *positions, const Document *pdoc);
};
inline bool IsSpaceOrTab(int ch) {
diff --git a/src/RESearch.cxx b/src/RESearch.cxx
index 438a3301f..9bcea1ce9 100644
--- a/src/RESearch.cxx
+++ b/src/RESearch.cxx
@@ -358,7 +358,7 @@ int RESearch::GetBackslashExpression(
incr = 0; // Most of the time, will skip the char "naturally".
int c;
int result = -1;
- unsigned char bsc = *pattern;
+ const unsigned char bsc = *pattern;
if (!bsc) {
// Avoid overrun
result = '\\'; // \ at end of pattern, take it literally
@@ -376,9 +376,9 @@ int RESearch::GetBackslashExpression(
result = escapeValue(bsc);
break;
case 'x': {
- unsigned char hd1 = *(pattern + 1);
- unsigned char hd2 = *(pattern + 2);
- int hexValue = GetHexaChar(hd1, hd2);
+ const unsigned char hd1 = *(pattern + 1);
+ const unsigned char hd2 = *(pattern + 2);
+ const int hexValue = GetHexaChar(hd1, hd2);
if (hexValue >= 0) {
result = hexValue;
incr = 2; // Must skip the digits
diff --git a/src/RunStyles.cxx b/src/RunStyles.cxx
index aa0177ca1..01eab156a 100644
--- a/src/RunStyles.cxx
+++ b/src/RunStyles.cxx
@@ -38,7 +38,7 @@ int RunStyles::RunFromPosition(int position) const {
// If there is no run boundary at position, insert one continuing style.
int RunStyles::SplitRun(int position) {
int run = RunFromPosition(position);
- int posRun = starts->PositionFromPartition(run);
+ const int posRun = starts->PositionFromPartition(run);
if (posRun < position) {
int runStyle = ValueAt(position);
run++;
@@ -91,12 +91,12 @@ int RunStyles::ValueAt(int position) const {
}
int RunStyles::FindNextChange(int position, int end) const {
- int run = starts->PartitionFromPosition(position);
+ const int run = starts->PartitionFromPosition(position);
if (run < starts->Partitions()) {
- int runChange = starts->PositionFromPartition(run);
+ const int runChange = starts->PositionFromPartition(run);
if (runChange > position)
return runChange;
- int nextChange = starts->PositionFromPartition(run + 1);
+ const int nextChange = starts->PositionFromPartition(run + 1);
if (nextChange > position) {
return nextChange;
} else if (position < end) {
@@ -273,7 +273,7 @@ void RunStyles::Check() const {
}
int start=0;
while (start < Length()) {
- int end = EndRun(start);
+ const int end = EndRun(start);
if (start >= end) {
throw std::runtime_error("RunStyles: Partition is 0 length.");
}
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index e06fc5495..659a37b90 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -79,7 +79,7 @@ void ScintillaBase::Finalise() {
}
void ScintillaBase::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
- bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
+ const bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
if (!isFillUp) {
Editor::AddCharUTF(s, len, treatAsDBCS);
}
@@ -365,7 +365,7 @@ void ScintillaBase::AutoCompleteCharacterDeleted() {
}
void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod) {
- int item = ac.GetSelection();
+ const int item = ac.GetSelection();
if (item == -1) {
AutoCompleteCancel();
return;
@@ -415,7 +415,7 @@ int ScintillaBase::AutoCompleteGetCurrent() const {
int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) const {
if (ac.Active()) {
- int item = ac.GetSelection();
+ const int item = ac.GetSelection();
if (item != -1) {
const std::string selected = ac.GetValue(item);
if (buffer != NULL)
@@ -453,7 +453,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
wMain);
// If the call-tip window would be out of the client
// space
- PRectangle rcClient = GetClientRectangle();
+ const PRectangle rcClient = GetClientRectangle();
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()) {
@@ -485,7 +485,7 @@ bool ScintillaBase::ShouldDisplayPopup(Point ptInWindowCoordinates) const {
void ScintillaBase::ContextMenu(Point pt) {
if (displayPopupMenu) {
- bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
+ const bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
popup.CreatePopUp();
AddToPopUp("Undo", idcmdUndo, writable && pdoc->CanUndo());
AddToPopUp("Redo", idcmdRedo, writable && pdoc->CanRedo());
diff --git a/src/Selection.cxx b/src/Selection.cxx
index aecd973a9..cc7065e3a 100644
--- a/src/Selection.cxx
+++ b/src/Selection.cxx
@@ -36,7 +36,7 @@ void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startC
virtualSpace = 0;
}
if (position > startChange) {
- Sci::Position endDeletion = startChange + length;
+ const Sci::Position endDeletion = startChange + length;
if (position > endDeletion) {
position -= length;
} else {
@@ -131,8 +131,8 @@ void SelectionRange::Swap() {
}
bool SelectionRange::Trim(SelectionRange range) {
- SelectionPosition startRange = range.Start();
- SelectionPosition endRange = range.End();
+ const SelectionPosition startRange = range.Start();
+ const SelectionPosition endRange = range.End();
SelectionPosition start = Start();
SelectionPosition end = End();
PLATFORM_ASSERT(start <= end);
diff --git a/src/SplitVector.h b/src/SplitVector.h
index df722530e..1601bfaa6 100644
--- a/src/SplitVector.h
+++ b/src/SplitVector.h
@@ -251,7 +251,7 @@ public:
// Split into up to 2 ranges, before and after the split then use memcpy on each.
int range1Length = 0;
if (position < part1Length) {
- int part1AfterPosition = part1Length - position;
+ const int part1AfterPosition = part1Length - position;
range1Length = retrieveLength;
if (range1Length > part1AfterPosition)
range1Length = part1AfterPosition;
diff --git a/src/UniConversion.cxx b/src/UniConversion.cxx
index 9c4acb422..9f0fa34e4 100644
--- a/src/UniConversion.cxx
+++ b/src/UniConversion.cxx
@@ -23,7 +23,7 @@ namespace Scintilla {
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
unsigned int len = 0;
for (unsigned int i = 0; i < tlen && uptr[i];) {
- unsigned int uch = uptr[i];
+ const unsigned int uch = uptr[i];
if (uch < 0x80) {
len++;
} else if (uch < 0x800) {
@@ -43,7 +43,7 @@ unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
unsigned int k = 0;
for (unsigned int i = 0; i < tlen && uptr[i];) {
- unsigned int uch = uptr[i];
+ const unsigned int uch = uptr[i];
if (uch < 0x80) {
putf[k++] = static_cast<char>(uch);
} else if (uch < 0x800) {
@@ -53,7 +53,7 @@ void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned
(uch <= SURROGATE_TRAIL_LAST)) {
// Half a surrogate pair
i++;
- unsigned int xch = 0x10000 + ((uch & 0x3ff) << 10) + (uptr[i] & 0x3ff);
+ const unsigned int xch = 0x10000 + ((uch & 0x3ff) << 10) + (uptr[i] & 0x3ff);
putf[k++] = static_cast<char>(0xF0 | (xch >> 18));
putf[k++] = static_cast<char>(0x80 | ((xch >> 12) & 0x3f));
putf[k++] = static_cast<char>(0x80 | ((xch >> 6) & 0x3f));
@@ -85,7 +85,7 @@ size_t UTF16Length(const char *s, size_t len) {
size_t ulen = 0;
size_t charLen;
for (size_t i = 0; i<len;) {
- unsigned char ch = static_cast<unsigned char>(s[i]);
+ const unsigned char ch = static_cast<unsigned char>(s[i]);
if (ch < 0x80) {
charLen = 1;
} else if (ch < 0x80 + 0x40 + 0x20) {
@@ -301,7 +301,7 @@ int UTF8Classify(const unsigned char *us, int len) {
}
int UTF8DrawBytes(const unsigned char *us, int len) {
- int utf8StatusNext = UTF8Classify(us, len);
+ const int utf8StatusNext = UTF8Classify(us, len);
return (utf8StatusNext & UTF8MaskInvalid) ? 1 : (utf8StatusNext & UTF8MaskWidth);
}
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index 64f9eee7b..701c51689 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -565,31 +565,31 @@ bool ViewStyle::SetWrapState(int wrapState_) {
wrapStateWanted = eWrapNone;
break;
}
- bool changed = wrapState != wrapStateWanted;
+ const bool changed = wrapState != wrapStateWanted;
wrapState = wrapStateWanted;
return changed;
}
bool ViewStyle::SetWrapVisualFlags(int wrapVisualFlags_) {
- bool changed = wrapVisualFlags != wrapVisualFlags_;
+ const bool changed = wrapVisualFlags != wrapVisualFlags_;
wrapVisualFlags = wrapVisualFlags_;
return changed;
}
bool ViewStyle::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) {
- bool changed = wrapVisualFlagsLocation != wrapVisualFlagsLocation_;
+ const bool changed = wrapVisualFlagsLocation != wrapVisualFlagsLocation_;
wrapVisualFlagsLocation = wrapVisualFlagsLocation_;
return changed;
}
bool ViewStyle::SetWrapVisualStartIndent(int wrapVisualStartIndent_) {
- bool changed = wrapVisualStartIndent != wrapVisualStartIndent_;
+ const bool changed = wrapVisualStartIndent != wrapVisualStartIndent_;
wrapVisualStartIndent = wrapVisualStartIndent_;
return changed;
}
bool ViewStyle::SetWrapIndentMode(int wrapIndentMode_) {
- bool changed = wrapIndentMode != wrapIndentMode_;
+ const bool changed = wrapIndentMode != wrapIndentMode_;
wrapIndentMode = wrapIndentMode_;
return changed;
}
diff --git a/src/XPM.cxx b/src/XPM.cxx
index 646981a80..0e5795cc5 100644
--- a/src/XPM.cxx
+++ b/src/XPM.cxx
@@ -117,24 +117,24 @@ void XPM::Init(const char *const *linesForm) {
for (int y=0; y<height; y++) {
const char *lform = linesForm[y+nColours+1];
- size_t len = MeasureLength(lform);
+ const size_t len = MeasureLength(lform);
for (size_t x = 0; x<len; x++)
pixels[y * width + x] = static_cast<unsigned char>(lform[x]);
}
}
-void XPM::Draw(Surface *surface, PRectangle &rc) {
+void XPM::Draw(Surface *surface, const PRectangle &rc) {
if (pixels.empty()) {
return;
}
// Centre the pixmap
- int startY = static_cast<int>(rc.top + (rc.Height() - height) / 2);
- int startX = static_cast<int>(rc.left + (rc.Width() - width) / 2);
+ const int startY = static_cast<int>(rc.top + (rc.Height() - height) / 2);
+ const int startX = static_cast<int>(rc.left + (rc.Width() - width) / 2);
for (int y=0; y<height; y++) {
int prevCode = 0;
int xStartRun = 0;
for (int x=0; x<width; x++) {
- int code = pixels[y * width + x];
+ const int code = pixels[y * width + x];
if (code != prevCode) {
FillRun(surface, prevCode, startX + xStartRun, startY + y, startX + x);
xStartRun = x;
diff --git a/src/XPM.h b/src/XPM.h
index f41b9d184..bb1b9b4f2 100644
--- a/src/XPM.h
+++ b/src/XPM.h
@@ -31,7 +31,7 @@ public:
void Init(const char *textForm);
void Init(const char *const *linesForm);
/// Decompose image into runs and use FillRectangle for each run
- void Draw(Surface *surface, PRectangle &rc);
+ void Draw(Surface *surface, const PRectangle &rc);
int GetHeight() const { return height; }
int GetWidth() const { return width; }
void PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const;