aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-07-10 15:06:50 +1000
committerNeil <nyamatongwe@gmail.com>2018-07-10 15:06:50 +1000
commit72b5df15f33da27c59efd54eb0c84e173ca8c692 (patch)
treea65cbcf60c89542255a27672302e5de5e715624e /src/Document.cxx
parent34540c84e31840787054652b72be7709d79eb1a2 (diff)
downloadscintilla-mirror-72b5df15f33da27c59efd54eb0c84e173ca8c692.tar.gz
Backport: Optional indexing of line starts in UTF-8 documents by UTF-32 code points and
UTF-16 code units added. Converted instances of C++17 std::string_view to C++11. Also used const_casts where appropriate to fix compile errors. Backport of changeset 7063:0d5edc93e280.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 99c15e3ef..681b3c371 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -122,6 +122,7 @@ Document::Document(int options) :
decorations = DecorationListCreate(IsLarge());
cb.SetPerLine(this);
+ cb.SetUTF8Substance(SC_CP_UTF8 == dbcsCodePage);
}
Document::~Document() {
@@ -197,6 +198,7 @@ bool Document::SetDBCSCodePage(int dbcsCodePage_) {
dbcsCodePage = dbcsCodePage_;
SetCaseFolder(nullptr);
cb.SetLineEndTypes(lineEndBitSet & LineEndTypesSupported());
+ cb.SetUTF8Substance(SC_CP_UTF8 == dbcsCodePage);
return true;
} else {
return false;
@@ -423,6 +425,14 @@ Sci::Position Document::VCHomePosition(Sci::Position position) const {
return startText;
}
+Sci::Position Document::IndexLineStart(Sci::Line line, int lineCharacterIndex) const {
+ return cb.IndexLineStart(line, lineCharacterIndex);
+}
+
+Sci::Line Document::LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const {
+ return cb.LineFromPositionIndex(pos, lineCharacterIndex);
+}
+
int SCI_METHOD Document::SetLevel(Sci_Position line, int level) {
const int prev = Levels()->SetLevel(static_cast<Sci::Line>(line), level, LinesTotal());
if (prev != level) {
@@ -2108,6 +2118,18 @@ const char *Document::SubstituteByPosition(const char *text, Sci::Position *leng
return 0;
}
+int Document::LineCharacterIndex() const {
+ return cb.LineCharacterIndex();
+}
+
+void Document::AllocateLineCharacterIndex(int lineCharacterIndex) {
+ return cb.AllocateLineCharacterIndex(lineCharacterIndex);
+}
+
+void Document::ReleaseLineCharacterIndex(int lineCharacterIndex) {
+ return cb.ReleaseLineCharacterIndex(lineCharacterIndex);
+}
+
Sci::Line Document::LinesTotal() const noexcept {
return cb.Lines();
}