aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/ScintillaCocoa.h6
-rw-r--r--cocoa/ScintillaCocoa.mm24
-rw-r--r--gtk/ScintillaGTK.cxx16
-rw-r--r--gtk/ScintillaGTK.h6
-rw-r--r--gtk/ScintillaGTKAccessible.cxx58
-rw-r--r--gtk/ScintillaGTKAccessible.h36
-rw-r--r--qt/ScintillaEdit/ScintillaDocument.cpp4
-rw-r--r--qt/ScintillaEditBase/ScintillaQt.cpp8
-rw-r--r--qt/ScintillaEditBase/ScintillaQt.h2
-rw-r--r--src/AutoComplete.cxx2
-rw-r--r--src/AutoComplete.h4
-rw-r--r--src/CallTip.cxx2
-rw-r--r--src/CallTip.h4
-rw-r--r--src/CellBuffer.cxx74
-rw-r--r--src/CellBuffer.h70
-rw-r--r--src/ContractionState.cxx64
-rw-r--r--src/ContractionState.h40
-rw-r--r--src/Document.cxx430
-rw-r--r--src/Document.h231
-rw-r--r--src/EditModel.cxx10
-rw-r--r--src/EditModel.h8
-rw-r--r--src/EditView.cxx216
-rw-r--r--src/EditView.h48
-rw-r--r--src/Editor.cxx657
-rw-r--r--src/Editor.h184
-rw-r--r--src/MarginView.cxx18
-rw-r--r--src/MarginView.h2
-rw-r--r--src/PerLine.cxx88
-rw-r--r--src/PerLine.h72
-rw-r--r--src/Position.h1
-rw-r--r--src/PositionCache.cxx16
-rw-r--r--src/PositionCache.h16
-rw-r--r--src/RESearch.cxx24
-rw-r--r--src/RESearch.h16
-rw-r--r--src/ScintillaBase.cxx24
-rw-r--r--src/ScintillaBase.h4
-rw-r--r--src/Selection.cxx34
-rw-r--r--src/Selection.h46
-rw-r--r--win32/ScintillaWin.cxx84
39 files changed, 1322 insertions, 1327 deletions
diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h
index 128ddb9f6..2e2bde524 100644
--- a/cocoa/ScintillaCocoa.h
+++ b/cocoa/ScintillaCocoa.h
@@ -158,10 +158,10 @@ public:
void SetMouseCapture(bool on) override;
bool HaveMouseCapture() override;
void WillDraw(NSRect rect);
- void ScrollText(int linesToMove) override;
+ void ScrollText(Sci::Line linesToMove) override;
void SetVerticalScrollPos() override;
void SetHorizontalScrollPos() override;
- bool ModifyScrollBars(int nMax, int nPage) override;
+ bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) override;
bool SetScrollingSize(void);
void Resize();
void UpdateForScroll();
@@ -197,7 +197,7 @@ public:
void ObserverAdd();
void ObserverRemove();
void IdleWork() override;
- void QueueIdleWork(WorkNeeded::workItems items, int upTo) override;
+ void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) override;
int InsertText(NSString* input);
NSRange PositionsFromCharacters(NSRange rangeCharacters) const;
NSRange CharactersFromPositions(NSRange rangePositions) const;
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index cc5ee0fc7..c8cf404ad 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -522,7 +522,7 @@ void ScintillaCocoa::IdleWork() {
//--------------------------------------------------------------------------------------------------
-void ScintillaCocoa::QueueIdleWork(WorkNeeded::workItems items, int upTo) {
+void ScintillaCocoa::QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) {
Editor::QueueIdleWork(items, upTo);
ObserverAdd();
}
@@ -1236,7 +1236,7 @@ void ScintillaCocoa::ClaimSelection()
*/
NSPoint ScintillaCocoa::GetCaretPosition()
{
- const int line = pdoc->LineFromPosition(sel.RangeMain().caret.Position());
+ const Sci::Line line = pdoc->LineFromPosition(sel.RangeMain().caret.Position());
NSPoint result;
result.y = line;
@@ -1261,9 +1261,9 @@ void ScintillaCocoa::DragScroll()
}
// TODO: does not work for wrapped lines, fix it.
- int line = pdoc->LineFromPosition(posDrag.Position());
- int currentVisibleLine = cs.DisplayFromDoc(line);
- int lastVisibleLine = Platform::Minimum(topLine + LinesOnScreen(), cs.LinesDisplayed()) - 2;
+ Sci::Line line = pdoc->LineFromPosition(posDrag.Position());
+ Sci::Line currentVisibleLine = cs.DisplayFromDoc(line);
+ Sci::Line lastVisibleLine = Platform::Minimum(topLine + LinesOnScreen(), cs.LinesDisplayed()) - 2;
if (currentVisibleLine <= topLine && topLine > 0)
ScrollTo(topLine - scrollSpeed);
@@ -1368,10 +1368,10 @@ void ScintillaCocoa::StartDrag()
// calculate the bounds of the selection
PRectangle client = GetTextRectangle();
- int selStart = sel.RangeMain().Start().Position();
- int selEnd = sel.RangeMain().End().Position();
- int startLine = pdoc->LineFromPosition(selStart);
- int endLine = pdoc->LineFromPosition(selEnd);
+ Sci::Position selStart = sel.RangeMain().Start().Position();
+ Sci::Position selEnd = sel.RangeMain().End().Position();
+ Sci::Line startLine = pdoc->LineFromPosition(selStart);
+ Sci::Line endLine = pdoc->LineFromPosition(selEnd);
Point pt;
long startPos, endPos, ep;
PRectangle rcSel;
@@ -1561,7 +1561,7 @@ NSDragOperation ScintillaCocoa::DraggingUpdated(id <NSDraggingInfo> info)
void ScintillaCocoa::DraggingExited(id <NSDraggingInfo> info)
{
#pragma unused(info)
- SetDragPosition(SelectionPosition(invalidPosition));
+ SetDragPosition(SelectionPosition(Sci::invalidPosition));
FineTickerCancel(tickPlatform);
inDragDrop = ddNone;
}
@@ -1914,7 +1914,7 @@ void ScintillaCocoa::WillDraw(NSRect rect)
/**
* ScrollText is empty because scrolling is handled by the NSScrollView.
*/
-void ScintillaCocoa::ScrollText(int)
+void ScintillaCocoa::ScrollText(Sci::Line)
{
}
@@ -1968,7 +1968,7 @@ void ScintillaCocoa::SetHorizontalScrollPos()
* @param nPage Number of lines per scroll page.
* @return True if there was a change, otherwise false.
*/
-bool ScintillaCocoa::ModifyScrollBars(int nMax, int nPage)
+bool ScintillaCocoa::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage)
{
#pragma unused(nMax, nPage)
return SetScrollingSize();
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 46a4b488f..a5c09c8e2 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -1029,7 +1029,7 @@ PRectangle ScintillaGTK::GetClientRectangle() const {
return rc;
}
-void ScintillaGTK::ScrollText(int linesToMove) {
+void ScintillaGTK::ScrollText(Sci::Line linesToMove) {
int diff = vs.lineHeight * -linesToMove;
//Platform::DebugPrintf("ScintillaGTK::ScrollText %d %d %0d,%0d %0d,%0d\n", linesToMove, diff,
// rc.left, rc.top, rc.right, rc.bottom);
@@ -1052,7 +1052,7 @@ void ScintillaGTK::SetHorizontalScrollPos() {
gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustmenth), xOffset);
}
-bool ScintillaGTK::ModifyScrollBars(int nMax, int nPage) {
+bool ScintillaGTK::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) {
bool modified = false;
int pageScroll = LinesToScroll();
@@ -2763,7 +2763,7 @@ gboolean ScintillaGTK::DragMotion(GtkWidget *widget, GdkDragContext *context,
void ScintillaGTK::DragLeave(GtkWidget *widget, GdkDragContext * /*context*/, guint) {
ScintillaGTK *sciThis = FromWidget(widget);
try {
- sciThis->SetDragPosition(SelectionPosition(invalidPosition));
+ sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
//Platform::DebugPrintf("DragLeave %x\n", sciThis);
} catch (...) {
sciThis->errorStatus = SC_STATUS_FAILURE;
@@ -2776,7 +2776,7 @@ void ScintillaGTK::DragEnd(GtkWidget *widget, GdkDragContext * /*context*/) {
// If drag did not result in drop here or elsewhere
if (!sciThis->dragWasDropped)
sciThis->SetEmptySelection(sciThis->posDrag);
- sciThis->SetDragPosition(SelectionPosition(invalidPosition));
+ sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
//Platform::DebugPrintf("DragEnd %x %d\n", sciThis, sciThis->dragWasDropped);
sciThis->inDragDrop = ddNone;
} catch (...) {
@@ -2789,7 +2789,7 @@ gboolean ScintillaGTK::Drop(GtkWidget *widget, GdkDragContext * /*context*/,
ScintillaGTK *sciThis = FromWidget(widget);
try {
//Platform::DebugPrintf("Drop %x\n", sciThis);
- sciThis->SetDragPosition(SelectionPosition(invalidPosition));
+ sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
} catch (...) {
sciThis->errorStatus = SC_STATUS_FAILURE;
}
@@ -2801,7 +2801,7 @@ void ScintillaGTK::DragDataReceived(GtkWidget *widget, GdkDragContext * /*contex
ScintillaGTK *sciThis = FromWidget(widget);
try {
sciThis->ReceivedDrop(selection_data);
- sciThis->SetDragPosition(SelectionPosition(invalidPosition));
+ sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
} catch (...) {
sciThis->errorStatus = SC_STATUS_FAILURE;
}
@@ -2832,7 +2832,7 @@ void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context,
}
sciThis->ClearSelection();
}
- sciThis->SetDragPosition(SelectionPosition(invalidPosition));
+ sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
} catch (...) {
sciThis->errorStatus = SC_STATUS_FAILURE;
}
@@ -2870,7 +2870,7 @@ void ScintillaGTK::IdleWork() {
styleIdleID = 0;
}
-void ScintillaGTK::QueueIdleWork(WorkNeeded::workItems items, int upTo) {
+void ScintillaGTK::QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) {
Editor::QueueIdleWork(items, upTo);
if (!styleIdleID) {
// Only allow one style needed to be queued
diff --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h
index 4ee55a6c8..225247c8f 100644
--- a/gtk/ScintillaGTK.h
+++ b/gtk/ScintillaGTK.h
@@ -111,10 +111,10 @@ private:
virtual bool PaintContains(PRectangle rc);
void FullPaint();
virtual PRectangle GetClientRectangle() const;
- virtual void ScrollText(int linesToMove);
+ virtual void ScrollText(Sci::Line linesToMove);
virtual void SetVerticalScrollPos();
virtual void SetHorizontalScrollPos();
- virtual bool ModifyScrollBars(int nMax, int nPage);
+ virtual bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage);
void ReconfigureScrollBars();
virtual void NotifyChange();
virtual void NotifyFocus(bool focus);
@@ -231,7 +231,7 @@ private:
static gboolean IdleCallback(gpointer pSci);
static gboolean StyleIdle(gpointer pSci);
virtual void IdleWork();
- virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo);
+ virtual void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo);
virtual void SetDocPointer(Document *document);
static void PopUpCB(GtkMenuItem *menuItem, ScintillaGTK *sciThis);
diff --git a/gtk/ScintillaGTKAccessible.cxx b/gtk/ScintillaGTKAccessible.cxx
index 5cabb5aa3..3b54ff1a8 100644
--- a/gtk/ScintillaGTKAccessible.cxx
+++ b/gtk/ScintillaGTKAccessible.cxx
@@ -168,7 +168,7 @@ ScintillaGTKAccessible::~ScintillaGTKAccessible() {
}
}
-gchar *ScintillaGTKAccessible::GetTextRangeUTF8(Position startByte, Position endByte) {
+gchar *ScintillaGTKAccessible::GetTextRangeUTF8(Sci::Position startByte, Sci::Position endByte) {
g_return_val_if_fail(startByte >= 0, NULL);
// FIXME: should we swap start/end if necessary?
g_return_val_if_fail(endByte >= startByte, NULL);
@@ -196,7 +196,7 @@ gchar *ScintillaGTKAccessible::GetTextRangeUTF8(Position startByte, Position end
}
gchar *ScintillaGTKAccessible::GetText(int startChar, int endChar) {
- Position startByte, endByte;
+ Sci::Position startByte, endByte;
if (endChar == -1) {
startByte = ByteOffsetFromCharacterOffset(startChar);
endByte = sci->pdoc->Length();
@@ -210,8 +210,8 @@ gchar *ScintillaGTKAccessible::GetTextAfterOffset(int charOffset,
AtkTextBoundary boundaryType, int *startChar, int *endChar) {
g_return_val_if_fail(charOffset >= 0, NULL);
- Position startByte, endByte;
- Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
+ Sci::Position startByte, endByte;
+ Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
switch (boundaryType) {
case ATK_TEXT_BOUNDARY_CHAR:
@@ -261,8 +261,8 @@ gchar *ScintillaGTKAccessible::GetTextBeforeOffset(int charOffset,
AtkTextBoundary boundaryType, int *startChar, int *endChar) {
g_return_val_if_fail(charOffset >= 0, NULL);
- Position startByte, endByte;
- Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
+ Sci::Position startByte, endByte;
+ Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
switch (boundaryType) {
case ATK_TEXT_BOUNDARY_CHAR:
@@ -323,8 +323,8 @@ gchar *ScintillaGTKAccessible::GetTextAtOffset(int charOffset,
AtkTextBoundary boundaryType, int *startChar, int *endChar) {
g_return_val_if_fail(charOffset >= 0, NULL);
- Position startByte, endByte;
- Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
+ Sci::Position startByte, endByte;
+ Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
switch (boundaryType) {
case ATK_TEXT_BOUNDARY_CHAR:
@@ -386,8 +386,8 @@ gchar *ScintillaGTKAccessible::GetStringAtOffset(int charOffset,
AtkTextGranularity granularity, int *startChar, int *endChar) {
g_return_val_if_fail(charOffset >= 0, NULL);
- Position startByte, endByte;
- Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
+ Sci::Position startByte, endByte;
+ Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
switch (granularity) {
case ATK_TEXT_GRANULARITY_CHAR:
@@ -417,8 +417,8 @@ gchar *ScintillaGTKAccessible::GetStringAtOffset(int charOffset,
gunichar ScintillaGTKAccessible::GetCharacterAtOffset(int charOffset) {
g_return_val_if_fail(charOffset >= 0, 0);
- Position startByte = ByteOffsetFromCharacterOffset(charOffset);
- Position endByte = PositionAfter(startByte);
+ Sci::Position startByte = ByteOffsetFromCharacterOffset(charOffset);
+ Sci::Position endByte = PositionAfter(startByte);
gchar *ch = GetTextRangeUTF8(startByte, endByte);
gunichar unichar = g_utf8_get_char_validated(ch, -1);
g_free(ch);
@@ -466,7 +466,7 @@ void ScintillaGTKAccessible::GetCharacterExtents(int charOffset,
gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) {
*x = *y = *height = *width = 0;
- Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
+ Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
// FIXME: should we handle scrolling?
*x = sci->WndProc(SCI_POINTXFROMPOSITION, 0, byteOffset);
@@ -550,7 +550,7 @@ AtkAttributeSet *ScintillaGTKAccessible::GetAttributesForStyle(unsigned int styl
AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *startChar, int *endChar) {
g_return_val_if_fail(charOffset >= -1, NULL);
- Position byteOffset;
+ Sci::Position byteOffset;
if (charOffset == -1) {
byteOffset = sci->WndProc(SCI_GETCURRENTPOS, 0, 0);
} else {
@@ -562,11 +562,11 @@ AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *s
const char style = StyleAt(byteOffset, true);
// compute the range for this style
- Position startByte = byteOffset;
+ Sci::Position startByte = byteOffset;
// when going backwards, we know the style is already computed
while (startByte > 0 && sci->pdoc->StyleAt((startByte) - 1) == style)
(startByte)--;
- Position endByte = byteOffset + 1;
+ Sci::Position endByte = byteOffset + 1;
while (endByte < length && StyleAt(endByte, true) == style)
(endByte)++;
@@ -586,8 +586,8 @@ gchar *ScintillaGTKAccessible::GetSelection(gint selection_num, int *startChar,
if (selection_num < 0 || (unsigned int) selection_num >= sci->sel.Count())
return NULL;
- Position startByte = sci->sel.Range(selection_num).Start().Position();
- Position endByte = sci->sel.Range(selection_num).End().Position();
+ Sci::Position startByte = sci->sel.Range(selection_num).Start().Position();
+ Sci::Position endByte = sci->sel.Range(selection_num).End().Position();
CharacterRangeFromByteRange(startByte, endByte, startChar, endChar);
return GetTextRangeUTF8(startByte, endByte);
@@ -595,7 +595,7 @@ gchar *ScintillaGTKAccessible::GetSelection(gint selection_num, int *startChar,
gboolean ScintillaGTKAccessible::AddSelection(int startChar, int endChar) {
size_t n_selections = sci->sel.Count();
- Position startByte, endByte;
+ Sci::Position startByte, endByte;
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
// use WndProc() to set the selections so it notifies as needed
if (n_selections > 1 || ! sci->sel.Empty()) {
@@ -627,7 +627,7 @@ gboolean ScintillaGTKAccessible::SetSelection(gint selection_num, int startChar,
if (selection_num < 0 || (unsigned int) selection_num >= sci->sel.Count())
return FALSE;
- Position startByte, endByte;
+ Sci::Position startByte, endByte;
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
sci->WndProc(SCI_SETSELECTIONNSTART, selection_num, startByte);
@@ -668,7 +668,7 @@ void ScintillaGTKAccessible::SetTextContents(const gchar *contents) {
}
}
-bool ScintillaGTKAccessible::InsertStringUTF8(Position bytePos, const gchar *utf8, int lengthBytes) {
+bool ScintillaGTKAccessible::InsertStringUTF8(Sci::Position bytePos, const gchar *utf8, Sci::Position lengthBytes) {
if (sci->pdoc->IsReadOnly()) {
return false;
}
@@ -688,7 +688,7 @@ bool ScintillaGTKAccessible::InsertStringUTF8(Position bytePos, const gchar *utf
}
void ScintillaGTKAccessible::InsertText(const gchar *text, int lengthBytes, int *charPosition) {
- Position bytePosition = ByteOffsetFromCharacterOffset(*charPosition);
+ Sci::Position bytePosition = ByteOffsetFromCharacterOffset(*charPosition);
// FIXME: should we update the target?
if (InsertStringUTF8(bytePosition, text, lengthBytes)) {
@@ -697,7 +697,7 @@ void ScintillaGTKAccessible::InsertText(const gchar *text, int lengthBytes, int
}
void ScintillaGTKAccessible::CopyText(int startChar, int endChar) {
- Position startByte, endByte;
+ Sci::Position startByte, endByte;
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
sci->CopyRangeToClipboard(startByte, endByte);
}
@@ -716,7 +716,7 @@ void ScintillaGTKAccessible::DeleteText(int startChar, int endChar) {
g_return_if_fail(endChar >= startChar);
if (! sci->pdoc->IsReadOnly()) {
- Position startByte, endByte;
+ Sci::Position startByte, endByte;
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
if (! sci->RangeContainsProtected(startByte, endByte)) {
@@ -735,13 +735,13 @@ void ScintillaGTKAccessible::PasteText(int charPosition) {
// has always done that without problems, so let's guess it's a fairly safe bet.
struct Helper : GObjectWatcher {
ScintillaGTKAccessible *scia;
- Position bytePosition;
+ Sci::Position bytePosition;
void Destroyed() override {
scia = 0;
}
- Helper(ScintillaGTKAccessible *scia_, Position bytePos_) :
+ Helper(ScintillaGTKAccessible *scia_, Sci::Position bytePos_) :
GObjectWatcher(G_OBJECT(scia_->sci->sci)),
scia(scia_),
bytePosition(bytePos_) {
@@ -757,7 +757,7 @@ void ScintillaGTKAccessible::PasteText(int charPosition) {
len = convertedText.length();
text = convertedText.c_str();
}
- scia->InsertStringUTF8(bytePosition, text, static_cast<int>(len));
+ scia->InsertStringUTF8(bytePosition, text, static_cast<Sci::Position>(len));
}
}
@@ -795,7 +795,7 @@ bool ScintillaGTKAccessible::Enabled() const {
// Callbacks
void ScintillaGTKAccessible::UpdateCursor() {
- Position pos = sci->WndProc(SCI_GETCURRENTPOS, 0, 0);
+ Sci::Position pos = sci->WndProc(SCI_GETCURRENTPOS, 0, 0);
if (old_pos != pos) {
int charPosition = CharacterOffsetFromByteOffset(pos);
g_signal_emit_by_name(accessible, "text-caret-moved", charPosition);
@@ -875,7 +875,7 @@ void ScintillaGTKAccessible::Notify(GtkWidget *, gint, SCNotification *nt) {
case SCN_MODIFIED: {
if (nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
// invalidate character offset cache if applicable
- const Position line = sci->pdoc->LineFromPosition(nt->position);
+ const Sci::Line line = sci->pdoc->LineFromPosition(nt->position);
if (character_offsets.size() > static_cast<size_t>(line + 1)) {
character_offsets.resize(line + 1);
}
diff --git a/gtk/ScintillaGTKAccessible.h b/gtk/ScintillaGTKAccessible.h
index 4403c4ed0..947b6198a 100644
--- a/gtk/ScintillaGTKAccessible.h
+++ b/gtk/ScintillaGTKAccessible.h
@@ -21,12 +21,12 @@ private:
ScintillaGTK *sci;
// cache holding character offset for each line start, see CharacterOffsetFromByteOffset()
- std::vector<Position> character_offsets;
+ std::vector<Sci::Position> character_offsets;
// cached length of the deletion, in characters (see Notify())
int deletionLengthChar;
// local state for comparing
- Position old_pos;
+ Sci::Position old_pos;
std::vector<SelectionRange> old_sels;
bool Enabled() const;
@@ -38,8 +38,8 @@ private:
} catch (...) {}
}
- Position ByteOffsetFromCharacterOffset(Position startByte, int characterOffset) {
- Position pos = sci->pdoc->GetRelativePosition(startByte, characterOffset);
+ Sci::Position ByteOffsetFromCharacterOffset(Sci::Position startByte, int characterOffset) {
+ Sci::Position pos = sci->pdoc->GetRelativePosition(startByte, characterOffset);
if (pos == INVALID_POSITION) {
// clamp invalid positions inside the document
if (characterOffset > 0) {
@@ -51,51 +51,51 @@ private:
return pos;
}
- Position ByteOffsetFromCharacterOffset(int characterOffset) {
+ Sci::Position ByteOffsetFromCharacterOffset(Sci::Position characterOffset) {
return ByteOffsetFromCharacterOffset(0, characterOffset);
}
- int CharacterOffsetFromByteOffset(Position byteOffset) {
- const Position line = sci->pdoc->LineFromPosition(byteOffset);
+ Sci::Position CharacterOffsetFromByteOffset(Sci::Position byteOffset) {
+ const Sci::Line line = sci->pdoc->LineFromPosition(byteOffset);
if (character_offsets.size() <= static_cast<size_t>(line)) {
if (character_offsets.empty())
character_offsets.push_back(0);
- for (Position i = character_offsets.size(); i <= line; i++) {
- const Position start = sci->pdoc->LineStart(i - 1);
- const Position end = sci->pdoc->LineStart(i);
+ for (Sci::Position i = character_offsets.size(); i <= line; i++) {
+ const Sci::Position start = sci->pdoc->LineStart(i - 1);
+ const Sci::Position end = sci->pdoc->LineStart(i);
character_offsets.push_back(character_offsets[i - 1] + sci->pdoc->CountCharacters(start, end));
}
}
- const Position lineStart = sci->pdoc->LineStart(line);
+ const Sci::Position lineStart = sci->pdoc->LineStart(line);
return character_offsets[line] + sci->pdoc->CountCharacters(lineStart, byteOffset);
}
- void CharacterRangeFromByteRange(Position startByte, Position endByte, int *startChar, int *endChar) {
+ void CharacterRangeFromByteRange(Sci::Position startByte, Sci::Position endByte, int *startChar, int *endChar) {
*startChar = CharacterOffsetFromByteOffset(startByte);
*endChar = *startChar + sci->pdoc->CountCharacters(startByte, endByte);
}
- void ByteRangeFromCharacterRange(int startChar, int endChar, Position& startByte, Position& endByte) {
+ void ByteRangeFromCharacterRange(int startChar, int endChar, Sci::Position& startByte, Sci::Position& endByte) {
startByte = ByteOffsetFromCharacterOffset(startChar);
endByte = ByteOffsetFromCharacterOffset(startByte, endChar - startChar);
}
- Position PositionBefore(Position pos) {
+ Sci::Position PositionBefore(Sci::Position pos) {
return sci->pdoc->MovePositionOutsideChar(pos - 1, -1, true);
}
- Position PositionAfter(Position pos) {
+ Sci::Position PositionAfter(Sci::Position pos) {
return sci->pdoc->MovePositionOutsideChar(pos + 1, 1, true);
}
- int StyleAt(Position position, bool ensureStyle = false) {
+ int StyleAt(Sci::Position position, bool ensureStyle = false) {
if (ensureStyle)
sci->pdoc->EnsureStyledTo(position);
return sci->pdoc->StyleAt(position);
}
// For AtkText
- gchar *GetTextRangeUTF8(Position startByte, Position endByte);
+ gchar *GetTextRangeUTF8(Sci::Position startByte, Sci::Position endByte);
gchar *GetText(int startChar, int endChar);
gchar *GetTextAfterOffset(int charOffset, AtkTextBoundary boundaryType, int *startChar, int *endChar);
gchar *GetTextBeforeOffset(int charOffset, AtkTextBoundary boundaryType, int *startChar, int *endChar);
@@ -118,7 +118,7 @@ private:
gboolean RemoveSelection(int selection_num);
gboolean SetSelection(gint selection_num, int startChar, int endChar);
// for AtkEditableText
- bool InsertStringUTF8(Position bytePos, const gchar *utf8, int lengthBytes);
+ bool InsertStringUTF8(Sci::Position bytePos, const gchar *utf8, Sci::Position lengthBytes);
void SetTextContents(const gchar *contents);
void InsertText(const gchar *contents, int lengthBytes, int *charPosition);
void CopyText(int startChar, int endChar);
diff --git a/qt/ScintillaEdit/ScintillaDocument.cpp b/qt/ScintillaEdit/ScintillaDocument.cpp
index 86f50db9d..5a6ef200c 100644
--- a/qt/ScintillaEdit/ScintillaDocument.cpp
+++ b/qt/ScintillaEdit/ScintillaDocument.cpp
@@ -45,7 +45,7 @@ public:
void NotifySavePoint(Document *doc, void *userData, bool atSavePoint);
void NotifyModified(Document *doc, DocModification mh, void *userData);
void NotifyDeleted(Document *doc, void *userData);
- void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
+ void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos);
void NotifyLexerChanged(Document *doc, void *userData);
void NotifyErrorOccurred(Document *doc, void *userData, int status);
};
@@ -76,7 +76,7 @@ void WatcherHelper::NotifyModified(Document *, DocModification mh, void *) {
void WatcherHelper::NotifyDeleted(Document *, void *) {
}
-void WatcherHelper::NotifyStyleNeeded(Document *, void *, int endPos) {
+void WatcherHelper::NotifyStyleNeeded(Document *, void *, Sci::Position endPos) {
owner->emit_style_needed(endPos);
}
diff --git a/qt/ScintillaEditBase/ScintillaQt.cpp b/qt/ScintillaEditBase/ScintillaQt.cpp
index 3b7db8002..fc1d40c74 100644
--- a/qt/ScintillaEditBase/ScintillaQt.cpp
+++ b/qt/ScintillaEditBase/ScintillaQt.cpp
@@ -239,7 +239,7 @@ bool ScintillaQt::ValidCodePage(int codePage) const
}
-void ScintillaQt::ScrollText(int linesToMove)
+void ScintillaQt::ScrollText(Sci::Line linesToMove)
{
int dy = vs.lineHeight * (linesToMove);
scrollArea->viewport()->scroll(0, dy);
@@ -257,7 +257,7 @@ void ScintillaQt::SetHorizontalScrollPos()
emit horizontalScrolled(xOffset);
}
-bool ScintillaQt::ModifyScrollBars(int nMax, int nPage)
+bool ScintillaQt::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage)
{
bool modified = false;
@@ -613,7 +613,7 @@ void ScintillaQt::StartDrag()
}
}
inDragDrop = ddNone;
- SetDragPosition(SelectionPosition(invalidPosition));
+ SetDragPosition(SelectionPosition(Sci::invalidPosition));
}
void ScintillaQt::CreateCallTipWindow(PRectangle rc)
@@ -740,7 +740,7 @@ void ScintillaQt::DragMove(const Point &point)
void ScintillaQt::DragLeave()
{
- SetDragPosition(SelectionPosition(invalidPosition));
+ SetDragPosition(SelectionPosition(Sci::invalidPosition));
}
void ScintillaQt::Drop(const Point &point, const QMimeData *data, bool move)
diff --git a/qt/ScintillaEditBase/ScintillaQt.h b/qt/ScintillaEditBase/ScintillaQt.h
index 0f8da8b1f..74d5eb770 100644
--- a/qt/ScintillaEditBase/ScintillaQt.h
+++ b/qt/ScintillaEditBase/ScintillaQt.h
@@ -107,7 +107,7 @@ private:
virtual void ScrollText(int linesToMove);
virtual void SetVerticalScrollPos();
virtual void SetHorizontalScrollPos();
- virtual bool ModifyScrollBars(int nMax, int nPage);
+ virtual bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage);
virtual void ReconfigureScrollBars();
void CopyToModeClipboard(const SelectionText &selectedText, QClipboard::Mode clipboardMode_);
virtual void Copy();
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index 3f3570283..419d495c2 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -58,7 +58,7 @@ bool AutoComplete::Active() const {
}
void AutoComplete::Start(Window &parent, int ctrlID,
- int position, Point location, int startLen_,
+ Sci::Position position, Point location, int startLen_,
int lineHeight, bool unicodeMode, int technology) {
if (active) {
Cancel();
diff --git a/src/AutoComplete.h b/src/AutoComplete.h
index c35fa1a0e..205d4e095 100644
--- a/src/AutoComplete.h
+++ b/src/AutoComplete.h
@@ -28,7 +28,7 @@ public:
bool ignoreCase;
bool chooseSingle;
ListBox *lb;
- int posStart;
+ Sci::Position posStart;
int startLen;
/// Should autocompletion be canceled if editor's currentPos <= startPos?
bool cancelAtStartPos;
@@ -50,7 +50,7 @@ public:
bool Active() const;
/// Display the auto completion list positioned to be near a character position
- void Start(Window &parent, int ctrlID, int position, Point location,
+ void Start(Window &parent, int ctrlID, Sci::Position position, Point location,
int startLen_, int lineHeight, bool unicodeMode, int technology);
/// The stop chars are characters which, when typed, cause the auto completion list to disappear
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index 541f4c683..11dbe6b52 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -250,7 +250,7 @@ void CallTip::MouseClick(Point pt) {
clickPlace = 2;
}
-PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char *defn,
+PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn,
const char *faceName, int size,
int codePage_, int characterSet,
int technology, Window &wParent) {
diff --git a/src/CallTip.h b/src/CallTip.h
index 840aa26ac..787941ded 100644
--- a/src/CallTip.h
+++ b/src/CallTip.h
@@ -41,7 +41,7 @@ public:
Window wCallTip;
Window wDraw;
bool inCallTipMode;
- int posStartCallTip;
+ Sci::Position posStartCallTip;
ColourDesired colourBG;
ColourDesired colourUnSel;
ColourDesired colourSel;
@@ -63,7 +63,7 @@ public:
void MouseClick(Point pt);
/// Setup the calltip and return a rectangle of the area required.
- PRectangle CallTipStart(int pos, Point pt, int textHeight, const char *defn,
+ PRectangle CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn,
const char *faceName, int size, int codePage_,
int characterSet, int technology, Window &wParent);
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index 6ad990a63..0001c812d 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -45,11 +45,11 @@ void LineVector::SetPerLine(PerLine *pl) {
perLine = pl;
}
-void LineVector::InsertText(int line, int delta) {
+void LineVector::InsertText(Sci::Line line, Sci::Position delta) {
starts.InsertText(line, delta);
}
-void LineVector::InsertLine(int line, int position, bool lineStart) {
+void LineVector::InsertLine(Sci::Line line, Sci::Position position, bool lineStart) {
starts.InsertPartition(line, position);
if (perLine) {
if ((line > 0) && lineStart)
@@ -58,18 +58,18 @@ void LineVector::InsertLine(int line, int position, bool lineStart) {
}
}
-void LineVector::SetLineStart(int line, int position) {
+void LineVector::SetLineStart(Sci::Line line, Sci::Position position) {
starts.SetPartitionStartPosition(line, position);
}
-void LineVector::RemoveLine(int line) {
+void LineVector::RemoveLine(Sci::Line line) {
starts.RemovePartition(line);
if (perLine) {
perLine->RemoveLine(line);
}
}
-int LineVector::LineFromPosition(int pos) const {
+Sci::Line LineVector::LineFromPosition(Sci::Position pos) const {
return starts.PartitionFromPosition(pos);
}
@@ -85,7 +85,7 @@ Action::~Action() {
Destroy();
}
-void Action::Create(actionType at_, int position_, const char *data_, int lenData_, bool mayCoalesce_) {
+void Action::Create(actionType at_, Sci::Position position_, const char *data_, Sci::Position lenData_, bool mayCoalesce_) {
delete []data;
data = NULL;
position = position_;
@@ -171,7 +171,7 @@ void UndoHistory::EnsureUndoRoom() {
}
}
-const char *UndoHistory::AppendAction(actionType at, int position, const char *data, int lengthData,
+const char *UndoHistory::AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position lengthData,
bool &startSequence, bool mayCoalesce) {
EnsureUndoRoom();
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
@@ -375,11 +375,11 @@ CellBuffer::CellBuffer() {
CellBuffer::~CellBuffer() {
}
-char CellBuffer::CharAt(int position) const {
+char CellBuffer::CharAt(Sci::Position position) const {
return substance.ValueAt(position);
}
-void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) const {
+void CellBuffer::GetCharRange(char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
if (lengthRetrieve <= 0)
return;
if (position < 0)
@@ -392,11 +392,11 @@ void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) co
substance.GetRange(buffer, position, lengthRetrieve);
}
-char CellBuffer::StyleAt(int position) const {
+char CellBuffer::StyleAt(Sci::Position position) const {
return style.ValueAt(position);
}
-void CellBuffer::GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const {
+void CellBuffer::GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
if (lengthRetrieve < 0)
return;
if (position < 0)
@@ -413,16 +413,16 @@ const char *CellBuffer::BufferPointer() {
return substance.BufferPointer();
}
-const char *CellBuffer::RangePointer(int position, int rangeLength) {
+const char *CellBuffer::RangePointer(Sci::Position position, Sci::Position rangeLength) {
return substance.RangePointer(position, rangeLength);
}
-int CellBuffer::GapPosition() const {
+Sci::Position CellBuffer::GapPosition() const {
return substance.GapPosition();
}
// The char* returned is to an allocation owned by the undo history
-const char *CellBuffer::InsertString(int position, const char *s, int insertLength, bool &startSequence) {
+const char *CellBuffer::InsertString(Sci::Position position, const char *s, Sci::Position insertLength, bool &startSequence) {
// InsertString and DeleteChars are the bottleneck though which all changes occur
const char *data = s;
if (!readOnly) {
@@ -437,7 +437,7 @@ const char *CellBuffer::InsertString(int position, const char *s, int insertLeng
return data;
}
-bool CellBuffer::SetStyleAt(int position, char styleValue) {
+bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) {
char curVal = style.ValueAt(position);
if (curVal != styleValue) {
style.SetValueAt(position, styleValue);
@@ -447,7 +447,7 @@ bool CellBuffer::SetStyleAt(int position, char styleValue) {
}
}
-bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue) {
+bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) {
bool changed = false;
PLATFORM_ASSERT(lengthStyle == 0 ||
(lengthStyle > 0 && lengthStyle + position <= style.Length()));
@@ -463,7 +463,7 @@ bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue) {
}
// The char* returned is to an allocation owned by the undo history
-const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startSequence) {
+const char *CellBuffer::DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence) {
// InsertString and DeleteChars are the bottleneck though which all changes occur
PLATFORM_ASSERT(deleteLength > 0);
const char *data = 0;
@@ -480,11 +480,11 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startS
return data;
}
-int CellBuffer::Length() const {
+Sci::Position CellBuffer::Length() const {
return substance.Length();
}
-void CellBuffer::Allocate(int newSize) {
+void CellBuffer::Allocate(Sci::Position newSize) {
substance.ReAllocate(newSize);
style.ReAllocate(newSize);
}
@@ -496,10 +496,10 @@ void CellBuffer::SetLineEndTypes(int utf8LineEnds_) {
}
}
-bool CellBuffer::ContainsLineEnd(const char *s, int length) const {
+bool CellBuffer::ContainsLineEnd(const char *s, Sci::Position length) const {
unsigned char chBeforePrev = 0;
unsigned char chPrev = 0;
- for (int i = 0; i < length; i++) {
+ for (Sci::Position i = 0; i < length; i++) {
const unsigned char ch = s[i];
if ((ch == '\r') || (ch == '\n')) {
return true;
@@ -519,11 +519,11 @@ void CellBuffer::SetPerLine(PerLine *pl) {
lv.SetPerLine(pl);
}
-int CellBuffer::Lines() const {
+Sci::Line CellBuffer::Lines() const {
return lv.Lines();
}
-int CellBuffer::LineStart(int line) const {
+Sci::Position CellBuffer::LineStart(Sci::Line line) const {
if (line < 0)
return 0;
else if (line >= Lines())
@@ -566,15 +566,15 @@ bool CellBuffer::TentativeActive() const {
// Without undo
-void CellBuffer::InsertLine(int line, int position, bool lineStart) {
+void CellBuffer::InsertLine(Sci::Line line, Sci::Position position, bool lineStart) {
lv.InsertLine(line, position, lineStart);
}
-void CellBuffer::RemoveLine(int line) {
+void CellBuffer::RemoveLine(Sci::Line line) {
lv.RemoveLine(line);
}
-bool CellBuffer::UTF8LineEndOverlaps(int position) const {
+bool CellBuffer::UTF8LineEndOverlaps(Sci::Position position) const {
unsigned char bytes[] = {
static_cast<unsigned char>(substance.ValueAt(position-2)),
static_cast<unsigned char>(substance.ValueAt(position-1)),
@@ -588,14 +588,14 @@ void CellBuffer::ResetLineEnds() {
// Reinitialize line data -- too much work to preserve
lv.Init();
- int position = 0;
- int length = Length();
- int lineInsert = 1;
+ Sci::Position position = 0;
+ Sci::Position length = Length();
+ Sci::Line lineInsert = 1;
bool atLineStart = true;
lv.InsertText(lineInsert-1, length);
unsigned char chBeforePrev = 0;
unsigned char chPrev = 0;
- for (int i = 0; i < length; i++) {
+ for (Sci::Position i = 0; i < length; i++) {
unsigned char ch = substance.ValueAt(position + i);
if (ch == '\r') {
InsertLine(lineInsert, (position + i) + 1, atLineStart);
@@ -620,7 +620,7 @@ void CellBuffer::ResetLineEnds() {
}
}
-void CellBuffer::BasicInsertString(int position, const char *s, int insertLength) {
+void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::Position insertLength) {
if (insertLength == 0)
return;
PLATFORM_ASSERT(insertLength > 0);
@@ -634,7 +634,7 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
substance.InsertFromArray(position, s, 0, insertLength);
style.InsertValue(position, insertLength, 0);
- int lineInsert = lv.LineFromPosition(position) + 1;
+ Sci::Line lineInsert = lv.LineFromPosition(position) + 1;
bool atLineStart = lv.LineStart(lineInsert-1) == position;
// Point all the lines after the insertion point further along in the buffer
lv.InsertText(lineInsert-1, insertLength);
@@ -649,7 +649,7 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
RemoveLine(lineInsert);
}
unsigned char ch = ' ';
- for (int i = 0; i < insertLength; i++) {
+ for (Sci::Position i = 0; i < insertLength; i++) {
ch = s[i];
if (ch == '\r') {
InsertLine(lineInsert, (position + i) + 1, atLineStart);
@@ -697,7 +697,7 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
}
}
-void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
+void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLength) {
if (deleteLength == 0)
return;
@@ -709,7 +709,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
// Have to fix up line positions before doing deletion as looking at text in buffer
// to work out which lines have been removed
- int lineRemove = lv.LineFromPosition(position) + 1;
+ Sci::Line lineRemove = lv.LineFromPosition(position) + 1;
lv.InsertText(lineRemove-1, - (deleteLength));
unsigned char chPrev = substance.ValueAt(position - 1);
unsigned char chBefore = chPrev;
@@ -728,7 +728,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
}
unsigned char ch = chNext;
- for (int i = 0; i < deleteLength; i++) {
+ for (Sci::Position i = 0; i < deleteLength; i++) {
chNext = substance.ValueAt(position + i + 1);
if (ch == '\r') {
if (chNext != '\n') {
@@ -783,7 +783,7 @@ void CellBuffer::EndUndoAction() {
uh.EndUndoAction();
}
-void CellBuffer::AddUndoAction(int token, bool mayCoalesce) {
+void CellBuffer::AddUndoAction(Sci::Position token, bool mayCoalesce) {
bool startSequence;
uh.AppendAction(containerAction, token, 0, 0, startSequence, mayCoalesce);
}
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index c1e973cff..60842ba95 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -17,8 +17,8 @@ class PerLine {
public:
virtual ~PerLine() {}
virtual void Init()=0;
- virtual void InsertLine(int line)=0;
- virtual void RemoveLine(int line)=0;
+ virtual void InsertLine(Sci::Line line)=0;
+ virtual void RemoveLine(Sci::Line line)=0;
};
/**
@@ -36,15 +36,15 @@ public:
void Init();
void SetPerLine(PerLine *pl);
- void InsertText(int line, int delta);
- void InsertLine(int line, int position, bool lineStart);
- void SetLineStart(int line, int position);
- void RemoveLine(int line);
- int Lines() const {
+ void InsertText(Sci::Line line, Sci::Position delta);
+ void InsertLine(Sci::Line line, Sci::Position position, bool lineStart);
+ void SetLineStart(Sci::Line line, Sci::Position position);
+ void RemoveLine(Sci::Line line);
+ Sci::Line Lines() const {
return starts.Partitions();
}
- int LineFromPosition(int pos) const;
- int LineStart(int line) const {
+ Sci::Line LineFromPosition(Sci::Position pos) const;
+ Sci::Position LineStart(Sci::Line line) const {
return starts.PositionFromPartition(line);
}
};
@@ -57,14 +57,14 @@ enum actionType { insertAction, removeAction, startAction, containerAction };
class Action {
public:
actionType at;
- int position;
+ Sci::Position position;
char *data;
- int lenData;
+ Sci::Position lenData;
bool mayCoalesce;
Action();
~Action();
- void Create(actionType at_, int position_=0, const char *data_=0, int lenData_=0, bool mayCoalesce_=true);
+ void Create(actionType at_, Sci::Position position_=0, const char *data_=0, Sci::Position lenData_=0, bool mayCoalesce_=true);
void Destroy();
void Grab(Action *source);
};
@@ -90,7 +90,7 @@ public:
UndoHistory();
~UndoHistory();
- const char *AppendAction(actionType at, int position, const char *data, int length, bool &startSequence, bool mayCoalesce=true);
+ const char *AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position length, bool &startSequence, bool mayCoalesce=true);
void BeginUndoAction();
void EndUndoAction();
@@ -137,11 +137,11 @@ private:
LineVector lv;
- bool UTF8LineEndOverlaps(int position) const;
+ bool UTF8LineEndOverlaps(Sci::Position position) const;
void ResetLineEnds();
/// Actions without undo
- void BasicInsertString(int position, const char *s, int insertLength);
- void BasicDeleteChars(int position, int deleteLength);
+ void BasicInsertString(Sci::Position position, const char *s, Sci::Position insertLength);
+ void BasicDeleteChars(Sci::Position position, Sci::Position deleteLength);
public:
@@ -149,33 +149,33 @@ public:
~CellBuffer();
/// Retrieving positions outside the range of the buffer works and returns 0
- char CharAt(int position) const;
- void GetCharRange(char *buffer, int position, int lengthRetrieve) const;
- char StyleAt(int position) const;
- void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const;
+ char CharAt(Sci::Position position) const;
+ void GetCharRange(char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const;
+ char StyleAt(Sci::Position position) const;
+ void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const;
const char *BufferPointer();
- const char *RangePointer(int position, int rangeLength);
- int GapPosition() const;
+ const char *RangePointer(Sci::Position position, Sci::Position rangeLength);
+ Sci::Position GapPosition() const;
- int Length() const;
- void Allocate(int newSize);
+ Sci::Position Length() const;
+ void Allocate(Sci::Position newSize);
int GetLineEndTypes() const { return utf8LineEnds; }
void SetLineEndTypes(int utf8LineEnds_);
- bool ContainsLineEnd(const char *s, int length) const;
+ bool ContainsLineEnd(const char *s, Sci::Position length) const;
void SetPerLine(PerLine *pl);
- int Lines() const;
- int LineStart(int line) const;
- int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); }
- void InsertLine(int line, int position, bool lineStart);
- void RemoveLine(int line);
- const char *InsertString(int position, const char *s, int insertLength, bool &startSequence);
+ Sci::Line Lines() const;
+ Sci::Position LineStart(Sci::Line line) const;
+ Sci::Line LineFromPosition(Sci::Position pos) const { return lv.LineFromPosition(pos); }
+ void InsertLine(Sci::Line line, Sci::Position position, bool lineStart);
+ void RemoveLine(Sci::Line line);
+ const char *InsertString(Sci::Position position, const char *s, Sci::Position insertLength, bool &startSequence);
/// Setting styles for positions outside the range of the buffer is safe and has no effect.
/// @return true if the style of a character is changed.
- bool SetStyleAt(int position, char styleValue);
- bool SetStyleFor(int position, int length, char styleValue);
+ bool SetStyleAt(Sci::Position position, char styleValue);
+ bool SetStyleFor(Sci::Position position, Sci::Position length, char styleValue);
- const char *DeleteChars(int position, int deleteLength, bool &startSequence);
+ const char *DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence);
bool IsReadOnly() const;
void SetReadOnly(bool set);
@@ -194,7 +194,7 @@ public:
bool IsCollectingUndo() const;
void BeginUndoAction();
void EndUndoAction();
- void AddUndoAction(int token, bool mayCoalesce);
+ void AddUndoAction(Sci::Position token, bool mayCoalesce);
void DeleteUndoHistory();
/// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx
index 41627c173..bf4cd6767 100644
--- a/src/ContractionState.cxx
+++ b/src/ContractionState.cxx
@@ -57,7 +57,7 @@ void ContractionState::Clear() {
linesInDocument = 1;
}
-int ContractionState::LinesInDoc() const {
+Sci::Line ContractionState::LinesInDoc() const {
if (OneToOne()) {
return linesInDocument;
} else {
@@ -65,7 +65,7 @@ int ContractionState::LinesInDoc() const {
}
}
-int ContractionState::LinesDisplayed() const {
+Sci::Line ContractionState::LinesDisplayed() const {
if (OneToOne()) {
return linesInDocument;
} else {
@@ -73,7 +73,7 @@ int ContractionState::LinesDisplayed() const {
}
}
-int ContractionState::DisplayFromDoc(int lineDoc) const {
+Sci::Line ContractionState::DisplayFromDoc(Sci::Line lineDoc) const {
if (OneToOne()) {
return (lineDoc <= linesInDocument) ? lineDoc : linesInDocument;
} else {
@@ -83,11 +83,11 @@ int ContractionState::DisplayFromDoc(int lineDoc) const {
}
}
-int ContractionState::DisplayLastFromDoc(int lineDoc) const {
+Sci::Line ContractionState::DisplayLastFromDoc(Sci::Line lineDoc) const {
return DisplayFromDoc(lineDoc) + GetHeight(lineDoc) - 1;
}
-int ContractionState::DocFromDisplay(int lineDisplay) const {
+Sci::Line ContractionState::DocFromDisplay(Sci::Line lineDisplay) const {
if (OneToOne()) {
return lineDisplay;
} else {
@@ -97,13 +97,13 @@ int ContractionState::DocFromDisplay(int lineDisplay) const {
if (lineDisplay > LinesDisplayed()) {
return displayLines->PartitionFromPosition(LinesDisplayed());
}
- int lineDoc = displayLines->PartitionFromPosition(lineDisplay);
+ Sci::Line lineDoc = displayLines->PartitionFromPosition(lineDisplay);
PLATFORM_ASSERT(GetVisible(lineDoc));
return lineDoc;
}
}
-void ContractionState::InsertLine(int lineDoc) {
+void ContractionState::InsertLine(Sci::Line lineDoc) {
if (OneToOne()) {
linesInDocument++;
} else {
@@ -115,20 +115,20 @@ void ContractionState::InsertLine(int lineDoc) {
heights->SetValueAt(lineDoc, 1);
foldDisplayTexts->InsertSpace(lineDoc, 1);
foldDisplayTexts->SetValueAt(lineDoc, NULL);
- int lineDisplay = DisplayFromDoc(lineDoc);
+ Sci::Line lineDisplay = DisplayFromDoc(lineDoc);
displayLines->InsertPartition(lineDoc, lineDisplay);
displayLines->InsertText(lineDoc, 1);
}
}
-void ContractionState::InsertLines(int lineDoc, int lineCount) {
+void ContractionState::InsertLines(Sci::Line lineDoc, Sci::Line lineCount) {
for (int l = 0; l < lineCount; l++) {
InsertLine(lineDoc + l);
}
Check();
}
-void ContractionState::DeleteLine(int lineDoc) {
+void ContractionState::DeleteLine(Sci::Line lineDoc) {
if (OneToOne()) {
linesInDocument--;
} else {
@@ -143,14 +143,14 @@ void ContractionState::DeleteLine(int lineDoc) {
}
}
-void ContractionState::DeleteLines(int lineDoc, int lineCount) {
- for (int l = 0; l < lineCount; l++) {
+void ContractionState::DeleteLines(Sci::Line lineDoc, Sci::Line lineCount) {
+ for (Sci::Line l = 0; l < lineCount; l++) {
DeleteLine(lineDoc);
}
Check();
}
-bool ContractionState::GetVisible(int lineDoc) const {
+bool ContractionState::GetVisible(Sci::Line lineDoc) const {
if (OneToOne()) {
return true;
} else {
@@ -160,15 +160,15 @@ bool ContractionState::GetVisible(int lineDoc) const {
}
}
-bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool isVisible) {
+bool ContractionState::SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd, bool isVisible) {
if (OneToOne() && isVisible) {
return false;
} else {
EnsureData();
- int delta = 0;
+ Sci::Line delta = 0;
Check();
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) {
- for (int line = lineDocStart; line <= lineDocEnd; line++) {
+ for (Sci::Line line = lineDocStart; line <= lineDocEnd; line++) {
if (GetVisible(line) != isVisible) {
int difference = isVisible ? heights->ValueAt(line) : -heights->ValueAt(line);
visible->SetValueAt(line, isVisible ? 1 : 0);
@@ -192,12 +192,12 @@ bool ContractionState::HiddenLines() const {
}
}
-const char *ContractionState::GetFoldDisplayText(int lineDoc) const {
+const char *ContractionState::GetFoldDisplayText(Sci::Line lineDoc) const {
Check();
return foldDisplayTexts->ValueAt(lineDoc);
}
-bool ContractionState::SetFoldDisplayText(int lineDoc, const char *text) {
+bool ContractionState::SetFoldDisplayText(Sci::Line lineDoc, const char *text) {
EnsureData();
const char *foldText = foldDisplayTexts->ValueAt(lineDoc);
if (!foldText || 0 != strcmp(text, foldText)) {
@@ -210,7 +210,7 @@ bool ContractionState::SetFoldDisplayText(int lineDoc, const char *text) {
}
}
-bool ContractionState::GetExpanded(int lineDoc) const {
+bool ContractionState::GetExpanded(Sci::Line lineDoc) const {
if (OneToOne()) {
return true;
} else {
@@ -219,7 +219,7 @@ bool ContractionState::GetExpanded(int lineDoc) const {
}
}
-bool ContractionState::SetExpanded(int lineDoc, bool isExpanded) {
+bool ContractionState::SetExpanded(Sci::Line lineDoc, bool isExpanded) {
if (OneToOne() && isExpanded) {
return false;
} else {
@@ -235,11 +235,11 @@ bool ContractionState::SetExpanded(int lineDoc, bool isExpanded) {
}
}
-bool ContractionState::GetFoldDisplayTextShown(int lineDoc) const {
+bool ContractionState::GetFoldDisplayTextShown(Sci::Line lineDoc) const {
return !GetExpanded(lineDoc) && GetFoldDisplayText(lineDoc);
}
-int ContractionState::ContractedNext(int lineDocStart) const {
+Sci::Line ContractionState::ContractedNext(Sci::Line lineDocStart) const {
if (OneToOne()) {
return -1;
} else {
@@ -247,7 +247,7 @@ int ContractionState::ContractedNext(int lineDocStart) const {
if (!expanded->ValueAt(lineDocStart)) {
return lineDocStart;
} else {
- int lineDocNextChange = expanded->EndRun(lineDocStart);
+ Sci::Line lineDocNextChange = expanded->EndRun(lineDocStart);
if (lineDocNextChange < LinesInDoc())
return lineDocNextChange;
else
@@ -256,7 +256,7 @@ int ContractionState::ContractedNext(int lineDocStart) const {
}
}
-int ContractionState::GetHeight(int lineDoc) const {
+int ContractionState::GetHeight(Sci::Line lineDoc) const {
if (OneToOne()) {
return 1;
} else {
@@ -266,7 +266,7 @@ int ContractionState::GetHeight(int lineDoc) const {
// Set the number of display lines needed for this line.
// Return true if this is a change.
-bool ContractionState::SetHeight(int lineDoc, int height) {
+bool ContractionState::SetHeight(Sci::Line lineDoc, int height) {
if (OneToOne() && (height == 1)) {
return false;
} else if (lineDoc < LinesInDoc()) {
@@ -288,7 +288,7 @@ bool ContractionState::SetHeight(int lineDoc, int height) {
}
void ContractionState::ShowAll() {
- int lines = LinesInDoc();
+ Sci::Line lines = LinesInDoc();
Clear();
linesInDocument = lines;
}
@@ -297,14 +297,14 @@ void ContractionState::ShowAll() {
void ContractionState::Check() const {
#ifdef CHECK_CORRECTNESS
- for (int vline = 0; vline < LinesDisplayed(); vline++) {
- const int lineDoc = DocFromDisplay(vline);
+ for (Sci::Line vline = 0; vline < LinesDisplayed(); vline++) {
+ const Sci::Line lineDoc = DocFromDisplay(vline);
PLATFORM_ASSERT(GetVisible(lineDoc));
}
- for (int lineDoc = 0; lineDoc < LinesInDoc(); lineDoc++) {
- const int displayThis = DisplayFromDoc(lineDoc);
- const int displayNext = DisplayFromDoc(lineDoc + 1);
- const int height = displayNext - displayThis;
+ for (Sci::Line lineDoc = 0; lineDoc < LinesInDoc(); lineDoc++) {
+ const Sci::Line displayThis = DisplayFromDoc(lineDoc);
+ const Sci::Line displayNext = DisplayFromDoc(lineDoc + 1);
+ const Sci::Line height = displayNext - displayThis;
PLATFORM_ASSERT(height >= 0);
if (GetVisible(lineDoc)) {
PLATFORM_ASSERT(GetHeight(lineDoc) == height);
diff --git a/src/ContractionState.h b/src/ContractionState.h
index 622696939..91146f409 100644
--- a/src/ContractionState.h
+++ b/src/ContractionState.h
@@ -24,7 +24,7 @@ class ContractionState {
RunStyles *heights;
SparseVector<const char *> *foldDisplayTexts;
Partitioning *displayLines;
- int linesInDocument;
+ Sci::Line linesInDocument;
void EnsureData();
@@ -40,31 +40,31 @@ public:
void Clear();
- int LinesInDoc() const;
- int LinesDisplayed() const;
- int DisplayFromDoc(int lineDoc) const;
- int DisplayLastFromDoc(int lineDoc) const;
- int DocFromDisplay(int lineDisplay) const;
+ Sci::Line LinesInDoc() const;
+ Sci::Line LinesDisplayed() const;
+ Sci::Line DisplayFromDoc(Sci::Line lineDoc) const;
+ Sci::Line DisplayLastFromDoc(Sci::Line lineDoc) const;
+ Sci::Line DocFromDisplay(Sci::Line lineDisplay) const;
- void InsertLine(int lineDoc);
- void InsertLines(int lineDoc, int lineCount);
- void DeleteLine(int lineDoc);
- void DeleteLines(int lineDoc, int lineCount);
+ void InsertLine(Sci::Line lineDoc);
+ void InsertLines(Sci::Line lineDoc, Sci::Line lineCount);
+ void DeleteLine(Sci::Line lineDoc);
+ void DeleteLines(Sci::Line lineDoc, Sci::Line lineCount);
- bool GetVisible(int lineDoc) const;
- bool SetVisible(int lineDocStart, int lineDocEnd, bool isVisible);
+ bool GetVisible(Sci::Line lineDoc) const;
+ bool SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd, bool isVisible);
bool HiddenLines() const;
- const char *GetFoldDisplayText(int lineDoc) const;
- bool SetFoldDisplayText(int lineDoc, const char *text);
+ const char *GetFoldDisplayText(Sci::Line lineDoc) const;
+ bool SetFoldDisplayText(Sci::Line lineDoc, const char *text);
- bool GetExpanded(int lineDoc) const;
- bool SetExpanded(int lineDoc, bool isExpanded);
- bool GetFoldDisplayTextShown(int lineDoc) const;
- int ContractedNext(int lineDocStart) const;
+ bool GetExpanded(Sci::Line lineDoc) const;
+ bool SetExpanded(Sci::Line lineDoc, bool isExpanded);
+ bool GetFoldDisplayTextShown(Sci::Line lineDoc) const;
+ Sci::Line ContractedNext(Sci::Line lineDocStart) const;
- int GetHeight(int lineDoc) const;
- bool SetHeight(int lineDoc, int height);
+ int GetHeight(Sci::Line lineDoc) const;
+ bool SetHeight(Sci::Line lineDoc, int height);
void ShowAll();
void Check() const;
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++;
diff --git a/src/Document.h b/src/Document.h
index a76c97141..c56177487 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -12,13 +12,6 @@
namespace Scintilla {
#endif
-/**
- * A Position is a position within a document between two characters or at the beginning or end.
- * Sometimes used as a character index where it identifies the character after the position.
- */
-typedef int Position;
-const Position invalidPosition = -1;
-
enum EncodingFamily { efEightBit, efUnicode, efDBCS };
/**
@@ -29,13 +22,13 @@ enum EncodingFamily { efEightBit, efUnicode, efDBCS };
*/
class Range {
public:
- Position start;
- Position end;
+ Sci::Position start;
+ Sci::Position end;
- explicit Range(Position pos=0) :
+ explicit Range(Sci::Position pos=0) :
start(pos), end(pos) {
}
- Range(Position start_, Position end_) :
+ Range(Sci::Position start_, Sci::Position end_) :
start(start_), end(end_) {
}
@@ -44,19 +37,19 @@ public:
}
bool Valid() const {
- return (start != invalidPosition) && (end != invalidPosition);
+ return (start != Sci::invalidPosition) && (end != Sci::invalidPosition);
}
- Position First() const {
+ Sci::Position First() const {
return (start <= end) ? start : end;
}
- Position Last() const {
+ Sci::Position Last() const {
return (start > end) ? start : end;
}
// Is the position within the range?
- bool Contains(Position pos) const {
+ bool Contains(Sci::Position pos) const {
if (start < end) {
return (pos >= start && pos <= end);
} else {
@@ -65,7 +58,7 @@ public:
}
// Is the character after pos within the range?
- bool ContainsCharacter(Position pos) const {
+ bool ContainsCharacter(Sci::Position pos) const {
if (start < end) {
return (pos >= start && pos < end);
} else {
@@ -97,11 +90,11 @@ class RegexSearchBase {
public:
virtual ~RegexSearchBase() {}
- virtual long FindText(Document *doc, int minPos, int maxPos, const char *s,
- bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0;
+ virtual long FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
+ bool caseSensitive, bool word, bool wordStart, int flags, Sci::Position *length) = 0;
///@return String with the substitutions, must remain valid until the next call or destruction
- virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length) = 0;
+ virtual const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) = 0;
};
/// Factory function for RegexSearchBase
@@ -142,30 +135,30 @@ public:
firstChangeableLineAfter = -1;
}
- bool NeedsDrawing(int line) const {
+ bool NeedsDrawing(Sci::Line line) const {
return isEnabled && (line <= firstChangeableLineBefore || line >= firstChangeableLineAfter);
}
- bool IsFoldBlockHighlighted(int line) const {
+ bool IsFoldBlockHighlighted(Sci::Line line) const {
return isEnabled && beginFoldBlock != -1 && beginFoldBlock <= line && line <= endFoldBlock;
}
- bool IsHeadOfFoldBlock(int line) const {
+ bool IsHeadOfFoldBlock(Sci::Line line) const {
return beginFoldBlock == line && line < endFoldBlock;
}
- bool IsBodyOfFoldBlock(int line) const {
+ bool IsBodyOfFoldBlock(Sci::Line line) const {
return beginFoldBlock != -1 && beginFoldBlock < line && line < endFoldBlock;
}
- bool IsTailOfFoldBlock(int line) const {
+ bool IsTailOfFoldBlock(Sci::Line line) const {
return beginFoldBlock != -1 && beginFoldBlock < line && line == endFoldBlock;
}
- int beginFoldBlock; // Begin of current fold block
- int endFoldBlock; // End of current fold block
- int firstChangeableLineBefore; // First line that triggers repaint before starting line that determined current fold block
- int firstChangeableLineAfter; // First line that triggers repaint after starting line that determined current fold block
+ Sci::Line beginFoldBlock; // Begin of current fold block
+ Sci::Line endFoldBlock; // End of current fold block
+ Sci::Line firstChangeableLineBefore; // First line that triggers repaint before starting line that determined current fold block
+ Sci::Line firstChangeableLineAfter; // First line that triggers repaint after starting line that determined current fold block
bool isEnabled;
};
@@ -185,7 +178,7 @@ public:
}
virtual ~LexInterface() {
}
- void Colourise(int start, int end);
+ void Colourise(Sci::Position start, Sci::Position end);
int LineEndTypesSupported();
bool UseContainerLexing() const {
return instance == 0;
@@ -218,7 +211,7 @@ private:
CellBuffer cb;
CharClassify charClass;
CaseFolder *pcf;
- int endStyled;
+ Sci::Position endStyled;
int styleClock;
int enteredModification;
int enteredStyling;
@@ -278,8 +271,8 @@ public:
int GetLineEndTypesAllowed() const { return cb.GetLineEndTypes(); }
bool SetLineEndTypesAllowed(int lineEndBitSet_);
int GetLineEndTypesActive() const { return cb.GetLineEndTypes(); }
- virtual void InsertLine(int line);
- virtual void RemoveLine(int line);
+ virtual void InsertLine(Sci::Line line);
+ virtual void RemoveLine(Sci::Line line);
int SCI_METHOD Version() const {
return dvLineEnd;
@@ -288,18 +281,18 @@ public:
void SCI_METHOD SetErrorStatus(int status);
Sci_Position SCI_METHOD LineFromPosition(Sci_Position pos) const;
- int ClampPositionIntoDocument(int pos) const;
- bool ContainsLineEnd(const char *s, int length) const { return cb.ContainsLineEnd(s, length); }
- bool IsCrLf(int pos) const;
- int LenChar(int pos);
- bool InGoodUTF8(int pos, int &start, int &end) const;
- int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
- int NextPosition(int pos, int moveDir) const;
- bool NextCharacter(int &pos, int moveDir) const; // Returns true if pos changed
- Document::CharacterExtracted CharacterAfter(int position) const;
- Document::CharacterExtracted CharacterBefore(int position) const;
+ Sci::Position ClampPositionIntoDocument(Sci::Position pos) const;
+ bool ContainsLineEnd(const char *s, Sci::Position length) const { return cb.ContainsLineEnd(s, length); }
+ bool IsCrLf(Sci::Position pos) const;
+ int LenChar(Sci::Position pos);
+ bool InGoodUTF8(Sci::Position pos, Sci::Position &start, Sci::Position &end) const;
+ Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd=true) const;
+ Sci::Position NextPosition(Sci::Position pos, int moveDir) const;
+ bool NextCharacter(Sci::Position &pos, int moveDir) const; // Returns true if pos changed
+ Document::CharacterExtracted CharacterAfter(Sci::Position position) const;
+ Document::CharacterExtracted CharacterBefore(Sci::Position position) const;
Sci_Position SCI_METHOD GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const;
- int GetRelativePositionUTF16(int positionStart, int characterOffset) const;
+ Sci::Position GetRelativePositionUTF16(Sci::Position positionStart, Sci::Position characterOffset) const;
int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const;
int SCI_METHOD CodePage() const;
bool SCI_METHOD IsDBCSLeadByte(char ch) const;
@@ -307,15 +300,15 @@ public:
EncodingFamily CodePageFamily() const;
// Gateways to modifying document
- void ModifiedAt(int pos);
+ void ModifiedAt(Sci::Position pos);
void CheckReadOnly();
- bool DeleteChars(int pos, int len);
- int InsertString(int position, const char *s, int insertLength);
- void ChangeInsertion(const char *s, int length);
+ bool DeleteChars(Sci::Position pos, Sci::Position len);
+ Sci::Position InsertString(Sci::Position position, const char *s, Sci::Position insertLength);
+ void ChangeInsertion(const char *s, Sci::Position length);
int SCI_METHOD AddData(char *data, Sci_Position length);
void * SCI_METHOD ConvertToDocument();
- int Undo();
- int Redo();
+ Sci::Position Undo();
+ Sci::Position Redo();
bool CanUndo() const { return cb.CanUndo(); }
bool CanRedo() const { return cb.CanRedo(); }
void DeleteUndoHistory() { cb.DeleteUndoHistory(); }
@@ -325,7 +318,7 @@ public:
bool IsCollectingUndo() const { return cb.IsCollectingUndo(); }
void BeginUndoAction() { cb.BeginUndoAction(); }
void EndUndoAction() { cb.EndUndoAction(); }
- void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); }
+ void AddUndoAction(Sci::Position token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); }
void SetSavePoint();
bool IsSavePoint() const { return cb.IsSavePoint(); }
@@ -335,76 +328,76 @@ public:
bool TentativeActive() const { return cb.TentativeActive(); }
const char * SCI_METHOD BufferPointer() { return cb.BufferPointer(); }
- const char *RangePointer(int position, int rangeLength) { return cb.RangePointer(position, rangeLength); }
- int GapPosition() const { return cb.GapPosition(); }
+ const char *RangePointer(Sci::Position position, Sci::Position rangeLength) { return cb.RangePointer(position, rangeLength); }
+ Sci::Position GapPosition() const { return cb.GapPosition(); }
int SCI_METHOD GetLineIndentation(Sci_Position line);
- int SetLineIndentation(int line, int indent);
- int GetLineIndentPosition(int line) const;
- int GetColumn(int position);
- int CountCharacters(int startPos, int endPos) const;
- int CountUTF16(int startPos, int endPos) const;
- int FindColumn(int line, int column);
- void Indent(bool forwards, int lineBottom, int lineTop);
+ Sci::Position SetLineIndentation(Sci::Line line, Sci::Position indent);
+ Sci::Position GetLineIndentPosition(Sci::Line line) const;
+ Sci::Position GetColumn(Sci::Position position);
+ Sci::Position CountCharacters(Sci::Position startPos, Sci::Position endPos) const;
+ Sci::Position CountUTF16(Sci::Position startPos, Sci::Position endPos) const;
+ Sci::Position FindColumn(Sci::Line line, Sci::Position column);
+ void Indent(bool forwards, Sci::Line lineBottom, Sci::Line lineTop);
static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted);
void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
bool IsReadOnly() const { return cb.IsReadOnly(); }
- void DelChar(int pos);
- void DelCharBack(int pos);
+ void DelChar(Sci::Position pos);
+ void DelCharBack(Sci::Position pos);
- char CharAt(int position) const { return cb.CharAt(position); }
+ char CharAt(Sci::Position position) const { return cb.CharAt(position); }
void SCI_METHOD GetCharRange(char *buffer, Sci_Position position, Sci_Position lengthRetrieve) const {
cb.GetCharRange(buffer, position, lengthRetrieve);
}
char SCI_METHOD StyleAt(Sci_Position position) const { return cb.StyleAt(position); }
int StyleIndexAt(Sci_Position position) const { return static_cast<unsigned char>(cb.StyleAt(position)); }
- void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const {
+ void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
cb.GetStyleRange(buffer, position, lengthRetrieve);
}
- int GetMark(int line);
- int MarkerNext(int lineStart, int mask) const;
- int AddMark(int line, int markerNum);
- void AddMarkSet(int line, int valueSet);
- void DeleteMark(int line, int markerNum);
+ int GetMark(Sci::Line line);
+ Sci::Line MarkerNext(Sci::Line lineStart, int mask) const;
+ int AddMark(Sci::Line line, int markerNum);
+ void AddMarkSet(Sci::Line line, int valueSet);
+ void DeleteMark(Sci::Line line, int markerNum);
void DeleteMarkFromHandle(int markerHandle);
void DeleteAllMarks(int markerNum);
- int LineFromHandle(int markerHandle);
+ Sci::Line LineFromHandle(int markerHandle);
Sci_Position SCI_METHOD LineStart(Sci_Position line) const;
- bool IsLineStartPosition(int position) const;
+ bool IsLineStartPosition(Sci::Position position) const;
Sci_Position SCI_METHOD LineEnd(Sci_Position line) const;
- int LineEndPosition(int position) const;
- bool IsLineEndPosition(int position) const;
- bool IsPositionInLineEnd(int position) const;
- int VCHomePosition(int position) const;
+ Sci::Position LineEndPosition(Sci::Position position) const;
+ bool IsLineEndPosition(Sci::Position position) const;
+ bool IsPositionInLineEnd(Sci::Position position) const;
+ Sci::Position VCHomePosition(Sci::Position position) const;
int SCI_METHOD SetLevel(Sci_Position line, int level);
int SCI_METHOD GetLevel(Sci_Position line) const;
void ClearLevels();
- int GetLastChild(int lineParent, int level=-1, int lastLine=-1);
- int GetFoldParent(int line) const;
- void GetHighlightDelimiters(HighlightDelimiter &hDelimiter, int line, int lastLine);
+ Sci::Line GetLastChild(Sci::Line lineParent, int level=-1, Sci::Line lastLine=-1);
+ Sci::Line GetFoldParent(Sci::Line line) const;
+ void GetHighlightDelimiters(HighlightDelimiter &hDelimiter, Sci::Line line, Sci::Line lastLine);
void Indent(bool forwards);
- int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false) const;
- int NextWordStart(int pos, int delta) const;
- int NextWordEnd(int pos, int delta) const;
+ Sci::Position ExtendWordSelect(Sci::Position pos, int delta, bool onlyWordCharacters=false) const;
+ Sci::Position NextWordStart(Sci::Position pos, int delta) const;
+ Sci::Position NextWordEnd(Sci::Position pos, int delta) const;
Sci_Position SCI_METHOD Length() const { return cb.Length(); }
- void Allocate(int newSize) { cb.Allocate(newSize); }
+ void Allocate(Sci::Position newSize) { cb.Allocate(newSize); }
- CharacterExtracted ExtractCharacter(int position) const;
+ CharacterExtracted ExtractCharacter(Sci::Position position) const;
- bool IsWordStartAt(int pos) const;
- bool IsWordEndAt(int pos) const;
- bool IsWordAt(int start, int end) const;
+ bool IsWordStartAt(Sci::Position pos) const;
+ bool IsWordEndAt(Sci::Position pos) const;
+ bool IsWordAt(Sci::Position start, Sci::Position end) const;
- bool MatchesWordOptions(bool word, bool wordStart, int pos, int length) const;
+ bool MatchesWordOptions(bool word, bool wordStart, Sci::Position pos, Sci::Position length) const;
bool HasCaseFolder() const;
void SetCaseFolder(CaseFolder *pcf_);
- long FindText(int minPos, int maxPos, const char *search, int flags, int *length);
- const char *SubstituteByPosition(const char *text, int *length);
- int LinesTotal() const;
+ long FindText(Sci::Position minPos, Sci::Position maxPos, const char *search, int flags, Sci::Position *length);
+ const char *SubstituteByPosition(const char *text, Sci::Position *length);
+ Sci::Line LinesTotal() const;
void SetDefaultCharClasses(bool includeWordClass);
void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
@@ -412,9 +405,9 @@ public:
void SCI_METHOD StartStyling(Sci_Position position, char mask);
bool SCI_METHOD SetStyleFor(Sci_Position length, char style);
bool SCI_METHOD SetStyles(Sci_Position length, const char *styles);
- int GetEndStyled() const { return endStyled; }
- void EnsureStyledTo(int pos);
- void StyleToAdjustingLineDuration(int pos);
+ Sci::Position GetEndStyled() const { return endStyled; }
+ void EnsureStyledTo(Sci::Position pos);
+ void StyleToAdjustingLineDuration(Sci::Position pos);
void LexerChanged();
int GetStyleClock() const { return styleClock; }
void IncrementStyleClock();
@@ -425,20 +418,20 @@ public:
int SCI_METHOD SetLineState(Sci_Position line, int state);
int SCI_METHOD GetLineState(Sci_Position line) const;
- int GetMaxLineState();
+ Sci::Line GetMaxLineState();
void SCI_METHOD ChangeLexerState(Sci_Position start, Sci_Position end);
- StyledText MarginStyledText(int line) const;
- void MarginSetStyle(int line, int style);
- void MarginSetStyles(int line, const unsigned char *styles);
- void MarginSetText(int line, const char *text);
+ StyledText MarginStyledText(Sci::Line line) const;
+ void MarginSetStyle(Sci::Line line, int style);
+ void MarginSetStyles(Sci::Line line, const unsigned char *styles);
+ void MarginSetText(Sci::Line line, const char *text);
void MarginClearAll();
- StyledText AnnotationStyledText(int line) const;
- void AnnotationSetText(int line, const char *text);
- void AnnotationSetStyle(int line, int style);
- void AnnotationSetStyles(int line, const unsigned char *styles);
- int AnnotationLines(int line) const;
+ StyledText AnnotationStyledText(Sci::Line line) const;
+ void AnnotationSetText(Sci::Line line, const char *text);
+ void AnnotationSetStyle(Sci::Line line, int style);
+ void AnnotationSetStyles(Sci::Line line, const unsigned char *styles);
+ int AnnotationLines(Sci::Line line) const;
void AnnotationClearAll();
bool AddWatcher(DocWatcher *watcher, void *userData);
@@ -447,14 +440,14 @@ public:
bool IsASCIIWordByte(unsigned char ch) const;
CharClassify::cc WordCharacterClass(unsigned int ch) const;
bool IsWordPartSeparator(unsigned int ch) const;
- int WordPartLeft(int pos) const;
- int WordPartRight(int pos) const;
- int ExtendStyleRange(int pos, int delta, bool singleLine = false);
- bool IsWhiteLine(int line) const;
- int ParaUp(int pos) const;
- int ParaDown(int pos) const;
+ Sci::Position WordPartLeft(Sci::Position pos) const;
+ Sci::Position WordPartRight(Sci::Position pos) const;
+ Sci::Position ExtendStyleRange(Sci::Position pos, int delta, bool singleLine = false);
+ bool IsWhiteLine(Sci::Line line) const;
+ Sci::Position ParaUp(Sci::Position pos) const;
+ Sci::Position ParaDown(Sci::Position pos) const;
int IndentSize() const { return actualIndentInChars; }
- int BraceMatch(int position, int maxReStyle);
+ Sci::Position BraceMatch(Sci::Position position, Sci::Position maxReStyle);
private:
void NotifyModifyAttempt();
@@ -491,18 +484,18 @@ public:
class DocModification {
public:
int modificationType;
- int position;
- int length;
- int linesAdded; /**< Negative if lines deleted. */
+ Sci::Position position;
+ Sci::Position length;
+ Sci::Line linesAdded; /**< Negative if lines deleted. */
const char *text; /**< Only valid for changes to text, not for changes to style. */
- int line;
+ Sci::Line line;
int foldLevelNow;
int foldLevelPrev;
- int annotationLinesAdded;
- int token;
+ Sci::Line annotationLinesAdded;
+ Sci::Position token;
- DocModification(int modificationType_, int position_=0, int length_=0,
- int linesAdded_=0, const char *text_=0, int line_=0) :
+ DocModification(int modificationType_, Sci::Position position_=0, Sci::Position length_=0,
+ Sci::Line linesAdded_=0, const char *text_=0, Sci::Line line_=0) :
modificationType(modificationType_),
position(position_),
length(length_),
@@ -514,7 +507,7 @@ public:
annotationLinesAdded(0),
token(0) {}
- DocModification(int modificationType_, const Action &act, int linesAdded_=0) :
+ DocModification(int modificationType_, const Action &act, Sci::Line linesAdded_=0) :
modificationType(modificationType_),
position(act.position),
length(act.lenData),
@@ -539,7 +532,7 @@ public:
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
- virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
+ virtual void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos) = 0;
virtual void NotifyLexerChanged(Document *doc, void *userData) = 0;
virtual void NotifyErrorOccurred(Document *doc, void *userData, int status) = 0;
};
diff --git a/src/EditModel.cxx b/src/EditModel.cxx
index 0f64e07f9..59ae18977 100644
--- a/src/EditModel.cxx
+++ b/src/EditModel.cxx
@@ -57,17 +57,17 @@ EditModel::EditModel() {
inOverstrike = false;
xOffset = 0;
trackLineWidth = false;
- posDrag = SelectionPosition(invalidPosition);
- braces[0] = invalidPosition;
- braces[1] = invalidPosition;
+ posDrag = SelectionPosition(Sci::invalidPosition);
+ braces[0] = Sci::invalidPosition;
+ braces[1] = Sci::invalidPosition;
bracesMatchStyle = STYLE_BRACEBAD;
highlightGuideColumn = 0;
primarySelection = true;
imeInteraction = imeWindowed;
foldFlags = 0;
foldDisplayTextStyle = SC_FOLDDISPLAYTEXT_HIDDEN;
- hotspot = Range(invalidPosition);
- hoverIndicatorPos = invalidPosition;
+ hotspot = Range(Sci::invalidPosition);
+ hoverIndicatorPos = Sci::invalidPosition;
wrapWidth = LineLayout::wrapWidthInfinite;
pdoc = new Document();
pdoc->AddRef();
diff --git a/src/EditModel.h b/src/EditModel.h
index 847fd728d..b67eadd3f 100644
--- a/src/EditModel.h
+++ b/src/EditModel.h
@@ -36,7 +36,7 @@ public:
SpecialRepresentations reprs;
Caret caret;
SelectionPosition posDrag;
- Position braces[2];
+ Sci::Position braces[2];
int bracesMatchStyle;
int highlightGuideColumn;
Selection sel;
@@ -49,7 +49,7 @@ public:
ContractionState cs;
// Hotspot support
Range hotspot;
- int hoverIndicatorPos;
+ Sci::Position hoverIndicatorPos;
// Wrapping support
int wrapWidth;
@@ -58,9 +58,9 @@ public:
EditModel();
virtual ~EditModel();
- virtual int TopLineOfMain() const = 0;
+ virtual Sci::Line TopLineOfMain() const = 0;
virtual Point GetVisibleOriginInMain() const = 0;
- virtual int LinesOnScreen() const = 0;
+ virtual Sci::Line LinesOnScreen() const = 0;
virtual Range GetHotSpotRange() const = 0;
};
diff --git a/src/EditView.cxx b/src/EditView.cxx
index e73781016..b6102223c 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -222,19 +222,19 @@ void EditView::ClearAllTabstops() {
ldTabstops = 0;
}
-XYPOSITION EditView::NextTabstopPos(int line, XYPOSITION x, XYPOSITION tabWidth) const {
+XYPOSITION EditView::NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const {
int next = GetNextTabstop(line, static_cast<int>(x + tabWidthMinimumPixels));
if (next > 0)
return static_cast<XYPOSITION>(next);
return (static_cast<int>((x + tabWidthMinimumPixels) / tabWidth) + 1) * tabWidth;
}
-bool EditView::ClearTabstops(int line) {
+bool EditView::ClearTabstops(Sci::Line line) {
LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops);
return lt && lt->ClearTabstops(line);
}
-bool EditView::AddTabstop(int line, int x) {
+bool EditView::AddTabstop(Sci::Line line, int x) {
if (!ldTabstops) {
ldTabstops = new LineTabstops();
}
@@ -242,7 +242,7 @@ bool EditView::AddTabstop(int line, int x) {
return lt && lt->AddTabstop(line, x);
}
-int EditView::GetNextTabstop(int line, int x) const {
+int EditView::GetNextTabstop(Sci::Line line, int x) const {
LineTabstops *lt = static_cast<LineTabstops *>(ldTabstops);
if (lt) {
return lt->GetNextTabstop(line, x);
@@ -251,14 +251,14 @@ int EditView::GetNextTabstop(int line, int x) const {
}
}
-void EditView::LinesAddedOrRemoved(int lineOfPos, int linesAdded) {
+void EditView::LinesAddedOrRemoved(Sci::Line lineOfPos, Sci::Line linesAdded) {
if (ldTabstops) {
if (linesAdded > 0) {
- for (int line = lineOfPos; line < lineOfPos + linesAdded; line++) {
+ for (Sci::Line line = lineOfPos; line < lineOfPos + linesAdded; line++) {
ldTabstops->InsertLine(line);
}
} else {
- for (int line = (lineOfPos + -linesAdded) - 1; line >= lineOfPos; line--) {
+ for (Sci::Line line = (lineOfPos + -linesAdded) - 1; line >= lineOfPos; line--) {
ldTabstops->RemoveLine(line);
}
}
@@ -345,11 +345,11 @@ void EditView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewSt
}
}
-LineLayout *EditView::RetrieveLineLayout(int lineNumber, const EditModel &model) {
- int posLineStart = model.pdoc->LineStart(lineNumber);
- int posLineEnd = model.pdoc->LineStart(lineNumber + 1);
+LineLayout *EditView::RetrieveLineLayout(Sci::Line lineNumber, const EditModel &model) {
+ Sci::Position posLineStart = model.pdoc->LineStart(lineNumber);
+ Sci::Position posLineEnd = model.pdoc->LineStart(lineNumber + 1);
PLATFORM_ASSERT(posLineEnd >= posLineStart);
- int lineCaret = model.pdoc->LineFromPosition(model.sel.MainCaret());
+ Sci::Line lineCaret = model.pdoc->LineFromPosition(model.sel.MainCaret());
return llc.Retrieve(lineNumber, lineCaret,
posLineEnd - posLineStart, model.pdoc->GetStyleClock(),
model.LinesOnScreen() + 1, model.pdoc->LinesTotal());
@@ -360,20 +360,20 @@ LineLayout *EditView::RetrieveLineLayout(int lineNumber, const EditModel &model)
* Copy the given @a line and its styles from the document into local arrays.
* Also determine the x position at which each character starts.
*/
-void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width) {
+void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width) {
if (!ll)
return;
PLATFORM_ASSERT(line < model.pdoc->LinesTotal());
PLATFORM_ASSERT(ll->chars != NULL);
- int posLineStart = model.pdoc->LineStart(line);
- int posLineEnd = model.pdoc->LineStart(line + 1);
+ Sci::Position posLineStart = model.pdoc->LineStart(line);
+ Sci::Position posLineEnd = model.pdoc->LineStart(line + 1);
// If the line is very long, limit the treatment to a length that should fit in the viewport
if (posLineEnd >(posLineStart + ll->maxLineLength)) {
posLineEnd = posLineStart + ll->maxLineLength;
}
if (ll->validity == LineLayout::llCheckTextAndStyle) {
- int lineLength = posLineEnd - posLineStart;
+ Sci::Position lineLength = posLineEnd - posLineStart;
if (!vstyle.viewEOL) {
lineLength = model.pdoc->LineEnd(line) - posLineStart;
}
@@ -384,7 +384,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co
int styleByte = 0;
int numCharsInLine = 0;
while (numCharsInLine < lineLength) {
- int charInDoc = numCharsInLine + posLineStart;
+ Sci::Position charInDoc = numCharsInLine + posLineStart;
char chDoc = model.pdoc->CharAt(charInDoc);
styleByte = model.pdoc->StyleIndexAt(charInDoc);
allSame = allSame &&
@@ -436,7 +436,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co
model.pdoc->GetStyleRange(ll->styles, posLineStart, lineLength);
int numCharsBeforeEOL = model.pdoc->LineEnd(line) - posLineStart;
const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL;
- for (int styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) {
+ for (Sci::Position styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) {
const unsigned char styleByte = ll->styles[styleInLine];
ll->styles[styleInLine] = styleByte;
}
@@ -503,7 +503,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co
lastSegItalics = (!ts.representation) && ((ll->chars[ts.end() - 1] != ' ') && vstyle.styles[ll->styles[ts.start]].italic);
}
- for (int posToIncrease = ts.start + 1; posToIncrease <= ts.end(); posToIncrease++) {
+ for (Sci::Position posToIncrease = ts.start + 1; posToIncrease <= ts.end(); posToIncrease++) {
ll->positions[posToIncrease] += ll->positions[ts.start];
}
}
@@ -600,19 +600,19 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co
}
}
-Point EditView::LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine,
+Point EditView::LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, Sci::Line topLine,
const ViewStyle &vs, PointEnd pe) {
Point pt;
if (pos.Position() == INVALID_POSITION)
return pt;
- int lineDoc = model.pdoc->LineFromPosition(pos.Position());
- int posLineStart = model.pdoc->LineStart(lineDoc);
+ Sci::Line lineDoc = model.pdoc->LineFromPosition(pos.Position());
+ Sci::Position posLineStart = model.pdoc->LineStart(lineDoc);
if ((pe & peLineEnd) && (lineDoc > 0) && (pos.Position() == posLineStart)) {
// Want point at end of first line
lineDoc--;
posLineStart = model.pdoc->LineStart(lineDoc);
}
- const int lineVisible = model.cs.DisplayFromDoc(lineDoc);
+ const Sci::Line lineVisible = model.cs.DisplayFromDoc(lineDoc);
AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model));
if (surface && ll) {
LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth);
@@ -625,17 +625,17 @@ Point EditView::LocationFromPosition(Surface *surface, const EditModel &model, S
return pt;
}
-Range EditView::RangeDisplayLine(Surface *surface, const EditModel &model, int lineVisible, const ViewStyle &vs) {
+Range EditView::RangeDisplayLine(Surface *surface, const EditModel &model, Sci::Line lineVisible, const ViewStyle &vs) {
Range rangeSubLine = Range(0,0);
if (lineVisible < 0) {
return rangeSubLine;
}
- const int lineDoc = model.cs.DocFromDisplay(lineVisible);
- const int positionLineStart = model.pdoc->LineStart(lineDoc);
+ const Sci::Line lineDoc = model.cs.DocFromDisplay(lineVisible);
+ const Sci::Position positionLineStart = model.pdoc->LineStart(lineDoc);
AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model));
if (surface && ll) {
LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth);
- const int lineStartSet = model.cs.DisplayFromDoc(lineDoc);
+ const Sci::Line lineStartSet = model.cs.DisplayFromDoc(lineDoc);
const int subLine = lineVisible - lineStartSet;
if (subLine < ll->lines) {
rangeSubLine = ll->SubLineRange(subLine);
@@ -652,26 +652,26 @@ Range EditView::RangeDisplayLine(Surface *surface, const EditModel &model, int l
SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditModel &model, PointDocument pt, bool canReturnInvalid, bool charPosition, bool virtualSpace, const ViewStyle &vs) {
pt.x = pt.x - vs.textStart;
- int visibleLine = static_cast<int>(floor(pt.y / vs.lineHeight));
+ Sci::Line visibleLine = static_cast<int>(floor(pt.y / vs.lineHeight));
if (!canReturnInvalid && (visibleLine < 0))
visibleLine = 0;
- const int lineDoc = model.cs.DocFromDisplay(visibleLine);
+ const Sci::Line lineDoc = model.cs.DocFromDisplay(visibleLine);
if (canReturnInvalid && (lineDoc < 0))
return SelectionPosition(INVALID_POSITION);
if (lineDoc >= model.pdoc->LinesTotal())
return SelectionPosition(canReturnInvalid ? INVALID_POSITION : model.pdoc->Length());
- const int posLineStart = model.pdoc->LineStart(lineDoc);
+ const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc);
AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model));
if (surface && ll) {
LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth);
- const int lineStartSet = model.cs.DisplayFromDoc(lineDoc);
+ const Sci::Line lineStartSet = model.cs.DisplayFromDoc(lineDoc);
const int subLine = visibleLine - lineStartSet;
if (subLine < ll->lines) {
const Range rangeSubLine = ll->SubLineRange(subLine);
const XYPOSITION subLineStart = ll->positions[rangeSubLine.start];
if (subLine > 0) // Wrapped
pt.x -= ll->wrapIndent;
- const int positionInLine = ll->FindPositionFromX(static_cast<XYPOSITION>(pt.x + subLineStart),
+ const Sci::Position positionInLine = ll->FindPositionFromX(static_cast<XYPOSITION>(pt.x + subLineStart),
rangeSubLine, charPosition);
if (positionInLine < rangeSubLine.end) {
return SelectionPosition(model.pdoc->MovePositionOutsideChar(positionInLine + posLineStart, 1));
@@ -700,14 +700,14 @@ SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditMo
* Ensure is between whole characters when document is in multi-byte or UTF-8 mode.
* This method is used for rectangular selections and does not work on wrapped lines.
*/
-SelectionPosition EditView::SPositionFromLineX(Surface *surface, const EditModel &model, int lineDoc, int x, const ViewStyle &vs) {
+SelectionPosition EditView::SPositionFromLineX(Surface *surface, const EditModel &model, Sci::Line lineDoc, int x, const ViewStyle &vs) {
AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model));
if (surface && ll) {
- const int posLineStart = model.pdoc->LineStart(lineDoc);
+ const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc);
LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth);
const Range rangeSubLine = ll->SubLineRange(0);
const XYPOSITION subLineStart = ll->positions[rangeSubLine.start];
- const int positionInLine = ll->FindPositionFromX(x + subLineStart, rangeSubLine, false);
+ const Sci::Position positionInLine = ll->FindPositionFromX(x + subLineStart, rangeSubLine, false);
if (positionInLine < rangeSubLine.end) {
return SelectionPosition(model.pdoc->MovePositionOutsideChar(positionInLine + posLineStart, 1));
}
@@ -719,14 +719,14 @@ SelectionPosition EditView::SPositionFromLineX(Surface *surface, const EditModel
return SelectionPosition(0);
}
-int EditView::DisplayFromPosition(Surface *surface, const EditModel &model, int pos, const ViewStyle &vs) {
- int lineDoc = model.pdoc->LineFromPosition(pos);
- int lineDisplay = model.cs.DisplayFromDoc(lineDoc);
+Sci::Line EditView::DisplayFromPosition(Surface *surface, const EditModel &model, int pos, const ViewStyle &vs) {
+ 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);
- unsigned int posLineStart = model.pdoc->LineStart(lineDoc);
- int posInLine = pos - posLineStart;
+ Sci::Position posLineStart = model.pdoc->LineStart(lineDoc);
+ 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)) {
@@ -737,14 +737,14 @@ int EditView::DisplayFromPosition(Surface *surface, const EditModel &model, int
return lineDisplay;
}
-int EditView::StartEndDisplayLine(Surface *surface, const EditModel &model, int pos, bool start, const ViewStyle &vs) {
- int line = model.pdoc->LineFromPosition(pos);
+Sci::Position EditView::StartEndDisplayLine(Surface *surface, const EditModel &model, Sci::Position pos, bool start, const ViewStyle &vs) {
+ Sci::Line line = model.pdoc->LineFromPosition(pos);
AutoLineLayout ll(llc, RetrieveLineLayout(line, model));
- int posRet = INVALID_POSITION;
+ Sci::Position posRet = INVALID_POSITION;
if (surface && ll) {
- unsigned int posLineStart = model.pdoc->LineStart(line);
+ Sci::Position posLineStart = model.pdoc->LineStart(line);
LayoutLine(model, line, surface, vs, ll, model.wrapWidth);
- int posInLine = pos - posLineStart;
+ Sci::Position posInLine = pos - posLineStart;
if (posInLine <= ll->maxLineLength) {
for (int subLine = 0; subLine < ll->lines; subLine++) {
if ((posInLine >= ll->LineStart(subLine)) &&
@@ -772,7 +772,7 @@ static ColourDesired SelectionBackground(const ViewStyle &vsDraw, bool main, boo
}
static ColourDesired TextBackground(const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- ColourOptional background, int inSelection, bool inHotspot, int styleMain, int i) {
+ ColourOptional background, int inSelection, bool inHotspot, int styleMain, Sci::Position i) {
if (inSelection == 1) {
if (vsDraw.selColours.back.isSet && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
return SelectionBackground(vsDraw, true, model.primarySelection);
@@ -796,7 +796,7 @@ static ColourDesired TextBackground(const EditModel &model, const ViewStyle &vsD
}
}
-void EditView::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight) {
+void EditView::DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, Sci::Position start, PRectangle rcSegment, bool highlight) {
Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0);
PRectangle rcCopyArea = PRectangle::FromInts(start + 1, static_cast<int>(rcSegment.top), start + 2, static_cast<int>(rcSegment.bottom));
surface->Copy(rcCopyArea, from,
@@ -836,10 +836,10 @@ static void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle r
}
void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- PRectangle rcLine, int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
+ PRectangle rcLine, Sci::Line line, Sci::Position lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
ColourOptional background) {
- const int posLineStart = model.pdoc->LineStart(line);
+ const Sci::Position posLineStart = model.pdoc->LineStart(line);
PRectangle rcSegment = rcLine;
const bool lastSubLine = subLine == (ll->lines - 1);
@@ -879,7 +879,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
int eolInSelection = 0;
int alpha = SC_ALPHA_NOALPHA;
if (!hideSelection) {
- int posAfterLineEnd = model.pdoc->LineStart(line + 1);
+ Sci::Position posAfterLineEnd = model.pdoc->LineStart(line + 1);
eolInSelection = (lastSubLine == true) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0;
alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
}
@@ -887,7 +887,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
// Draw the [CR], [LF], or [CR][LF] blobs if visible line ends are on
XYPOSITION blobsWidth = 0;
if (lastSubLine) {
- for (int eolPos = ll->numCharsBeforeEOL; eolPos<ll->numCharsInLine; eolPos++) {
+ for (Sci::Position eolPos = ll->numCharsBeforeEOL; eolPos<ll->numCharsInLine; eolPos++) {
rcSegment.left = xStart + ll->positions[eolPos] - static_cast<XYPOSITION>(subLineStart)+virtualSpace;
rcSegment.right = xStart + ll->positions[eolPos + 1] - static_cast<XYPOSITION>(subLineStart)+virtualSpace;
blobsWidth += rcSegment.Width();
@@ -987,8 +987,8 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
}
}
-static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw,
- const LineLayout *ll, int xStart, PRectangle rcLine, int secondCharacter, int subLine, Indicator::DrawState drawState, int value) {
+static void DrawIndicator(int indicNum, Sci::Position startPos, Sci::Position endPos, Surface *surface, const ViewStyle &vsDraw,
+ const LineLayout *ll, int xStart, PRectangle rcLine, Sci::Position secondCharacter, int subLine, Indicator::DrawState drawState, int value) {
const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)];
PRectangle rcIndic(
ll->positions[startPos] + xStart - subLineStart,
@@ -1008,26 +1008,26 @@ static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surfa
}
static void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, int xStart, PRectangle rcLine, int subLine, int lineEnd, bool under, int hoverIndicatorPos) {
+ Sci::Line line, int xStart, PRectangle rcLine, int subLine, Sci::Position lineEnd, bool under, Sci::Position hoverIndicatorPos) {
// Draw decorators
- const int posLineStart = model.pdoc->LineStart(line);
- const int lineStart = ll->LineStart(subLine);
- const int posLineEnd = posLineStart + lineEnd;
+ const Sci::Position posLineStart = model.pdoc->LineStart(line);
+ const Sci::Position lineStart = ll->LineStart(subLine);
+ const Sci::Position posLineEnd = posLineStart + lineEnd;
for (Decoration *deco = model.pdoc->decorations.root; deco; deco = deco->next) {
if (under == vsDraw.indicators[deco->indicator].under) {
- int startPos = posLineStart + lineStart;
+ Sci::Position startPos = posLineStart + lineStart;
if (!deco->rs.ValueAt(startPos)) {
startPos = deco->rs.EndRun(startPos);
}
while ((startPos < posLineEnd) && (deco->rs.ValueAt(startPos))) {
const Range rangeRun(deco->rs.StartRun(startPos), deco->rs.EndRun(startPos));
- const int endPos = std::min(rangeRun.end, posLineEnd);
+ const Sci::Position endPos = std::min(rangeRun.end, posLineEnd);
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 int posSecond = model.pdoc->MovePositionOutsideChar(rangeRun.First() + 1, 1);
+ 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);
startPos = endPos;
@@ -1045,16 +1045,16 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
if (under == vsDraw.indicators[braceIndicator].under) {
Range rangeLine(posLineStart + lineStart, posLineEnd);
if (rangeLine.ContainsCharacter(model.braces[0])) {
- int braceOffset = model.braces[0] - posLineStart;
+ Sci::Position braceOffset = model.braces[0] - posLineStart;
if (braceOffset < ll->numCharsInLine) {
- const int secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[0] + 1, 1) - posLineStart;
+ const Sci::Position secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[0] + 1, 1) - posLineStart;
DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1);
}
}
if (rangeLine.ContainsCharacter(model.braces[1])) {
- int braceOffset = model.braces[1] - posLineStart;
+ Sci::Position braceOffset = model.braces[1] - posLineStart;
if (braceOffset < ll->numCharsInLine) {
- const int secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[1] + 1, 1) - posLineStart;
+ const Sci::Position secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[1] + 1, 1) - posLineStart;
DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1);
}
}
@@ -1063,7 +1063,7 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
}
void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase) {
+ Sci::Line line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase) {
const bool lastSubLine = subLine == (ll->lines - 1);
if (!lastSubLine)
return;
@@ -1080,7 +1080,7 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
int eolInSelection = 0;
int alpha = SC_ALPHA_NOALPHA;
if (!hideSelection) {
- int posAfterLineEnd = model.pdoc->LineStart(line + 1);
+ Sci::Position posAfterLineEnd = model.pdoc->LineStart(line + 1);
eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0;
alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
}
@@ -1159,7 +1159,7 @@ static bool AnnotationBoxedOrIndented(int annotationVisible) {
}
void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) {
+ Sci::Line line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) {
int indent = static_cast<int>(model.pdoc->GetLineIndentation(line) * vsDraw.spaceWidth);
PRectangle rcSegment = rcLine;
int annotationLine = subLine - ll->lines;
@@ -1216,18 +1216,18 @@ void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const Vi
}
static void DrawBlockCaret(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) {
+ int subLine, int xStart, Sci::Position offset, Sci::Position posCaret, PRectangle rcCaret, ColourDesired caretColour) {
- int lineStart = ll->LineStart(subLine);
- int posBefore = posCaret;
- int posAfter = model.pdoc->MovePositionOutsideChar(posCaret + 1, 1);
- int numCharsToDraw = posAfter - posCaret;
+ Sci::Position lineStart = ll->LineStart(subLine);
+ Sci::Position posBefore = posCaret;
+ Sci::Position posAfter = model.pdoc->MovePositionOutsideChar(posCaret + 1, 1);
+ Sci::Position numCharsToDraw = posAfter - posCaret;
// Work out where the starting and ending offsets are. We need to
// see if the previous character shares horizontal space, such as a
// glyph / combining character. If so we'll need to draw that too.
- int offsetFirstChar = offset;
- int offsetLastChar = offset + (posAfter - posCaret);
+ Sci::Position offsetFirstChar = offset;
+ Sci::Position offsetLastChar = offset + (posAfter - posCaret);
while ((posBefore > 0) && ((offsetLastChar - numCharsToDraw) >= lineStart)) {
if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - numCharsToDraw]) > 0) {
// The char does not share horizontal space
@@ -1282,12 +1282,12 @@ static void DrawBlockCaret(Surface *surface, const EditModel &model, const ViewS
}
void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int lineDoc, int xStart, PRectangle rcLine, int subLine) const {
+ 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();
if (hideSelection && !drawDrag)
return;
- const int posLineStart = model.pdoc->LineStart(lineDoc);
+ const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc);
// For each selection draw
for (size_t r = 0; (r<model.sel.Count()) || drawDrag; r++) {
const bool mainCaret = r == model.sel.Main();
@@ -1304,7 +1304,7 @@ 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) {
- int lineStart = ll->LineStart(subLine);
+ Sci::Position lineStart = ll->LineStart(subLine);
if (lineStart != 0) // Wrapped
xposCaret += ll->wrapIndent;
}
@@ -1399,7 +1399,7 @@ static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, c
}
void EditView::DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- PRectangle rcLine, Range lineRange, int posLineStart, int xStart,
+ PRectangle rcLine, Range lineRange, Sci::Position posLineStart, int xStart,
int subLine, ColourOptional background) const {
const bool selBackDrawn = vsDraw.SelectionBackgroundDrawn();
@@ -1416,8 +1416,8 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
while (bfBack.More()) {
const TextSegment ts = bfBack.Next();
- const int i = ts.end() - 1;
- const int iDoc = i + posLineStart;
+ const Sci::Position i = ts.end() - 1;
+ const Sci::Position iDoc = i + posLineStart;
PRectangle rcSegment = rcLine;
rcSegment.left = ll->positions[ts.start] + xStart - static_cast<XYPOSITION>(subLineStart);
@@ -1498,7 +1498,7 @@ static void DrawEdgeLine(Surface *surface, const ViewStyle &vsDraw, const LineLa
// Draw underline mark as part of background if not transparent
static void DrawMarkUnderline(Surface *surface, const EditModel &model, const ViewStyle &vsDraw,
- int line, PRectangle rcLine) {
+ Sci::Line line, PRectangle rcLine) {
int marks = model.pdoc->GetMark(line);
for (int markBit = 0; (markBit < 32) && marks; markBit++) {
if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) &&
@@ -1511,12 +1511,12 @@ static void DrawMarkUnderline(Surface *surface, const EditModel &model, const Vi
}
}
static void DrawTranslucentSelection(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, PRectangle rcLine, int subLine, Range lineRange, int xStart) {
+ Sci::Line line, PRectangle rcLine, int subLine, Range lineRange, int xStart) {
if ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha != SC_ALPHA_NOALPHA)) {
- const int posLineStart = model.pdoc->LineStart(line);
+ const Sci::Position posLineStart = model.pdoc->LineStart(line);
const XYACCUMULATOR subLineStart = ll->positions[lineRange.start];
// For each selection draw
- int virtualSpaces = 0;
+ Sci::Position virtualSpaces = 0;
if (subLine == (ll->lines - 1)) {
virtualSpaces = model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line));
}
@@ -1550,7 +1550,7 @@ static void DrawTranslucentSelection(Surface *surface, const EditModel &model, c
// Draw any translucent whole line states
static void DrawTranslucentLineState(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, PRectangle rcLine) {
+ Sci::Line line, PRectangle rcLine) {
if ((model.caret.active || vsDraw.alwaysShowCaretLineBackground) && vsDraw.showCaretLineBackground && ll->containsCaret) {
SimpleAlphaRectangle(surface, rcLine, vsDraw.caretLineBackground, vsDraw.caretLineAlpha);
}
@@ -1578,7 +1578,7 @@ static void DrawTranslucentLineState(Surface *surface, const EditModel &model, c
}
void EditView::DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int lineVisible, PRectangle rcLine, Range lineRange, int posLineStart, int xStart,
+ Sci::Line lineVisible, PRectangle rcLine, Range lineRange, Sci::Position posLineStart, int xStart,
int subLine, ColourOptional background) {
const bool selBackDrawn = vsDraw.SelectionBackgroundDrawn();
@@ -1598,8 +1598,8 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
while (bfFore.More()) {
const TextSegment ts = bfFore.Next();
- const int i = ts.end() - 1;
- const int iDoc = i + posLineStart;
+ const Sci::Position i = ts.end() - 1;
+ const Sci::Position iDoc = i + posLineStart;
PRectangle rcSegment = rcLine;
rcSegment.left = ll->positions[ts.start] + xStart - static_cast<XYPOSITION>(subLineStart);
@@ -1770,16 +1770,16 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
}
void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, int lineVisible, PRectangle rcLine, int xStart, int subLine) {
+ Sci::Line line, Sci::Line lineVisible, PRectangle rcLine, int xStart, int subLine) {
if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth)
&& (subLine == 0)) {
- const int posLineStart = model.pdoc->LineStart(line);
+ const Sci::Position posLineStart = model.pdoc->LineStart(line);
int indentSpace = model.pdoc->GetLineIndentation(line);
int xStartText = static_cast<int>(ll->positions[model.pdoc->GetLineIndentPosition(line) - posLineStart]);
// Find the most recent line with some text
- int lineLastWithText = line;
+ Sci::Line lineLastWithText = line;
while (lineLastWithText > Platform::Maximum(line - 20, 0) && model.pdoc->IsWhiteLine(lineLastWithText)) {
lineLastWithText--;
}
@@ -1802,7 +1802,7 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode
}
}
- int lineNextWithText = line;
+ Sci::Line lineNextWithText = line;
while (lineNextWithText < Platform::Minimum(line + 20, model.pdoc->LinesTotal()) && model.pdoc->IsWhiteLine(lineNextWithText)) {
lineNextWithText++;
}
@@ -1824,7 +1824,7 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode
}
void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, int lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) {
+ Sci::Line line, Sci::Line lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) {
if (subLine >= ll->lines) {
DrawAnnotation(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, phase);
@@ -1834,7 +1834,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
// See if something overrides the line background color.
const ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
- const int posLineStart = model.pdoc->LineStart(line);
+ const Sci::Position posLineStart = model.pdoc->LineStart(line);
const Range lineRange = ll->SubLineRange(subLine);
const XYACCUMULATOR subLineStart = ll->positions[lineRange.start];
@@ -1894,7 +1894,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
}
}
-static void DrawFoldLines(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, int line, PRectangle rcLine) {
+static void DrawFoldLines(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, Sci::Line line, PRectangle rcLine) {
bool expanded = model.cs.GetExpanded(line);
const int level = model.pdoc->GetLevel(line);
const int levelNext = model.pdoc->GetLevel(line + 1);
@@ -1944,7 +1944,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
SelectionPosition posCaret = model.sel.RangeMain().caret;
if (model.posDrag.IsValid())
posCaret = model.posDrag;
- const int lineCaret = model.pdoc->LineFromPosition(posCaret.Position());
+ const Sci::Line lineCaret = model.pdoc->LineFromPosition(posCaret.Position());
PRectangle rcTextArea = rcClient;
if (vsDraw.marginInside) {
@@ -1971,7 +1971,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
const bool bracesIgnoreStyle = ((vsDraw.braceHighlightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACELIGHT)) ||
(vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACEBAD)));
- int lineDocPrevious = -1; // Used to avoid laying out one document line multiple times
+ Sci::Line lineDocPrevious = -1; // Used to avoid laying out one document line multiple times
AutoLineLayout ll(llc, 0);
std::vector<DrawPhase> phases;
if ((phasesDraw == phasesMultiple) && !bufferedDraw) {
@@ -1986,13 +1986,13 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
if (!bufferedDraw)
ypos += screenLinePaintFirst * vsDraw.lineHeight;
int yposScreen = screenLinePaintFirst * vsDraw.lineHeight;
- int visibleLine = model.TopLineOfMain() + screenLinePaintFirst;
+ Sci::Line visibleLine = model.TopLineOfMain() + screenLinePaintFirst;
while (visibleLine < model.cs.LinesDisplayed() && yposScreen < rcArea.bottom) {
- const int lineDoc = model.cs.DocFromDisplay(visibleLine);
+ const Sci::Line lineDoc = model.cs.DocFromDisplay(visibleLine);
// Only visible lines should be handled by the code within the loop
PLATFORM_ASSERT(model.cs.GetVisible(lineDoc));
- const int lineStartSet = model.cs.DisplayFromDoc(lineDoc);
+ const Sci::Line lineStartSet = model.cs.DisplayFromDoc(lineDoc);
const int subLine = visibleLine - lineStartSet;
// Copy this line and its styles from the document into local arrays
@@ -2099,11 +2099,11 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
}
void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, PRectangle rcArea, int subLine) const {
+ Sci::Line line, PRectangle rcArea, int subLine) const {
int eolInSelection = 0;
int alpha = SC_ALPHA_NOALPHA;
if (!hideSelection) {
- int posAfterLineEnd = model.pdoc->LineStart(line + 1);
+ Sci::Position posAfterLineEnd = model.pdoc->LineStart(line + 1);
eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0;
alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
}
@@ -2212,17 +2212,17 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface,
vsPrint.Refresh(*surfaceMeasure, model.pdoc->tabInChars); // Recalculate fixedColumnWidth
}
- int linePrintStart = model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMin));
- int linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1;
+ Sci::Line linePrintStart = model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMin));
+ Sci::Line linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1;
if (linePrintLast < linePrintStart)
linePrintLast = linePrintStart;
- int linePrintMax = model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMax));
+ Sci::Line linePrintMax = model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMax));
if (linePrintLast > linePrintMax)
linePrintLast = linePrintMax;
//Platform::DebugPrintf("Formatting lines=[%0d,%0d,%0d] top=%0d bottom=%0d line=%0d %0d\n",
// linePrintStart, linePrintLast, linePrintMax, pfr->rc.top, pfr->rc.bottom, vsPrint.lineHeight,
// surfaceMeasure->Height(vsPrint.styles[STYLE_LINENUMBER].font));
- int endPosPrint = model.pdoc->Length();
+ Sci::Position endPosPrint = model.pdoc->Length();
if (linePrintLast < model.pdoc->LinesTotal())
endPosPrint = model.pdoc->LineStart(linePrintLast + 1);
@@ -2232,9 +2232,9 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface,
int xStart = vsPrint.fixedColumnWidth + pfr->rc.left;
int ypos = pfr->rc.top;
- int lineDoc = linePrintStart;
+ Sci::Line lineDoc = linePrintStart;
- int nPrintPos = static_cast<int>(pfr->chrg.cpMin);
+ Sci::Position nPrintPos = static_cast<Sci::Position>(pfr->chrg.cpMin);
int visibleLine = 0;
int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth;
if (printParameters.wrapState == eWrapNone)
@@ -2265,7 +2265,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) {
- int startWithinLine = nPrintPos - model.pdoc->LineStart(lineDoc);
+ 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/EditView.h b/src/EditView.h
index 9bdf1b86c..172a1ddbc 100644
--- a/src/EditView.h
+++ b/src/EditView.h
@@ -97,53 +97,53 @@ public:
bool LinesOverlap() const;
void ClearAllTabstops();
- XYPOSITION NextTabstopPos(int line, XYPOSITION x, XYPOSITION tabWidth) const;
- bool ClearTabstops(int line);
- bool AddTabstop(int line, int x);
- int GetNextTabstop(int line, int x) const;
- void LinesAddedOrRemoved(int lineOfPos, int linesAdded);
+ XYPOSITION NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const;
+ bool ClearTabstops(Sci::Line line);
+ bool AddTabstop(Sci::Line line, int x);
+ int GetNextTabstop(Sci::Line line, int x) const;
+ void LinesAddedOrRemoved(Sci::Line lineOfPos, Sci::Line linesAdded);
void DropGraphics(bool freeObjects);
void AllocateGraphics(const ViewStyle &vsDraw);
void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw);
- LineLayout *RetrieveLineLayout(int lineNumber, const EditModel &model);
- void LayoutLine(const EditModel &model, int line, Surface *surface, const ViewStyle &vstyle,
+ LineLayout *RetrieveLineLayout(Sci::Line lineNumber, const EditModel &model);
+ void LayoutLine(const EditModel &model, Sci::Line line, Surface *surface, const ViewStyle &vstyle,
LineLayout *ll, int width = LineLayout::wrapWidthInfinite);
- Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine,
+ Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, Sci::Line topLine,
const ViewStyle &vs, PointEnd pe);
- Range RangeDisplayLine(Surface *surface, const EditModel &model, int lineVisible, const ViewStyle &vs);
+ Range RangeDisplayLine(Surface *surface, const EditModel &model, Sci::Line lineVisible, const ViewStyle &vs);
SelectionPosition SPositionFromLocation(Surface *surface, const EditModel &model, PointDocument pt, bool canReturnInvalid,
bool charPosition, bool virtualSpace, const ViewStyle &vs);
- SelectionPosition SPositionFromLineX(Surface *surface, const EditModel &model, int lineDoc, int x, const ViewStyle &vs);
- int DisplayFromPosition(Surface *surface, const EditModel &model, int pos, const ViewStyle &vs);
- int StartEndDisplayLine(Surface *surface, const EditModel &model, int pos, bool start, const ViewStyle &vs);
+ SelectionPosition SPositionFromLineX(Surface *surface, const EditModel &model, Sci::Line lineDoc, int x, const ViewStyle &vs);
+ Sci::Line DisplayFromPosition(Surface *surface, const EditModel &model, int pos, const ViewStyle &vs);
+ Sci::Position StartEndDisplayLine(Surface *surface, const EditModel &model, Sci::Position pos, bool start, const ViewStyle &vs);
- void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
+ void DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, Sci::Position start, PRectangle rcSegment, bool highlight);
void DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine,
- int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
+ Sci::Line line, Sci::Position lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
ColourOptional background);
void DrawFoldDisplayText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase);
+ Sci::Line line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase);
void DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
- void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line,
+ Sci::Line line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
+ void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line line,
int xStart, PRectangle rcLine, int subLine) const;
void DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine,
- Range lineRange, int posLineStart, int xStart,
+ Range lineRange, Sci::Position posLineStart, int xStart,
int subLine, ColourOptional background) const;
- void DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int lineVisible,
- PRectangle rcLine, Range lineRange, int posLineStart, int xStart,
+ void DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line lineVisible,
+ PRectangle rcLine, Range lineRange, Sci::Position posLineStart, int xStart,
int subLine, ColourOptional background);
void DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, int lineVisible, PRectangle rcLine, int xStart, int subLine);
- void DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line,
- int lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
+ Sci::Line line, Sci::Line lineVisible, PRectangle rcLine, int xStart, int subLine);
+ void DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line line,
+ Sci::Line lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
void PaintText(Surface *surfaceWindow, const EditModel &model, PRectangle rcArea, PRectangle rcClient,
const ViewStyle &vsDraw);
void FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
- int line, PRectangle rcArea, int subLine) const;
+ Sci::Line line, PRectangle rcArea, int subLine) const;
long FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure,
const EditModel &model, const ViewStyle &vs);
};
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 35bbc10fe..21c8fdf40 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -123,7 +123,7 @@ Editor::Editor() {
ptMouseLast.y = 0;
inDragDrop = ddNone;
dropWentOutside = false;
- posDrop = SelectionPosition(invalidPosition);
+ posDrop = SelectionPosition(Sci::invalidPosition);
hotSpotClickPos = INVALID_POSITION;
selectionType = selChar;
@@ -296,7 +296,7 @@ PointDocument Editor::DocumentPointFromView(Point ptView) const {
return ptDocument;
}
-int Editor::TopLineOfMain() const {
+Sci::Line Editor::TopLineOfMain() const {
if (wMargin.GetID())
return 0;
else
@@ -319,25 +319,25 @@ PRectangle Editor::GetTextRectangle() const {
return rc;
}
-int Editor::LinesOnScreen() const {
+Sci::Line Editor::LinesOnScreen() const {
PRectangle rcClient = GetClientRectangle();
int htClient = static_cast<int>(rcClient.bottom - rcClient.top);
//Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1);
return htClient / vs.lineHeight;
}
-int Editor::LinesToScroll() const {
- int retVal = LinesOnScreen() - 1;
+Sci::Line Editor::LinesToScroll() const {
+ Sci::Line retVal = LinesOnScreen() - 1;
if (retVal < 1)
return 1;
else
return retVal;
}
-int Editor::MaxScrollPos() const {
+Sci::Line Editor::MaxScrollPos() const {
//Platform::DebugPrintf("Lines %d screen = %d maxScroll = %d\n",
//LinesTotal(), LinesOnScreen(), LinesTotal() - LinesOnScreen() + 1);
- int retVal = cs.LinesDisplayed();
+ Sci::Line retVal = cs.LinesDisplayed();
if (endAtLastLine) {
retVal -= LinesOnScreen();
} else {
@@ -369,11 +369,11 @@ Point Editor::LocationFromPosition(SelectionPosition pos, PointEnd pe) {
return view.LocationFromPosition(surface, *this, pos, topLine, vs, pe);
}
-Point Editor::LocationFromPosition(int pos, PointEnd pe) {
+Point Editor::LocationFromPosition(Sci::Position pos, PointEnd pe) {
return LocationFromPosition(SelectionPosition(pos), pe);
}
-int Editor::XFromPosition(int pos) {
+int Editor::XFromPosition(Sci::Position pos) {
Point pt = LocationFromPosition(pos);
return static_cast<int>(pt.x) - vs.textStart + xOffset;
}
@@ -403,7 +403,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
return view.SPositionFromLocation(surface, *this, ptdoc, canReturnInvalid, charPosition, virtualSpace, vs);
}
-int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) {
+Sci::Position Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) {
return SPositionFromLocation(pt, canReturnInvalid, charPosition, false).Position();
}
@@ -412,7 +412,7 @@ int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosit
* Ensure is between whole characters when document is in multi-byte or UTF-8 mode.
* This method is used for rectangular selections and does not work on wrapped lines.
*/
-SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) {
+SelectionPosition Editor::SPositionFromLineX(Sci::Line lineDoc, int x) {
RefreshStyleData();
if (lineDoc >= pdoc->LinesTotal())
return SelectionPosition(pdoc->Length());
@@ -421,15 +421,15 @@ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) {
return view.SPositionFromLineX(surface, *this, lineDoc, x, vs);
}
-int Editor::PositionFromLineX(int lineDoc, int x) {
+Sci::Position Editor::PositionFromLineX(Sci::Line lineDoc, int x) {
return SPositionFromLineX(lineDoc, x).Position();
}
-int Editor::LineFromLocation(Point pt) const {
+Sci::Line Editor::LineFromLocation(Point pt) const {
return cs.DocFromDisplay(static_cast<int>(pt.y) / vs.lineHeight + topLine);
}
-void Editor::SetTopLine(int topLineNew) {
+void Editor::SetTopLine(Sci::Line topLineNew) {
if ((topLine != topLineNew) && (topLineNew >= 0)) {
topLine = topLineNew;
ContainerNeedsUpdate(SC_UPDATE_V_SCROLL);
@@ -480,7 +480,7 @@ void Editor::Redraw() {
//wMain.InvalidateAll();
}
-void Editor::RedrawSelMargin(int line, bool allAfter) {
+void Editor::RedrawSelMargin(Sci::Line line, bool allAfter) {
const bool markersInText = vs.maskInLine || vs.maskDrawInText;
if (!wMargin.GetID() || markersInText) { // May affect text area so may need to abandon and retry
if (AbandonPaint()) {
@@ -526,8 +526,8 @@ void Editor::RedrawSelMargin(int line, bool allAfter) {
}
PRectangle Editor::RectangleFromRange(Range r, int overlap) {
- const int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(r.First()));
- const int maxLine = cs.DisplayLastFromDoc(pdoc->LineFromPosition(r.Last()));
+ const Sci::Line minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(r.First()));
+ const Sci::Line maxLine = cs.DisplayLastFromDoc(pdoc->LineFromPosition(r.Last()));
const PRectangle rcClientDrawing = GetClientDrawingRectangle();
PRectangle rc;
const int leftTextOverlap = ((xOffset == 0) && (vs.leftMarginWidth > 0)) ? 1 : 0;
@@ -542,11 +542,11 @@ PRectangle Editor::RectangleFromRange(Range r, int overlap) {
return rc;
}
-void Editor::InvalidateRange(int start, int end) {
+void Editor::InvalidateRange(Sci::Position start, Sci::Position end) {
RedrawRect(RectangleFromRange(Range(start, end), view.LinesOverlap() ? vs.lineOverlap : 0));
}
-int Editor::CurrentPosition() const {
+Sci::Position Editor::CurrentPosition() const {
return sel.MainCaret();
}
@@ -569,10 +569,10 @@ void Editor::SetRectangularRange() {
if (sel.selType == Selection::selThin) {
xCaret = xAnchor;
}
- int lineAnchorRect = pdoc->LineFromPosition(sel.Rectangular().anchor.Position());
- int lineCaret = pdoc->LineFromPosition(sel.Rectangular().caret.Position());
+ Sci::Line lineAnchorRect = pdoc->LineFromPosition(sel.Rectangular().anchor.Position());
+ Sci::Line lineCaret = pdoc->LineFromPosition(sel.Rectangular().caret.Position());
int increment = (lineCaret > lineAnchorRect) ? 1 : -1;
- for (int line=lineAnchorRect; line != lineCaret+increment; line += increment) {
+ for (Sci::Line line=lineAnchorRect; line != lineCaret+increment; line += increment) {
SelectionRange range(SPositionFromLineX(line, xCaret), SPositionFromLineX(line, xAnchor));
if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) == 0)
range.ClearVirtualSpace();
@@ -600,9 +600,9 @@ void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSel
if (sel.Count() > 1 || !(sel.RangeMain().anchor == newMain.anchor) || sel.IsRectangular()) {
invalidateWholeSelection = true;
}
- int firstAffected = Platform::Minimum(sel.RangeMain().Start().Position(), newMain.Start().Position());
+ Sci::Position firstAffected = Platform::Minimum(sel.RangeMain().Start().Position(), newMain.Start().Position());
// +1 for lastAffected ensures caret repainted
- int lastAffected = Platform::Maximum(newMain.caret.Position()+1, newMain.anchor.Position());
+ Sci::Position lastAffected = Platform::Maximum(newMain.caret.Position()+1, newMain.anchor.Position());
lastAffected = Platform::Maximum(lastAffected, sel.RangeMain().End().Position());
if (invalidateWholeSelection) {
for (size_t r=0; r<sel.Count(); r++) {
@@ -623,7 +623,7 @@ void Editor::InvalidateWholeSelection() {
void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) {
currentPos_ = ClampPositionIntoDocument(currentPos_);
anchor_ = ClampPositionIntoDocument(anchor_);
- int currentLine = pdoc->LineFromPosition(currentPos_.Position());
+ Sci::Line currentLine = pdoc->LineFromPosition(currentPos_.Position());
/* For Line selection - ensure the anchor and caret are always
at the beginning and end of the region lines. */
if (sel.selType == Selection::selLines) {
@@ -650,14 +650,14 @@ void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition ancho
QueueIdleWork(WorkNeeded::workUpdateUI);
}
-void Editor::SetSelection(int currentPos_, int anchor_) {
+void Editor::SetSelection(Sci::Position currentPos_, Sci::Position anchor_) {
SetSelection(SelectionPosition(currentPos_), SelectionPosition(anchor_));
}
// Just move the caret on the main selection
void Editor::SetSelection(SelectionPosition currentPos_) {
currentPos_ = ClampPositionIntoDocument(currentPos_);
- int currentLine = pdoc->LineFromPosition(currentPos_.Position());
+ Sci::Line currentLine = pdoc->LineFromPosition(currentPos_.Position());
if (sel.Count() > 1 || !(sel.RangeMain().caret == currentPos_)) {
InvalidateSelection(SelectionRange(currentPos_));
}
@@ -683,7 +683,7 @@ void Editor::SetSelection(int currentPos_) {
}
void Editor::SetEmptySelection(SelectionPosition currentPos_) {
- int currentLine = pdoc->LineFromPosition(currentPos_.Position());
+ Sci::Line currentLine = pdoc->LineFromPosition(currentPos_.Position());
SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_));
if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) {
InvalidateSelection(rangeNew);
@@ -700,15 +700,15 @@ void Editor::SetEmptySelection(SelectionPosition currentPos_) {
QueueIdleWork(WorkNeeded::workUpdateUI);
}
-void Editor::SetEmptySelection(int currentPos_) {
+void Editor::SetEmptySelection(Sci::Position currentPos_) {
SetEmptySelection(SelectionPosition(currentPos_));
}
void Editor::MultipleSelectAdd(AddNumber addNumber) {
if (SelectionEmpty() || !multipleSelection) {
// Select word at caret
- const int startWord = pdoc->ExtendWordSelect(sel.MainCaret(), -1, true);
- const int endWord = pdoc->ExtendWordSelect(startWord, 1, true);
+ const Sci::Position startWord = pdoc->ExtendWordSelect(sel.MainCaret(), -1, true);
+ const Sci::Position endWord = pdoc->ExtendWordSelect(startWord, 1, true);
TrimAndSetSelection(endWord, startWord);
} else {
@@ -736,11 +736,11 @@ void Editor::MultipleSelectAdd(AddNumber addNumber) {
}
for (std::vector<Range>::const_iterator it = searchRanges.begin(); it != searchRanges.end(); ++it) {
- int searchStart = it->start;
- const int searchEnd = it->end;
+ Sci::Position searchStart = it->start;
+ const Sci::Position searchEnd = it->end;
for (;;) {
- int lengthFound = static_cast<int>(selectedText.length());
- int pos = static_cast<int>(pdoc->FindText(searchStart, searchEnd,
+ Sci::Position lengthFound = static_cast<Sci::Position>(selectedText.length());
+ Sci::Position pos = static_cast<Sci::Position>(pdoc->FindText(searchStart, searchEnd,
selectedText.c_str(), searchFlags, &lengthFound));
if (pos >= 0) {
sel.AddSelection(SelectionRange(pos + lengthFound, pos));
@@ -757,14 +757,14 @@ void Editor::MultipleSelectAdd(AddNumber addNumber) {
}
}
-bool Editor::RangeContainsProtected(int start, int end) const {
+bool Editor::RangeContainsProtected(Sci::Position start, Sci::Position end) const {
if (vs.ProtectionActive()) {
if (start > end) {
- int t = start;
+ Sci::Position t = start;
start = end;
end = t;
}
- for (int pos = start; pos < end; pos++) {
+ for (Sci::Position pos = start; pos < end; pos++) {
if (vs.styles[pdoc->StyleIndexAt(pos)].IsProtected())
return true;
}
@@ -785,12 +785,12 @@ bool Editor::SelectionContainsProtected() {
/**
* Asks document to find a good position and then moves out of any invisible positions.
*/
-int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) const {
+Sci::Position Editor::MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd) const {
return MovePositionOutsideChar(SelectionPosition(pos), moveDir, checkLineEnd).Position();
}
-SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd) const {
- int posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd);
+SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, Sci::Position moveDir, bool checkLineEnd) const {
+ Sci::Position posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd);
if (posMoved != pos.Position())
pos.SetPosition(posMoved);
if (vs.ProtectionActive()) {
@@ -812,7 +812,7 @@ SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int mov
}
void Editor::MovedCaret(SelectionPosition newPos, SelectionPosition previousPos, bool ensureVisible) {
- const int currentLine = pdoc->LineFromPosition(newPos.Position());
+ const Sci::Line currentLine = pdoc->LineFromPosition(newPos.Position());
if (ensureVisible) {
// In case in need of wrapping to ensure DisplayFromDoc works.
if (currentLine >= wrapPending.start)
@@ -844,7 +844,7 @@ void Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt,
const SelectionPosition spCaret = ((sel.Count() == 1) && sel.Empty()) ?
sel.Last() : SelectionPosition(INVALID_POSITION);
- int delta = newPos.Position() - sel.MainCaret();
+ Sci::Position delta = newPos.Position() - sel.MainCaret();
newPos = ClampPositionIntoDocument(newPos);
newPos = MovePositionOutsideChar(newPos, delta);
if (!multipleSelection && sel.IsRectangular() && (selt == Selection::selStream)) {
@@ -871,18 +871,18 @@ void Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt,
MovedCaret(newPos, spCaret, ensureVisible);
}
-void Editor::MovePositionTo(int newPos, Selection::selTypes selt, bool ensureVisible) {
+void Editor::MovePositionTo(Sci::Position newPos, Selection::selTypes selt, bool ensureVisible) {
MovePositionTo(SelectionPosition(newPos), selt, ensureVisible);
}
SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveDir) {
pos = ClampPositionIntoDocument(pos);
pos = MovePositionOutsideChar(pos, moveDir);
- int lineDoc = pdoc->LineFromPosition(pos.Position());
+ Sci::Line lineDoc = pdoc->LineFromPosition(pos.Position());
if (cs.GetVisible(lineDoc)) {
return pos;
} else {
- int lineDisplay = cs.DisplayFromDoc(lineDoc);
+ Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
if (moveDir > 0) {
// lineDisplay is already line before fold as lines in fold use display line of line after fold
lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed());
@@ -894,7 +894,7 @@ SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveD
}
}
-SelectionPosition Editor::MovePositionSoVisible(int pos, int moveDir) {
+SelectionPosition Editor::MovePositionSoVisible(Sci::Position pos, int moveDir) {
return MovePositionSoVisible(SelectionPosition(pos), moveDir);
}
@@ -908,15 +908,15 @@ Point Editor::PointMainCaret() {
*/
void Editor::SetLastXChosen() {
Point pt = PointMainCaret();
- lastXChosen = static_cast<int>(pt.x) + xOffset;
+ lastXChosen = static_cast<Sci::Position>(pt.x) + xOffset;
}
-void Editor::ScrollTo(int line, bool moveThumb) {
- int topLineNew = Platform::Clamp(line, 0, MaxScrollPos());
+void Editor::ScrollTo(Sci::Line line, bool moveThumb) {
+ Sci::Line topLineNew = Platform::Clamp(line, 0, MaxScrollPos());
if (topLineNew != topLine) {
// Try to optimise small scrolls
#ifndef UNDER_CE
- int linesToMove = topLine - topLineNew;
+ Sci::Line linesToMove = topLine - topLineNew;
bool performBlit = (abs(linesToMove) <= 10) && (paintState == notPainting);
willRedrawAll = !performBlit;
#endif
@@ -941,7 +941,7 @@ void Editor::ScrollTo(int line, bool moveThumb) {
}
}
-void Editor::ScrollText(int /* linesToMove */) {
+void Editor::ScrollText(Sci::Line /* linesToMove */) {
//Platform::DebugPrintf("Editor::ScrollText %d\n", linesToMove);
Redraw();
}
@@ -959,9 +959,9 @@ void Editor::HorizontalScrollTo(int xPos) {
}
void Editor::VerticalCentreCaret() {
- int lineDoc = pdoc->LineFromPosition(sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret());
- int lineDisplay = cs.DisplayFromDoc(lineDoc);
- int newTop = lineDisplay - (LinesOnScreen() / 2);
+ 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);
if (topLine != newTop) {
SetTopLine(newTop > 0 ? newTop : 0);
RedrawRect(GetClientRectangle());
@@ -977,16 +977,16 @@ static int istrlen(const char *s) {
void Editor::MoveSelectedLines(int lineDelta) {
// if selection doesn't start at the beginning of the line, set the new start
- int selectionStart = SelectionStart().Position();
- int startLine = pdoc->LineFromPosition(selectionStart);
- int beginningOfStartLine = pdoc->LineStart(startLine);
+ Sci::Position selectionStart = SelectionStart().Position();
+ Sci::Line startLine = pdoc->LineFromPosition(selectionStart);
+ 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
- int selectionEnd = SelectionEnd().Position();
- int endLine = pdoc->LineFromPosition(selectionEnd);
- int beginningOfEndLine = pdoc->LineStart(endLine);
+ Sci::Position selectionEnd = SelectionEnd().Position();
+ Sci::Line endLine = pdoc->LineFromPosition(selectionEnd);
+ Sci::Position beginningOfEndLine = pdoc->LineStart(endLine);
bool appendEol = false;
if (selectionEnd > beginningOfEndLine
|| selectionStart == selectionEnd) {
@@ -1015,9 +1015,9 @@ void Editor::MoveSelectedLines(int lineDelta) {
SelectionText selectedText;
CopySelectionRange(&selectedText);
- int selectionLength = SelectionRange(selectionStart, selectionEnd).Length();
+ Sci::Position selectionLength = SelectionRange(selectionStart, selectionEnd).Length();
Point currentLocation = LocationFromPosition(CurrentPosition());
- int currentLine = LineFromLocation(currentLocation);
+ Sci::Line currentLine = LineFromLocation(currentLocation);
if (appendEol)
SetSelection(pdoc->MovePositionOutsideChar(selectionStart - 1, -1), selectionEnd);
@@ -1030,7 +1030,7 @@ void Editor::MoveSelectedLines(int lineDelta) {
selectionLength = pdoc->InsertString(CurrentPosition(), selectedText.Data(), selectionLength);
if (appendEol) {
- const int lengthInserted = pdoc->InsertString(CurrentPosition() + selectionLength, eol, istrlen(eol));
+ const Sci::Position lengthInserted = pdoc->InsertString(CurrentPosition() + selectionLength, eol, istrlen(eol));
selectionLength += lengthInserted;
}
SetSelection(CurrentPosition(), CurrentPosition() + selectionLength);
@@ -1053,7 +1053,7 @@ void Editor::MoveCaretInsideView(bool ensureVisible) {
false, false, UserVirtualSpace()),
Selection::noSel, ensureVisible);
} else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) {
- int yOfLastLineFullyDisplayed = static_cast<int>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight;
+ Sci::Position yOfLastLineFullyDisplayed = static_cast<Sci::Position>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight;
MovePositionTo(SPositionFromLocation(
Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top) + yOfLastLineFullyDisplayed),
false, false, UserVirtualSpace()),
@@ -1061,7 +1061,7 @@ void Editor::MoveCaretInsideView(bool ensureVisible) {
}
}
-int Editor::DisplayFromPosition(int pos) {
+Sci::Line Editor::DisplayFromPosition(Sci::Position pos) {
AutoSurface surface(this);
return view.DisplayFromPosition(surface, *this, pos, vs);
}
@@ -1130,9 +1130,9 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
// Vertical positioning
if ((options & xysVertical) && (pt.y < rcClient.top || ptBottomCaret.y >= rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) {
- const int lineCaret = DisplayFromPosition(range.caret.Position());
- const int linesOnScreen = LinesOnScreen();
- const int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2;
+ const Sci::Line lineCaret = DisplayFromPosition(range.caret.Position());
+ const Sci::Line linesOnScreen = LinesOnScreen();
+ const Sci::Line halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2;
const bool bSlop = (caretYPolicy & CARET_SLOP) != 0;
const bool bStrict = (caretYPolicy & CARET_STRICT) != 0;
const bool bJump = (caretYPolicy & CARET_JUMPS) != 0;
@@ -1141,9 +1141,9 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
// It should be possible to scroll the window to show the caret,
// but this fails to remove the caret on GTK+
if (bSlop) { // A margin is defined
- int yMoveT, yMoveB;
+ Sci::Line yMoveT, yMoveB;
if (bStrict) {
- int yMarginT, yMarginB;
+ Sci::Line yMarginT, yMarginB;
if (!(options & xysUseMargin)) {
// In drag mode, avoid moves
// otherwise, a double click will select several lines.
@@ -1215,7 +1215,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
}
}
if (!(range.caret == range.anchor)) {
- const int lineAnchor = DisplayFromPosition(range.anchor.Position());
+ const Sci::Line lineAnchor = DisplayFromPosition(range.anchor.Position());
if (lineAnchor < lineCaret) {
// Shift up to show anchor or as much of range as possible
newXY.topLine = std::min(newXY.topLine, lineAnchor);
@@ -1339,8 +1339,8 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
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<int>(ptAnchor.x + xOffset - rcClient.right) + 1;
- int maxOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 1;
+ int minOffset = static_cast<Sci::Position>(ptAnchor.x + xOffset - rcClient.right) + 1;
+ 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);
}
@@ -1366,7 +1366,7 @@ void Editor::SetXYScroll(XYScrollPosition newXY) {
PRectangle rcText = GetTextRectangle();
if (horizontalScrollBarVisible &&
rcText.Width() + xOffset > scrollWidth) {
- scrollWidth = xOffset + static_cast<int>(rcText.Width());
+ scrollWidth = xOffset + static_cast<Sci::Position>(rcText.Width());
SetScrollBars();
}
}
@@ -1449,7 +1449,7 @@ bool Editor::Wrapping() const {
return vs.wrapState != eWrapNone;
}
-void Editor::NeedWrapping(int docLineStart, int docLineEnd) {
+void Editor::NeedWrapping(Sci::Line docLineStart, Sci::Line docLineEnd) {
//Platform::DebugPrintf("\nNeedWrapping: %0d..%0d\n", docLineStart, docLineEnd);
if (wrapPending.AddRange(docLineStart, docLineEnd)) {
view.llc.Invalidate(LineLayout::llPositions);
@@ -1460,7 +1460,7 @@ void Editor::NeedWrapping(int docLineStart, int docLineEnd) {
}
}
-bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {
+bool Editor::WrapOneLine(Surface *surface, Sci::Line lineToWrap) {
AutoLineLayout ll(view.llc, view.RetrieveLineLayout(lineToWrap, *this));
int linesWrapped = 1;
if (ll) {
@@ -1477,12 +1477,12 @@ bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {
// wsIdle: wrap one page + 100 lines
// Return true if wrapping occurred.
bool Editor::WrapLines(WrapScope ws) {
- int goodTopLine = topLine;
+ Sci::Line goodTopLine = topLine;
bool wrapOccurred = false;
if (!Wrapping()) {
if (wrapWidth != LineLayout::wrapWidthInfinite) {
wrapWidth = LineLayout::wrapWidthInfinite;
- for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) {
+ for (Sci::Line lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) {
cs.SetHeight(lineDoc, 1 +
(vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0));
}
@@ -1497,9 +1497,9 @@ bool Editor::WrapLines(WrapScope ws) {
ws = WrapScope::wsAll;
}
// Decide where to start wrapping
- int lineToWrap = wrapPending.start;
- int lineToWrapEnd = std::min(wrapPending.end, pdoc->LinesTotal());
- const int lineDocTop = cs.DocFromDisplay(topLine);
+ Sci::Line lineToWrap = wrapPending.start;
+ Sci::Line lineToWrapEnd = std::min(wrapPending.end, pdoc->LinesTotal());
+ const Sci::Line lineDocTop = cs.DocFromDisplay(topLine);
const int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop);
if (ws == WrapScope::wsVisible) {
lineToWrap = Platform::Clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal());
@@ -1507,7 +1507,7 @@ bool Editor::WrapLines(WrapScope ws) {
// Since wrapping could reduce display lines, treat each
// as taking only one display line.
lineToWrapEnd = lineDocTop;
- int lines = LinesOnScreen() + 1;
+ Sci::Line lines = LinesOnScreen() + 1;
while ((lineToWrapEnd < cs.LinesInDoc()) && (lines>0)) {
if (cs.GetVisible(lineToWrapEnd))
lines--;
@@ -1521,7 +1521,7 @@ bool Editor::WrapLines(WrapScope ws) {
} else if (ws == WrapScope::wsIdle) {
lineToWrapEnd = lineToWrap + LinesOnScreen() + 100;
}
- const int lineEndNeedWrap = std::min(wrapPending.end, pdoc->LinesTotal());
+ const Sci::Line lineEndNeedWrap = std::min(wrapPending.end, pdoc->LinesTotal());
lineToWrapEnd = std::min(lineToWrapEnd, lineEndNeedWrap);
// Ensure all lines being wrapped are styled.
@@ -1569,13 +1569,13 @@ void Editor::LinesJoin() {
if (!RangeContainsProtected(targetStart, targetEnd)) {
UndoGroup ug(pdoc);
bool prevNonWS = true;
- for (int pos = targetStart; pos < targetEnd; pos++) {
+ for (Sci::Position pos = targetStart; pos < targetEnd; pos++) {
if (pdoc->IsPositionInLineEnd(pos)) {
targetEnd -= pdoc->LenChar(pos);
pdoc->DelChar(pos);
if (prevNonWS) {
// Ensure at least one space separating previous lines
- const int lengthInserted = pdoc->InsertString(pos, " ", 1);
+ const Sci::Position lengthInserted = pdoc->InsertString(pos, " ", 1);
targetEnd += lengthInserted;
}
} else {
@@ -1601,19 +1601,19 @@ void Editor::LinesSplit(int pixelWidth) {
PRectangle rcText = GetTextRectangle();
pixelWidth = static_cast<int>(rcText.Width());
}
- int lineStart = pdoc->LineFromPosition(targetStart);
- int lineEnd = pdoc->LineFromPosition(targetEnd);
+ Sci::Line lineStart = pdoc->LineFromPosition(targetStart);
+ Sci::Line lineEnd = pdoc->LineFromPosition(targetEnd);
const char *eol = StringFromEOLMode(pdoc->eolMode);
UndoGroup ug(pdoc);
- for (int line = lineStart; line <= lineEnd; line++) {
+ for (Sci::Line line = lineStart; line <= lineEnd; line++) {
AutoSurface surface(this);
AutoLineLayout ll(view.llc, view.RetrieveLineLayout(line, *this));
if (surface && ll) {
- unsigned int posLineStart = pdoc->LineStart(line);
+ Sci::Position posLineStart = pdoc->LineStart(line);
view.LayoutLine(*this, line, surface, vs, ll, pixelWidth);
- int lengthInsertedTotal = 0;
+ Sci::Position lengthInsertedTotal = 0;
for (int subLine = 1; subLine < ll->lines; subLine++) {
- const int lengthInserted = pdoc->InsertString(
+ const Sci::Position lengthInserted = pdoc->InsertString(
static_cast<int>(posLineStart + lengthInsertedTotal +
ll->LineStart(subLine)),
eol, istrlen(eol));
@@ -1803,8 +1803,8 @@ void Editor::ReconfigureScrollBars() {}
void Editor::SetScrollBars() {
RefreshStyleData();
- int nMax = MaxScrollPos();
- int nPage = LinesOnScreen();
+ Sci::Line nMax = MaxScrollPos();
+ Sci::Line nPage = LinesOnScreen();
bool modified = ModifyScrollBars(nMax + nPage - 1, nPage);
if (modified) {
DwellEnd(true);
@@ -1838,15 +1838,15 @@ void Editor::ChangeSize() {
}
}
-int Editor::RealizeVirtualSpace(int position, unsigned int virtualSpace) {
+Sci::Position Editor::RealizeVirtualSpace(Sci::Position position, Sci::Position virtualSpace) {
if (virtualSpace > 0) {
- const int line = pdoc->LineFromPosition(position);
- const int indent = pdoc->GetLineIndentPosition(line);
+ const Sci::Line line = pdoc->LineFromPosition(position);
+ const Sci::Position indent = pdoc->GetLineIndentPosition(line);
if (indent == position) {
return pdoc->SetLineIndentation(line, pdoc->GetLineIndentation(line) + virtualSpace);
} else {
std::string spaceText(virtualSpace, ' ');
- const int lengthInserted = pdoc->InsertString(position, spaceText.c_str(), virtualSpace);
+ const Sci::Position lengthInserted = pdoc->InsertString(position, spaceText.c_str(), virtualSpace);
position += lengthInserted;
}
}
@@ -1893,7 +1893,7 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
SelectionRange *currentSel = *rit;
if (!RangeContainsProtected(currentSel->Start().Position(),
currentSel->End().Position())) {
- int positionInsert = currentSel->Start().Position();
+ Sci::Position positionInsert = currentSel->Start().Position();
if (!currentSel->Empty()) {
if (currentSel->Length()) {
pdoc->DeleteChars(positionInsert, currentSel->Length());
@@ -1911,7 +1911,7 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
}
}
positionInsert = RealizeVirtualSpace(positionInsert, currentSel->caret.VirtualSpace());
- const int lengthInserted = pdoc->InsertString(positionInsert, s, len);
+ const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, s, len);
if (lengthInserted > 0) {
currentSel->caret.SetPosition(positionInsert + lengthInserted);
currentSel->anchor.SetPosition(positionInsert + lengthInserted);
@@ -1974,7 +1974,7 @@ void Editor::ClearBeforeTentativeStart() {
for (size_t r = 0; r<sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
- int positionInsert = sel.Range(r).Start().Position();
+ Sci::Position positionInsert = sel.Range(r).Start().Position();
if (!sel.Range(r).Empty()) {
if (sel.Range(r).Length()) {
pdoc->DeleteChars(positionInsert, sel.Range(r).Length());
@@ -1994,7 +1994,7 @@ void Editor::InsertPaste(const char *text, int len) {
if (multiPasteMode == SC_MULTIPASTE_ONCE) {
SelectionPosition selStart = sel.Start();
selStart = RealizeVirtualSpace(selStart);
- const int lengthInserted = pdoc->InsertString(selStart.Position(), text, len);
+ const Sci::Position lengthInserted = pdoc->InsertString(selStart.Position(), text, len);
if (lengthInserted > 0) {
SetEmptySelection(selStart.Position() + lengthInserted);
}
@@ -2003,7 +2003,7 @@ void Editor::InsertPaste(const char *text, int len) {
for (size_t r=0; r<sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
- int positionInsert = sel.Range(r).Start().Position();
+ Sci::Position positionInsert = sel.Range(r).Start().Position();
if (!sel.Range(r).Empty()) {
if (sel.Range(r).Length()) {
pdoc->DeleteChars(positionInsert, sel.Range(r).Length());
@@ -2014,7 +2014,7 @@ void Editor::InsertPaste(const char *text, int len) {
}
}
positionInsert = RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
- const int lengthInserted = pdoc->InsertString(positionInsert, text, len);
+ const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, text, len);
if (lengthInserted > 0) {
sel.Range(r).caret.SetPosition(positionInsert + lengthInserted);
sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted);
@@ -2037,8 +2037,8 @@ void Editor::InsertPasteShape(const char *text, int len, PasteShape shape) {
PasteRectangular(sel.Start(), text, len);
} else {
if (shape == pasteLine) {
- int insertPos = pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()));
- int lengthInserted = pdoc->InsertString(insertPos, text, len);
+ Sci::Position insertPos = pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()));
+ Sci::Position lengthInserted = pdoc->InsertString(insertPos, text, len);
// add the newline if necessary
if ((len > 0) && (text[len - 1] != '\n' && text[len - 1] != '\r')) {
const char *endline = StringFromEOLMode(pdoc->eolMode);
@@ -2127,20 +2127,20 @@ void Editor::Cut() {
}
}
-void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
+void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, Sci::Position len) {
if (pdoc->IsReadOnly() || SelectionContainsProtected()) {
return;
}
sel.Clear();
sel.RangeMain() = SelectionRange(pos);
- int line = pdoc->LineFromPosition(sel.MainCaret());
+ Sci::Line line = pdoc->LineFromPosition(sel.MainCaret());
UndoGroup ug(pdoc);
sel.RangeMain().caret = RealizeVirtualSpace(sel.RangeMain().caret);
int xInsert = XFromPosition(sel.RangeMain().caret);
bool prevCr = false;
while ((len > 0) && IsEOLChar(ptr[len-1]))
len--;
- for (int i = 0; i < len; i++) {
+ for (Sci::Position i = 0; i < len; i++) {
if (IsEOLChar(ptr[i])) {
if ((ptr[i] == '\r') || (!prevCr))
line++;
@@ -2155,13 +2155,13 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
if ((XFromPosition(sel.MainCaret()) < xInsert) && (i + 1 < len)) {
while (XFromPosition(sel.MainCaret()) < xInsert) {
assert(pdoc);
- const int lengthInserted = pdoc->InsertString(sel.MainCaret(), " ", 1);
+ const Sci::Position lengthInserted = pdoc->InsertString(sel.MainCaret(), " ", 1);
sel.RangeMain().caret.Add(lengthInserted);
}
}
prevCr = ptr[i] == '\r';
} else {
- const int lengthInserted = pdoc->InsertString(sel.MainCaret(), ptr + i, 1);
+ const Sci::Position lengthInserted = pdoc->InsertString(sel.MainCaret(), ptr + i, 1);
sel.RangeMain().caret.Add(lengthInserted);
prevCr = false;
}
@@ -2215,7 +2215,7 @@ void Editor::SelectAll() {
void Editor::Undo() {
if (pdoc->CanUndo()) {
InvalidateCaret();
- int newPos = pdoc->Undo();
+ Sci::Position newPos = pdoc->Undo();
if (newPos >= 0)
SetEmptySelection(newPos);
EnsureCaretVisible();
@@ -2224,7 +2224,7 @@ void Editor::Undo() {
void Editor::Redo() {
if (pdoc->CanRedo()) {
- int newPos = pdoc->Redo();
+ Sci::Position newPos = pdoc->Redo();
if (newPos >= 0)
SetEmptySelection(newPos);
EnsureCaretVisible();
@@ -2245,7 +2245,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
sel.Range(r).caret.SetVirtualSpace(sel.Range(r).caret.VirtualSpace() - 1);
sel.Range(r).anchor.SetVirtualSpace(sel.Range(r).caret.VirtualSpace());
} else {
- int lineCurrentPos = pdoc->LineFromPosition(sel.Range(r).caret.Position());
+ Sci::Line lineCurrentPos = pdoc->LineFromPosition(sel.Range(r).caret.Position());
if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != sel.Range(r).caret.Position())) {
if (pdoc->GetColumn(sel.Range(r).caret.Position()) <= pdoc->GetLineIndentation(lineCurrentPos) &&
pdoc->GetColumn(sel.Range(r).caret.Position()) > 0 && pdoc->backspaceUnindents) {
@@ -2255,7 +2255,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
int indentationChange = indentation % indentationStep;
if (indentationChange == 0)
indentationChange = indentationStep;
- const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationChange);
+ const Sci::Position posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationChange);
// SetEmptySelection
sel.Range(r) = SelectionRange(posSelect);
} else {
@@ -2296,14 +2296,14 @@ void Editor::SetCtrlID(int identifier) {
ctrlID = identifier;
}
-void Editor::NotifyStyleToNeeded(int endStyleNeeded) {
+void Editor::NotifyStyleToNeeded(Sci::Position endStyleNeeded) {
SCNotification scn = {};
scn.nmhdr.code = SCN_STYLENEEDED;
scn.position = endStyleNeeded;
NotifyParent(scn);
}
-void Editor::NotifyStyleNeeded(Document *, void *, int endStyleNeeded) {
+void Editor::NotifyStyleNeeded(Document *, void *, Sci::Position endStyleNeeded) {
NotifyStyleToNeeded(endStyleNeeded);
}
@@ -2350,7 +2350,7 @@ void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) {
NotifyDoubleClick(pt, ModifierFlags(shift, ctrl, alt));
}
-void Editor::NotifyHotSpotDoubleClicked(int position, int modifiers) {
+void Editor::NotifyHotSpotDoubleClicked(Sci::Position position, int modifiers) {
SCNotification scn = {};
scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK;
scn.position = position;
@@ -2358,11 +2358,11 @@ void Editor::NotifyHotSpotDoubleClicked(int position, int modifiers) {
NotifyParent(scn);
}
-void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) {
+void Editor::NotifyHotSpotDoubleClicked(Sci::Position position, bool shift, bool ctrl, bool alt) {
NotifyHotSpotDoubleClicked(position, ModifierFlags(shift, ctrl, alt));
}
-void Editor::NotifyHotSpotClicked(int position, int modifiers) {
+void Editor::NotifyHotSpotClicked(Sci::Position position, int modifiers) {
SCNotification scn = {};
scn.nmhdr.code = SCN_HOTSPOTCLICK;
scn.position = position;
@@ -2370,11 +2370,11 @@ void Editor::NotifyHotSpotClicked(int position, int modifiers) {
NotifyParent(scn);
}
-void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) {
+void Editor::NotifyHotSpotClicked(Sci::Position position, bool shift, bool ctrl, bool alt) {
NotifyHotSpotClicked(position, ModifierFlags(shift, ctrl, alt));
}
-void Editor::NotifyHotSpotReleaseClick(int position, int modifiers) {
+void Editor::NotifyHotSpotReleaseClick(Sci::Position position, int modifiers) {
SCNotification scn = {};
scn.nmhdr.code = SCN_HOTSPOTRELEASECLICK;
scn.position = position;
@@ -2382,7 +2382,7 @@ void Editor::NotifyHotSpotReleaseClick(int position, int modifiers) {
NotifyParent(scn);
}
-void Editor::NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt) {
+void Editor::NotifyHotSpotReleaseClick(Sci::Position position, bool shift, bool ctrl, bool alt) {
NotifyHotSpotReleaseClick(position, ModifierFlags(shift, ctrl, alt));
}
@@ -2404,7 +2404,7 @@ void Editor::NotifyPainted() {
NotifyParent(scn);
}
-void Editor::NotifyIndicatorClick(bool click, int position, int modifiers) {
+void Editor::NotifyIndicatorClick(bool click, Sci::Position position, int modifiers) {
int mask = pdoc->decorations.AllOnFor(position);
if ((click && mask) || pdoc->decorations.clickNotified) {
SCNotification scn = {};
@@ -2416,18 +2416,18 @@ void Editor::NotifyIndicatorClick(bool click, int position, int modifiers) {
}
}
-void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) {
+void Editor::NotifyIndicatorClick(bool click, Sci::Position position, bool shift, bool ctrl, bool alt) {
NotifyIndicatorClick(click, position, ModifierFlags(shift, ctrl, alt));
}
bool Editor::NotifyMarginClick(Point pt, int modifiers) {
const int marginClicked = vs.MarginFromLocation(pt);
if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) {
- int position = pdoc->LineStart(LineFromLocation(pt));
+ Sci::Position position = pdoc->LineStart(LineFromLocation(pt));
if ((vs.ms[marginClicked].mask & SC_MASK_FOLDERS) && (foldAutomatic & SC_AUTOMATICFOLD_CLICK)) {
const bool ctrl = (modifiers & SCI_CTRL) != 0;
const bool shift = (modifiers & SCI_SHIFT) != 0;
- int lineClick = pdoc->LineFromPosition(position);
+ Sci::Line lineClick = pdoc->LineFromPosition(position);
if (shift && ctrl) {
FoldAll(SC_FOLDACTION_TOGGLE);
} else {
@@ -2465,7 +2465,7 @@ bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) {
bool Editor::NotifyMarginRightClick(Point pt, int modifiers) {
int marginRightClicked = vs.MarginFromLocation(pt);
if ((marginRightClicked >= 0) && vs.ms[marginRightClicked].sensitive) {
- int position = pdoc->LineStart(LineFromLocation(pt));
+ Sci::Position position = pdoc->LineStart(LineFromLocation(pt));
SCNotification scn = {};
scn.nmhdr.code = SCN_MARGINRIGHTCLICK;
scn.modifiers = modifiers;
@@ -2478,7 +2478,7 @@ bool Editor::NotifyMarginRightClick(Point pt, int modifiers) {
}
}
-void Editor::NotifyNeedShown(int pos, int len) {
+void Editor::NotifyNeedShown(Sci::Position pos, Sci::Position len) {
SCNotification scn = {};
scn.nmhdr.code = SCN_NEEDSHOWN;
scn.position = pos;
@@ -2515,8 +2515,8 @@ void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) {
void Editor::CheckModificationForWrap(DocModification mh) {
if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
view.llc.Invalidate(LineLayout::llCheckTextAndStyle);
- int lineDoc = pdoc->LineFromPosition(mh.position);
- int lines = Platform::Maximum(0, mh.linesAdded);
+ Sci::Line lineDoc = pdoc->LineFromPosition(mh.position);
+ Sci::Line lines = std::max(static_cast<Sci::Line>(0), mh.linesAdded);
if (Wrapping()) {
NeedWrapping(lineDoc, lineDoc + lines + 1);
}
@@ -2527,7 +2527,7 @@ void Editor::CheckModificationForWrap(DocModification mh) {
}
// Move a position so it is still after the same character as before the insertion.
-static inline int MovePositionForInsertion(int position, int startInsertion, int length) {
+static inline Sci::Position MovePositionForInsertion(Sci::Position position, Sci::Position startInsertion, Sci::Position length) {
if (position > startInsertion) {
return position + length;
}
@@ -2536,9 +2536,9 @@ static inline int MovePositionForInsertion(int position, int startInsertion, int
// Move a position so it is still after the same character as before the deletion if that
// character is still present else after the previous surviving character.
-static inline int MovePositionForDeletion(int position, int startDeletion, int length) {
+static inline Sci::Position MovePositionForDeletion(Sci::Position position, Sci::Position startDeletion, Sci::Position length) {
if (position > startDeletion) {
- int endDeletion = startDeletion + length;
+ Sci::Position endDeletion = startDeletion + length;
if (position > endDeletion) {
return position - length;
} else {
@@ -2602,17 +2602,17 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
}
if ((mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) && cs.HiddenLines()) {
// Some lines are hidden so may need shown.
- const int lineOfPos = pdoc->LineFromPosition(mh.position);
- int endNeedShown = mh.position;
+ const Sci::Line lineOfPos = pdoc->LineFromPosition(mh.position);
+ Sci::Position endNeedShown = mh.position;
if (mh.modificationType & SC_MOD_BEFOREINSERT) {
if (pdoc->ContainsLineEnd(mh.text, mh.length) && (mh.position != pdoc->LineStart(lineOfPos)))
endNeedShown = pdoc->LineStart(lineOfPos+1);
} else if (mh.modificationType & SC_MOD_BEFOREDELETE) {
// If the deletion includes any EOL then we extend the need shown area.
endNeedShown = mh.position + mh.length;
- int lineLast = pdoc->LineFromPosition(mh.position+mh.length);
- for (int line = lineOfPos + 1; line <= lineLast; line++) {
- const int lineMaxSubord = pdoc->GetLastChild(line, -1, -1);
+ Sci::Line lineLast = pdoc->LineFromPosition(mh.position+mh.length);
+ for (Sci::Line line = lineOfPos + 1; line <= lineLast; line++) {
+ const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, -1, -1);
if (lineLast < lineMaxSubord) {
lineLast = lineMaxSubord;
endNeedShown = pdoc->LineEnd(lineLast);
@@ -2624,7 +2624,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
if (mh.linesAdded != 0) {
// Update contraction state for inserted and removed lines
// lineOfPos should be calculated in context of state before modification, shouldn't it
- int lineOfPos = pdoc->LineFromPosition(mh.position);
+ Sci::Line lineOfPos = pdoc->LineFromPosition(mh.position);
if (mh.position > pdoc->LineStart(lineOfPos))
lineOfPos++; // Affecting subsequent lines
if (mh.linesAdded > 0) {
@@ -2635,7 +2635,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
view.LinesAddedOrRemoved(lineOfPos, mh.linesAdded);
}
if (mh.modificationType & SC_MOD_CHANGEANNOTATION) {
- int lineDoc = pdoc->LineFromPosition(mh.position);
+ Sci::Line lineDoc = pdoc->LineFromPosition(mh.position);
if (vs.annotationVisible) {
cs.SetHeight(lineDoc, cs.GetHeight(lineDoc) + mh.annotationLinesAdded);
Redraw();
@@ -2645,7 +2645,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
if (mh.linesAdded != 0) {
// Avoid scrolling of display if change before current display
if (mh.position < posTopLine && !CanDeferToLastStep(mh)) {
- int newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos());
+ Sci::Line newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos());
if (newTop != topLine) {
SetTopLine(newTop);
SetVerticalScrollPos();
@@ -2857,12 +2857,12 @@ void Editor::ContainerNeedsUpdate(int flags) {
* If stuttered = true and already at first/last row, scroll as normal.
*/
void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {
- int topLineNew;
+ Sci::Line topLineNew;
SelectionPosition newPos;
- int currentLine = pdoc->LineFromPosition(sel.MainCaret());
- int topStutterLine = topLine + caretYSlop;
- int bottomStutterLine =
+ Sci::Line currentLine = pdoc->LineFromPosition(sel.MainCaret());
+ Sci::Line topStutterLine = topLine + caretYSlop;
+ Sci::Line bottomStutterLine =
pdoc->LineFromPosition(PositionFromLocation(
Point::FromInts(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll())))
- caretYSlop - 1;
@@ -2921,15 +2921,15 @@ void Editor::ChangeCaseOfSelection(int caseMapping) {
}
size_t endDifferenceText = sText.size() - 1 - lastDifferenceText;
pdoc->DeleteChars(
- static_cast<int>(currentNoVS.Start().Position() + firstDifference),
- static_cast<int>(rangeBytes - firstDifference - endDifferenceText));
- const int lengthChange = static_cast<int>(lastDifferenceMapped - firstDifference + 1);
- const int lengthInserted = pdoc->InsertString(
+ static_cast<Sci::Position>(currentNoVS.Start().Position() + firstDifference),
+ static_cast<Sci::Position>(rangeBytes - firstDifference - endDifferenceText));
+ const Sci::Position lengthChange = static_cast<Sci::Position>(lastDifferenceMapped - firstDifference + 1);
+ const Sci::Position lengthInserted = pdoc->InsertString(
static_cast<int>(currentNoVS.Start().Position() + firstDifference),
sMapped.c_str() + firstDifference,
lengthChange);
// Automatic movement changes selection so reset to exactly the same as it was.
- int diffSizes = static_cast<int>(sMapped.size() - sText.size()) + lengthInserted - lengthChange;
+ Sci::Position diffSizes = static_cast<Sci::Position>(sMapped.size() - sText.size()) + lengthInserted - lengthChange;
if (diffSizes != 0) {
if (current.anchor > current.caret)
current.anchor.Add(diffSizes);
@@ -2943,24 +2943,24 @@ void Editor::ChangeCaseOfSelection(int caseMapping) {
}
void Editor::LineTranspose() {
- int line = pdoc->LineFromPosition(sel.MainCaret());
+ Sci::Line line = pdoc->LineFromPosition(sel.MainCaret());
if (line > 0) {
UndoGroup ug(pdoc);
- const int startPrevious = pdoc->LineStart(line - 1);
+ const Sci::Position startPrevious = pdoc->LineStart(line - 1);
const std::string linePrevious = RangeText(startPrevious, pdoc->LineEnd(line - 1));
- int startCurrent = pdoc->LineStart(line);
+ Sci::Position startCurrent = pdoc->LineStart(line);
const std::string lineCurrent = RangeText(startCurrent, pdoc->LineEnd(line));
- pdoc->DeleteChars(startCurrent, static_cast<int>(lineCurrent.length()));
- pdoc->DeleteChars(startPrevious, static_cast<int>(linePrevious.length()));
- startCurrent -= static_cast<int>(linePrevious.length());
+ pdoc->DeleteChars(startCurrent, static_cast<Sci::Position>(lineCurrent.length()));
+ pdoc->DeleteChars(startPrevious, static_cast<Sci::Position>(linePrevious.length()));
+ startCurrent -= static_cast<Sci::Position>(linePrevious.length());
startCurrent += pdoc->InsertString(startPrevious, lineCurrent.c_str(),
- static_cast<int>(lineCurrent.length()));
+ static_cast<Sci::Position>(lineCurrent.length()));
pdoc->InsertString(startCurrent, linePrevious.c_str(),
- static_cast<int>(linePrevious.length()));
+ static_cast<Sci::Position>(linePrevious.length()));
// Move caret to start of current line
MovePositionTo(SelectionPosition(startCurrent));
}
@@ -2981,20 +2981,20 @@ void Editor::Duplicate(bool forLine) {
SelectionPosition start = sel.Range(r).Start();
SelectionPosition end = sel.Range(r).End();
if (forLine) {
- int line = pdoc->LineFromPosition(sel.Range(r).caret.Position());
+ Sci::Line line = pdoc->LineFromPosition(sel.Range(r).caret.Position());
start = SelectionPosition(pdoc->LineStart(line));
end = SelectionPosition(pdoc->LineEnd(line));
}
std::string text = RangeText(start.Position(), end.Position());
- int lengthInserted = eolLen;
+ Sci::Position lengthInserted = eolLen;
if (forLine)
lengthInserted = pdoc->InsertString(end.Position(), eol, eolLen);
- pdoc->InsertString(end.Position() + lengthInserted, text.c_str(), static_cast<int>(text.length()));
+ pdoc->InsertString(end.Position() + lengthInserted, text.c_str(), static_cast<Sci::Position>(text.length()));
}
if (sel.Count() && sel.IsRectangular()) {
SelectionPosition last = sel.Last();
if (forLine) {
- int line = pdoc->LineFromPosition(last.Position());
+ Sci::Line line = pdoc->LineFromPosition(last.Position());
last = SelectionPosition(last.Position() + pdoc->LineStart(line+1) - pdoc->LineStart(line));
}
if (sel.Rectangular().anchor > sel.Rectangular().caret)
@@ -3028,8 +3028,8 @@ void Editor::NewLine() {
for (size_t r = 0; r < sel.Count(); r++) {
sel.Range(r).ClearVirtualSpace();
const char *eol = StringFromEOLMode(pdoc->eolMode);
- const int positionInsert = sel.Range(r).caret.Position();
- const int insertLength = pdoc->InsertString(positionInsert, eol, istrlen(eol));
+ const Sci::Position positionInsert = sel.Range(r).caret.Position();
+ const Sci::Position insertLength = pdoc->InsertString(positionInsert, eol, istrlen(eol));
if (insertLength > 0) {
sel.Range(r) = SelectionRange(positionInsert + insertLength);
countInsertions++;
@@ -3064,12 +3064,12 @@ SelectionPosition Editor::PositionUpOrDown(SelectionPosition spStart, int direct
int skipLines = 0;
if (vs.annotationVisible) {
- const int lineDoc = pdoc->LineFromPosition(spStart.Position());
+ const Sci::Line lineDoc = pdoc->LineFromPosition(spStart.Position());
const Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
const int subLine = static_cast<int>(pt.y - ptStartLine.y) / vs.lineHeight;
if (direction < 0 && subLine == 0) {
- const int lineDisplay = cs.DisplayFromDoc(lineDoc);
+ const Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
if (lineDisplay > 0) {
skipLines = pdoc->AnnotationLines(cs.DocFromDisplay(lineDisplay - 1));
}
@@ -3078,9 +3078,9 @@ SelectionPosition Editor::PositionUpOrDown(SelectionPosition spStart, int direct
}
}
- const int newY = static_cast<int>(pt.y) + (1 + skipLines) * direction * vs.lineHeight;
+ const Sci::Line newY = static_cast<Sci::Line>(pt.y) + (1 + skipLines) * direction * vs.lineHeight;
if (lastX < 0) {
- lastX = static_cast<int>(pt.x) + xOffset;
+ lastX = static_cast<Sci::Position>(pt.x) + xOffset;
}
SelectionPosition posNew = SPositionFromLocation(
Point::FromInts(lastX - xOffset, newY), false, false, UserVirtualSpace());
@@ -3151,7 +3151,8 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
}
void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) {
- int lineDoc, savedPos = sel.MainCaret();
+ Sci::Line lineDoc;
+ Sci::Position savedPos = sel.MainCaret();
do {
MovePositionTo(SelectionPosition(direction > 0 ? pdoc->ParaDown(sel.MainCaret()) : pdoc->ParaUp(sel.MainCaret())), selt);
lineDoc = pdoc->LineFromPosition(sel.MainCaret());
@@ -3166,16 +3167,16 @@ void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) {
} while (!cs.GetVisible(lineDoc));
}
-Range Editor::RangeDisplayLine(int lineVisible) {
+Range Editor::RangeDisplayLine(Sci::Line lineVisible) {
RefreshStyleData();
AutoSurface surface(this);
return view.RangeDisplayLine(surface, *this, lineVisible, vs);
}
-int Editor::StartEndDisplayLine(int pos, bool start) {
+Sci::Position Editor::StartEndDisplayLine(Sci::Position pos, bool start) {
RefreshStyleData();
AutoSurface surface(this);
- int posRet = view.StartEndDisplayLine(surface, *this, pos, start, vs);
+ Sci::Position posRet = view.StartEndDisplayLine(surface, *this, pos, start, vs);
if (posRet == INVALID_POSITION) {
return pos;
} else {
@@ -3258,27 +3259,27 @@ bool IsRectExtend(unsigned int iMessage) {
}
-int Editor::VCHomeDisplayPosition(int position) {
- const int homePos = pdoc->VCHomePosition(position);
- const int viewLineStart = StartEndDisplayLine(position, true);
+Sci::Position Editor::VCHomeDisplayPosition(Sci::Position position) {
+ const Sci::Position homePos = pdoc->VCHomePosition(position);
+ const Sci::Position viewLineStart = StartEndDisplayLine(position, true);
if (viewLineStart > homePos)
return viewLineStart;
else
return homePos;
}
-int Editor::VCHomeWrapPosition(int position) {
- const int homePos = pdoc->VCHomePosition(position);
- const int viewLineStart = StartEndDisplayLine(position, true);
+Sci::Position Editor::VCHomeWrapPosition(Sci::Position position) {
+ const Sci::Position homePos = pdoc->VCHomePosition(position);
+ const Sci::Position viewLineStart = StartEndDisplayLine(position, true);
if ((viewLineStart < position) && (viewLineStart > homePos))
return viewLineStart;
else
return homePos;
}
-int Editor::LineEndWrapPosition(int position) {
- const int endPos = StartEndDisplayLine(position, false);
- const int realEndPos = pdoc->LineEndPosition(position);
+Sci::Position Editor::LineEndWrapPosition(Sci::Position position) {
+ const Sci::Position endPos = StartEndDisplayLine(position, false);
+ const Sci::Position realEndPos = pdoc->LineEndPosition(position);
if (endPos > realEndPos // if moved past visible EOLs
|| position >= endPos) // if at end of display line already
return realEndPos;
@@ -3781,26 +3782,26 @@ int Editor::KeyCommand(unsigned int iMessage) {
return DelWordOrLine(iMessage);
case SCI_LINECOPY: {
- int lineStart = pdoc->LineFromPosition(SelectionStart().Position());
- int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
+ Sci::Line lineStart = pdoc->LineFromPosition(SelectionStart().Position());
+ Sci::Line lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
CopyRangeToClipboard(pdoc->LineStart(lineStart),
pdoc->LineStart(lineEnd + 1));
}
break;
case SCI_LINECUT: {
- int lineStart = pdoc->LineFromPosition(SelectionStart().Position());
- int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
- int start = pdoc->LineStart(lineStart);
- int end = pdoc->LineStart(lineEnd + 1);
+ 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);
SetSelection(start, end);
Cut();
SetLastXChosen();
}
break;
case SCI_LINEDELETE: {
- int line = pdoc->LineFromPosition(sel.MainCaret());
- int start = pdoc->LineStart(line);
- int end = pdoc->LineStart(line + 1);
+ Sci::Line line = pdoc->LineFromPosition(sel.MainCaret());
+ Sci::Position start = pdoc->LineStart(line);
+ Sci::Position end = pdoc->LineStart(line + 1);
pdoc->DeleteChars(start, end - start);
}
break;
@@ -3854,9 +3855,9 @@ int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) {
void Editor::Indent(bool forwards) {
UndoGroup ug(pdoc);
for (size_t r=0; r<sel.Count(); r++) {
- int lineOfAnchor = pdoc->LineFromPosition(sel.Range(r).anchor.Position());
- int caretPosition = sel.Range(r).caret.Position();
- int lineCurrentPos = pdoc->LineFromPosition(caretPosition);
+ Sci::Line lineOfAnchor = pdoc->LineFromPosition(sel.Range(r).anchor.Position());
+ Sci::Position caretPosition = sel.Range(r).caret.Position();
+ Sci::Line lineCurrentPos = pdoc->LineFromPosition(caretPosition);
if (lineOfAnchor == lineCurrentPos) {
if (forwards) {
pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length());
@@ -3865,12 +3866,12 @@ void Editor::Indent(bool forwards) {
pdoc->tabIndents) {
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
int indentationStep = pdoc->IndentSize();
- const int posSelect = pdoc->SetLineIndentation(
+ const Sci::Position posSelect = pdoc->SetLineIndentation(
lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
sel.Range(r) = SelectionRange(posSelect);
} else {
if (pdoc->useTabs) {
- const int lengthInserted = pdoc->InsertString(caretPosition, "\t", 1);
+ const Sci::Position lengthInserted = pdoc->InsertString(caretPosition, "\t", 1);
sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
} else {
int numSpaces = (pdoc->tabInChars) -
@@ -3878,8 +3879,8 @@ void Editor::Indent(bool forwards) {
if (numSpaces < 1)
numSpaces = pdoc->tabInChars;
const std::string spaceText(numSpaces, ' ');
- const int lengthInserted = pdoc->InsertString(caretPosition, spaceText.c_str(),
- static_cast<int>(spaceText.length()));
+ const Sci::Position lengthInserted = pdoc->InsertString(caretPosition, spaceText.c_str(),
+ static_cast<Sci::Position>(spaceText.length()));
sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
}
}
@@ -3888,25 +3889,25 @@ void Editor::Indent(bool forwards) {
pdoc->tabIndents) {
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
int indentationStep = pdoc->IndentSize();
- const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
+ const Sci::Position posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
sel.Range(r) = SelectionRange(posSelect);
} else {
- int newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) *
+ Sci::Position newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) *
pdoc->tabInChars;
if (newColumn < 0)
newColumn = 0;
- int newPos = caretPosition;
+ Sci::Position newPos = caretPosition;
while (pdoc->GetColumn(newPos) > newColumn)
newPos--;
sel.Range(r) = SelectionRange(newPos);
}
}
} else { // Multiline
- int anchorPosOnLine = sel.Range(r).anchor.Position() - pdoc->LineStart(lineOfAnchor);
- int currentPosPosOnLine = caretPosition - pdoc->LineStart(lineCurrentPos);
+ Sci::Position anchorPosOnLine = sel.Range(r).anchor.Position() - pdoc->LineStart(lineOfAnchor);
+ Sci::Position currentPosPosOnLine = caretPosition - pdoc->LineStart(lineCurrentPos);
// Multiple lines selected so indent / dedent
- int lineTopSel = Platform::Minimum(lineOfAnchor, lineCurrentPos);
- int lineBottomSel = Platform::Maximum(lineOfAnchor, lineCurrentPos);
+ Sci::Line lineTopSel = Platform::Minimum(lineOfAnchor, lineCurrentPos);
+ Sci::Line lineBottomSel = Platform::Maximum(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
pdoc->Indent(forwards, lineBottomSel, lineTopSel);
@@ -3951,13 +3952,13 @@ long Editor::FindText(
sptr_t lParam) { ///< @c Sci_TextToFind structure: The text to search for in the given range.
Sci_TextToFind *ft = reinterpret_cast<Sci_TextToFind *>(lParam);
- int lengthFound = istrlen(ft->lpstrText);
+ Sci::Position lengthFound = istrlen(ft->lpstrText);
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
long pos = pdoc->FindText(
- static_cast<int>(ft->chrg.cpMin),
- static_cast<int>(ft->chrg.cpMax),
+ static_cast<Sci::Position>(ft->chrg.cpMin),
+ static_cast<Sci::Position>(ft->chrg.cpMax),
ft->lpstrText,
static_cast<int>(wParam),
&lengthFound);
@@ -4000,7 +4001,7 @@ long Editor::SearchText(
const char *txt = reinterpret_cast<char *>(lParam);
long pos;
- int lengthFound = istrlen(txt);
+ Sci::Position lengthFound = istrlen(txt);
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
@@ -4045,8 +4046,8 @@ std::string Editor::CaseMapString(const std::string &s, int caseMapping) {
* Search for text in the target range of the document.
* @return The position of the found text, -1 if not found.
*/
-long Editor::SearchInTarget(const char *text, int length) {
- int lengthFound = length;
+long Editor::SearchInTarget(const char *text, Sci::Position length) {
+ Sci::Position lengthFound = length;
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
@@ -4065,7 +4066,7 @@ long Editor::SearchInTarget(const char *text, int length) {
}
}
-void Editor::GoToLine(int lineNo) {
+void Editor::GoToLine(Sci::Line lineNo) {
if (lineNo > pdoc->LinesTotal())
lineNo = pdoc->LinesTotal();
if (lineNo < 0)
@@ -4083,9 +4084,9 @@ static bool Close(Point pt1, Point pt2, Point threshold) {
return true;
}
-std::string Editor::RangeText(int start, int end) const {
+std::string Editor::RangeText(Sci::Position start, Sci::Position end) const {
if (start < end) {
- int len = end - start;
+ Sci::Position len = end - start;
std::string ret(len, '\0');
for (int i = 0; i < len; i++) {
ret[i] = pdoc->CharAt(start + i);
@@ -4098,9 +4099,9 @@ std::string Editor::RangeText(int start, int end) const {
void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
if (sel.Empty()) {
if (allowLineCopy) {
- int currentLine = pdoc->LineFromPosition(sel.MainCaret());
- int start = pdoc->LineStart(currentLine);
- int end = pdoc->LineEnd(currentLine);
+ Sci::Line currentLine = pdoc->LineFromPosition(sel.MainCaret());
+ Sci::Position start = pdoc->LineStart(currentLine);
+ Sci::Position end = pdoc->LineEnd(currentLine);
std::string text = RangeText(start, end);
if (pdoc->eolMode != SC_EOL_LF)
@@ -4130,7 +4131,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
}
}
-void Editor::CopyRangeToClipboard(int start, int end) {
+void Editor::CopyRangeToClipboard(Sci::Position start, Sci::Position end) {
start = pdoc->ClampPositionIntoDocument(start);
end = pdoc->ClampPositionIntoDocument(end);
SelectionText selectedText;
@@ -4230,13 +4231,13 @@ void Editor::DropAt(SelectionPosition position, const char *value, size_t length
std::string convertedText = Document::TransformLineEnds(value, lengthValue, pdoc->eolMode);
if (rectangular) {
- PasteRectangular(position, convertedText.c_str(), static_cast<int>(convertedText.length()));
+ PasteRectangular(position, convertedText.c_str(), static_cast<Sci::Position>(convertedText.length()));
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position
SetEmptySelection(position);
} else {
position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());
position = RealizeVirtualSpace(position);
- const int lengthInserted = pdoc->InsertString(
+ const Sci::Position lengthInserted = pdoc->InsertString(
position.Position(), convertedText.c_str(), static_cast<int>(convertedText.length()));
if (lengthInserted > 0) {
SelectionPosition posAfterInsertion = position;
@@ -4256,7 +4257,7 @@ void Editor::DropAt(SelectionPosition position, const char *value, bool moving,
/**
* @return true if given position is inside the selection,
*/
-bool Editor::PositionInSelection(int pos) {
+bool Editor::PositionInSelection(Sci::Position pos) {
pos = MovePositionOutsideChar(pos, sel.MainCaret() - pos);
for (size_t r=0; r<sel.Count(); r++) {
if (sel.Range(r).Contains(pos))
@@ -4313,16 +4314,16 @@ Window::Cursor Editor::GetMarginCursor(Point pt) const {
return Window::cursorReverseArrow;
}
-void Editor::TrimAndSetSelection(int currentPos_, int anchor_) {
+void Editor::TrimAndSetSelection(Sci::Position currentPos_, Sci::Position anchor_) {
sel.TrimSelection(SelectionRange(currentPos_, anchor_));
SetSelection(currentPos_, anchor_);
}
-void Editor::LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine) {
- int selCurrentPos, selAnchorPos;
+void Editor::LineSelection(Sci::Position lineCurrentPos_, Sci::Position lineAnchorPos_, bool wholeLine) {
+ Sci::Position selCurrentPos, selAnchorPos;
if (wholeLine) {
- int lineCurrent_ = pdoc->LineFromPosition(lineCurrentPos_);
- int lineAnchor_ = pdoc->LineFromPosition(lineAnchorPos_);
+ Sci::Line lineCurrent_ = pdoc->LineFromPosition(lineCurrentPos_);
+ Sci::Line lineAnchor_ = pdoc->LineFromPosition(lineAnchorPos_);
if (lineAnchorPos_ < lineCurrentPos_) {
selCurrentPos = pdoc->LineStart(lineCurrent_ + 1);
selAnchorPos = pdoc->LineStart(lineAnchor_);
@@ -4351,7 +4352,7 @@ void Editor::LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLi
TrimAndSetSelection(selCurrentPos, selAnchorPos);
}
-void Editor::WordSelection(int pos) {
+void Editor::WordSelection(Sci::Position pos) {
if (pos < wordSelectAnchorStartPos) {
// Extend backward to the word containing pos.
// Skip ExtendWordSelect if the line is empty or if pos is after the last character.
@@ -4472,13 +4473,13 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
}
if (selectionType == selWord) {
- int charPos = originalAnchorPos;
+ Sci::Position charPos = originalAnchorPos;
if (sel.MainCaret() == originalAnchorPos) {
charPos = PositionFromLocation(pt, false, true);
charPos = MovePositionOutsideChar(charPos, -1);
}
- int startWord, endWord;
+ Sci::Position startWord, endWord;
if ((sel.MainCaret() >= originalAnchorPos) && !pdoc->IsLineEndPosition(charPos)) {
startWord = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(charPos + 1, 1), -1);
endWord = pdoc->ExtendWordSelect(charPos, 1);
@@ -4539,7 +4540,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
LineSelection(newPos.Position(), lineAnchorPos, selectionType == selWholeLine);
}
- SetDragPosition(SelectionPosition(invalidPosition));
+ SetDragPosition(SelectionPosition(Sci::invalidPosition));
SetMouseCapture(true);
if (FineTickerAvailable()) {
FineTickerStart(tickScroll, 100, 10);
@@ -4560,7 +4561,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
FineTickerStart(tickScroll, 100, 10);
}
if (inDragDrop != ddInitial) {
- SetDragPosition(SelectionPosition(invalidPosition));
+ SetDragPosition(SelectionPosition(Sci::invalidPosition));
if (!shift) {
if (ctrl && multipleSelection) {
SelectionRange range(newPos);
@@ -4603,19 +4604,19 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
return ButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt));
}
-bool Editor::PositionIsHotspot(int position) const {
+bool Editor::PositionIsHotspot(Sci::Position position) const {
return vs.styles[pdoc->StyleIndexAt(position)].hotspot;
}
bool Editor::PointIsHotspot(Point pt) {
- int pos = PositionFromLocation(pt, true, true);
+ Sci::Position pos = PositionFromLocation(pt, true, true);
if (pos == INVALID_POSITION)
return false;
return PositionIsHotspot(pos);
}
-void Editor::SetHoverIndicatorPosition(int position) {
- int hoverIndicatorPosPrev = hoverIndicatorPos;
+void Editor::SetHoverIndicatorPosition(Sci::Position position) {
+ Sci::Position hoverIndicatorPosPrev = hoverIndicatorPos;
hoverIndicatorPos = INVALID_POSITION;
if (vs.indicatorsDynamic == 0)
return;
@@ -4643,7 +4644,7 @@ void Editor::SetHoverIndicatorPoint(Point pt) {
void Editor::SetHotSpotRange(Point *pt) {
if (pt) {
- int pos = PositionFromLocation(*pt, false, true);
+ Sci::Position pos = PositionFromLocation(*pt, false, true);
// If we don't limit this to word characters then the
// range can encompass more than the run range and then
@@ -4664,7 +4665,7 @@ void Editor::SetHotSpotRange(Point *pt) {
if (hotspot.Valid()) {
InvalidateRange(hotspot.start, hotspot.end);
}
- hotspot = Range(invalidPosition);
+ hotspot = Range(Sci::invalidPosition);
}
}
@@ -4752,7 +4753,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) {
}
// Autoscroll
- int lineMove = DisplayFromPosition(movePos.Position());
+ Sci::Line lineMove = DisplayFromPosition(movePos.Position());
if (pt.y > rcClient.bottom) {
ScrollTo(lineMove - LinesOnScreen() + 1);
Redraw();
@@ -4789,7 +4790,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) {
DisplayCursor(Window::cursorHand);
SetHotSpotRange(&pt);
} else {
- if (hoverIndicatorPos != invalidPosition)
+ if (hoverIndicatorPos != Sci::invalidPosition)
DisplayCursor(Window::cursorHand);
else
DisplayCursor(Window::cursorText);
@@ -4842,14 +4843,14 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
if (drag.Length()) {
const int length = static_cast<int>(drag.Length());
if (ctrl) {
- const int lengthInserted = pdoc->InsertString(
+ const Sci::Position lengthInserted = pdoc->InsertString(
newPos.Position(), drag.Data(), length);
if (lengthInserted > 0) {
SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else if (newPos < selStart) {
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
- const int lengthInserted = pdoc->InsertString(
+ const Sci::Position lengthInserted = pdoc->InsertString(
newPos.Position(), drag.Data(), length);
if (lengthInserted > 0) {
SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
@@ -4857,7 +4858,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
} else if (newPos > selEnd) {
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
newPos.Add(-static_cast<int>(drag.Length()));
- const int lengthInserted = pdoc->InsertString(
+ const Sci::Position lengthInserted = pdoc->InsertString(
newPos.Position(), drag.Data(), length);
if (lengthInserted > 0) {
SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
@@ -5017,11 +5018,11 @@ void Editor::SetFocusState(bool focusState) {
ShowCaretAtCurrentPosition();
}
-int Editor::PositionAfterArea(PRectangle rcArea) const {
+Sci::Position Editor::PositionAfterArea(PRectangle rcArea) const {
// The start of the document line after the display line after the area
// This often means that the line after a modification is restyled which helps
// detect multiline comment additions and heals single line comments
- int lineAfter = TopLineOfMain() + static_cast<int>(rcArea.bottom - 1) / vs.lineHeight + 1;
+ Sci::Line lineAfter = TopLineOfMain() + static_cast<Sci::Line>(rcArea.bottom - 1) / vs.lineHeight + 1;
if (lineAfter < cs.LinesDisplayed())
return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1);
else
@@ -5030,8 +5031,8 @@ int Editor::PositionAfterArea(PRectangle rcArea) const {
// Style to a position within the view. If this causes a change at end of last line then
// affects later lines so style all the viewed text.
-void Editor::StyleToPositionInView(Position pos) {
- int endWindow = PositionAfterArea(GetClientDrawingRectangle());
+void Editor::StyleToPositionInView(Sci::Position pos) {
+ Sci::Position endWindow = PositionAfterArea(GetClientDrawingRectangle());
if (pos > endWindow)
pos = endWindow;
const int styleAtEnd = pdoc->StyleIndexAt(pos-1);
@@ -5046,7 +5047,7 @@ void Editor::StyleToPositionInView(Position pos) {
}
}
-int Editor::PositionAfterMaxStyling(int posMax, bool scrolling) const {
+Sci::Position Editor::PositionAfterMaxStyling(Sci::Position posMax, bool scrolling) const {
if ((idleStyling == SC_IDLESTYLING_NONE) || (idleStyling == SC_IDLESTYLING_AFTERVISIBLE)) {
// Both states do not limit styling
return posMax;
@@ -5056,12 +5057,12 @@ int Editor::PositionAfterMaxStyling(int posMax, bool scrolling) const {
// When scrolling, allow less time to ensure responsive
const double secondsAllowed = scrolling ? 0.005 : 0.02;
- const int linesToStyle = Platform::Clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine),
+ const Sci::Line linesToStyle = Platform::Clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine),
10, 0x10000);
- const int stylingMaxLine = std::min(
- static_cast<int>(pdoc->LineFromPosition(pdoc->GetEndStyled()) + linesToStyle),
+ const Sci::Line stylingMaxLine = std::min(
+ static_cast<Sci::Line>(pdoc->LineFromPosition(pdoc->GetEndStyled()) + linesToStyle),
pdoc->LinesTotal());
- return std::min(static_cast<int>(pdoc->LineStart(stylingMaxLine)), posMax);
+ return std::min(static_cast<Sci::Position>(pdoc->LineStart(stylingMaxLine)), posMax);
}
void Editor::StartIdleStyling(bool truncatedLastStyling) {
@@ -5081,8 +5082,8 @@ void Editor::StartIdleStyling(bool truncatedLastStyling) {
// Style for an area but bound the amount of styling to remain responsive
void Editor::StyleAreaBounded(PRectangle rcArea, bool scrolling) {
- const int posAfterArea = PositionAfterArea(rcArea);
- const int posAfterMax = PositionAfterMaxStyling(posAfterArea, scrolling);
+ const Sci::Position posAfterArea = PositionAfterArea(rcArea);
+ const Sci::Position posAfterMax = PositionAfterMaxStyling(posAfterArea, scrolling);
if (posAfterMax < posAfterArea) {
// Idle styling may be performed before current visible area
// Style a bit now then style further in idle time
@@ -5095,10 +5096,10 @@ void Editor::StyleAreaBounded(PRectangle rcArea, bool scrolling) {
}
void Editor::IdleStyling() {
- const int posAfterArea = PositionAfterArea(GetClientRectangle());
- const int endGoal = (idleStyling >= SC_IDLESTYLING_AFTERVISIBLE) ?
+ const Sci::Position posAfterArea = PositionAfterArea(GetClientRectangle());
+ const Sci::Position endGoal = (idleStyling >= SC_IDLESTYLING_AFTERVISIBLE) ?
pdoc->Length() : posAfterArea;
- const int posAfterMax = PositionAfterMaxStyling(endGoal, false);
+ const Sci::Position posAfterMax = PositionAfterMaxStyling(endGoal, false);
pdoc->StyleToAdjustingLineDuration(posAfterMax);
if (pdoc->GetEndStyled() >= endGoal) {
needIdleStyling = false;
@@ -5115,7 +5116,7 @@ void Editor::IdleWork() {
workNeeded.Reset();
}
-void Editor::QueueIdleWork(WorkNeeded::workItems items, int upTo) {
+void Editor::QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) {
workNeeded.Need(items, upTo);
}
@@ -5160,7 +5161,7 @@ void Editor::CheckForChangeOutsidePaint(Range r) {
}
}
-void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) {
+void Editor::SetBraceHighlight(Sci::Position pos0, Sci::Position pos1, int matchStyle) {
if ((pos0 != braces[0]) || (pos1 != braces[1]) || (matchStyle != bracesMatchStyle)) {
if ((braces[0] != pos0) || (matchStyle != bracesMatchStyle)) {
CheckForChangeOutsidePaint(Range(braces[0]));
@@ -5179,11 +5180,11 @@ void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) {
}
}
-void Editor::SetAnnotationHeights(int start, int end) {
+void Editor::SetAnnotationHeights(Sci::Line start, Sci::Line end) {
if (vs.annotationVisible) {
RefreshStyleData();
bool changedHeight = false;
- for (int line=start; line<end && line<pdoc->LinesTotal(); line++) {
+ for (Sci::Line line=start; line<end && line<pdoc->LinesTotal(); line++) {
int linesWrapped = 1;
if (Wrapping()) {
AutoSurface surface(this);
@@ -5218,8 +5219,8 @@ void Editor::SetDocPointer(Document *document) {
targetStart = 0;
targetEnd = 0;
- braces[0] = invalidPosition;
- braces[1] = invalidPosition;
+ braces[0] = Sci::invalidPosition;
+ braces[1] = Sci::invalidPosition;
vs.ReleaseAllExtendedStyles();
@@ -5232,8 +5233,8 @@ void Editor::SetDocPointer(Document *document) {
view.llc.Deallocate();
NeedWrapping();
- hotspot = Range(invalidPosition);
- hoverIndicatorPos = invalidPosition;
+ hotspot = Range(Sci::invalidPosition);
+ hoverIndicatorPos = Sci::invalidPosition;
view.ClearAllTabstops();
@@ -5248,7 +5249,7 @@ void Editor::SetAnnotationVisible(int visible) {
vs.annotationVisible = visible;
if (changedFromOrToHidden) {
int dir = vs.annotationVisible ? 1 : -1;
- for (int line=0; line<pdoc->LinesTotal(); line++) {
+ for (Sci::Line line=0; line<pdoc->LinesTotal(); line++) {
int annotationLines = pdoc->AnnotationLines(line);
if (annotationLines > 0) {
cs.SetHeight(line, cs.GetHeight(line) + annotationLines * dir);
@@ -5262,8 +5263,8 @@ void Editor::SetAnnotationVisible(int visible) {
/**
* Recursively expand a fold, making lines visible except where they have an unexpanded parent.
*/
-int Editor::ExpandLine(int line) {
- int lineMaxSubord = pdoc->GetLastChild(line);
+Sci::Line Editor::ExpandLine(Sci::Line line) {
+ Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
line++;
while (line <= lineMaxSubord) {
cs.SetVisible(line, line, true);
@@ -5280,13 +5281,13 @@ int Editor::ExpandLine(int line) {
return lineMaxSubord;
}
-void Editor::SetFoldExpanded(int lineDoc, bool expanded) {
+void Editor::SetFoldExpanded(Sci::Line lineDoc, bool expanded) {
if (cs.SetExpanded(lineDoc, expanded)) {
RedrawSelMargin();
}
}
-void Editor::FoldLine(int line, int action) {
+void Editor::FoldLine(Sci::Line line, int action) {
if (line >= 0) {
if (action == SC_FOLDACTION_TOGGLE) {
if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) {
@@ -5298,12 +5299,12 @@ void Editor::FoldLine(int line, int action) {
}
if (action == SC_FOLDACTION_CONTRACT) {
- int lineMaxSubord = pdoc->GetLastChild(line);
+ Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
if (lineMaxSubord > line) {
cs.SetExpanded(line, 0);
cs.SetVisible(line + 1, lineMaxSubord, false);
- int lineCurrent = pdoc->LineFromPosition(sel.MainCaret());
+ Sci::Line lineCurrent = pdoc->LineFromPosition(sel.MainCaret());
if (lineCurrent > line && lineCurrent <= lineMaxSubord) {
// This does not re-expand the fold
EnsureCaretVisible();
@@ -5324,7 +5325,7 @@ void Editor::FoldLine(int line, int action) {
}
}
-void Editor::FoldExpand(int line, int action, int level) {
+void Editor::FoldExpand(Sci::Line line, int action, int level) {
bool expanding = action == SC_FOLDACTION_EXPAND;
if (action == SC_FOLDACTION_TOGGLE) {
expanding = !cs.GetExpanded(line);
@@ -5336,7 +5337,7 @@ void Editor::FoldExpand(int line, int action, int level) {
if (expanding && (cs.HiddenLines() == 0))
// Nothing to do
return;
- int lineMaxSubord = pdoc->GetLastChild(line, LevelNumber(level));
+ Sci::Line lineMaxSubord = pdoc->GetLastChild(line, LevelNumber(level));
line++;
cs.SetVisible(line, lineMaxSubord, expanding);
while (line <= lineMaxSubord) {
@@ -5350,8 +5351,8 @@ void Editor::FoldExpand(int line, int action, int level) {
Redraw();
}
-int Editor::ContractedFoldNext(int lineStart) const {
- for (int line = lineStart; line<pdoc->LinesTotal();) {
+Sci::Line Editor::ContractedFoldNext(Sci::Line lineStart) const {
+ for (Sci::Line line = lineStart; line<pdoc->LinesTotal();) {
if (!cs.GetExpanded(line) && (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG))
return line;
line = cs.ContractedNext(line+1);
@@ -5366,7 +5367,7 @@ int Editor::ContractedFoldNext(int lineStart) const {
* Recurse up from this line to find any folds that prevent this line from being visible
* and unfold them all.
*/
-void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {
+void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {
// In case in need of wrapping to ensure DisplayFromDoc works.
if (lineDoc >= wrapPending.start)
@@ -5374,12 +5375,12 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {
if (!cs.GetVisible(lineDoc)) {
// Back up to find a non-blank line
- int lookLine = lineDoc;
+ Sci::Line lookLine = lineDoc;
int lookLineLevel = pdoc->GetLevel(lookLine);
while ((lookLine > 0) && (lookLineLevel & SC_FOLDLEVELWHITEFLAG)) {
lookLineLevel = pdoc->GetLevel(--lookLine);
}
- int lineParent = pdoc->GetFoldParent(lookLine);
+ Sci::Line lineParent = pdoc->GetFoldParent(lookLine);
if (lineParent < 0) {
// Backed up to a top level line, so try to find parent of initial line
lineParent = pdoc->GetFoldParent(lineDoc);
@@ -5396,7 +5397,7 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {
Redraw();
}
if (enforcePolicy) {
- int lineDisplay = cs.DisplayFromDoc(lineDoc);
+ 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()));
@@ -5420,7 +5421,7 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {
void Editor::FoldAll(int action) {
pdoc->EnsureStyledTo(pdoc->Length());
- int maxLine = pdoc->LinesTotal();
+ Sci::Line maxLine = pdoc->LinesTotal();
bool expanding = action == SC_FOLDACTION_EXPAND;
if (action == SC_FOLDACTION_TOGGLE) {
// Discover current state
@@ -5445,7 +5446,7 @@ void Editor::FoldAll(int action) {
if ((level & SC_FOLDLEVELHEADERFLAG) &&
(SC_FOLDLEVELBASE == LevelNumber(level))) {
SetFoldExpanded(line, false);
- int lineMaxSubord = pdoc->GetLastChild(line, -1);
+ Sci::Line lineMaxSubord = pdoc->GetLastChild(line, -1);
if (lineMaxSubord > line) {
cs.SetVisible(line + 1, lineMaxSubord, false);
}
@@ -5456,7 +5457,7 @@ void Editor::FoldAll(int action) {
Redraw();
}
-void Editor::FoldChanged(int line, int levelNow, int levelPrev) {
+void Editor::FoldChanged(Sci::Line line, int levelNow, int levelPrev) {
if (levelNow & SC_FOLDLEVELHEADERFLAG) {
if (!(levelPrev & SC_FOLDLEVELHEADERFLAG)) {
// Adding a fold point.
@@ -5466,7 +5467,7 @@ void Editor::FoldChanged(int line, int levelNow, int levelPrev) {
FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev);
}
} else if (levelPrev & SC_FOLDLEVELHEADERFLAG) {
- const int prevLine = line - 1;
+ const Sci::Line prevLine = line - 1;
const int prevLineLevel = pdoc->GetLevel(prevLine);
// Combining two blocks where the first block is collapsed (e.g. by deleting the line(s) which separate(s) the two blocks)
@@ -5487,7 +5488,7 @@ void Editor::FoldChanged(int line, int levelNow, int levelPrev) {
(LevelNumber(levelPrev) > LevelNumber(levelNow))) {
if (cs.HiddenLines()) {
// See if should still be hidden
- int parentLine = pdoc->GetFoldParent(line);
+ Sci::Line parentLine = pdoc->GetFoldParent(line);
if ((parentLine < 0) || (cs.GetExpanded(parentLine) && cs.GetVisible(parentLine))) {
cs.SetVisible(line, line, true);
SetScrollBars();
@@ -5499,18 +5500,18 @@ void Editor::FoldChanged(int line, int levelNow, int levelPrev) {
// Combining two blocks where the first one is collapsed (e.g. by adding characters in the line which separates the two blocks)
if (!(levelNow & SC_FOLDLEVELWHITEFLAG) && (LevelNumber(levelPrev) < LevelNumber(levelNow))) {
if (cs.HiddenLines()) {
- const int parentLine = pdoc->GetFoldParent(line);
+ const Sci::Line parentLine = pdoc->GetFoldParent(line);
if (!cs.GetExpanded(parentLine) && cs.GetVisible(line))
FoldLine(parentLine, SC_FOLDACTION_EXPAND);
}
}
}
-void Editor::NeedShown(int pos, int len) {
+void Editor::NeedShown(Sci::Position pos, Sci::Position len) {
if (foldAutomatic & SC_AUTOMATICFOLD_SHOW) {
- int lineStart = pdoc->LineFromPosition(pos);
- int lineEnd = pdoc->LineFromPosition(pos+len);
- for (int line = lineStart; line <= lineEnd; line++) {
+ Sci::Line lineStart = pdoc->LineFromPosition(pos);
+ Sci::Line lineEnd = pdoc->LineFromPosition(pos+len);
+ for (Sci::Line line = lineStart; line <= lineEnd; line++) {
EnsureLineVisible(line, false);
}
} else {
@@ -5518,9 +5519,9 @@ void Editor::NeedShown(int pos, int len) {
}
}
-int Editor::GetTag(char *tagValue, int tagNumber) {
+Sci::Position Editor::GetTag(char *tagValue, int tagNumber) {
const char *text = 0;
- int length = 0;
+ Sci::Position length = 0;
if ((tagNumber >= 1) && (tagNumber <= 9)) {
char name[3] = "\\?";
name[1] = static_cast<char>(tagNumber + '0');
@@ -5536,7 +5537,7 @@ int Editor::GetTag(char *tagValue, int tagNumber) {
return length;
}
-int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) {
+Sci::Position Editor::ReplaceTarget(bool replacePatterns, const char *text, Sci::Position length) {
UndoGroup ug(pdoc);
if (length == -1)
length = istrlen(text);
@@ -5549,7 +5550,7 @@ int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) {
if (targetStart != targetEnd)
pdoc->DeleteChars(targetStart, targetEnd - targetStart);
targetEnd = targetStart;
- const int lengthInserted = pdoc->InsertString(targetStart, text, length);
+ const Sci::Position lengthInserted = pdoc->InsertString(targetStart, text, length);
targetEnd = targetStart + lengthInserted;
return length;
}
@@ -5577,15 +5578,15 @@ int Editor::WrapCount(int line) {
}
}
-void Editor::AddStyledText(char *buffer, int appendLength) {
+void Editor::AddStyledText(char *buffer, Sci::Position appendLength) {
// The buffer consists of alternating character bytes and style bytes
- int textLength = appendLength / 2;
+ Sci::Position textLength = appendLength / 2;
std::string text(textLength, '\0');
- int i;
+ Sci::Position i;
for (i = 0; i < textLength; i++) {
text[i] = buffer[i*2];
}
- const int lengthInserted = pdoc->InsertString(CurrentPosition(), text.c_str(), textLength);
+ const Sci::Position lengthInserted = pdoc->InsertString(CurrentPosition(), text.c_str(), textLength);
for (i = 0; i < textLength; i++) {
text[i] = buffer[i*2+1];
}
@@ -5854,14 +5855,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETLINE: { // Risk of overwriting the end of the buffer
- int lineStart = pdoc->LineStart(static_cast<int>(wParam));
- int lineEnd = pdoc->LineStart(static_cast<int>(wParam + 1));
+ Sci::Position lineStart = pdoc->LineStart(static_cast<Sci::Line>(wParam));
+ Sci::Position lineEnd = pdoc->LineStart(static_cast<Sci::Line>(wParam + 1));
if (lParam == 0) {
return lineEnd - lineStart;
}
char *ptr = CharPtrFromSPtr(lParam);
- int iPlace = 0;
- for (int iChar = lineStart; iChar < lineEnd; iChar++) {
+ Sci::Position iPlace = 0;
+ for (Sci::Position iChar = lineStart; iChar < lineEnd; iChar++) {
ptr[iPlace++] = pdoc->CharAt(iChar);
}
return iPlace;
@@ -5877,8 +5878,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return !pdoc->IsSavePoint();
case SCI_SETSEL: {
- int nStart = static_cast<int>(wParam);
- int nEnd = static_cast<int>(lParam);
+ Sci::Position nStart = static_cast<Sci::Position>(wParam);
+ Sci::Position nEnd = static_cast<Sci::Position>(lParam);
if (nEnd < 0)
nEnd = pdoc->Length();
if (nStart < 0)
@@ -5919,7 +5920,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
wParam = pdoc->LineFromPosition(SelectionStart().Position());
if (wParam == 0)
return 0; // Even if there is no text, there is a first line that starts at 0
- if (static_cast<int>(wParam) > pdoc->LinesTotal())
+ if (static_cast<Sci::Line>(wParam) > pdoc->LinesTotal())
return -1;
//if (wParam > pdoc->LineFromPosition(pdoc->Length())) // Useful test, anyway...
// return -1;
@@ -5938,7 +5939,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
UndoGroup ug(pdoc);
ClearSelection();
char *replacement = CharPtrFromSPtr(lParam);
- const int lengthInserted = pdoc->InsertString(
+ const Sci::Position lengthInserted = pdoc->InsertString(
sel.MainCaret(), replacement, istrlen(replacement));
SetEmptySelection(sel.MainCaret() + lengthInserted);
EnsureCaretVisible();
@@ -5986,15 +5987,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_REPLACETARGET:
PLATFORM_ASSERT(lParam);
- return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast<int>(wParam));
+ return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
case SCI_REPLACETARGETRE:
PLATFORM_ASSERT(lParam);
- return ReplaceTarget(true, CharPtrFromSPtr(lParam), static_cast<int>(wParam));
+ return ReplaceTarget(true, CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
case SCI_SEARCHINTARGET:
PLATFORM_ASSERT(lParam);
- return SearchInTarget(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
+ return SearchInTarget(CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
case SCI_SETSEARCHFLAGS:
searchFlags = static_cast<int>(wParam);
@@ -6016,8 +6017,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return Platform::Clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length());
case SCI_LINESCROLL:
- ScrollTo(topLine + static_cast<int>(lParam));
- HorizontalScrollTo(xOffset + static_cast<int>(wParam)* static_cast<int>(vs.spaceWidth));
+ ScrollTo(topLine + static_cast<Sci::Line>(lParam));
+ HorizontalScrollTo(xOffset + static_cast<int>(wParam) * static_cast<int>(vs.spaceWidth));
return 1;
case SCI_SETXOFFSET:
@@ -6072,7 +6073,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (lParam == 0)
return 0;
Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam);
- int cpMax = static_cast<int>(tr->chrg.cpMax);
+ Sci::Position cpMax = static_cast<Sci::Position>(tr->chrg.cpMax);
if (cpMax == -1)
cpMax = pdoc->Length();
PLATFORM_ASSERT(cpMax <= pdoc->Length());
@@ -6113,26 +6114,26 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_ADDTEXT: {
if (lParam == 0)
return 0;
- const int lengthInserted = pdoc->InsertString(
- CurrentPosition(), CharPtrFromSPtr(lParam), static_cast<int>(wParam));
+ const Sci::Position lengthInserted = pdoc->InsertString(
+ CurrentPosition(), CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
SetEmptySelection(sel.MainCaret() + lengthInserted);
return 0;
}
case SCI_ADDSTYLEDTEXT:
if (lParam)
- AddStyledText(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
+ AddStyledText(CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
return 0;
case SCI_INSERTTEXT: {
if (lParam == 0)
return 0;
- int insertPos = static_cast<int>(wParam);
+ Sci::Position insertPos = static_cast<Sci::Position>(wParam);
if (static_cast<int>(wParam) == -1)
insertPos = CurrentPosition();
- int newCurrent = CurrentPosition();
+ Sci::Position newCurrent = CurrentPosition();
char *sz = CharPtrFromSPtr(lParam);
- const int lengthInserted = pdoc->InsertString(insertPos, sz, istrlen(sz));
+ const Sci::Position lengthInserted = pdoc->InsertString(insertPos, sz, istrlen(sz));
if (newCurrent > insertPos)
newCurrent += lengthInserted;
SetEmptySelection(newCurrent);
@@ -6221,11 +6222,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->Length();
case SCI_ALLOCATE:
- pdoc->Allocate(static_cast<int>(wParam));
+ pdoc->Allocate(static_cast<Sci::Position>(wParam));
break;
case SCI_GETCHARAT:
- return pdoc->CharAt(static_cast<int>(wParam));
+ return pdoc->CharAt(static_cast<Sci::Position>(wParam));
case SCI_SETCURRENTPOS:
if (sel.IsRectangular()) {
@@ -6233,7 +6234,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
SetRectangularRange();
Redraw();
} else {
- SetSelection(static_cast<int>(wParam), sel.MainAnchor());
+ SetSelection(static_cast<Sci::Position>(wParam), sel.MainAnchor());
}
break;
@@ -6242,11 +6243,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETANCHOR:
if (sel.IsRectangular()) {
- sel.Rectangular().anchor.SetPosition(static_cast<int>(wParam));
+ sel.Rectangular().anchor.SetPosition(static_cast<Sci::Position>(wParam));
SetRectangularRange();
Redraw();
} else {
- SetSelection(sel.MainCaret(), static_cast<int>(wParam));
+ SetSelection(sel.MainCaret(), static_cast<Sci::Position>(wParam));
}
break;
@@ -6254,14 +6255,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor();
case SCI_SETSELECTIONSTART:
- SetSelection(Platform::Maximum(sel.MainCaret(), static_cast<int>(wParam)), static_cast<int>(wParam));
+ SetSelection(std::max(sel.MainCaret(), static_cast<Sci::Position>(wParam)), static_cast<Sci::Position>(wParam));
break;
case SCI_GETSELECTIONSTART:
return sel.LimitsForRectangularElseMain().start.Position();
case SCI_SETSELECTIONEND:
- SetSelection(static_cast<int>(wParam), Platform::Minimum(sel.MainAnchor(), static_cast<int>(wParam)));
+ SetSelection(static_cast<Sci::Position>(wParam), Platform::Minimum(sel.MainAnchor(), static_cast<Sci::Position>(wParam)));
break;
case SCI_GETSELECTIONEND:
@@ -6384,16 +6385,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETCURLINE: {
- int lineCurrentPos = pdoc->LineFromPosition(sel.MainCaret());
- int lineStart = pdoc->LineStart(lineCurrentPos);
- unsigned int lineEnd = pdoc->LineStart(lineCurrentPos + 1);
+ const Sci::Line lineCurrentPos = pdoc->LineFromPosition(sel.MainCaret());
+ const Sci::Position lineStart = pdoc->LineStart(lineCurrentPos);
+ const Sci::Position lineEnd = pdoc->LineStart(lineCurrentPos + 1);
if (lParam == 0) {
return 1 + lineEnd - lineStart;
}
PLATFORM_ASSERT(wParam > 0);
char *ptr = CharPtrFromSPtr(lParam);
unsigned int iPlace = 0;
- for (unsigned int iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) {
+ for (Sci::Position iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) {
ptr[iPlace++] = pdoc->CharAt(iChar);
}
ptr[iPlace] = '\0';
diff --git a/src/Editor.h b/src/Editor.h
index 985f64bae..00611cf1c 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -47,14 +47,14 @@ public:
workUpdateUI=2
};
enum workItems items;
- Position upTo;
+ Sci::Position upTo;
WorkNeeded() : items(workNone), upTo(0) {}
void Reset() {
items = workNone;
upTo = 0;
}
- void Need(workItems items_, Position pos) {
+ void Need(workItems items_, Sci::Position pos) {
if ((items_ & workStyle) && (upTo < pos))
upTo = pos;
items = static_cast<workItems>(items | items_);
@@ -115,8 +115,8 @@ private:
struct WrapPending {
// The range of lines that need to be wrapped
enum { lineLarge = 0x7ffffff };
- int start; // When there are wraps pending, will be in document range
- int end; // May be lineLarge to indicate all of document after start
+ Sci::Line start; // When there are wraps pending, will be in document range
+ Sci::Line end; // May be lineLarge to indicate all of document after start
WrapPending() {
start = lineLarge;
end = lineLarge;
@@ -125,14 +125,14 @@ struct WrapPending {
start = lineLarge;
end = lineLarge;
}
- void Wrapped(int line) {
+ void Wrapped(Sci::Line line) {
if (start == line)
start++;
}
bool NeedsWrap() const {
return start < end;
}
- bool AddRange(int lineStart, int lineEnd) {
+ bool AddRange(Sci::Line lineStart, Sci::Line lineEnd) {
const bool neededWrap = NeedsWrap();
bool changed = false;
if (start > lineStart) {
@@ -211,19 +211,19 @@ protected: // ScintillaBase subclass needs access to much of Editor
enum { ddNone, ddInitial, ddDragging } inDragDrop;
bool dropWentOutside;
SelectionPosition posDrop;
- int hotSpotClickPos;
+ Sci::Position hotSpotClickPos;
int lastXChosen;
- int lineAnchorPos;
- int originalAnchorPos;
- int wordSelectAnchorStartPos;
- int wordSelectAnchorEndPos;
- int wordSelectInitialCaretPos;
- int targetStart;
- int targetEnd;
+ Sci::Position lineAnchorPos;
+ Sci::Position originalAnchorPos;
+ Sci::Position wordSelectAnchorStartPos;
+ Sci::Position wordSelectAnchorEndPos;
+ Sci::Position wordSelectInitialCaretPos;
+ Sci::Position targetStart;
+ Sci::Position targetEnd;
int searchFlags;
- int topLine;
- int posTopLine;
- int lengthForEncode;
+ Sci::Line topLine;
+ Sci::Position posTopLine;
+ Sci::Position lengthForEncode;
int needUpdateUI;
@@ -249,7 +249,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
int visiblePolicy;
int visibleSlop;
- int searchAnchor;
+ Sci::Position searchAnchor;
bool recordingMacro;
@@ -276,38 +276,38 @@ protected: // ScintillaBase subclass needs access to much of Editor
// scroll views where it will be equivalent to the current scroll position.
virtual Point GetVisibleOriginInMain() const override;
PointDocument DocumentPointFromView(Point ptView) const; // Convert a point from view space to document
- int TopLineOfMain() const override; // Return the line at Main's y coordinate 0
+ Sci::Line TopLineOfMain() const override; // Return the line at Main's y coordinate 0
virtual PRectangle GetClientRectangle() const;
virtual PRectangle GetClientDrawingRectangle();
PRectangle GetTextRectangle() const;
- virtual int LinesOnScreen() const override;
- int LinesToScroll() const;
- int MaxScrollPos() const;
+ virtual Sci::Line LinesOnScreen() const override;
+ Sci::Line LinesToScroll() const;
+ Sci::Line MaxScrollPos() const;
SelectionPosition ClampPositionIntoDocument(SelectionPosition sp) const;
Point LocationFromPosition(SelectionPosition pos, PointEnd pe=peDefault);
- Point LocationFromPosition(int pos, PointEnd pe=peDefault);
- int XFromPosition(int pos);
+ Point LocationFromPosition(Sci::Position pos, PointEnd pe=peDefault);
+ int XFromPosition(Sci::Position pos);
int XFromPosition(SelectionPosition sp);
SelectionPosition SPositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false, bool virtualSpace=true);
- int PositionFromLocation(Point pt, bool canReturnInvalid = false, bool charPosition = false);
- SelectionPosition SPositionFromLineX(int lineDoc, int x);
- int PositionFromLineX(int line, int x);
- int LineFromLocation(Point pt) const;
- void SetTopLine(int topLineNew);
+ Sci::Position PositionFromLocation(Point pt, bool canReturnInvalid = false, bool charPosition = false);
+ SelectionPosition SPositionFromLineX(Sci::Line lineDoc, int x);
+ Sci::Position PositionFromLineX(Sci::Line line, int x);
+ Sci::Line LineFromLocation(Point pt) const;
+ void SetTopLine(Sci::Line topLineNew);
virtual bool AbandonPaint();
virtual void RedrawRect(PRectangle rc);
virtual void DiscardOverdraw();
virtual void Redraw();
- void RedrawSelMargin(int line=-1, bool allAfter=false);
+ void RedrawSelMargin(Sci::Line line=-1, bool allAfter=false);
PRectangle RectangleFromRange(Range r, int overlap);
- void InvalidateRange(int start, int end);
+ void InvalidateRange(Sci::Position start, Sci::Position end);
bool UserVirtualSpace() const {
return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0);
}
- int CurrentPosition() const;
+ Sci::Position CurrentPosition() const;
bool SelectionEmpty() const;
SelectionPosition SelectionStart();
SelectionPosition SelectionEnd();
@@ -316,39 +316,39 @@ protected: // ScintillaBase subclass needs access to much of Editor
void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false);
void InvalidateWholeSelection();
void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_);
- void SetSelection(int currentPos_, int anchor_);
+ void SetSelection(Sci::Position currentPos_, Sci::Position anchor_);
void SetSelection(SelectionPosition currentPos_);
void SetSelection(int currentPos_);
void SetEmptySelection(SelectionPosition currentPos_);
- void SetEmptySelection(int currentPos_);
+ void SetEmptySelection(Sci::Position currentPos_);
enum AddNumber { addOne, addEach };
void MultipleSelectAdd(AddNumber addNumber);
- bool RangeContainsProtected(int start, int end) const;
+ bool RangeContainsProtected(Sci::Position start, Sci::Position end) const;
bool SelectionContainsProtected();
- int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
- SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const;
+ Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd=true) const;
+ SelectionPosition MovePositionOutsideChar(SelectionPosition pos, Sci::Position moveDir, bool checkLineEnd=true) const;
void MovedCaret(SelectionPosition newPos, SelectionPosition previousPos, bool ensureVisible);
void MovePositionTo(SelectionPosition newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
- void MovePositionTo(int newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
+ void MovePositionTo(Sci::Position newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
SelectionPosition MovePositionSoVisible(SelectionPosition pos, int moveDir);
- SelectionPosition MovePositionSoVisible(int pos, int moveDir);
+ SelectionPosition MovePositionSoVisible(Sci::Position pos, int moveDir);
Point PointMainCaret();
void SetLastXChosen();
- void ScrollTo(int line, bool moveThumb=true);
- virtual void ScrollText(int linesToMove);
+ void ScrollTo(Sci::Line line, bool moveThumb=true);
+ virtual void ScrollText(Sci::Line linesToMove);
void HorizontalScrollTo(int xPos);
void VerticalCentreCaret();
void MoveSelectedLines(int lineDelta);
void MoveSelectedLinesUp();
void MoveSelectedLinesDown();
void MoveCaretInsideView(bool ensureVisible=true);
- int DisplayFromPosition(int pos);
+ Sci::Line DisplayFromPosition(Sci::Position pos);
struct XYScrollPosition {
int xOffset;
- int topLine;
- XYScrollPosition(int xOffset_, int topLine_) : xOffset(xOffset_), topLine(topLine_) {}
+ Sci::Line topLine;
+ XYScrollPosition(int xOffset_, Sci::Line topLine_) : xOffset(xOffset_), topLine(topLine_) {}
bool operator==(const XYScrollPosition &other) const {
return (xOffset == other.xOffset) && (topLine == other.topLine);
}
@@ -370,8 +370,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void UpdateSystemCaret();
bool Wrapping() const;
- void NeedWrapping(int docLineStart=0, int docLineEnd=WrapPending::lineLarge);
- bool WrapOneLine(Surface *surface, int lineToWrap);
+ void NeedWrapping(Sci::Line docLineStart=0, Sci::Line docLineEnd=WrapPending::lineLarge);
+ bool WrapOneLine(Surface *surface, Sci::Line lineToWrap);
enum class WrapScope {wsAll, wsVisible, wsIdle};
bool WrapLines(WrapScope ws);
void LinesJoin();
@@ -385,13 +385,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void SetVerticalScrollPos() = 0;
virtual void SetHorizontalScrollPos() = 0;
- virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
+ virtual bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) = 0;
virtual void ReconfigureScrollBars();
void SetScrollBars();
void ChangeSize();
void FilterSelections();
- int RealizeVirtualSpace(int position, unsigned int virtualSpace);
+ Sci::Position RealizeVirtualSpace(Sci::Position position, Sci::Position virtualSpace);
SelectionPosition RealizeVirtualSpace(const SelectionPosition &position);
void AddChar(char ch);
virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false);
@@ -403,7 +403,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void ClearAll();
void ClearDocumentStyle();
virtual void Cut();
- void PasteRectangular(SelectionPosition pos, const char *ptr, int len);
+ void PasteRectangular(SelectionPosition pos, const char *ptr, Sci::Position len);
virtual void Copy() = 0;
virtual void CopyAllowLine();
virtual bool CanPaste();
@@ -421,26 +421,26 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void SetCtrlID(int identifier);
virtual int GetCtrlID() { return ctrlID; }
virtual void NotifyParent(SCNotification scn) = 0;
- virtual void NotifyStyleToNeeded(int endStyleNeeded);
+ virtual void NotifyStyleToNeeded(Sci::Position endStyleNeeded);
void NotifyChar(int ch);
void NotifySavePoint(bool isSavePoint);
void NotifyModifyAttempt();
virtual void NotifyDoubleClick(Point pt, int modifiers);
virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt);
- void NotifyHotSpotClicked(int position, int modifiers);
- void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt);
- void NotifyHotSpotDoubleClicked(int position, int modifiers);
- void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);
- void NotifyHotSpotReleaseClick(int position, int modifiers);
- void NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt);
+ void NotifyHotSpotClicked(Sci::Position position, int modifiers);
+ void NotifyHotSpotClicked(Sci::Position position, bool shift, bool ctrl, bool alt);
+ void NotifyHotSpotDoubleClicked(Sci::Position position, int modifiers);
+ void NotifyHotSpotDoubleClicked(Sci::Position position, bool shift, bool ctrl, bool alt);
+ void NotifyHotSpotReleaseClick(Sci::Position position, int modifiers);
+ void NotifyHotSpotReleaseClick(Sci::Position position, bool shift, bool ctrl, bool alt);
bool NotifyUpdateUI();
void NotifyPainted();
- void NotifyIndicatorClick(bool click, int position, int modifiers);
- void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);
+ void NotifyIndicatorClick(bool click, Sci::Position position, int modifiers);
+ void NotifyIndicatorClick(bool click, Sci::Position position, bool shift, bool ctrl, bool alt);
bool NotifyMarginClick(Point pt, int modifiers);
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
bool NotifyMarginRightClick(Point pt, int modifiers);
- void NotifyNeedShown(int pos, int len);
+ void NotifyNeedShown(Sci::Position pos, Sci::Position len);
void NotifyDwelling(Point pt, bool state);
void NotifyZoom();
@@ -449,7 +449,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void CheckModificationForWrap(DocModification mh);
void NotifyModified(Document *document, DocModification mh, void *userData) override;
void NotifyDeleted(Document *document, void *userData) override;
- void NotifyStyleNeeded(Document *doc, void *userData, int endPos) override;
+ void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos) override;
void NotifyLexerChanged(Document *doc, void *userData) override;
void NotifyErrorOccurred(Document *doc, void *userData, int status) override;
void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
@@ -466,11 +466,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
SelectionPosition PositionUpOrDown(SelectionPosition spStart, int direction, int lastX);
void CursorUpOrDown(int direction, Selection::selTypes selt);
void ParaUpOrDown(int direction, Selection::selTypes selt);
- Range RangeDisplayLine(int lineVisible);
- int StartEndDisplayLine(int pos, bool start);
- int VCHomeDisplayPosition(int position);
- int VCHomeWrapPosition(int position);
- int LineEndWrapPosition(int position);
+ Range RangeDisplayLine(Sci::Line lineVisible);
+ Sci::Position StartEndDisplayLine(Sci::Position pos, bool start);
+ Sci::Position VCHomeDisplayPosition(Sci::Position position);
+ Sci::Position VCHomeWrapPosition(Sci::Position position);
+ Sci::Position LineEndWrapPosition(Sci::Position position);
int HorizontalMove(unsigned int iMessage);
int DelWordOrLine(unsigned int iMessage);
virtual int KeyCommand(unsigned int iMessage);
@@ -484,13 +484,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
long FindText(uptr_t wParam, sptr_t lParam);
void SearchAnchor();
long SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
- long SearchInTarget(const char *text, int length);
- void GoToLine(int lineNo);
+ long SearchInTarget(const char *text, Sci::Position length);
+ void GoToLine(Sci::Line lineNo);
virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
- std::string RangeText(int start, int end) const;
+ std::string RangeText(Sci::Position start, Sci::Position end) const;
void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false);
- void CopyRangeToClipboard(int start, int end);
+ void CopyRangeToClipboard(Sci::Position start, Sci::Position end);
void CopyText(int length, const char *text);
void SetDragPosition(SelectionPosition newPos);
virtual void DisplayCursor(Window::Cursor c);
@@ -499,13 +499,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
void DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular);
void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular);
/** PositionInSelection returns true if position in selection. */
- bool PositionInSelection(int pos);
+ bool PositionInSelection(Sci::Position pos);
bool PointInSelection(Point pt);
bool PointInSelMargin(Point pt) const;
Window::Cursor GetMarginCursor(Point pt) const;
- void TrimAndSetSelection(int currentPos_, int anchor_);
- void LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine);
- void WordSelection(int pos);
+ void TrimAndSetSelection(Sci::Position currentPos_, Sci::Position anchor_);
+ void LineSelection(Sci::Position lineCurrentPos_, Sci::Position lineAnchorPos_, bool wholeLine);
+ void WordSelection(Sci::Position pos);
void DwellEnd(bool mouseMoved);
void MouseLeave();
virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
@@ -529,49 +529,49 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual bool HaveMouseCapture() = 0;
void SetFocusState(bool focusState);
- int PositionAfterArea(PRectangle rcArea) const;
- void StyleToPositionInView(Position pos);
- int PositionAfterMaxStyling(int posMax, bool scrolling) const;
+ Sci::Position PositionAfterArea(PRectangle rcArea) const;
+ void StyleToPositionInView(Sci::Position pos);
+ Sci::Position PositionAfterMaxStyling(Sci::Position posMax, bool scrolling) const;
void StartIdleStyling(bool truncatedLastStyling);
void StyleAreaBounded(PRectangle rcArea, bool scrolling);
void IdleStyling();
virtual void IdleWork();
- virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo=0);
+ virtual void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo=0);
virtual bool PaintContains(PRectangle rc);
bool PaintContainsMargin();
void CheckForChangeOutsidePaint(Range r);
- void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
+ void SetBraceHighlight(Sci::Position pos0, Sci::Position pos1, int matchStyle);
- void SetAnnotationHeights(int start, int end);
+ void SetAnnotationHeights(Sci::Line start, Sci::Line end);
virtual void SetDocPointer(Document *document);
void SetAnnotationVisible(int visible);
- int ExpandLine(int line);
- void SetFoldExpanded(int lineDoc, bool expanded);
- void FoldLine(int line, int action);
- void FoldExpand(int line, int action, int level);
- int ContractedFoldNext(int lineStart) const;
- void EnsureLineVisible(int lineDoc, bool enforcePolicy);
- void FoldChanged(int line, int levelNow, int levelPrev);
- void NeedShown(int pos, int len);
+ Sci::Line ExpandLine(Sci::Line line);
+ void SetFoldExpanded(Sci::Line lineDoc, bool expanded);
+ void FoldLine(Sci::Line line, int action);
+ void FoldExpand(Sci::Line line, int action, int level);
+ Sci::Line ContractedFoldNext(Sci::Line lineStart) const;
+ void EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy);
+ void FoldChanged(Sci::Line line, int levelNow, int levelPrev);
+ void NeedShown(Sci::Position pos, Sci::Position len);
void FoldAll(int action);
- int GetTag(char *tagValue, int tagNumber);
- int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
+ Sci::Position GetTag(char *tagValue, int tagNumber);
+ Sci::Position ReplaceTarget(bool replacePatterns, const char *text, Sci::Position length=-1);
- bool PositionIsHotspot(int position) const;
+ bool PositionIsHotspot(Sci::Position position) const;
bool PointIsHotspot(Point pt);
void SetHotSpotRange(Point *pt);
Range GetHotSpotRange() const override;
- void SetHoverIndicatorPosition(int position);
+ void SetHoverIndicatorPosition(Sci::Position position);
void SetHoverIndicatorPoint(Point pt);
int CodePage() const;
virtual bool ValidCodePage(int /* codePage */) const { return true; }
int WrapCount(int line);
- void AddStyledText(char *buffer, int appendLength);
+ void AddStyledText(char *buffer, Sci::Position appendLength);
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
bool ValidMargin(uptr_t wParam) const;
diff --git a/src/MarginView.cxx b/src/MarginView.cxx
index 3ec70f01e..ed1219a5d 100644
--- a/src/MarginView.cxx
+++ b/src/MarginView.cxx
@@ -183,7 +183,7 @@ static int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault, const Vie
return markerCheck;
}
-void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRectangle rcMargin,
+void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc, PRectangle rcMargin,
const EditModel &model, const ViewStyle &vs) {
PRectangle rcSelMargin = rcMargin;
@@ -230,8 +230,8 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
}
const int lineStartPaint = static_cast<int>(rcMargin.top + ptOrigin.y) / vs.lineHeight;
- int visibleLine = model.TopLineOfMain() + lineStartPaint;
- int yposScreen = lineStartPaint * vs.lineHeight - static_cast<int>(ptOrigin.y);
+ Sci::Line visibleLine = model.TopLineOfMain() + lineStartPaint;
+ Sci::Position yposScreen = lineStartPaint * vs.lineHeight - static_cast<Sci::Position>(ptOrigin.y);
// Work out whether the top line is whitespace located after a
// lessening of fold level which implies a 'fold tail' but which should not
// be displayed until the last of a sequence of whitespace.
@@ -239,7 +239,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
if (vs.ms[margin].mask & SC_MASK_FOLDERS) {
int level = model.pdoc->GetLevel(model.cs.DocFromDisplay(visibleLine));
if (level & SC_FOLDLEVELWHITEFLAG) {
- int lineBack = model.cs.DocFromDisplay(visibleLine);
+ Sci::Line lineBack = model.cs.DocFromDisplay(visibleLine);
int levelPrev = level;
while ((lineBack > 0) && (levelPrev & SC_FOLDLEVELWHITEFLAG)) {
lineBack--;
@@ -251,7 +251,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
}
}
if (highlightDelimiter.isEnabled) {
- int lastLine = model.cs.DocFromDisplay(topLine + model.LinesOnScreen()) + 1;
+ Sci::Line lastLine = model.cs.DocFromDisplay(topLine + model.LinesOnScreen()) + 1;
model.pdoc->GetHighlightDelimiters(highlightDelimiter, model.pdoc->LineFromPosition(model.sel.MainCaret()), lastLine);
}
}
@@ -265,10 +265,10 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
while ((visibleLine < model.cs.LinesDisplayed()) && yposScreen < rc.bottom) {
PLATFORM_ASSERT(visibleLine < model.cs.LinesDisplayed());
- const int lineDoc = model.cs.DocFromDisplay(visibleLine);
+ const Sci::Line lineDoc = model.cs.DocFromDisplay(visibleLine);
PLATFORM_ASSERT(model.cs.GetVisible(lineDoc));
- const int firstVisibleLine = model.cs.DisplayFromDoc(lineDoc);
- const int lastVisibleLine = model.cs.DisplayLastFromDoc(lineDoc);
+ const Sci::Line firstVisibleLine = model.cs.DisplayFromDoc(lineDoc);
+ const Sci::Line lastVisibleLine = model.cs.DisplayLastFromDoc(lineDoc);
const bool firstSubLine = visibleLine == firstVisibleLine;
const bool lastSubLine = visibleLine == lastVisibleLine;
@@ -313,7 +313,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
}
}
needWhiteClosure = false;
- const int firstFollowupLine = model.cs.DocFromDisplay(model.cs.DisplayFromDoc(lineDoc + 1));
+ const Sci::Line firstFollowupLine = model.cs.DocFromDisplay(model.cs.DisplayFromDoc(lineDoc + 1));
const int firstFollowupLineLevel = model.pdoc->GetLevel(firstFollowupLine);
const int secondFollowupLineLevelNum = LevelNumber(model.pdoc->GetLevel(firstFollowupLine + 1));
if (!model.cs.GetExpanded(lineDoc)) {
diff --git a/src/MarginView.h b/src/MarginView.h
index ff5564676..eb136d71e 100644
--- a/src/MarginView.h
+++ b/src/MarginView.h
@@ -39,7 +39,7 @@ public:
void DropGraphics(bool freeObjects);
void AllocateGraphics(const ViewStyle &vsDraw);
void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw);
- void PaintMargin(Surface *surface, int topLine, PRectangle rc, PRectangle rcMargin,
+ void PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc, PRectangle rcMargin,
const EditModel &model, const ViewStyle &vs);
};
diff --git a/src/PerLine.cxx b/src/PerLine.cxx
index 6a3dd33dd..6b1267b5d 100644
--- a/src/PerLine.cxx
+++ b/src/PerLine.cxx
@@ -131,13 +131,13 @@ void LineMarkers::Init() {
markers.DeleteAll();
}
-void LineMarkers::InsertLine(int line) {
+void LineMarkers::InsertLine(Sci::Line line) {
if (markers.Length()) {
markers.Insert(line, 0);
}
}
-void LineMarkers::RemoveLine(int line) {
+void LineMarkers::RemoveLine(Sci::Line line) {
// Retain the markers from the deleted line by oring them into the previous line
if (markers.Length()) {
if (line > 0) {
@@ -147,9 +147,9 @@ void LineMarkers::RemoveLine(int line) {
}
}
-int LineMarkers::LineFromHandle(int markerHandle) {
+Sci::Line LineMarkers::LineFromHandle(int markerHandle) {
if (markers.Length()) {
- for (int line = 0; line < markers.Length(); line++) {
+ for (Sci::Line line = 0; line < markers.Length(); line++) {
if (markers[line]) {
if (markers[line]->Contains(markerHandle)) {
return line;
@@ -160,28 +160,28 @@ int LineMarkers::LineFromHandle(int markerHandle) {
return -1;
}
-void LineMarkers::MergeMarkers(int pos) {
- if (markers[pos + 1] != NULL) {
- if (markers[pos] == NULL)
- markers[pos] = new MarkerHandleSet;
- markers[pos]->CombineWith(markers[pos + 1]);
- delete markers[pos + 1];
- markers[pos + 1] = NULL;
+void LineMarkers::MergeMarkers(Sci::Line line) {
+ if (markers[line + 1] != NULL) {
+ if (markers[line] == NULL)
+ markers[line] = new MarkerHandleSet;
+ markers[line]->CombineWith(markers[line + 1]);
+ delete markers[line + 1];
+ markers[line + 1] = NULL;
}
}
-int LineMarkers::MarkValue(int line) {
+int LineMarkers::MarkValue(Sci::Line line) {
if (markers.Length() && (line >= 0) && (line < markers.Length()) && markers[line])
return markers[line]->MarkValue();
else
return 0;
}
-int LineMarkers::MarkerNext(int lineStart, int mask) const {
+Sci::Line LineMarkers::MarkerNext(Sci::Line lineStart, int mask) const {
if (lineStart < 0)
lineStart = 0;
- int length = markers.Length();
- for (int iLine = lineStart; iLine < length; iLine++) {
+ Sci::Line length = markers.Length();
+ for (Sci::Line iLine = lineStart; iLine < length; iLine++) {
MarkerHandleSet *onLine = markers[iLine];
if (onLine && ((onLine->MarkValue() & mask) != 0))
//if ((pdoc->GetMark(iLine) & lParam) != 0)
@@ -190,7 +190,7 @@ int LineMarkers::MarkerNext(int lineStart, int mask) const {
return -1;
}
-int LineMarkers::AddMark(int line, int markerNum, int lines) {
+int LineMarkers::AddMark(Sci::Line line, int markerNum, Sci::Line lines) {
handleCurrent++;
if (!markers.Length()) {
// No existing markers so allocate one element per line
@@ -208,7 +208,7 @@ int LineMarkers::AddMark(int line, int markerNum, int lines) {
return handleCurrent;
}
-bool LineMarkers::DeleteMark(int line, int markerNum, bool all) {
+bool LineMarkers::DeleteMark(Sci::Line line, int markerNum, bool all) {
bool someChanges = false;
if (markers.Length() && (line >= 0) && (line < markers.Length()) && markers[line]) {
if (markerNum == -1) {
@@ -227,7 +227,7 @@ bool LineMarkers::DeleteMark(int line, int markerNum, bool all) {
}
void LineMarkers::DeleteMarkFromHandle(int markerHandle) {
- int line = LineFromHandle(markerHandle);
+ Sci::Line line = LineFromHandle(markerHandle);
if (line >= 0) {
markers[line]->RemoveHandle(markerHandle);
if (markers[line]->Length() == 0) {
@@ -244,14 +244,14 @@ void LineLevels::Init() {
levels.DeleteAll();
}
-void LineLevels::InsertLine(int line) {
+void LineLevels::InsertLine(Sci::Line line) {
if (levels.Length()) {
int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE;
levels.InsertValue(line, 1, level);
}
}
-void LineLevels::RemoveLine(int line) {
+void LineLevels::RemoveLine(Sci::Line line) {
if (levels.Length()) {
// Move up following lines but merge header flag from this line
// to line before to avoid a temporary disappearence causing expansion.
@@ -264,7 +264,7 @@ void LineLevels::RemoveLine(int line) {
}
}
-void LineLevels::ExpandLevels(int sizeNew) {
+void LineLevels::ExpandLevels(Sci::Line sizeNew) {
levels.InsertValue(levels.Length(), sizeNew - levels.Length(), SC_FOLDLEVELBASE);
}
@@ -272,7 +272,7 @@ void LineLevels::ClearLevels() {
levels.DeleteAll();
}
-int LineLevels::SetLevel(int line, int level, int lines) {
+int LineLevels::SetLevel(Sci::Line line, int level, Sci::Line lines) {
int prev = 0;
if ((line >= 0) && (line < lines)) {
if (!levels.Length()) {
@@ -286,7 +286,7 @@ int LineLevels::SetLevel(int line, int level, int lines) {
return prev;
}
-int LineLevels::GetLevel(int line) const {
+int LineLevels::GetLevel(Sci::Line line) const {
if (levels.Length() && (line >= 0) && (line < levels.Length())) {
return levels[line];
} else {
@@ -301,7 +301,7 @@ void LineState::Init() {
lineStates.DeleteAll();
}
-void LineState::InsertLine(int line) {
+void LineState::InsertLine(Sci::Line line) {
if (lineStates.Length()) {
lineStates.EnsureLength(line);
int val = (line < lineStates.Length()) ? lineStates[line] : 0;
@@ -309,27 +309,27 @@ void LineState::InsertLine(int line) {
}
}
-void LineState::RemoveLine(int line) {
+void LineState::RemoveLine(Sci::Line line) {
if (lineStates.Length() > line) {
lineStates.Delete(line);
}
}
-int LineState::SetLineState(int line, int state) {
+int LineState::SetLineState(Sci::Line line, int state) {
lineStates.EnsureLength(line + 1);
int stateOld = lineStates[line];
lineStates[line] = state;
return stateOld;
}
-int LineState::GetLineState(int line) {
+int LineState::GetLineState(Sci::Line line) {
if (line < 0)
return 0;
lineStates.EnsureLength(line + 1);
return lineStates[line];
}
-int LineState::GetMaxLineState() const {
+Sci::Line LineState::GetMaxLineState() const {
return lineStates.Length();
}
@@ -366,42 +366,42 @@ void LineAnnotation::Init() {
ClearAll();
}
-void LineAnnotation::InsertLine(int line) {
+void LineAnnotation::InsertLine(Sci::Line line) {
if (annotations.Length()) {
annotations.EnsureLength(line);
annotations.Insert(line, 0);
}
}
-void LineAnnotation::RemoveLine(int line) {
+void LineAnnotation::RemoveLine(Sci::Line line) {
if (annotations.Length() && (line > 0) && (line <= annotations.Length())) {
delete []annotations[line-1];
annotations.Delete(line-1);
}
}
-bool LineAnnotation::MultipleStyles(int line) const {
+bool LineAnnotation::MultipleStyles(Sci::Line line) const {
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
return reinterpret_cast<AnnotationHeader *>(annotations[line])->style == IndividualStyles;
else
return 0;
}
-int LineAnnotation::Style(int line) const {
+int LineAnnotation::Style(Sci::Line line) const {
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
return reinterpret_cast<AnnotationHeader *>(annotations[line])->style;
else
return 0;
}
-const char *LineAnnotation::Text(int line) const {
+const char *LineAnnotation::Text(Sci::Line line) const {
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
return annotations[line]+sizeof(AnnotationHeader);
else
return 0;
}
-const unsigned char *LineAnnotation::Styles(int line) const {
+const unsigned char *LineAnnotation::Styles(Sci::Line line) const {
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line] && MultipleStyles(line))
return reinterpret_cast<unsigned char *>(annotations[line] + sizeof(AnnotationHeader) + Length(line));
else
@@ -414,7 +414,7 @@ static char *AllocateAnnotation(int length, int style) {
return ret;
}
-void LineAnnotation::SetText(int line, const char *text) {
+void LineAnnotation::SetText(Sci::Line line, const char *text) {
if (text && (line >= 0)) {
annotations.EnsureLength(line+1);
int style = Style(line);
@@ -443,7 +443,7 @@ void LineAnnotation::ClearAll() {
annotations.DeleteAll();
}
-void LineAnnotation::SetStyle(int line, int style) {
+void LineAnnotation::SetStyle(Sci::Line line, int style) {
annotations.EnsureLength(line+1);
if (!annotations[line]) {
annotations[line] = AllocateAnnotation(0, style);
@@ -451,7 +451,7 @@ void LineAnnotation::SetStyle(int line, int style) {
reinterpret_cast<AnnotationHeader *>(annotations[line])->style = static_cast<short>(style);
}
-void LineAnnotation::SetStyles(int line, const unsigned char *styles) {
+void LineAnnotation::SetStyles(Sci::Line line, const unsigned char *styles) {
if (line >= 0) {
annotations.EnsureLength(line+1);
if (!annotations[line]) {
@@ -474,14 +474,14 @@ void LineAnnotation::SetStyles(int line, const unsigned char *styles) {
}
}
-int LineAnnotation::Length(int line) const {
+int LineAnnotation::Length(Sci::Line line) const {
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
return reinterpret_cast<AnnotationHeader *>(annotations[line])->length;
else
return 0;
}
-int LineAnnotation::Lines(int line) const {
+int LineAnnotation::Lines(Sci::Line line) const {
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
return reinterpret_cast<AnnotationHeader *>(annotations[line])->lines;
else
@@ -499,21 +499,21 @@ void LineTabstops::Init() {
tabstops.DeleteAll();
}
-void LineTabstops::InsertLine(int line) {
+void LineTabstops::InsertLine(Sci::Line line) {
if (tabstops.Length()) {
tabstops.EnsureLength(line);
tabstops.Insert(line, 0);
}
}
-void LineTabstops::RemoveLine(int line) {
+void LineTabstops::RemoveLine(Sci::Line line) {
if (tabstops.Length() > line) {
delete tabstops[line];
tabstops.Delete(line);
}
}
-bool LineTabstops::ClearTabstops(int line) {
+bool LineTabstops::ClearTabstops(Sci::Line line) {
if (line < tabstops.Length()) {
TabstopList *tl = tabstops[line];
if (tl) {
@@ -524,7 +524,7 @@ bool LineTabstops::ClearTabstops(int line) {
return false;
}
-bool LineTabstops::AddTabstop(int line, int x) {
+bool LineTabstops::AddTabstop(Sci::Line line, int x) {
tabstops.EnsureLength(line + 1);
if (!tabstops[line]) {
tabstops[line] = new TabstopList();
@@ -543,7 +543,7 @@ bool LineTabstops::AddTabstop(int line, int x) {
return false;
}
-int LineTabstops::GetNextTabstop(int line, int x) const {
+int LineTabstops::GetNextTabstop(Sci::Line line, int x) const {
if (line < tabstops.Length()) {
TabstopList *tl = tabstops[line];
if (tl) {
diff --git a/src/PerLine.h b/src/PerLine.h
index 4bf1c88fd..86e6a10e0 100644
--- a/src/PerLine.h
+++ b/src/PerLine.h
@@ -49,16 +49,16 @@ public:
}
virtual ~LineMarkers();
virtual void Init();
- virtual void InsertLine(int line);
- virtual void RemoveLine(int line);
-
- int MarkValue(int line);
- int MarkerNext(int lineStart, int mask) const;
- int AddMark(int line, int marker, int lines);
- void MergeMarkers(int pos);
- bool DeleteMark(int line, int markerNum, bool all);
+ virtual void InsertLine(Sci::Line line);
+ virtual void RemoveLine(Sci::Line line);
+
+ int MarkValue(Sci::Line line);
+ Sci::Line MarkerNext(Sci::Line lineStart, int mask) const;
+ int AddMark(Sci::Line line, int marker, Sci::Line lines);
+ void MergeMarkers(Sci::Line line);
+ bool DeleteMark(Sci::Line line, int markerNum, bool all);
void DeleteMarkFromHandle(int markerHandle);
- int LineFromHandle(int markerHandle);
+ Sci::Line LineFromHandle(int markerHandle);
};
class LineLevels : public PerLine {
@@ -66,13 +66,13 @@ class LineLevels : public PerLine {
public:
virtual ~LineLevels();
virtual void Init();
- virtual void InsertLine(int line);
- virtual void RemoveLine(int line);
+ virtual void InsertLine(Sci::Line line);
+ virtual void RemoveLine(Sci::Line line);
- void ExpandLevels(int sizeNew=-1);
+ void ExpandLevels(Sci::Line sizeNew=-1);
void ClearLevels();
- int SetLevel(int line, int level, int lines);
- int GetLevel(int line) const;
+ int SetLevel(Sci::Line line, int level, Sci::Line lines);
+ int GetLevel(Sci::Line line) const;
};
class LineState : public PerLine {
@@ -82,12 +82,12 @@ public:
}
virtual ~LineState();
virtual void Init();
- virtual void InsertLine(int line);
- virtual void RemoveLine(int line);
+ virtual void InsertLine(Sci::Line line);
+ virtual void RemoveLine(Sci::Line line);
- int SetLineState(int line, int state);
- int GetLineState(int line);
- int GetMaxLineState() const;
+ int SetLineState(Sci::Line line, int state);
+ int GetLineState(Sci::Line line);
+ Sci::Line GetMaxLineState() const;
};
class LineAnnotation : public PerLine {
@@ -97,19 +97,19 @@ public:
}
virtual ~LineAnnotation();
virtual void Init();
- virtual void InsertLine(int line);
- virtual void RemoveLine(int line);
-
- bool MultipleStyles(int line) const;
- int Style(int line) const;
- const char *Text(int line) const;
- const unsigned char *Styles(int line) const;
- void SetText(int line, const char *text);
+ virtual void InsertLine(Sci::Line line);
+ virtual void RemoveLine(Sci::Line line);
+
+ bool MultipleStyles(Sci::Line line) const;
+ int Style(Sci::Line line) const;
+ const char *Text(Sci::Line line) const;
+ const unsigned char *Styles(Sci::Line line) const;
+ void SetText(Sci::Line line, const char *text);
void ClearAll();
- void SetStyle(int line, int style);
- void SetStyles(int line, const unsigned char *styles);
- int Length(int line) const;
- int Lines(int line) const;
+ void SetStyle(Sci::Line line, int style);
+ void SetStyles(Sci::Line line, const unsigned char *styles);
+ int Length(Sci::Line line) const;
+ int Lines(Sci::Line line) const;
};
typedef std::vector<int> TabstopList;
@@ -121,12 +121,12 @@ public:
}
virtual ~LineTabstops();
virtual void Init();
- virtual void InsertLine(int line);
- virtual void RemoveLine(int line);
+ virtual void InsertLine(Sci::Line line);
+ virtual void RemoveLine(Sci::Line line);
- bool ClearTabstops(int line);
- bool AddTabstop(int line, int x);
- int GetNextTabstop(int line, int x) const;
+ bool ClearTabstops(Sci::Line line);
+ bool AddTabstop(Sci::Line line, int x);
+ int GetNextTabstop(Sci::Line line, int x) const;
};
#ifdef SCI_NAMESPACE
diff --git a/src/Position.h b/src/Position.h
index 120b92f62..67365e30f 100644
--- a/src/Position.h
+++ b/src/Position.h
@@ -16,6 +16,7 @@
namespace Sci {
typedef int Position;
+typedef int Line;
// A later version (4.x) of this file may:
//#if defined(SCI_LARGE_FILE_SUPPORT)
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 82cda7b78..3eee9058b 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -149,7 +149,7 @@ void LineLayout::SetLineStart(int line, int start) {
lineStarts[line] = start;
}
-void LineLayout::SetBracesHighlight(Range rangeLine, const Position braces[],
+void LineLayout::SetBracesHighlight(Range rangeLine, const Sci::Position braces[],
char bracesMatchStyle, int xHighlight, bool ignoreStyle) {
if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {
int braceOffset = braces[0] - rangeLine.start;
@@ -171,7 +171,7 @@ void LineLayout::SetBracesHighlight(Range rangeLine, const Position braces[],
}
}
-void LineLayout::RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle) {
+void LineLayout::RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle) {
if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {
int braceOffset = braces[0] - rangeLine.start;
if (braceOffset < numCharsInLine) {
@@ -267,7 +267,7 @@ void LineLayoutCache::Allocate(size_t length_) {
cache.resize(length_);
}
-void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
+void LineLayoutCache::AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc) {
PLATFORM_ASSERT(useCount == 0);
size_t lengthForLevel = 0;
if (level == llcCaret) {
@@ -320,15 +320,15 @@ void LineLayoutCache::SetLevel(int level_) {
}
}
-LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
- int linesOnScreen, int linesInDoc) {
+LineLayout *LineLayoutCache::Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_,
+ Sci::Line linesOnScreen, Sci::Line linesInDoc) {
AllocateForLevel(linesOnScreen, linesInDoc);
if (styleClock != styleClock_) {
Invalidate(LineLayout::llCheckTextAndStyle);
styleClock = styleClock_;
}
allInvalidated = false;
- int pos = -1;
+ Sci::Position pos = -1;
LineLayout *ret = 0;
if (level == llcCaret) {
pos = 0;
@@ -447,7 +447,7 @@ void BreakFinder::Insert(int val) {
}
}
-BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, int posLineStart_,
+BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_,
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw) :
ll(ll_),
lineRange(lineRange_),
@@ -486,7 +486,7 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin
if (pvsDraw && pvsDraw->indicatorsSetFore > 0) {
for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
if (pvsDraw->indicators[deco->indicator].OverridesTextFore()) {
- int startPos = deco->rs.EndRun(posLineStart);
+ Sci::Position startPos = deco->rs.EndRun(posLineStart);
while (startPos < (posLineStart + lineRange.end)) {
Insert(startPos - posLineStart);
startPos = deco->rs.EndRun(startPos);
diff --git a/src/PositionCache.h b/src/PositionCache.h
index c0d2b7f3e..8c6f0f2e1 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -50,7 +50,7 @@ private:
int *lineStarts;
int lenLineStarts;
/// Drawing is only performed for @a maxLineLength characters on each line.
- int lineNumber;
+ Sci::Line lineNumber;
bool inCache;
public:
enum { wrapWidthInfinite = 0x7ffffff };
@@ -86,9 +86,9 @@ public:
Range SubLineRange(int line) const;
bool InLine(int offset, int line) const;
void SetLineStart(int line, int start);
- void SetBracesHighlight(Range rangeLine, const Position braces[],
+ void SetBracesHighlight(Range rangeLine, const Sci::Position braces[],
char bracesMatchStyle, int xHighlight, bool ignoreStyle);
- void RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle);
+ void RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle);
int FindBefore(XYPOSITION x, int lower, int upper) const;
int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const;
Point PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const;
@@ -104,7 +104,7 @@ class LineLayoutCache {
int styleClock;
int useCount;
void Allocate(size_t length_);
- void AllocateForLevel(int linesOnScreen, int linesInDoc);
+ void AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc);
public:
LineLayoutCache();
virtual ~LineLayoutCache();
@@ -118,8 +118,8 @@ public:
void Invalidate(LineLayout::validLevel validity_);
void SetLevel(int level_);
int GetLevel() const { return level; }
- LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
- int linesOnScreen, int linesInDoc);
+ LineLayout *Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_,
+ Sci::Line linesOnScreen, Sci::Line linesInDoc);
void Dispose(LineLayout *ll);
};
@@ -176,7 +176,7 @@ struct TextSegment {
class BreakFinder {
const LineLayout *ll;
Range lineRange;
- int posLineStart;
+ Sci::Position posLineStart;
int nextBreak;
std::vector<int> selAndEdge;
unsigned int saeCurrentPos;
@@ -194,7 +194,7 @@ public:
enum { lengthStartSubdivision = 300 };
// Try to make each subdivided run lengthEachSubdivision or shorter.
enum { lengthEachSubdivision = 100 };
- BreakFinder(const LineLayout *ll_, const Selection *psel, Range rangeLine_, int posLineStart_,
+ BreakFinder(const LineLayout *ll_, const Selection *psel, Range rangeLine_, Sci::Position posLineStart_,
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw);
~BreakFinder();
TextSegment Next();
diff --git a/src/RESearch.cxx b/src/RESearch.cxx
index 3509c3f22..612596986 100644
--- a/src/RESearch.cxx
+++ b/src/RESearch.cxx
@@ -277,9 +277,9 @@ void RESearch::Clear() {
void RESearch::GrabMatches(CharacterIndexer &ci) {
for (unsigned int i = 0; i < MAXTAG; i++) {
if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) {
- unsigned int len = eopat[i] - bopat[i];
+ Sci::Position len = eopat[i] - bopat[i];
pat[i].resize(len);
- for (unsigned int j = 0; j < len; j++)
+ for (Sci::Position j = 0; j < len; j++)
pat[i][j] = ci.CharAt(bopat[i] + j);
}
}
@@ -434,7 +434,7 @@ int RESearch::GetBackslashExpression(
return result;
}
-const char *RESearch::Compile(const char *pattern, int length, bool caseSensitive, bool posix) {
+const char *RESearch::Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) {
char *mp=nfa; /* nfa pointer */
char *lp; /* saved pointer */
char *sp=nfa; /* another one */
@@ -755,9 +755,9 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv
* respectively.
*
*/
-int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
+int RESearch::Execute(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp) {
unsigned char c;
- int ep = NOTFOUND;
+ Sci::Position ep = NOTFOUND;
char *ap = nfa;
bol = lp;
@@ -844,13 +844,13 @@ extern void re_fail(char *,char);
#define CHRSKIP 3 /* [CLO] CHR chr END */
#define CCLSKIP 34 /* [CLO] CCL 32 bytes END */
-int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) {
+Sci::Position RESearch::PMatch(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, char *ap) {
int op, c, n;
- int e; /* extra pointer for CLO */
- int bp; /* beginning of subpat... */
- int ep; /* ending of subpat... */
- int are; /* to save the line ptr. */
- int llp; /* lazy lp for LCLO */
+ Sci::Position e; /* extra pointer for CLO */
+ Sci::Position bp; /* beginning of subpat... */
+ Sci::Position ep; /* ending of subpat... */
+ Sci::Position are; /* to save the line ptr. */
+ Sci::Position llp; /* lazy lp for LCLO */
while ((op = *ap++) != END)
switch (op) {
@@ -940,7 +940,7 @@ int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) {
llp = lp;
e = NOTFOUND;
while (llp >= are) {
- int q;
+ Sci::Position q;
if ((q = PMatch(ci, llp, endp, ap)) != NOTFOUND) {
e = q;
lp = llp;
diff --git a/src/RESearch.h b/src/RESearch.h
index 23795babe..f61b3008b 100644
--- a/src/RESearch.h
+++ b/src/RESearch.h
@@ -23,7 +23,7 @@ namespace Scintilla {
class CharacterIndexer {
public:
- virtual char CharAt(int index)=0;
+ virtual char CharAt(Sci::Position index)=0;
virtual ~CharacterIndexer() {
}
};
@@ -35,15 +35,15 @@ public:
~RESearch();
void Clear();
void GrabMatches(CharacterIndexer &ci);
- const char *Compile(const char *pattern, int length, bool caseSensitive, bool posix);
- int Execute(CharacterIndexer &ci, int lp, int endp);
+ const char *Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix);
+ int Execute(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp);
enum { MAXTAG=10 };
enum { MAXNFA=4096 };
enum { NOTFOUND=-1 };
- int bopat[MAXTAG];
- int eopat[MAXTAG];
+ Sci::Position bopat[MAXTAG];
+ Sci::Position eopat[MAXTAG];
std::string pat[MAXTAG];
private:
@@ -51,10 +51,10 @@ private:
void ChSetWithCase(unsigned char c, bool caseSensitive);
int GetBackslashExpression(const char *pattern, int &incr);
- int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap);
+ Sci::Position PMatch(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, char *ap);
- int bol;
- int tagstk[MAXTAG]; /* subpat tag stack */
+ Sci::Position bol;
+ Sci::Position tagstk[MAXTAG]; /* subpat tag stack */
char nfa[MAXNFA]; /* automaton */
int sta;
unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 27ed95135..0e947b6c8 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -207,24 +207,24 @@ void ScintillaBase::AutoCompleteDoubleClick(void *p) {
sci->AutoCompleteCompleted(0, SC_AC_DOUBLECLICK);
}
-void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) {
+void ScintillaBase::AutoCompleteInsert(Sci::Position startPos, int removeLen, const char *text, int textLen) {
UndoGroup ug(pdoc);
if (multiAutoCMode == SC_MULTIAUTOC_ONCE) {
pdoc->DeleteChars(startPos, removeLen);
- const int lengthInserted = pdoc->InsertString(startPos, text, textLen);
+ const Sci::Position lengthInserted = pdoc->InsertString(startPos, text, textLen);
SetEmptySelection(startPos + lengthInserted);
} else {
// SC_MULTIAUTOC_EACH
for (size_t r=0; r<sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
- int positionInsert = sel.Range(r).Start().Position();
+ Sci::Position positionInsert = sel.Range(r).Start().Position();
positionInsert = RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
if (positionInsert - removeLen >= 0) {
positionInsert -= removeLen;
pdoc->DeleteChars(positionInsert, removeLen);
}
- const int lengthInserted = pdoc->InsertString(positionInsert, text, textLen);
+ const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, text, textLen);
if (lengthInserted > 0) {
sel.Range(r).caret.SetPosition(positionInsert + lengthInserted);
sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted);
@@ -382,7 +382,7 @@ void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod
scn.listCompletionMethod = completionMethod;
scn.wParam = listType;
scn.listType = listType;
- Position firstPos = ac.posStart - ac.startLen;
+ Sci::Position firstPos = ac.posStart - ac.startLen;
scn.position = firstPos;
scn.lParam = firstPos;
scn.text = selected.c_str();
@@ -395,7 +395,7 @@ void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod
if (listType > 0)
return;
- Position endPos = sel.MainCaret();
+ Sci::Position endPos = sel.MainCaret();
if (ac.dropRestOfWord)
endPos = pdoc->ExtendWordSelect(endPos, 1, true);
if (endPos < firstPos)
@@ -771,11 +771,11 @@ const char *LexState::GetSubStyleBases() {
#endif
-void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
+void ScintillaBase::NotifyStyleToNeeded(Sci::Position endStyleNeeded) {
#ifdef SCI_LEXER
if (DocumentLexState()->lexLanguage != SCLEX_CONTAINER) {
- int lineEndStyled = pdoc->LineFromPosition(pdoc->GetEndStyled());
- int endStyled = pdoc->LineStart(lineEndStyled);
+ Sci::Line lineEndStyled = pdoc->LineFromPosition(pdoc->GetEndStyled());
+ Sci::Position endStyled = pdoc->LineStart(lineEndStyled);
DocumentLexState()->Colourise(endStyled, endStyleNeeded);
return;
}
@@ -994,10 +994,10 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
case SCI_COLOURISE:
if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) {
- pdoc->ModifiedAt(static_cast<int>(wParam));
- NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : static_cast<int>(lParam));
+ pdoc->ModifiedAt(static_cast<Sci::Position>(wParam));
+ NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : static_cast<Sci::Position>(lParam));
} else {
- DocumentLexState()->Colourise(static_cast<int>(wParam), static_cast<int>(lParam));
+ DocumentLexState()->Colourise(static_cast<Sci::Position>(wParam), static_cast<Sci::Position>(lParam));
}
Redraw();
break;
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index e66403367..f59722ec4 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -67,7 +67,7 @@ protected:
virtual void CancelModes();
virtual int KeyCommand(unsigned int iMessage);
- void AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen);
+ void AutoCompleteInsert(Sci::Position startPos, int removeLen, const char *text, int textLen);
void AutoCompleteStart(int lenEntered, const char *list);
void AutoCompleteCancel();
void AutoCompleteMove(int delta);
@@ -91,7 +91,7 @@ protected:
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
virtual void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
- void NotifyStyleToNeeded(int endStyleNeeded);
+ void NotifyStyleToNeeded(Sci::Position endStyleNeeded);
void NotifyLexerChanged(Document *doc, void *userData);
public:
diff --git a/src/Selection.cxx b/src/Selection.cxx
index d58a03980..7d4be8f68 100644
--- a/src/Selection.cxx
+++ b/src/Selection.cxx
@@ -22,10 +22,10 @@
using namespace Scintilla;
#endif
-void SelectionPosition::MoveForInsertDelete(bool insertion, int startChange, int length) {
+void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length) {
if (insertion) {
if (position == startChange) {
- int virtualLengthRemove = std::min(length, virtualSpace);
+ Sci::Position virtualLengthRemove = std::min(length, virtualSpace);
virtualSpace -= virtualLengthRemove;
position += virtualLengthRemove;
} else if (position > startChange) {
@@ -36,7 +36,7 @@ void SelectionPosition::MoveForInsertDelete(bool insertion, int startChange, int
virtualSpace = 0;
}
if (position > startChange) {
- int endDeletion = startChange + length;
+ Sci::Position endDeletion = startChange + length;
if (position > endDeletion) {
position -= length;
} else {
@@ -75,7 +75,7 @@ bool SelectionPosition::operator >=(const SelectionPosition &other) const {
return *this > other;
}
-int SelectionRange::Length() const {
+Sci::Position SelectionRange::Length() const {
if (anchor > caret) {
return anchor.Position() - caret.Position();
} else {
@@ -83,12 +83,12 @@ int SelectionRange::Length() const {
}
}
-void SelectionRange::MoveForInsertDelete(bool insertion, int startChange, int length) {
+void SelectionRange::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length) {
caret.MoveForInsertDelete(insertion, startChange, length);
anchor.MoveForInsertDelete(insertion, startChange, length);
}
-bool SelectionRange::Contains(int pos) const {
+bool SelectionRange::Contains(Sci::Position pos) const {
if (anchor > caret)
return (pos >= caret.Position()) && (pos <= anchor.Position());
else
@@ -102,7 +102,7 @@ bool SelectionRange::Contains(SelectionPosition sp) const {
return (sp >= anchor) && (sp <= caret);
}
-bool SelectionRange::ContainsCharacter(int posCharacter) const {
+bool SelectionRange::ContainsCharacter(Sci::Position posCharacter) const {
if (anchor > caret)
return (posCharacter >= caret.Position()) && (posCharacter < anchor.Position());
else
@@ -168,7 +168,7 @@ bool SelectionRange::Trim(SelectionRange range) {
// If range is all virtual collapse to start of virtual space
void SelectionRange::MinimizeVirtualSpace() {
if (caret.Position() == anchor.Position()) {
- int virtualSpace = caret.VirtualSpace();
+ Sci::Position virtualSpace = caret.VirtualSpace();
if (virtualSpace > anchor.VirtualSpace())
virtualSpace = anchor.VirtualSpace();
caret.SetVirtualSpace(virtualSpace);
@@ -187,11 +187,11 @@ bool Selection::IsRectangular() const {
return (selType == selRectangle) || (selType == selThin);
}
-int Selection::MainCaret() const {
+Sci::Position Selection::MainCaret() const {
return ranges[mainRange].caret.Position();
}
-int Selection::MainAnchor() const {
+Sci::Position Selection::MainAnchor() const {
return ranges[mainRange].anchor.Position();
}
@@ -284,15 +284,15 @@ SelectionPosition Selection::Last() const {
return lastPosition;
}
-int Selection::Length() const {
- int len = 0;
+Sci::Position Selection::Length() const {
+ Sci::Position len = 0;
for (size_t i=0; i<ranges.size(); i++) {
len += ranges[i].Length();
}
return len;
}
-void Selection::MovePositions(bool insertion, int startChange, int length) {
+void Selection::MovePositions(bool insertion, Sci::Position startChange, Sci::Position length) {
for (size_t i=0; i<ranges.size(); i++) {
ranges[i].MoveForInsertDelete(insertion, startChange, length);
}
@@ -376,7 +376,7 @@ void Selection::CommitTentative() {
tentativeMain = false;
}
-int Selection::CharacterInSelection(int posCharacter) const {
+int Selection::CharacterInSelection(Sci::Position posCharacter) const {
for (size_t i=0; i<ranges.size(); i++) {
if (ranges[i].ContainsCharacter(posCharacter))
return i == mainRange ? 1 : 2;
@@ -384,7 +384,7 @@ int Selection::CharacterInSelection(int posCharacter) const {
return 0;
}
-int Selection::InSelectionForEOL(int pos) const {
+int Selection::InSelectionForEOL(Sci::Position pos) const {
for (size_t i=0; i<ranges.size(); i++) {
if (!ranges[i].Empty() && (pos > ranges[i].Start().Position()) && (pos <= ranges[i].End().Position()))
return i == mainRange ? 1 : 2;
@@ -392,8 +392,8 @@ int Selection::InSelectionForEOL(int pos) const {
return 0;
}
-int Selection::VirtualSpaceFor(int pos) const {
- int virtualSpace = 0;
+Sci::Position Selection::VirtualSpaceFor(Sci::Position pos) const {
+ Sci::Position virtualSpace = 0;
for (size_t i=0; i<ranges.size(); i++) {
if ((ranges[i].caret.Position() == pos) && (virtualSpace < ranges[i].caret.VirtualSpace()))
virtualSpace = ranges[i].caret.VirtualSpace();
diff --git a/src/Selection.h b/src/Selection.h
index 5ec5c5424..991864e01 100644
--- a/src/Selection.h
+++ b/src/Selection.h
@@ -13,10 +13,10 @@ namespace Scintilla {
#endif
class SelectionPosition {
- int position;
- int virtualSpace;
+ Sci::Position position;
+ Sci::Position virtualSpace;
public:
- explicit SelectionPosition(int position_=INVALID_POSITION, int virtualSpace_=0) : position(position_), virtualSpace(virtualSpace_) {
+ explicit SelectionPosition(Sci::Position position_=INVALID_POSITION, Sci::Position virtualSpace_=0) : position(position_), virtualSpace(virtualSpace_) {
PLATFORM_ASSERT(virtualSpace < 800000);
if (virtualSpace < 0)
virtualSpace = 0;
@@ -25,7 +25,7 @@ public:
position = 0;
virtualSpace = 0;
}
- void MoveForInsertDelete(bool insertion, int startChange, int length);
+ void MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length);
bool operator ==(const SelectionPosition &other) const {
return position == other.position && virtualSpace == other.virtualSpace;
}
@@ -33,22 +33,22 @@ public:
bool operator >(const SelectionPosition &other) const;
bool operator <=(const SelectionPosition &other) const;
bool operator >=(const SelectionPosition &other) const;
- int Position() const {
+ Sci::Position Position() const {
return position;
}
- void SetPosition(int position_) {
+ void SetPosition(Sci::Position position_) {
position = position_;
virtualSpace = 0;
}
- int VirtualSpace() const {
+ Sci::Position VirtualSpace() const {
return virtualSpace;
}
- void SetVirtualSpace(int virtualSpace_) {
+ void SetVirtualSpace(Sci::Position virtualSpace_) {
PLATFORM_ASSERT(virtualSpace_ < 800000);
if (virtualSpace_ >= 0)
virtualSpace = virtualSpace_;
}
- void Add(int increment) {
+ void Add(Sci::Position increment) {
position = position + increment;
}
bool IsValid() const {
@@ -90,17 +90,17 @@ struct SelectionRange {
}
explicit SelectionRange(SelectionPosition single) : caret(single), anchor(single) {
}
- explicit SelectionRange(int single) : caret(single), anchor(single) {
+ explicit SelectionRange(Sci::Position single) : caret(single), anchor(single) {
}
SelectionRange(SelectionPosition caret_, SelectionPosition anchor_) : caret(caret_), anchor(anchor_) {
}
- SelectionRange(int caret_, int anchor_) : caret(caret_), anchor(anchor_) {
+ SelectionRange(Sci::Position caret_, Sci::Position anchor_) : caret(caret_), anchor(anchor_) {
}
bool Empty() const {
return anchor == caret;
}
- int Length() const;
- // int Width() const; // Like Length but takes virtual space into account
+ Sci::Position Length() const;
+ // Sci::Position Width() const; // Like Length but takes virtual space into account
bool operator ==(const SelectionRange &other) const {
return caret == other.caret && anchor == other.anchor;
}
@@ -115,10 +115,10 @@ struct SelectionRange {
anchor.SetVirtualSpace(0);
caret.SetVirtualSpace(0);
}
- void MoveForInsertDelete(bool insertion, int startChange, int length);
- bool Contains(int pos) const;
+ void MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length);
+ bool Contains(Sci::Position pos) const;
bool Contains(SelectionPosition sp) const;
- bool ContainsCharacter(int posCharacter) const;
+ bool ContainsCharacter(Sci::Position posCharacter) const;
SelectionSegment Intersect(SelectionSegment check) const;
SelectionPosition Start() const {
return (anchor < caret) ? anchor : caret;
@@ -146,8 +146,8 @@ public:
Selection();
~Selection();
bool IsRectangular() const;
- int MainCaret() const;
- int MainAnchor() const;
+ Sci::Position MainCaret() const;
+ Sci::Position MainAnchor() const;
SelectionRange &Rectangular();
SelectionSegment Limits() const;
// This is for when you want to move the caret in response to a
@@ -166,8 +166,8 @@ public:
void SetMoveExtends(bool moveExtends_);
bool Empty() const;
SelectionPosition Last() const;
- int Length() const;
- void MovePositions(bool insertion, int startChange, int length);
+ Sci::Position Length() const;
+ void MovePositions(bool insertion, Sci::Position startChange, Sci::Position length);
void TrimSelection(SelectionRange range);
void TrimOtherSelections(size_t r, SelectionRange range);
void SetSelection(SelectionRange range);
@@ -177,9 +177,9 @@ public:
void DropAdditionalRanges();
void TentativeSelection(SelectionRange range);
void CommitTentative();
- int CharacterInSelection(int posCharacter) const;
- int InSelectionForEOL(int pos) const;
- int VirtualSpaceFor(int pos) const;
+ int CharacterInSelection(Sci::Position posCharacter) const;
+ int InSelectionForEOL(Sci::Position pos) const;
+ Sci::Position VirtualSpaceFor(Sci::Position pos) const;
void Clear();
void RemoveDuplicates();
void RotateMain();
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 574232697..525462f61 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -294,15 +294,15 @@ class ScintillaWin :
bool DragThreshold(Point ptStart, Point ptNow) override;
void StartDrag() override;
- int TargetAsUTF8(char *text);
+ Sci::Position TargetAsUTF8(char *text);
void AddCharUTF16(wchar_t const *wcs, unsigned int wclen);
- int EncodedFromUTF8(char *utf8, char *encoded) const;
+ Sci::Position EncodedFromUTF8(char *utf8, char *encoded) const;
sptr_t WndPaint(uptr_t wParam);
sptr_t HandleCompositionWindowed(uptr_t wParam, sptr_t lParam);
sptr_t HandleCompositionInline(uptr_t wParam, sptr_t lParam);
static bool KoreanIME();
- void MoveImeCarets(int offset);
+ void MoveImeCarets(Sci::Position offset);
void DrawImeIndicator(int indicator, int len);
void SetCandidateWindowPos();
void SelectionToHangul();
@@ -323,12 +323,12 @@ class ScintillaWin :
bool HaveMouseCapture() override;
void SetTrackMouseLeaveEvent(bool on);
bool PaintContains(PRectangle rc) override;
- void ScrollText(int linesToMove) override;
+ void ScrollText(Sci::Line linesToMove) override;
void NotifyCaretMove() override;
void UpdateSystemCaret() override;
void SetVerticalScrollPos() override;
void SetHorizontalScrollPos() override;
- bool ModifyScrollBars(int nMax, int nPage) override;
+ bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) override;
void NotifyChange() override;
void NotifyFocus(bool focus) override;
void SetCtrlID(int identifier) override;
@@ -361,7 +361,7 @@ class ScintillaWin :
int SetScrollInfo(int nBar, LPCSCROLLINFO lpsi, BOOL bRedraw);
bool GetScrollInfo(int nBar, LPSCROLLINFO lpsi);
- void ChangeScrollPos(int barType, int pos);
+ void ChangeScrollPos(int barType, Sci::Position pos);
sptr_t GetTextLength();
sptr_t GetText(uptr_t wParam, sptr_t lParam);
@@ -618,7 +618,7 @@ void ScintillaWin::StartDrag() {
}
}
inDragDrop = ddNone;
- SetDragPosition(SelectionPosition(invalidPosition));
+ SetDragPosition(SelectionPosition(Sci::invalidPosition));
}
// Avoid warnings everywhere for old style casts by concentrating them here
@@ -730,8 +730,8 @@ static std::wstring StringMapCase(const std::wstring &ws, DWORD mapFlags) {
// Returns the target converted to UTF8.
// Return the length in bytes.
-int ScintillaWin::TargetAsUTF8(char *text) {
- int targetLength = targetEnd - targetStart;
+Sci::Position ScintillaWin::TargetAsUTF8(char *text) {
+ Sci::Position targetLength = targetEnd - targetStart;
if (IsUnicodeMode()) {
if (text) {
pdoc->GetCharRange(text, targetStart, targetLength);
@@ -752,8 +752,8 @@ int ScintillaWin::TargetAsUTF8(char *text) {
// Translates a nul terminated UTF8 string into the document encoding.
// Return the length of the result in bytes.
-int ScintillaWin::EncodedFromUTF8(char *utf8, char *encoded) const {
- int inputLength = (lengthForEncode >= 0) ? lengthForEncode : static_cast<int>(strlen(utf8));
+Sci::Position ScintillaWin::EncodedFromUTF8(char *utf8, char *encoded) const {
+ Sci::Position inputLength = (lengthForEncode >= 0) ? lengthForEncode : static_cast<Sci::Position>(strlen(utf8));
if (IsUnicodeMode()) {
if (encoded) {
memcpy(encoded, utf8, inputLength);
@@ -889,10 +889,10 @@ bool ScintillaWin::KoreanIME() {
return codePage == 949 || codePage == 1361;
}
-void ScintillaWin::MoveImeCarets(int offset) {
+void ScintillaWin::MoveImeCarets(Sci::Position offset) {
// Move carets relatively by bytes.
for (size_t r=0; r<sel.Count(); r++) {
- int positionInsert = sel.Range(r).Start().Position();
+ Sci::Position positionInsert = sel.Range(r).Start().Position();
sel.Range(r).caret.SetPosition(positionInsert + offset);
sel.Range(r).anchor.SetPosition(positionInsert + offset);
}
@@ -908,7 +908,7 @@ void ScintillaWin::DrawImeIndicator(int indicator, int len) {
}
pdoc->decorations.SetCurrentIndicator(indicator);
for (size_t r=0; r<sel.Count(); r++) {
- int positionInsert = sel.Range(r).Start().Position();
+ Sci::Position positionInsert = sel.Range(r).Start().Position();
pdoc->DecorationFillRange(positionInsert - len, 1, len);
}
}
@@ -928,10 +928,10 @@ void ScintillaWin::SetCandidateWindowPos() {
void ScintillaWin::SelectionToHangul() {
// Convert every hanja to hangul within the main range.
- const int selStart = sel.RangeMain().Start().Position();
- const int documentStrLen = sel.RangeMain().Length();
- const int selEnd = selStart + documentStrLen;
- const int utf16Len = pdoc->CountUTF16(selStart, selEnd);
+ const Sci::Position selStart = sel.RangeMain().Start().Position();
+ const Sci::Position documentStrLen = sel.RangeMain().Length();
+ const Sci::Position selEnd = selStart + documentStrLen;
+ const Sci::Position utf16Len = pdoc->CountUTF16(selStart, selEnd);
if (utf16Len > 0) {
std::string documentStr(documentStrLen, '\0');
@@ -957,7 +957,7 @@ void ScintillaWin::EscapeHanja() {
if (sel.Count() > 1) {
return; // Do not allow multi carets.
}
- int currentPos = CurrentPosition();
+ Sci::Position currentPos = CurrentPosition();
int oneCharLen = pdoc->LenChar(currentPos);
if (oneCharLen < 2) {
@@ -1091,7 +1091,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
// Move IME caret from current last position to imeCaretPos.
int imeEndToImeCaretU16 = imc.GetImeCaretPos() - static_cast<unsigned int>(wcs.size());
- int imeCaretPosDoc = pdoc->GetRelativePositionUTF16(CurrentPosition(), imeEndToImeCaretU16);
+ Sci::Position imeCaretPosDoc = pdoc->GetRelativePositionUTF16(CurrentPosition(), imeEndToImeCaretU16);
MoveImeCarets(- CurrentPosition() + imeCaretPosDoc);
@@ -1298,7 +1298,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// Either SCROLL or ZOOM. We handle the wheel steppings calculation
wheelDelta -= static_cast<short>(HiWord(wParam));
if (abs(wheelDelta) >= WHEEL_DELTA && linesPerScroll > 0) {
- int linesToScroll = linesPerScroll;
+ Sci::Line linesToScroll = linesPerScroll;
if (linesPerScroll == WHEEL_PAGESCROLL)
linesToScroll = LinesOnScreen() - 1;
if (linesToScroll == 0) {
@@ -1663,8 +1663,8 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
break;
case EM_SETSEL: {
- int nStart = static_cast<int>(wParam);
- int nEnd = static_cast<int>(lParam);
+ Sci::Position nStart = static_cast<Sci::Position>(wParam);
+ Sci::Position nEnd = static_cast<Sci::Position>(lParam);
if (nStart == 0 && nEnd == -1) {
nEnd = pdoc->Length();
}
@@ -1850,7 +1850,7 @@ bool ScintillaWin::PaintContains(PRectangle rc) {
return true;
}
-void ScintillaWin::ScrollText(int /* linesToMove */) {
+void ScintillaWin::ScrollText(Sci::Line /* linesToMove */) {
//Platform::DebugPrintf("ScintillaWin::ScrollText %d\n", linesToMove);
//::ScrollWindow(MainHWND(), 0,
// vs.lineHeight * linesToMove, 0, 0);
@@ -1883,7 +1883,7 @@ bool ScintillaWin::GetScrollInfo(int nBar, LPSCROLLINFO lpsi) {
}
// Change the scroll position but avoid repaint if changing to same value
-void ScintillaWin::ChangeScrollPos(int barType, int pos) {
+void ScintillaWin::ChangeScrollPos(int barType, Sci::Position pos) {
SCROLLINFO sci = {
sizeof(sci), 0, 0, 0, 0, 0, 0
};
@@ -1904,14 +1904,14 @@ void ScintillaWin::SetHorizontalScrollPos() {
ChangeScrollPos(SB_HORZ, xOffset);
}
-bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
+bool ScintillaWin::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) {
bool modified = false;
SCROLLINFO sci = {
sizeof(sci), 0, 0, 0, 0, 0, 0
};
sci.fMask = SIF_PAGE | SIF_RANGE;
GetScrollInfo(SB_VERT, &sci);
- int vertEndPreferred = nMax;
+ Sci::Line vertEndPreferred = nMax;
if (!verticalScrollBarVisible)
nPage = vertEndPreferred + 1;
if ((sci.nMin != 0) ||
@@ -1932,14 +1932,14 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
int horizEndPreferred = scrollWidth;
if (horizEndPreferred < 0)
horizEndPreferred = 0;
- unsigned int pageWidth = static_cast<unsigned int>(rcText.Width());
+ int pageWidth = static_cast<int>(rcText.Width());
if (!horizontalScrollBarVisible || Wrapping())
pageWidth = horizEndPreferred + 1;
sci.fMask = SIF_PAGE | SIF_RANGE;
GetScrollInfo(SB_HORZ, &sci);
if ((sci.nMin != 0) ||
(sci.nMax != horizEndPreferred) ||
- (sci.nPage != pageWidth) ||
+ (sci.nPage != static_cast<unsigned int>(pageWidth)) ||
(sci.nPos != 0)) {
sci.fMask = SIF_PAGE | SIF_RANGE;
sci.nMin = 0;
@@ -1949,7 +1949,7 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
sci.nTrackPos = 1;
SetScrollInfo(SB_HORZ, &sci, TRUE);
modified = true;
- if (scrollWidth < static_cast<int>(pageWidth)) {
+ if (scrollWidth < pageWidth) {
HorizontalScrollTo(0);
}
}
@@ -2673,13 +2673,13 @@ void ScintillaWin::ImeEndComposition() {
LRESULT ScintillaWin::ImeOnReconvert(LPARAM lParam) {
// Reconversion on windows limits within one line without eol.
// Look around: baseStart <-- (|mainStart| -- mainEnd) --> baseEnd.
- const int mainStart = sel.RangeMain().Start().Position();
- const int mainEnd = sel.RangeMain().End().Position();
- const int curLine = pdoc->LineFromPosition(mainStart);
+ const Sci::Position mainStart = sel.RangeMain().Start().Position();
+ const Sci::Position mainEnd = sel.RangeMain().End().Position();
+ const Sci::Line curLine = pdoc->LineFromPosition(mainStart);
if (curLine != pdoc->LineFromPosition(mainEnd))
return 0;
- const int baseStart = pdoc->LineStart(curLine);
- const int baseEnd = pdoc->LineEnd(curLine);
+ const Sci::Position baseStart = pdoc->LineStart(curLine);
+ const Sci::Position baseEnd = pdoc->LineEnd(curLine);
if ((baseStart == baseEnd) || (mainEnd > baseEnd))
return 0;
@@ -2730,8 +2730,8 @@ LRESULT ScintillaWin::ImeOnReconvert(LPARAM lParam) {
// Make place for next composition string to sit in.
for (size_t r=0; r<sel.Count(); r++) {
- int rBase = sel.Range(r).Start().Position();
- int docCompStart = rBase + adjust;
+ Sci::Position rBase = sel.Range(r).Start().Position();
+ Sci::Position docCompStart = rBase + adjust;
if (inOverstrike) { // the docCompLen of bytes will be overstriked.
sel.Range(r).caret.SetPosition(docCompStart);
@@ -2739,8 +2739,8 @@ LRESULT ScintillaWin::ImeOnReconvert(LPARAM lParam) {
} else {
// Ensure docCompStart+docCompLen be not beyond lineEnd.
// since docCompLen by byte might break eol.
- int lineEnd = pdoc->LineEnd(pdoc->LineFromPosition(rBase));
- int overflow = (docCompStart + docCompLen) - lineEnd;
+ Sci::Position lineEnd = pdoc->LineEnd(pdoc->LineFromPosition(rBase));
+ Sci::Position overflow = (docCompStart + docCompLen) - lineEnd;
if (overflow > 0) {
pdoc->DeleteChars(docCompStart, docCompLen - overflow);
} else {
@@ -2833,7 +2833,7 @@ void ScintillaWin::ScrollMessage(WPARAM wParam) {
//Platform::DebugPrintf("ScrollInfo %d mask=%x min=%d max=%d page=%d pos=%d track=%d\n", b,sci.fMask,
//sci.nMin, sci.nMax, sci.nPage, sci.nPos, sci.nTrackPos);
- int topLineNew = topLine;
+ Sci::Line topLineNew = topLine;
switch (LoWord(wParam)) {
case SB_LINEUP:
topLineNew -= 1;
@@ -3038,7 +3038,7 @@ STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffe
STDMETHODIMP ScintillaWin::DragLeave() {
try {
- SetDragPosition(SelectionPosition(invalidPosition));
+ SetDragPosition(SelectionPosition(Sci::invalidPosition));
return S_OK;
} catch (...) {
errorStatus = SC_STATUS_FAILURE;
@@ -3054,7 +3054,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
if (pIDataSource == NULL)
return E_POINTER;
- SetDragPosition(SelectionPosition(invalidPosition));
+ SetDragPosition(SelectionPosition(Sci::invalidPosition));
STGMEDIUM medium = {0, {0}, 0};