aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2025-09-09 20:50:07 +0300
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-05-09 23:00:17 +0200
commita534721011f35a1a56c2a815f8b2fa31e0a8ebbd (patch)
tree097b6b1f87310aa6bbe53b8021719d99d2605412 /src
parent01a9fb54ba284e440cbf4799fc3b8840584471be (diff)
downloadscintilla-mirror-a534721011f35a1a56c2a815f8b2fa31e0a8ebbd.tar.gz
added SC_LINE_END_TYPE_NONE: allows ignoring all line endssciteco-rel-5-6-2
This can help when using Scintilla views as command line widgets. It can also help when using Scintilla to edit binary files as you don't want to attach special meaning to CR and LF. This patch will not be merged for the time being, so we strive to reduce the number of touched lines. See https://groups.google.com/g/scintilla-interest/c/iE6E4n9zWT4
Diffstat (limited to 'src')
-rw-r--r--src/CellBuffer.cxx32
-rw-r--r--src/Document.cxx4
-rw-r--r--src/ScintillaBase.cxx2
3 files changed, 28 insertions, 10 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index 1eac3f9c2..a3904094d 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -576,6 +576,9 @@ void CellBuffer::SetLineEndTypes(LineEndType utf8LineEnds_) {
}
bool CellBuffer::ContainsLineEnd(const char *s, Sci::Position length) const noexcept {
+ if (utf8LineEnds == LineEndType::None) {
+ return false;
+ }
unsigned char chBeforePrev = 0;
unsigned char chPrev = 0;
for (Sci::Position i = 0; i < length; i++) {
@@ -627,6 +630,8 @@ Sci::Position CellBuffer::LineStart(Sci::Line line) const noexcept {
return 0;
else if (line >= Lines())
return Length();
+ else if (LineEndType::None == GetLineEndTypes())
+ return 0;
else
return plv->LineStart(line);
}
@@ -634,6 +639,8 @@ Sci::Position CellBuffer::LineStart(Sci::Line line) const noexcept {
Sci::Position CellBuffer::LineEnd(Sci::Line line) const noexcept {
if (line >= Lines() - 1) {
return LineStart(line + 1);
+ } else if (LineEndType::None == GetLineEndTypes()) {
+ return Length();
} else {
Sci::Position position = LineStart(line + 1);
if (LineEndType::Unicode == GetLineEndTypes()) {
@@ -773,6 +780,11 @@ void CellBuffer::ResetLineEnds() {
constexpr Sci::Position position = 0;
const Sci::Position length = Length();
plv->InsertText(0, length);
+
+ if (LineEndType::None == GetLineEndTypes()) {
+ return;
+ }
+
Sci::Line lineInsert = 1;
constexpr bool atLineStart = true;
unsigned char chBeforePrev = 0;
@@ -874,7 +886,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
plv->InsertText(lineInsert-1, insertLength);
unsigned char chBeforePrev = substance.ValueAt(position - 2);
unsigned char chPrev = substance.ValueAt(position - 1);
- if (chPrev == '\r' && chAfter == '\n') {
+ if (LineEndType::None != GetLineEndTypes() && chPrev == '\r' && chAfter == '\n') {
// Splitting up a crlf pair at position
InsertLine(lineInsert, position, false);
lineInsert++;
@@ -893,7 +905,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
const char *ptr = s;
unsigned char ch = 0;
- if (chPrev == '\r' && *ptr == '\n') {
+ if (LineEndType::None != GetLineEndTypes() && chPrev == '\r' && *ptr == '\n') {
++ptr;
// Patch up what was end of line
plv->SetLineStart(lineInsert - 1, (position + ptr - s));
@@ -902,8 +914,10 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
if (ptr < end) {
uint8_t eolTable[256]{};
- eolTable[static_cast<uint8_t>('\n')] = 1;
- eolTable[static_cast<uint8_t>('\r')] = 2;
+ if (LineEndType::None != GetLineEndTypes()) {
+ eolTable[static_cast<uint8_t>('\n')] = 1;
+ eolTable[static_cast<uint8_t>('\r')] = 2;
+ }
if (utf8LineEnds == LineEndType::Unicode) {
// see UniConversion.h for LS, PS and NEL
eolTable[0x85] = 4;
@@ -961,7 +975,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
ch = *end;
if (ptr == end) {
++ptr;
- if (ch == '\r' || ch == '\n') {
+ if (LineEndType::None != GetLineEndTypes() && (ch == '\r' || ch == '\n')) {
InsertLine(lineInsert, (position + ptr - s), atLineStart);
lineInsert++;
} else if (utf8LineEnds == LineEndType::Unicode && !UTF8IsAscii(ch)) {
@@ -973,7 +987,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
}
// Joining two lines where last insertion is cr and following substance starts with lf
- if (chAfter == '\n') {
+ if (LineEndType::None != GetLineEndTypes() && chAfter == '\n') {
if (ch == '\r') {
// End of line already in buffer so drop the newly created one
RemoveLine(lineInsert - 1);
@@ -1054,7 +1068,7 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
}
bool ignoreNL = false;
- if (chPrev == '\r' && chNext == '\n') {
+ if (LineEndType::None != GetLineEndTypes() && chPrev == '\r' && chNext == '\n') {
// Move back one
plv->SetLineStart(lineRemove, position);
lineRemove++;
@@ -1066,6 +1080,8 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
}
}
+ if (LineEndType::None != GetLineEndTypes()) {
+
unsigned char ch = chNext;
for (Sci::Position i = 0; i < deleteLength; i++) {
chNext = substance.ValueAt(position + i + 1);
@@ -1099,6 +1115,8 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
RemoveLine(lineRemove - 1);
plv->SetLineStart(lineRemove - 1, position + 1);
}
+
+ } /* LineEndType::None != GetLineEndTypes() */
}
substance.DeleteRange(position, deleteLength);
if (lineRecalculateStart >= 0) {
diff --git a/src/Document.cxx b/src/Document.cxx
index 289fb6731..d57fe24ec 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -100,7 +100,7 @@ LineEndType LexInterface::LineEndTypesSupported() {
if (instance) {
return static_cast<LineEndType>(instance->LineEndTypesSupported());
}
- return LineEndType::Default;
+ return LineEndType::None;
}
bool LexInterface::UseContainerLexing() const noexcept {
@@ -260,7 +260,7 @@ LineAnnotation *Document::EOLAnnotations() const noexcept {
LineEndType Document::LineEndTypesSupported() const {
if ((CpUtf8 == dbcsCodePage) && pli)
return pli->LineEndTypesSupported();
- return LineEndType::Default;
+ return LineEndType::None;
}
bool Document::SetDBCSCodePage(int dbcsCodePage_) {
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 1f4c360da..90b3d3275 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -735,7 +735,7 @@ LineEndType LexState::LineEndTypesSupported() {
if (instance) {
return static_cast<LineEndType>(instance->LineEndTypesSupported());
}
- return LineEndType::Default;
+ return LineEndType::None;
}
int LexState::AllocateSubStyles(int styleBase, int numberStyles) {