aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx430
1 files changed, 215 insertions, 215 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index f302533dc..93467274c 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -54,17 +54,17 @@
using namespace Scintilla;
#endif
-void LexInterface::Colourise(int start, int end) {
+void LexInterface::Colourise(Sci::Position start, Sci::Position end) {
if (pdoc && instance && !performingStyle) {
// Protect against reentrance, which may occur, for example, when
// fold points are discovered while performing styling and the folding
// code looks for child lines which may trigger styling.
performingStyle = true;
- int lengthDoc = pdoc->Length();
+ Sci::Position lengthDoc = pdoc->Length();
if (end == -1)
end = lengthDoc;
- int len = end - start;
+ Sci::Position len = end - start;
PLATFORM_ASSERT(len >= 0);
PLATFORM_ASSERT(start + len <= lengthDoc);
@@ -189,14 +189,14 @@ bool Document::SetLineEndTypesAllowed(int lineEndBitSet_) {
}
}
-void Document::InsertLine(int line) {
+void Document::InsertLine(Sci::Line line) {
for (int j=0; j<ldSize; j++) {
if (perLineData[j])
perLineData[j]->InsertLine(line);
}
}
-void Document::RemoveLine(int line) {
+void Document::RemoveLine(Sci::Line line) {
for (int j=0; j<ldSize; j++) {
if (perLineData[j])
perLineData[j]->RemoveLine(line);
@@ -234,7 +234,7 @@ void Document::TentativeUndo() {
int steps = cb.TentativeSteps();
//Platform::DebugPrintf("Steps=%d\n", steps);
for (int step = 0; step < steps; step++) {
- const int prevLinesTotal = LinesTotal();
+ const Sci::Line prevLinesTotal = LinesTotal();
const Action &action = cb.GetUndoStep();
if (action.at == removeAction) {
NotifyModified(DocModification(
@@ -261,7 +261,7 @@ void Document::TentativeUndo() {
}
if (steps > 1)
modFlags |= SC_MULTISTEPUNDOREDO;
- const int linesAdded = LinesTotal() - prevLinesTotal;
+ const Sci::Line linesAdded = LinesTotal() - prevLinesTotal;
if (linesAdded != 0)
multiLine = true;
if (step == steps - 1) {
@@ -283,15 +283,15 @@ void Document::TentativeUndo() {
}
}
-int Document::GetMark(int line) {
+int Document::GetMark(Sci::Line line) {
return static_cast<LineMarkers *>(perLineData[ldMarkers])->MarkValue(line);
}
-int Document::MarkerNext(int lineStart, int mask) const {
+Sci::Line Document::MarkerNext(Sci::Line lineStart, int mask) const {
return static_cast<LineMarkers *>(perLineData[ldMarkers])->MarkerNext(lineStart, mask);
}
-int Document::AddMark(int line, int markerNum) {
+int Document::AddMark(Sci::Line line, int markerNum) {
if (line >= 0 && line <= LinesTotal()) {
int prev = static_cast<LineMarkers *>(perLineData[ldMarkers])->
AddMark(line, markerNum, LinesTotal());
@@ -303,7 +303,7 @@ int Document::AddMark(int line, int markerNum) {
}
}
-void Document::AddMarkSet(int line, int valueSet) {
+void Document::AddMarkSet(Sci::Line line, int valueSet) {
if (line < 0 || line > LinesTotal()) {
return;
}
@@ -316,7 +316,7 @@ void Document::AddMarkSet(int line, int valueSet) {
NotifyModified(mh);
}
-void Document::DeleteMark(int line, int markerNum) {
+void Document::DeleteMark(Sci::Line line, int markerNum) {
static_cast<LineMarkers *>(perLineData[ldMarkers])->DeleteMark(line, markerNum, false);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
NotifyModified(mh);
@@ -331,7 +331,7 @@ void Document::DeleteMarkFromHandle(int markerHandle) {
void Document::DeleteAllMarks(int markerNum) {
bool someChanges = false;
- for (int line = 0; line < LinesTotal(); line++) {
+ for (Sci::Line line = 0; line < LinesTotal(); line++) {
if (static_cast<LineMarkers *>(perLineData[ldMarkers])->DeleteMark(line, markerNum, true))
someChanges = true;
}
@@ -342,7 +342,7 @@ void Document::DeleteAllMarks(int markerNum) {
}
}
-int Document::LineFromHandle(int markerHandle) {
+Sci::Line Document::LineFromHandle(int markerHandle) {
return static_cast<LineMarkers *>(perLineData[ldMarkers])->LineFromHandle(markerHandle);
}
@@ -350,7 +350,7 @@ Sci_Position SCI_METHOD Document::LineStart(Sci_Position line) const {
return cb.LineStart(line);
}
-bool Document::IsLineStartPosition(int position) const {
+bool Document::IsLineStartPosition(Sci::Position position) const {
return LineStart(LineFromPosition(position)) == position;
}
@@ -358,7 +358,7 @@ Sci_Position SCI_METHOD Document::LineEnd(Sci_Position line) const {
if (line >= LinesTotal() - 1) {
return LineStart(line + 1);
} else {
- int position = LineStart(line + 1);
+ Sci::Position position = LineStart(line + 1);
if (SC_CP_UTF8 == dbcsCodePage) {
unsigned char bytes[] = {
static_cast<unsigned char>(cb.CharAt(position-3)),
@@ -392,23 +392,23 @@ Sci_Position SCI_METHOD Document::LineFromPosition(Sci_Position pos) const {
return cb.LineFromPosition(pos);
}
-int Document::LineEndPosition(int position) const {
+Sci::Position Document::LineEndPosition(Sci::Position position) const {
return LineEnd(LineFromPosition(position));
}
-bool Document::IsLineEndPosition(int position) const {
+bool Document::IsLineEndPosition(Sci::Position position) const {
return LineEnd(LineFromPosition(position)) == position;
}
-bool Document::IsPositionInLineEnd(int position) const {
+bool Document::IsPositionInLineEnd(Sci::Position position) const {
return position >= LineEnd(LineFromPosition(position));
}
-int Document::VCHomePosition(int position) const {
- int line = LineFromPosition(position);
- int startPosition = LineStart(line);
- int endLine = LineEnd(line);
- int startText = startPosition;
+Sci::Position Document::VCHomePosition(Sci::Position position) const {
+ Sci::Line line = LineFromPosition(position);
+ Sci::Position startPosition = LineStart(line);
+ Sci::Position endLine = LineEnd(line);
+ Sci::Position startText = startPosition;
while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t'))
startText++;
if (position == startText)
@@ -444,12 +444,12 @@ static bool IsSubordinate(int levelStart, int levelTry) {
return LevelNumber(levelStart) < LevelNumber(levelTry);
}
-int Document::GetLastChild(int lineParent, int level, int lastLine) {
+Sci::Line Document::GetLastChild(Sci::Line lineParent, int level, Sci::Line lastLine) {
if (level == -1)
level = LevelNumber(GetLevel(lineParent));
- int maxLine = LinesTotal();
- int lookLastLine = (lastLine != -1) ? Platform::Minimum(LinesTotal() - 1, lastLine) : -1;
- int lineMaxSubord = lineParent;
+ Sci::Line maxLine = LinesTotal();
+ Sci::Line lookLastLine = (lastLine != -1) ? Platform::Minimum(LinesTotal() - 1, lastLine) : -1;
+ Sci::Line lineMaxSubord = lineParent;
while (lineMaxSubord < maxLine - 1) {
EnsureStyledTo(LineStart(lineMaxSubord + 2));
if (!IsSubordinate(level, GetLevel(lineMaxSubord + 1)))
@@ -469,9 +469,9 @@ int Document::GetLastChild(int lineParent, int level, int lastLine) {
return lineMaxSubord;
}
-int Document::GetFoldParent(int line) const {
+Sci::Line Document::GetFoldParent(Sci::Line line) const {
int level = LevelNumber(GetLevel(line));
- int lineLook = line - 1;
+ Sci::Line lineLook = line - 1;
while ((lineLook > 0) && (
(!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) ||
(LevelNumber(GetLevel(lineLook)) >= level))
@@ -486,11 +486,11 @@ int Document::GetFoldParent(int line) const {
}
}
-void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, int line, int lastLine) {
+void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine) {
int level = GetLevel(line);
- int lookLastLine = Platform::Maximum(line, lastLine) + 1;
+ Sci::Line lookLastLine = Platform::Maximum(line, lastLine) + 1;
- int lookLine = line;
+ Sci::Line lookLine = line;
int lookLineLevel = level;
int lookLineLevelNum = LevelNumber(lookLineLevel);
while ((lookLine > 0) && ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) ||
@@ -499,14 +499,14 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in
lookLineLevelNum = LevelNumber(lookLineLevel);
}
- int beginFoldBlock = (lookLineLevel & SC_FOLDLEVELHEADERFLAG) ? lookLine : GetFoldParent(lookLine);
+ Sci::Line beginFoldBlock = (lookLineLevel & SC_FOLDLEVELHEADERFLAG) ? lookLine : GetFoldParent(lookLine);
if (beginFoldBlock == -1) {
highlightDelimiter.Clear();
return;
}
- int endFoldBlock = GetLastChild(beginFoldBlock, -1, lookLastLine);
- int firstChangeableLineBefore = -1;
+ Sci::Line endFoldBlock = GetLastChild(beginFoldBlock, -1, lookLastLine);
+ Sci::Line firstChangeableLineBefore = -1;
if (endFoldBlock < line) {
lookLine = beginFoldBlock - 1;
lookLineLevel = GetLevel(lookLine);
@@ -538,7 +538,7 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in
if (firstChangeableLineBefore == -1)
firstChangeableLineBefore = beginFoldBlock - 1;
- int firstChangeableLineAfter = -1;
+ Sci::Line firstChangeableLineAfter = -1;
for (lookLine = line + 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = LevelNumber(lookLineLevel);
lookLine <= endFoldBlock;
lookLineLevel = GetLevel(++lookLine), lookLineLevelNum = LevelNumber(lookLineLevel)) {
@@ -556,11 +556,11 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in
highlightDelimiter.firstChangeableLineAfter = firstChangeableLineAfter;
}
-int Document::ClampPositionIntoDocument(int pos) const {
+Sci::Position Document::ClampPositionIntoDocument(Sci::Position pos) const {
return Platform::Clamp(pos, 0, Length());
}
-bool Document::IsCrLf(int pos) const {
+bool Document::IsCrLf(Sci::Position pos) const {
if (pos < 0)
return false;
if (pos >= (Length() - 1))
@@ -568,7 +568,7 @@ bool Document::IsCrLf(int pos) const {
return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n');
}
-int Document::LenChar(int pos) {
+int Document::LenChar(Sci::Position pos) {
if (pos < 0) {
return 1;
} else if (IsCrLf(pos)) {
@@ -576,7 +576,7 @@ int Document::LenChar(int pos) {
} else if (SC_CP_UTF8 == dbcsCodePage) {
const unsigned char leadByte = static_cast<unsigned char>(cb.CharAt(pos));
const int widthCharBytes = UTF8BytesOfLead[leadByte];
- int lengthDoc = Length();
+ Sci::Position lengthDoc = Length();
if ((pos + widthCharBytes) > lengthDoc)
return lengthDoc - pos;
else
@@ -588,8 +588,8 @@ int Document::LenChar(int pos) {
}
}
-bool Document::InGoodUTF8(int pos, int &start, int &end) const {
- int trail = pos;
+bool Document::InGoodUTF8(Sci::Position pos, Sci::Position &start, Sci::Position &end) const {
+ Sci::Position trail = pos;
while ((trail>0) && (pos-trail < UTF8MaxBytes) && UTF8IsTrailByte(static_cast<unsigned char>(cb.CharAt(trail-1))))
trail--;
start = (trail > 0) ? trail-1 : trail;
@@ -600,13 +600,13 @@ bool Document::InGoodUTF8(int pos, int &start, int &end) const {
return false;
} else {
int trailBytes = widthCharBytes - 1;
- int len = pos - start;
+ 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<int>(start+b));
+ charBytes[b] = cb.CharAt(static_cast<Sci::Position>(start+b));
int utf8status = UTF8Classify(reinterpret_cast<const unsigned char *>(charBytes), widthCharBytes);
if (utf8status & UTF8MaskInvalid)
return false;
@@ -620,7 +620,7 @@ bool Document::InGoodUTF8(int pos, int &start, int &end) const {
// When lines are terminated with \r\n pairs which should be treated as one character.
// When displaying DBCS text such as Japanese.
// If moving, move the position in the indicated direction.
-int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) const {
+Sci::Position Document::MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd) const {
//Platform::DebugPrintf("NoCRLF %d %d\n", pos, moveDir);
// If out of range, just return minimum/maximum value.
if (pos <= 0)
@@ -641,8 +641,8 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) c
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)) {
- int startUTF = pos;
- int endUTF = pos;
+ Sci::Position startUTF = pos;
+ Sci::Position endUTF = pos;
if (InGoodUTF8(pos, startUTF, endUTF)) {
// ch is a trail byte within a UTF-8 character
if (moveDir > 0)
@@ -655,12 +655,12 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) c
} else {
// Anchor DBCS calculations at start of line because start of line can
// not be a DBCS trail byte.
- int posStartLine = LineStart(LineFromPosition(pos));
+ Sci::Position posStartLine = LineStart(LineFromPosition(pos));
if (pos == posStartLine)
return pos;
// Step back until a non-lead-byte is found.
- int posCheck = pos;
+ Sci::Position posCheck = pos;
while ((posCheck > posStartLine) && IsDBCSLeadByte(cb.CharAt(posCheck-1)))
posCheck--;
@@ -687,7 +687,7 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) c
// NextPosition moves between valid positions - it can not handle a position in the middle of a
// multi-byte character. It is used to iterate through text more efficiently than MovePositionOutsideChar.
// A \r\n pair is treated as two characters.
-int Document::NextPosition(int pos, int moveDir) const {
+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;
if (pos + increment <= 0)
@@ -721,8 +721,8 @@ int Document::NextPosition(int pos, int moveDir) const {
// 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
- int startUTF = pos;
- int endUTF = pos;
+ Sci::Position startUTF = pos;
+ Sci::Position endUTF = pos;
if (InGoodUTF8(pos, startUTF, endUTF)) {
pos = startUTF;
}
@@ -738,7 +738,7 @@ int Document::NextPosition(int pos, int moveDir) const {
} else {
// Anchor DBCS calculations at start of line because start of line can
// not be a DBCS trail byte.
- int posStartLine = LineStart(LineFromPosition(pos));
+ 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) {
@@ -748,7 +748,7 @@ int Document::NextPosition(int pos, int moveDir) const {
return pos - 2;
} else {
// Otherwise, step back until a non-lead-byte is found.
- int posTemp = pos - 1;
+ Sci::Position posTemp = pos - 1;
while (posStartLine <= --posTemp && IsDBCSLeadByte(cb.CharAt(posTemp)))
;
// Now posTemp+1 must point to the beginning of a character,
@@ -765,9 +765,9 @@ int Document::NextPosition(int pos, int moveDir) const {
return pos;
}
-bool Document::NextCharacter(int &pos, int moveDir) const {
+bool Document::NextCharacter(Sci::Position &pos, int moveDir) const {
// Returns true if pos changed
- int posNext = NextPosition(pos, moveDir);
+ Sci::Position posNext = NextPosition(pos, moveDir);
if (posNext == pos) {
return false;
} else {
@@ -776,7 +776,7 @@ bool Document::NextCharacter(int &pos, int moveDir) const {
}
}
-Document::CharacterExtracted Document::CharacterAfter(int position) const {
+Document::CharacterExtracted Document::CharacterAfter(Sci::Position position) const {
if (position >= Length()) {
return CharacterExtracted(unicodeReplacementChar, 0);
}
@@ -806,7 +806,7 @@ Document::CharacterExtracted Document::CharacterAfter(int position) const {
}
}
-Document::CharacterExtracted Document::CharacterBefore(int position) const {
+Document::CharacterExtracted Document::CharacterBefore(Sci::Position position) const {
if (position <= 0) {
return CharacterExtracted(unicodeReplacementChar, 0);
}
@@ -822,8 +822,8 @@ Document::CharacterExtracted Document::CharacterBefore(int position) const {
// If previousByte is not a trail byte then its invalid
if (UTF8IsTrailByte(previousByte)) {
// If previousByte is a trail byte in a valid UTF-8 character then find start of character
- int startUTF = position;
- int endUTF = position;
+ Sci::Position startUTF = position;
+ Sci::Position endUTF = position;
if (InGoodUTF8(position, startUTF, endUTF)) {
const int widthCharBytes = endUTF - startUTF;
unsigned char charBytes[UTF8MaxBytes] = { 0, 0, 0, 0 };
@@ -842,18 +842,18 @@ Document::CharacterExtracted Document::CharacterBefore(int position) const {
return CharacterExtracted(unicodeReplacementChar, 1);
} else {
// Moving backwards in DBCS is complex so use NextPosition
- const int posStartCharacter = NextPosition(position, -1);
+ const Sci::Position posStartCharacter = NextPosition(position, -1);
return CharacterAfter(posStartCharacter);
}
}
// Return -1 on out-of-bounds
Sci_Position SCI_METHOD Document::GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const {
- int pos = positionStart;
+ Sci::Position pos = positionStart;
if (dbcsCodePage) {
const int increment = (characterOffset > 0) ? 1 : -1;
while (characterOffset != 0) {
- const int posNext = NextPosition(pos, increment);
+ const Sci::Position posNext = NextPosition(pos, increment);
if (posNext == pos)
return INVALID_POSITION;
pos = posNext;
@@ -867,12 +867,12 @@ Sci_Position SCI_METHOD Document::GetRelativePosition(Sci_Position positionStart
return pos;
}
-int Document::GetRelativePositionUTF16(int positionStart, int characterOffset) const {
- int pos = positionStart;
+Sci::Position Document::GetRelativePositionUTF16(Sci::Position positionStart, Sci::Position characterOffset) const {
+ Sci::Position pos = positionStart;
if (dbcsCodePage) {
const int increment = (characterOffset > 0) ? 1 : -1;
while (characterOffset != 0) {
- const int posNext = NextPosition(pos, increment);
+ const Sci::Position posNext = NextPosition(pos, increment);
if (posNext == pos)
return INVALID_POSITION;
if (abs(pos-posNext) > 3) // 4 byte character = 2*UTF16.
@@ -1018,7 +1018,7 @@ EncodingFamily Document::CodePageFamily() const {
return efEightBit;
}
-void Document::ModifiedAt(int pos) {
+void Document::ModifiedAt(Sci::Position pos) {
if (endStyled > pos)
endStyled = pos;
}
@@ -1034,7 +1034,7 @@ void Document::CheckReadOnly() {
// Document only modified by gateways DeleteChars, InsertString, Undo, Redo, and SetStyleAt.
// SetStyleAt does not change the persistent state of a document
-bool Document::DeleteChars(int pos, int len) {
+bool Document::DeleteChars(Sci::Position pos, Sci::Position len) {
if (pos < 0)
return false;
if (len <= 0)
@@ -1052,7 +1052,7 @@ bool Document::DeleteChars(int pos, int len) {
SC_MOD_BEFOREDELETE | SC_PERFORMED_USER,
pos, len,
0, 0));
- int prevLinesTotal = LinesTotal();
+ Sci::Line prevLinesTotal = LinesTotal();
bool startSavePoint = cb.IsSavePoint();
bool startSequence = false;
const char *text = cb.DeleteChars(pos, len, startSequence);
@@ -1076,7 +1076,7 @@ bool Document::DeleteChars(int pos, int len) {
/**
* Insert a string with a length.
*/
-int Document::InsertString(int position, const char *s, int insertLength) {
+Sci::Position Document::InsertString(Sci::Position position, const char *s, Sci::Position insertLength) {
if (insertLength <= 0) {
return 0;
}
@@ -1104,7 +1104,7 @@ int Document::InsertString(int position, const char *s, int insertLength) {
SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
position, insertLength,
0, s));
- int prevLinesTotal = LinesTotal();
+ Sci::Line prevLinesTotal = LinesTotal();
bool startSavePoint = cb.IsSavePoint();
bool startSequence = false;
const char *text = cb.InsertString(position, s, insertLength, startSequence);
@@ -1123,14 +1123,14 @@ int Document::InsertString(int position, const char *s, int insertLength) {
return insertLength;
}
-void Document::ChangeInsertion(const char *s, int length) {
+void Document::ChangeInsertion(const char *s, Sci::Position length) {
insertionSet = true;
insertion.assign(s, length);
}
int SCI_METHOD Document::AddData(char *data, Sci_Position length) {
try {
- int position = Length();
+ Sci::Position position = Length();
InsertString(position, data, length);
} catch (std::bad_alloc &) {
return SC_STATUS_BADALLOC;
@@ -1144,8 +1144,8 @@ void * SCI_METHOD Document::ConvertToDocument() {
return this;
}
-int Document::Undo() {
- int newPos = -1;
+Sci::Position Document::Undo() {
+ Sci::Position newPos = -1;
CheckReadOnly();
if ((enteredModification == 0) && (cb.IsCollectingUndo())) {
enteredModification++;
@@ -1154,12 +1154,12 @@ int Document::Undo() {
bool multiLine = false;
int steps = cb.StartUndo();
//Platform::DebugPrintf("Steps=%d\n", steps);
- int coalescedRemovePos = -1;
- int coalescedRemoveLen = 0;
- int prevRemoveActionPos = -1;
- int prevRemoveActionLen = 0;
+ Sci::Position coalescedRemovePos = -1;
+ Sci::Position coalescedRemoveLen = 0;
+ Sci::Position prevRemoveActionPos = -1;
+ Sci::Position prevRemoveActionLen = 0;
for (int step = 0; step < steps; step++) {
- const int prevLinesTotal = LinesTotal();
+ const Sci::Line prevLinesTotal = LinesTotal();
const Action &action = cb.GetUndoStep();
if (action.at == removeAction) {
NotifyModified(DocModification(
@@ -1208,7 +1208,7 @@ int Document::Undo() {
}
if (steps > 1)
modFlags |= SC_MULTISTEPUNDOREDO;
- const int linesAdded = LinesTotal() - prevLinesTotal;
+ const Sci::Line linesAdded = LinesTotal() - prevLinesTotal;
if (linesAdded != 0)
multiLine = true;
if (step == steps - 1) {
@@ -1229,8 +1229,8 @@ int Document::Undo() {
return newPos;
}
-int Document::Redo() {
- int newPos = -1;
+Sci::Position Document::Redo() {
+ Sci::Position newPos = -1;
CheckReadOnly();
if ((enteredModification == 0) && (cb.IsCollectingUndo())) {
enteredModification++;
@@ -1239,7 +1239,7 @@ int Document::Redo() {
bool multiLine = false;
int steps = cb.StartRedo();
for (int step = 0; step < steps; step++) {
- const int prevLinesTotal = LinesTotal();
+ const Sci::Line prevLinesTotal = LinesTotal();
const Action &action = cb.GetRedoStep();
if (action.at == insertAction) {
NotifyModified(DocModification(
@@ -1267,7 +1267,7 @@ int Document::Redo() {
}
if (steps > 1)
modFlags |= SC_MULTISTEPUNDOREDO;
- const int linesAdded = LinesTotal() - prevLinesTotal;
+ const Sci::Line linesAdded = LinesTotal() - prevLinesTotal;
if (linesAdded != 0)
multiLine = true;
if (step == steps - 1) {
@@ -1289,28 +1289,28 @@ int Document::Redo() {
return newPos;
}
-void Document::DelChar(int pos) {
+void Document::DelChar(Sci::Position pos) {
DeleteChars(pos, LenChar(pos));
}
-void Document::DelCharBack(int pos) {
+void Document::DelCharBack(Sci::Position pos) {
if (pos <= 0) {
return;
} else if (IsCrLf(pos - 2)) {
DeleteChars(pos - 2, 2);
} else if (dbcsCodePage) {
- int startChar = NextPosition(pos, -1);
+ Sci::Position startChar = NextPosition(pos, -1);
DeleteChars(startChar, pos - startChar);
} else {
DeleteChars(pos - 1, 1);
}
}
-static int NextTab(int pos, int tabSize) {
+static Sci::Position NextTab(Sci::Position pos, Sci::Position tabSize) {
return ((pos / tabSize) + 1) * tabSize;
}
-static std::string CreateIndentation(int indent, int tabSize, bool insertSpaces) {
+static std::string CreateIndentation(Sci::Position indent, int tabSize, bool insertSpaces) {
std::string indentation;
if (!insertSpaces) {
while (indent >= tabSize) {
@@ -1328,9 +1328,9 @@ static std::string CreateIndentation(int indent, int tabSize, bool insertSpaces)
int SCI_METHOD Document::GetLineIndentation(Sci_Position line) {
int indent = 0;
if ((line >= 0) && (line < LinesTotal())) {
- int lineStart = LineStart(line);
- int length = Length();
- for (int i = lineStart; i < length; i++) {
+ Sci::Position lineStart = LineStart(line);
+ Sci::Position length = Length();
+ for (Sci::Position i = lineStart; i < length; i++) {
char ch = cb.CharAt(i);
if (ch == ' ')
indent++;
@@ -1343,39 +1343,39 @@ int SCI_METHOD Document::GetLineIndentation(Sci_Position line) {
return indent;
}
-int Document::SetLineIndentation(int line, int indent) {
+Sci::Position Document::SetLineIndentation(Sci::Line line, Sci::Position indent) {
int indentOfLine = GetLineIndentation(line);
if (indent < 0)
indent = 0;
if (indent != indentOfLine) {
std::string linebuf = CreateIndentation(indent, tabInChars, !useTabs);
- int thisLineStart = LineStart(line);
- int indentPos = GetLineIndentPosition(line);
+ Sci::Position thisLineStart = LineStart(line);
+ Sci::Position indentPos = GetLineIndentPosition(line);
UndoGroup ug(this);
DeleteChars(thisLineStart, indentPos - thisLineStart);
return thisLineStart + InsertString(thisLineStart, linebuf.c_str(),
- static_cast<int>(linebuf.length()));
+ static_cast<Sci::Position>(linebuf.length()));
} else {
return GetLineIndentPosition(line);
}
}
-int Document::GetLineIndentPosition(int line) const {
+Sci::Position Document::GetLineIndentPosition(Sci::Line line) const {
if (line < 0)
return 0;
- int pos = LineStart(line);
- int length = Length();
+ Sci::Position pos = LineStart(line);
+ Sci::Position length = Length();
while ((pos < length) && IsSpaceOrTab(cb.CharAt(pos))) {
pos++;
}
return pos;
}
-int Document::GetColumn(int pos) {
- int column = 0;
- int line = LineFromPosition(pos);
+Sci::Position Document::GetColumn(Sci::Position pos) {
+ Sci::Position column = 0;
+ Sci::Line line = LineFromPosition(pos);
if ((line >= 0) && (line < LinesTotal())) {
- for (int i = LineStart(line); i < pos;) {
+ for (Sci::Position i = LineStart(line); i < pos;) {
char ch = cb.CharAt(i);
if (ch == '\t') {
column = NextTab(column, tabInChars);
@@ -1395,11 +1395,11 @@ int Document::GetColumn(int pos) {
return column;
}
-int Document::CountCharacters(int startPos, int endPos) const {
+Sci::Position Document::CountCharacters(Sci::Position startPos, Sci::Position endPos) const {
startPos = MovePositionOutsideChar(startPos, 1, false);
endPos = MovePositionOutsideChar(endPos, -1, false);
- int count = 0;
- int i = startPos;
+ Sci::Position count = 0;
+ Sci::Position i = startPos;
while (i < endPos) {
count++;
i = NextPosition(i, 1);
@@ -1407,14 +1407,14 @@ int Document::CountCharacters(int startPos, int endPos) const {
return count;
}
-int Document::CountUTF16(int startPos, int endPos) const {
+Sci::Position Document::CountUTF16(Sci::Position startPos, Sci::Position endPos) const {
startPos = MovePositionOutsideChar(startPos, 1, false);
endPos = MovePositionOutsideChar(endPos, -1, false);
- int count = 0;
- int i = startPos;
+ Sci::Position count = 0;
+ Sci::Position i = startPos;
while (i < endPos) {
count++;
- const int next = NextPosition(i, 1);
+ const Sci::Position next = NextPosition(i, 1);
if ((next - i) > 3)
count++;
i = next;
@@ -1422,10 +1422,10 @@ int Document::CountUTF16(int startPos, int endPos) const {
return count;
}
-int Document::FindColumn(int line, int column) {
- int position = LineStart(line);
+Sci::Position Document::FindColumn(Sci::Line line, Sci::Position column) {
+ Sci::Position position = LineStart(line);
if ((line >= 0) && (line < LinesTotal())) {
- int columnCurrent = 0;
+ Sci::Position columnCurrent = 0;
while ((columnCurrent < column) && (position < Length())) {
char ch = cb.CharAt(position);
if (ch == '\t') {
@@ -1446,10 +1446,10 @@ int Document::FindColumn(int line, int column) {
return position;
}
-void Document::Indent(bool forwards, int lineBottom, int lineTop) {
+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 (int line = lineBottom; line >= lineTop; line--) {
- int indentOfLine = GetLineIndentation(line);
+ for (Sci::Line line = lineBottom; line >= lineTop; line--) {
+ Sci::Position indentOfLine = GetLineIndentation(line);
if (forwards) {
if (LineStart(line) < LineEnd(line)) {
SetLineIndentation(line, indentOfLine + IndentSize());
@@ -1487,7 +1487,7 @@ std::string Document::TransformLineEnds(const char *s, size_t len, int eolModeWa
void Document::ConvertLineEnds(int eolModeSet) {
UndoGroup ug(this);
- for (int pos = 0; pos < Length(); pos++) {
+ for (Sci::Position pos = 0; pos < Length(); pos++) {
if (cb.CharAt(pos) == '\r') {
if (cb.CharAt(pos + 1) == '\n') {
// CRLF
@@ -1522,9 +1522,9 @@ void Document::ConvertLineEnds(int eolModeSet) {
}
-bool Document::IsWhiteLine(int line) const {
- int currentChar = LineStart(line);
- int endLine = LineEnd(line);
+bool Document::IsWhiteLine(Sci::Line line) const {
+ Sci::Position currentChar = LineStart(line);
+ Sci::Position endLine = LineEnd(line);
while (currentChar < endLine) {
if (cb.CharAt(currentChar) != ' ' && cb.CharAt(currentChar) != '\t') {
return false;
@@ -1534,8 +1534,8 @@ bool Document::IsWhiteLine(int line) const {
return true;
}
-int Document::ParaUp(int pos) const {
- int line = LineFromPosition(pos);
+Sci::Position Document::ParaUp(Sci::Position pos) const {
+ Sci::Line line = LineFromPosition(pos);
line--;
while (line >= 0 && IsWhiteLine(line)) { // skip empty lines
line--;
@@ -1547,8 +1547,8 @@ int Document::ParaUp(int pos) const {
return LineStart(line);
}
-int Document::ParaDown(int pos) const {
- int line = LineFromPosition(pos);
+Sci::Position Document::ParaDown(Sci::Position pos) const {
+ Sci::Line line = LineFromPosition(pos);
while (line < LinesTotal() && !IsWhiteLine(line)) { // skip non-empty lines
line++;
}
@@ -1635,7 +1635,7 @@ CharClassify::cc Document::WordCharacterClass(unsigned int ch) const {
* Used by commmands that want to select whole words.
* Finds the start of word at pos when delta < 0 or the end of the word when delta >= 0.
*/
-int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) const {
+Sci::Position Document::ExtendWordSelect(Sci::Position pos, int delta, bool onlyWordCharacters) const {
CharClassify::cc ccStart = CharClassify::ccWord;
if (delta < 0) {
if (!onlyWordCharacters) {
@@ -1670,7 +1670,7 @@ int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) cons
* additional movement to transit white space.
* Used by cursor movement by word commands.
*/
-int Document::NextWordStart(int pos, int delta) const {
+Sci::Position Document::NextWordStart(Sci::Position pos, int delta) const {
if (delta < 0) {
while (pos > 0) {
const CharacterExtracted ce = CharacterBefore(pos);
@@ -1714,7 +1714,7 @@ int Document::NextWordStart(int pos, int delta) const {
* additional movement to transit white space.
* Used by cursor movement by word commands.
*/
-int Document::NextWordEnd(int pos, int delta) const {
+Sci::Position Document::NextWordEnd(Sci::Position pos, int delta) const {
if (delta < 0) {
if (pos > 0) {
CharacterExtracted ce = CharacterBefore(pos);
@@ -1759,7 +1759,7 @@ int Document::NextWordEnd(int pos, int delta) const {
* Check that the character at the given position is a word or punctuation character and that
* the previous character is of a different character class.
*/
-bool Document::IsWordStartAt(int pos) const {
+bool Document::IsWordStartAt(Sci::Position pos) const {
if (pos >= Length())
return false;
if (pos > 0) {
@@ -1777,7 +1777,7 @@ bool Document::IsWordStartAt(int pos) const {
* Check that the character at the given position is a word or punctuation character and that
* the next character is of a different character class.
*/
-bool Document::IsWordEndAt(int pos) const {
+bool Document::IsWordEndAt(Sci::Position pos) const {
if (pos <= 0)
return false;
if (pos < Length()) {
@@ -1795,11 +1795,11 @@ bool Document::IsWordEndAt(int pos) const {
* Check that the given range is has transitions between character classes at both
* ends and where the characters on the inside are word or punctuation characters.
*/
-bool Document::IsWordAt(int start, int end) const {
+bool Document::IsWordAt(Sci::Position start, Sci::Position end) const {
return (start < end) && IsWordStartAt(start) && IsWordEndAt(end);
}
-bool Document::MatchesWordOptions(bool word, bool wordStart, int pos, int length) const {
+bool Document::MatchesWordOptions(bool word, bool wordStart, Sci::Position pos, Sci::Position length) const {
return (!word && !wordStart) ||
(word && IsWordAt(pos, pos + length)) ||
(wordStart && IsWordStartAt(pos));
@@ -1814,7 +1814,7 @@ void Document::SetCaseFolder(CaseFolder *pcf_) {
pcf = pcf_;
}
-Document::CharacterExtracted Document::ExtractCharacter(int position) const {
+Document::CharacterExtracted Document::ExtractCharacter(Sci::Position position) const {
const unsigned char leadByte = static_cast<unsigned char>(cb.CharAt(position));
if (UTF8IsAscii(leadByte)) {
// Common case: ASCII character
@@ -1838,8 +1838,8 @@ Document::CharacterExtracted Document::ExtractCharacter(int position) const {
* searches (just pass minPos > maxPos to do a backward search)
* Has not been tested with backwards DBCS searches yet.
*/
-long Document::FindText(int minPos, int maxPos, const char *search,
- int flags, int *length) {
+long Document::FindText(Sci::Position minPos, Sci::Position maxPos, const char *search,
+ int flags, Sci::Position *length) {
if (*length <= 0)
return minPos;
const bool caseSensitive = (flags & SCFIND_MATCHCASE) != 0;
@@ -1856,21 +1856,21 @@ long Document::FindText(int minPos, int maxPos, const char *search,
const int increment = forward ? 1 : -1;
// Range endpoints should not be inside DBCS characters, but just in case, move them.
- const int startPos = MovePositionOutsideChar(minPos, increment, false);
- const int endPos = MovePositionOutsideChar(maxPos, increment, false);
+ const Sci::Position startPos = MovePositionOutsideChar(minPos, increment, false);
+ const Sci::Position endPos = MovePositionOutsideChar(maxPos, increment, false);
// Compute actual search ranges needed
- const int lengthFind = *length;
+ const Sci::Position lengthFind = *length;
//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind);
- const int limitPos = Platform::Maximum(startPos, endPos);
- int pos = startPos;
+ const Sci::Position limitPos = Platform::Maximum(startPos, endPos);
+ Sci::Position pos = startPos;
if (!forward) {
// Back all of a character
pos = NextPosition(pos, increment);
}
if (caseSensitive) {
- const int endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos;
+ const Sci::Position endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos;
const char charStartSearch = search[0];
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
if (CharAt(pos) == charStartSearch) {
@@ -1894,7 +1894,7 @@ long Document::FindText(int minPos, int maxPos, const char *search,
char folded[UTF8MaxBytes * maxFoldingExpansion + 1];
while (forward ? (pos < endPos) : (pos >= endPos)) {
int widthFirstCharacter = 0;
- int posIndexDocument = pos;
+ Sci::Position posIndexDocument = pos;
int indexSearch = 0;
bool characterMatches = true;
for (;;) {
@@ -1978,7 +1978,7 @@ long Document::FindText(int minPos, int maxPos, const char *search,
break;
}
} else {
- const int endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos;
+ const Sci::Position endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos;
std::vector<char> searchThing(lengthFind + 1);
pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind);
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
@@ -2001,14 +2001,14 @@ long Document::FindText(int minPos, int maxPos, const char *search,
return -1;
}
-const char *Document::SubstituteByPosition(const char *text, int *length) {
+const char *Document::SubstituteByPosition(const char *text, Sci::Position *length) {
if (regex)
return regex->SubstituteByPosition(this, text, length);
else
return 0;
}
-int Document::LinesTotal() const {
+Sci::Line Document::LinesTotal() const {
return cb.Lines();
}
@@ -2033,7 +2033,7 @@ bool SCI_METHOD Document::SetStyleFor(Sci_Position length, char style) {
return false;
} else {
enteredStyling++;
- int prevEndStyled = endStyled;
+ Sci::Position prevEndStyled = endStyled;
if (cb.SetStyleFor(endStyled, length, style)) {
DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
prevEndStyled, length);
@@ -2051,8 +2051,8 @@ bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) {
} else {
enteredStyling++;
bool didChange = false;
- int startMod = 0;
- int endMod = 0;
+ Sci::Position startMod = 0;
+ Sci::Position endMod = 0;
for (int iPos = 0; iPos < length; iPos++, endStyled++) {
PLATFORM_ASSERT(endStyled < Length());
if (cb.SetStyleAt(endStyled, styles[iPos])) {
@@ -2073,12 +2073,12 @@ bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) {
}
}
-void Document::EnsureStyledTo(int pos) {
+void Document::EnsureStyledTo(Sci::Position pos) {
if ((enteredStyling == 0) && (pos > GetEndStyled())) {
IncrementStyleClock();
if (pli && !pli->UseContainerLexing()) {
- int lineEndStyled = LineFromPosition(GetEndStyled());
- int endStyledTo = LineStart(lineEndStyled);
+ Sci::Line lineEndStyled = LineFromPosition(GetEndStyled());
+ Sci::Position endStyledTo = LineStart(lineEndStyled);
pli->Colourise(endStyledTo, pos);
} else {
// Ask the watchers to style, and stop as soon as one responds.
@@ -2090,7 +2090,7 @@ void Document::EnsureStyledTo(int pos) {
}
}
-void Document::StyleToAdjustingLineDuration(int pos) {
+void Document::StyleToAdjustingLineDuration(Sci::Position pos) {
// Place bounds on the duration used to avoid glitches spiking it
// and so causing slow styling or non-responsive scrolling
const double minDurationOneLine = 0.000001;
@@ -2100,11 +2100,11 @@ void Document::StyleToAdjustingLineDuration(int pos) {
// Most recent value contributes 25% to smoothed value.
const double alpha = 0.25;
- const Sci_Position lineFirst = LineFromPosition(GetEndStyled());
+ const Sci::Line lineFirst = LineFromPosition(GetEndStyled());
ElapsedTime etStyling;
EnsureStyledTo(pos);
const double durationStyling = etStyling.Duration();
- const Sci_Position lineLast = LineFromPosition(GetEndStyled());
+ const Sci::Line lineLast = LineFromPosition(GetEndStyled());
if (lineLast >= lineFirst + 8) {
// Only adjust for styling multiple lines to avoid instability
const double durationOneLine = durationStyling / (lineLast - lineFirst);
@@ -2137,7 +2137,7 @@ int SCI_METHOD Document::GetLineState(Sci_Position line) const {
return static_cast<LineState *>(perLineData[ldState])->GetLineState(line);
}
-int Document::GetMaxLineState() {
+Sci::Line Document::GetMaxLineState() {
return static_cast<LineState *>(perLineData[ldState])->GetMaxLineState();
}
@@ -2146,45 +2146,45 @@ void SCI_METHOD Document::ChangeLexerState(Sci_Position start, Sci_Position end)
NotifyModified(mh);
}
-StyledText Document::MarginStyledText(int line) const {
+StyledText Document::MarginStyledText(Sci::Line line) 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));
}
-void Document::MarginSetText(int line, const char *text) {
+void Document::MarginSetText(Sci::Line line, const char *text) {
static_cast<LineAnnotation *>(perLineData[ldMargin])->SetText(line, text);
DocModification mh(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line);
NotifyModified(mh);
}
-void Document::MarginSetStyle(int line, int style) {
+void Document::MarginSetStyle(Sci::Line line, int style) {
static_cast<LineAnnotation *>(perLineData[ldMargin])->SetStyle(line, style);
NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line));
}
-void Document::MarginSetStyles(int line, const unsigned char *styles) {
+void Document::MarginSetStyles(Sci::Line line, const unsigned char *styles) {
static_cast<LineAnnotation *>(perLineData[ldMargin])->SetStyles(line, styles);
NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line));
}
void Document::MarginClearAll() {
- int maxEditorLine = LinesTotal();
- for (int l=0; l<maxEditorLine; l++)
+ Sci::Line maxEditorLine = LinesTotal();
+ for (Sci::Line l=0; l<maxEditorLine; l++)
MarginSetText(l, 0);
// Free remaining data
static_cast<LineAnnotation *>(perLineData[ldMargin])->ClearAll();
}
-StyledText Document::AnnotationStyledText(int line) const {
+StyledText Document::AnnotationStyledText(Sci::Line line) 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));
}
-void Document::AnnotationSetText(int line, const char *text) {
+void Document::AnnotationSetText(Sci::Line line, const char *text) {
if (line >= 0 && line < LinesTotal()) {
- const int linesBefore = AnnotationLines(line);
+ const Sci::Line linesBefore = AnnotationLines(line);
static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetText(line, text);
const int linesAfter = AnnotationLines(line);
DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), 0, 0, 0, line);
@@ -2193,25 +2193,25 @@ void Document::AnnotationSetText(int line, const char *text) {
}
}
-void Document::AnnotationSetStyle(int line, int style) {
+void Document::AnnotationSetStyle(Sci::Line line, int style) {
static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetStyle(line, style);
DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), 0, 0, 0, line);
NotifyModified(mh);
}
-void Document::AnnotationSetStyles(int line, const unsigned char *styles) {
+void Document::AnnotationSetStyles(Sci::Line line, const unsigned char *styles) {
if (line >= 0 && line < LinesTotal()) {
static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetStyles(line, styles);
}
}
-int Document::AnnotationLines(int line) const {
+int Document::AnnotationLines(Sci::Line line) const {
return static_cast<LineAnnotation *>(perLineData[ldAnnotation])->Lines(line);
}
void Document::AnnotationClearAll() {
- int maxEditorLine = LinesTotal();
- for (int l=0; l<maxEditorLine; l++)
+ Sci::Line maxEditorLine = LinesTotal();
+ for (Sci::Line l=0; l<maxEditorLine; l++)
AnnotationSetText(l, 0);
// Free remaining data
static_cast<LineAnnotation *>(perLineData[ldAnnotation])->ClearAll();
@@ -2317,7 +2317,7 @@ bool Document::IsWordPartSeparator(unsigned int ch) const {
return (WordCharacterClass(ch) == CharClassify::ccWord) && IsASCIIPunctuationCharacter(ch);
}
-int Document::WordPartLeft(int pos) const {
+Sci::Position Document::WordPartLeft(Sci::Position pos) const {
if (pos > 0) {
pos -= CharacterBefore(pos).widthBytes;
CharacterExtracted ceStart = CharacterAfter(pos);
@@ -2367,9 +2367,9 @@ int Document::WordPartLeft(int pos) const {
return pos;
}
-int Document::WordPartRight(int pos) const {
+Sci::Position Document::WordPartRight(Sci::Position pos) const {
CharacterExtracted ceStart = CharacterAfter(pos);
- const int length = Length();
+ const Sci::Position length = Length();
if (IsWordPartSeparator(ceStart.character)) {
while (pos < length && IsWordPartSeparator(CharacterAfter(pos).character))
pos += CharacterAfter(pos).widthBytes;
@@ -2411,7 +2411,7 @@ static bool IsLineEndChar(char c) {
return (c == '\n' || c == '\r');
}
-int Document::ExtendStyleRange(int pos, int delta, bool singleLine) {
+Sci::Position Document::ExtendStyleRange(Sci::Position pos, int delta, bool singleLine) {
int sStart = cb.StyleAt(pos);
if (delta < 0) {
while (pos > 0 && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))))
@@ -2448,7 +2448,7 @@ static char BraceOpposite(char ch) {
}
// TODO: should be able to extend styled region to find matching brace
-int Document::BraceMatch(int position, int /*maxReStyle*/) {
+Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxReStyle*/) {
char chBrace = CharAt(position);
char chSeek = BraceOpposite(chBrace);
if (chSeek == '\0')
@@ -2470,7 +2470,7 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) {
if (depth == 0)
return position;
}
- int positionBeforeMove = position;
+ Sci::Position positionBeforeMove = position;
position = NextPosition(position, direction);
if (position == positionBeforeMove)
break;
@@ -2488,11 +2488,11 @@ public:
~BuiltinRegex() override {
}
- long FindText(Document *doc, int minPos, int maxPos, const char *s,
+ long FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
bool caseSensitive, bool word, bool wordStart, int flags,
- int *length) override;
+ Sci::Position *length) override;
- const char *SubstituteByPosition(Document *doc, const char *text, int *length) override;
+ const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) override;
private:
RESearch search;
@@ -2508,12 +2508,12 @@ class RESearchRange {
public:
const Document *doc;
int increment;
- int startPos;
- int endPos;
- int lineRangeStart;
- int lineRangeEnd;
- int lineRangeBreak;
- RESearchRange(const Document *doc_, int minPos, int maxPos) : doc(doc_) {
+ Sci::Position startPos;
+ Sci::Position endPos;
+ Sci::Line lineRangeStart;
+ Sci::Line lineRangeEnd;
+ Sci::Line lineRangeBreak;
+ RESearchRange(const Document *doc_, Sci::Position minPos, Sci::Position maxPos) : doc(doc_) {
increment = (minPos <= maxPos) ? 1 : -1;
// Range endpoints should not be inside DBCS characters, but just in case, move them.
@@ -2537,7 +2537,7 @@ public:
}
lineRangeBreak = lineRangeEnd + increment;
}
- Range LineRange(int line) const {
+ Range LineRange(Sci::Line line) const {
Range range(doc->LineStart(line), doc->LineEnd(line));
if (increment == 1) {
if (line == lineRangeStart)
@@ -2557,16 +2557,16 @@ public:
// Define a way for the Regular Expression code to access the document
class DocumentIndexer : public CharacterIndexer {
Document *pdoc;
- int end;
+ Sci::Position end;
public:
- DocumentIndexer(Document *pdoc_, int end_) :
+ DocumentIndexer(Document *pdoc_, Sci::Position end_) :
pdoc(pdoc_), end(end_) {
}
~DocumentIndexer() override {
}
- char CharAt(int index) override {
+ char CharAt(Sci::Position index) override {
if (index < 0 || index >= end)
return 0;
else
@@ -2579,8 +2579,8 @@ public:
class ByteIterator : public std::iterator<std::bidirectional_iterator_tag, char> {
public:
const Document *doc;
- Position position;
- ByteIterator(const Document *doc_ = 0, Position position_ = 0) : doc(doc_), position(position_) {
+ Sci::Position position;
+ ByteIterator(const Document *doc_ = 0, Sci::Position position_ = 0) : doc(doc_), position(position_) {
}
ByteIterator(const ByteIterator &other) NOEXCEPT {
doc = other.doc;
@@ -2615,10 +2615,10 @@ public:
bool operator!=(const ByteIterator &other) const {
return doc != other.doc || position != other.position;
}
- int Pos() const {
+ Sci::Position Pos() const {
return position;
}
- int PosRoundUp() const {
+ Sci::Position PosRoundUp() const {
return position;
}
};
@@ -2642,14 +2642,14 @@ public:
class UTF8Iterator : public std::iterator<std::bidirectional_iterator_tag, wchar_t> {
// These 3 fields determine the iterator position and are used for comparisons
const Document *doc;
- Position position;
+ Sci::Position position;
size_t characterIndex;
// Remaining fields are derived from the determining fields so are excluded in comparisons
unsigned int lenBytes;
size_t lenCharacters;
wchar_t buffered[2];
public:
- UTF8Iterator(const Document *doc_ = 0, Position position_ = 0) :
+ UTF8Iterator(const Document *doc_ = 0, Sci::Position position_ = 0) :
doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0) {
buffered[0] = 0;
buffered[1] = 0;
@@ -2725,10 +2725,10 @@ public:
position != other.position ||
characterIndex != other.characterIndex;
}
- int Pos() const {
+ Sci::Position Pos() const {
return position;
}
- int PosRoundUp() const {
+ Sci::Position PosRoundUp() const {
if (characterIndex)
return position + lenBytes; // Force to end of character
else
@@ -2753,9 +2753,9 @@ private:
class UTF8Iterator : public std::iterator<std::bidirectional_iterator_tag, wchar_t> {
const Document *doc;
- Position position;
+ Sci::Position position;
public:
- UTF8Iterator(const Document *doc_=0, Position position_=0) : doc(doc_), position(position_) {
+ UTF8Iterator(const Document *doc_=0, Sci::Position position_=0) : doc(doc_), position(position_) {
}
UTF8Iterator(const UTF8Iterator &other) NOEXCEPT {
doc = other.doc;
@@ -2791,17 +2791,17 @@ public:
bool operator!=(const UTF8Iterator &other) const {
return doc != other.doc || position != other.position;
}
- int Pos() const {
+ Sci::Position Pos() const {
return position;
}
- int PosRoundUp() const {
+ Sci::Position PosRoundUp() const {
return position;
}
};
#endif
-std::regex_constants::match_flag_type MatchFlags(const Document *doc, int startPos, int endPos) {
+std::regex_constants::match_flag_type MatchFlags(const Document *doc, Sci::Position startPos, Sci::Position endPos) {
std::regex_constants::match_flag_type flagsMatch = std::regex_constants::match_default;
if (!doc->IsLineStartPosition(startPos))
flagsMatch |= std::regex_constants::match_not_bol;
@@ -2824,7 +2824,7 @@ bool MatchOnLines(const Document *doc, const Regex &regexp, const RESearchRange
// matched = std::regex_search(uiStart, uiEnd, match, regexp, flagsMatch);
// Line by line.
- for (int line = resr.lineRangeStart; line != resr.lineRangeBreak; line += resr.increment) {
+ for (Sci::Line line = resr.lineRangeStart; line != resr.lineRangeBreak; line += resr.increment) {
const Range lineRange = resr.LineRange(line);
Iterator itStart(doc, lineRange.start);
Iterator itEnd(doc, lineRange.end);
@@ -2865,8 +2865,8 @@ bool MatchOnLines(const Document *doc, const Regex &regexp, const RESearchRange
return matched;
}
-long Cxx11RegexFindText(Document *doc, int minPos, int maxPos, const char *s,
- bool caseSensitive, int *length, RESearch &search) {
+Sci::Position Cxx11RegexFindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
+ bool caseSensitive, Sci::Position *length, RESearch &search) {
const RESearchRange resr(doc, minPos, maxPos);
try {
//ElapsedTime et;
@@ -2906,7 +2906,7 @@ long Cxx11RegexFindText(Document *doc, int minPos, int maxPos, const char *s,
matched = MatchOnLines<ByteIterator>(doc, regexp, resr, search);
}
- int posMatch = -1;
+ Sci::Position posMatch = -1;
if (matched) {
posMatch = search.bopat[0];
*length = search.eopat[0] - search.bopat[0];
@@ -2930,9 +2930,9 @@ long Cxx11RegexFindText(Document *doc, int minPos, int maxPos, const char *s,
}
-long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s,
+long BuiltinRegex::FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
bool caseSensitive, bool, bool, int flags,
- int *length) {
+ Sci::Position *length) {
#ifndef NO_CXX11_REGEX
if (flags & SCFIND_CXX11REGEX) {
@@ -2953,13 +2953,13 @@ long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s
// Replace first '.' with '-' in each property file variable reference:
// Search: \$(\([A-Za-z0-9_-]+\)\.\([A-Za-z0-9_.]+\))
// Replace: $(\1-\2)
- int pos = -1;
- int lenRet = 0;
+ Sci::Position pos = -1;
+ Sci::Position lenRet = 0;
const char searchEnd = s[*length - 1];
const char searchEndPrev = (*length > 1) ? s[*length - 2] : '\0';
- for (int line = resr.lineRangeStart; line != resr.lineRangeBreak; line += resr.increment) {
- int startOfLine = doc->LineStart(line);
- int endOfLine = doc->LineEnd(line);
+ for (Sci::Line line = resr.lineRangeStart; line != resr.lineRangeBreak; line += resr.increment) {
+ Sci::Position startOfLine = doc->LineStart(line);
+ Sci::Position endOfLine = doc->LineEnd(line);
if (resr.increment == 1) {
if (line == resr.lineRangeStart) {
if ((resr.startPos != startOfLine) && (s[0] == '^'))
@@ -3014,7 +3014,7 @@ long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s
return pos;
}
-const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, int *length) {
+const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) {
substituted.clear();
DocumentIndexer di(doc, doc->Length());
search.GrabMatches(di);
@@ -3022,7 +3022,7 @@ const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text,
if (text[j] == '\\') {
if (text[j + 1] >= '0' && text[j + 1] <= '9') {
unsigned int patNum = text[j + 1] - '0';
- unsigned int len = search.eopat[patNum] - search.bopat[patNum];
+ 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++;