aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CellBuffer.cxx17
-rw-r--r--src/CellBuffer.h5
-rw-r--r--src/ContractionState.cxx7
-rw-r--r--src/ContractionState.h2
-rw-r--r--src/Document.cxx9
-rw-r--r--src/Document.h2
-rw-r--r--src/EditModel.cxx2
-rw-r--r--src/EditView.cxx7
-rw-r--r--src/Editor.cxx9
-rw-r--r--src/MarginView.cxx13
-rw-r--r--src/Position.h4
-rw-r--r--src/RunStyles.cxx2
12 files changed, 56 insertions, 23 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index d6d83c20b..fcc75a741 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -364,12 +364,17 @@ void UndoHistory::CompletedRedoStep() {
currentAction++;
}
-CellBuffer::CellBuffer(bool hasStyles_) :
- hasStyles(hasStyles_) {
+CellBuffer::CellBuffer(bool hasStyles_, bool largeDocument_) :
+ hasStyles(hasStyles_), largeDocument(largeDocument_) {
readOnly = false;
utf8LineEnds = 0;
collectingUndo = true;
plv = std::make_unique<LineVector<Sci::Position>>();
+ if (largeDocument)
+ plv = std::make_unique<LineVector<Sci::Position>>();
+ else
+ plv = std::make_unique<LineVector<int>>();
+
}
CellBuffer::~CellBuffer() {
@@ -556,6 +561,14 @@ void CellBuffer::SetReadOnly(bool set) {
readOnly = set;
}
+bool CellBuffer::IsLarge() const {
+ return largeDocument;
+}
+
+bool CellBuffer::HasStyles() const {
+ return hasStyles;
+}
+
void CellBuffer::SetSavePoint() {
uh.SetSavePoint();
}
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index 544a26711..935ea6e69 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -108,6 +108,7 @@ public:
class CellBuffer {
private:
bool hasStyles;
+ bool largeDocument;
SplitVector<char> substance;
SplitVector<char> style;
bool readOnly;
@@ -126,7 +127,7 @@ private:
public:
- CellBuffer(bool hasStyles_);
+ CellBuffer(bool hasStyles_, bool largeDocument_);
// Deleted so CellBuffer objects can not be copied.
CellBuffer(const CellBuffer &) = delete;
void operator=(const CellBuffer &) = delete;
@@ -163,6 +164,8 @@ public:
bool IsReadOnly() const;
void SetReadOnly(bool set);
+ bool IsLarge() const;
+ bool HasStyles() const;
/// The save point is a marker in the undo stack where the container has stated that
/// the buffer was saved. Undo and redo can move over the save point.
diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx
index 2950587cb..b513c20a6 100644
--- a/src/ContractionState.cxx
+++ b/src/ContractionState.cxx
@@ -407,8 +407,11 @@ void ContractionState<LINE>::Check() const {
namespace Scintilla {
-std::unique_ptr<IContractionState> ContractionStateCreate() {
- return std::make_unique<ContractionState<Sci::Line>>();
+std::unique_ptr<IContractionState> ContractionStateCreate(bool largeDocument) {
+ if (largeDocument)
+ return std::make_unique<ContractionState<Sci::Line>>();
+ else
+ return std::make_unique<ContractionState<int>>();
}
}
diff --git a/src/ContractionState.h b/src/ContractionState.h
index a951e0a0c..90f5c0784 100644
--- a/src/ContractionState.h
+++ b/src/ContractionState.h
@@ -45,7 +45,7 @@ public:
virtual void ShowAll()=0;
};
-std::unique_ptr<IContractionState> ContractionStateCreate();
+std::unique_ptr<IContractionState> ContractionStateCreate(bool largeDocument);
}
diff --git a/src/Document.cxx b/src/Document.cxx
index 09a91d469..4765248d1 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -82,7 +82,7 @@ int LexInterface::LineEndTypesSupported() {
}
Document::Document(int options) :
- cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0) {
+ cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0, (options & SC_DOCUMENTOPTION_TEXT_LARGE) != 0) {
refCount = 0;
#ifdef _WIN32
eolMode = SC_EOL_CRLF;
@@ -113,7 +113,7 @@ Document::Document(int options) :
perLineData[ldMargin] = std::make_unique<LineAnnotation>();
perLineData[ldAnnotation] = std::make_unique<LineAnnotation>();
- decorations = DecorationListCreate(false);
+ decorations = DecorationListCreate(IsLarge());
cb.SetPerLine(this);
}
@@ -1520,6 +1520,11 @@ void Document::ConvertLineEnds(int eolModeSet) {
}
+int Document::Options() const {
+ return (IsLarge() ? SC_DOCUMENTOPTION_TEXT_LARGE : 0) |
+ (cb.HasStyles() ? 0 : SC_DOCUMENTOPTION_STYLES_NONE);
+}
+
bool Document::IsWhiteLine(Sci::Line line) const {
Sci::Position currentChar = static_cast<Sci::Position>(LineStart(line));
const Sci::Position endLine = static_cast<Sci::Position>(LineEnd(line));
diff --git a/src/Document.h b/src/Document.h
index 7614373e2..d5d0a4d2e 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -352,6 +352,8 @@ public:
void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
bool IsReadOnly() const { return cb.IsReadOnly(); }
+ bool IsLarge() const { return cb.IsLarge(); }
+ int Options() const;
void DelChar(Sci::Position pos);
void DelCharBack(Sci::Position pos);
diff --git a/src/EditModel.cxx b/src/EditModel.cxx
index 7782f583e..e7400ca37 100644
--- a/src/EditModel.cxx
+++ b/src/EditModel.cxx
@@ -70,7 +70,7 @@ EditModel::EditModel() {
wrapWidth = LineLayout::wrapWidthInfinite;
pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT);
pdoc->AddRef();
- pcs = ContractionStateCreate();
+ pcs = ContractionStateCreate(pdoc->IsLarge());
}
EditModel::~EditModel() {
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 37a6a9f9e..3f490af5e 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -2330,16 +2330,15 @@ Sci::Position EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *
if (draw && lineNumberWidth &&
(ypos + vsPrint.lineHeight <= pfr->rc.bottom) &&
(visibleLine >= 0)) {
- char number[100];
- sprintf(number, "%d" lineNumberPrintSpace, lineDoc + 1);
+ const std::string number = std::to_string(lineDoc + 1) + lineNumberPrintSpace;
PRectangle rcNumber = rcLine;
rcNumber.right = rcNumber.left + lineNumberWidth;
// Right justify
rcNumber.left = rcNumber.right - surfaceMeasure->WidthText(
- vsPrint.styles[STYLE_LINENUMBER].font, number, static_cast<int>(strlen(number)));
+ vsPrint.styles[STYLE_LINENUMBER].font, number.c_str(), static_cast<int>(number.length()));
surface->FlushCachedState();
surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
- static_cast<XYPOSITION>(ypos + vsPrint.maxAscent), number, static_cast<int>(strlen(number)),
+ static_cast<XYPOSITION>(ypos + vsPrint.maxAscent), number.c_str(), static_cast<int>(number.length()),
vsPrint.styles[STYLE_LINENUMBER].fore,
vsPrint.styles[STYLE_LINENUMBER].back);
}
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 0a2cf9c7c..ca23b0030 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5212,7 +5212,7 @@ void Editor::SetDocPointer(Document *document) {
pdoc = document;
}
pdoc->AddRef();
- pcs = ContractionStateCreate();
+ pcs = ContractionStateCreate(pdoc->IsLarge());
// Ensure all positions within document
sel.Clear();
@@ -7604,7 +7604,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
Document *doc = new Document(static_cast<int>(lParam));
doc->AddRef();
doc->Allocate(static_cast<int>(wParam));
- pcs = ContractionStateCreate();
+ pcs = ContractionStateCreate(pdoc->IsLarge());
return reinterpret_cast<sptr_t>(doc);
}
@@ -7616,12 +7616,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
(reinterpret_cast<Document *>(lParam))->Release();
break;
+ case SCI_GETDOCUMENTOPTIONS:
+ return pdoc->Options();
+
case SCI_CREATELOADER: {
Document *doc = new Document(static_cast<int>(lParam));
doc->AddRef();
doc->Allocate(static_cast<int>(wParam));
doc->SetUndoCollection(false);
- pcs = ContractionStateCreate();
+ pcs = ContractionStateCreate(pdoc->IsLarge());
return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc));
}
diff --git a/src/MarginView.cxx b/src/MarginView.cxx
index a7f9a9a2d..02a961b10 100644
--- a/src/MarginView.cxx
+++ b/src/MarginView.cxx
@@ -367,10 +367,12 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
rcMarker.bottom = static_cast<XYPOSITION>(yposScreen + vs.lineHeight);
if (vs.ms[margin].style == SC_MARGIN_NUMBER) {
if (firstSubLine) {
- char number[100] = "";
- if (lineDoc >= 0)
- sprintf(number, "%d", lineDoc + 1);
+ std::string sNumber;
+ if (lineDoc >= 0) {
+ sNumber = std::to_string(lineDoc + 1);
+ }
if (model.foldFlags & (SC_FOLDFLAG_LEVELNUMBERS | SC_FOLDFLAG_LINESTATE)) {
+ char number[100] = "";
if (model.foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
const int lev = model.pdoc->GetLevel(lineDoc);
sprintf(number, "%c%c %03X %03X",
@@ -383,14 +385,15 @@ void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc,
const int state = model.pdoc->GetLineState(lineDoc);
sprintf(number, "%0X", state);
}
+ sNumber = number;
}
PRectangle rcNumber = rcMarker;
// Right justify
- const XYPOSITION width = surface->WidthText(fontLineNumber, number, static_cast<int>(strlen(number)));
+ const XYPOSITION width = surface->WidthText(fontLineNumber, sNumber.c_str(), static_cast<int>(sNumber.length()));
const XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding;
rcNumber.left = xpos;
DrawTextNoClipPhase(surface, rcNumber, vs.styles[STYLE_LINENUMBER],
- rcNumber.top + vs.maxAscent, number, static_cast<int>(strlen(number)), drawAll);
+ rcNumber.top + vs.maxAscent, sNumber.c_str(), static_cast<int>(sNumber.length()), drawAll);
} else if (vs.wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) {
PRectangle rcWrapMarker = rcMarker;
rcWrapMarker.right -= wrapMarkerPaddingRight;
diff --git a/src/Position.h b/src/Position.h
index a8fbfb494..e0bbcb53f 100644
--- a/src/Position.h
+++ b/src/Position.h
@@ -16,8 +16,8 @@
namespace Sci {
-typedef int Position;
-typedef int Line;
+typedef ptrdiff_t Position;
+typedef ptrdiff_t Line;
const Position invalidPosition = -1;
diff --git a/src/RunStyles.cxx b/src/RunStyles.cxx
index 03692f673..f92da5047 100644
--- a/src/RunStyles.cxx
+++ b/src/RunStyles.cxx
@@ -306,3 +306,5 @@ void RunStyles<DISTANCE, STYLE>::Check() const {
template class Scintilla::RunStyles<int, int>;
template class Scintilla::RunStyles<int, char>;
+template class Scintilla::RunStyles<ptrdiff_t, int>;
+template class Scintilla::RunStyles<ptrdiff_t, char>;