diff options
author | nyamatongwe <devnull@localhost> | 2013-01-19 11:40:47 +1100 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2013-01-19 11:40:47 +1100 |
commit | d6ac5bf56d40512ac0634d7a5bee6f7328b7d41f (patch) | |
tree | c8a0a61379695115cde7c7423ce4308f4c195336 /src/Document.cxx | |
parent | 46ff1fe3d148b9d131788be6b4d7da8daa65189c (diff) | |
download | scintilla-mirror-d6ac5bf56d40512ac0634d7a5bee6f7328b7d41f.tar.gz |
Support the three Unicode line ends NEL, LS, and PS in CellBuffer, Document,
Editor and the message interface.
Will only be turned on for lexers that support Unicode line ends.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r-- | src/Document.cxx | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 2036f383c..b75c754ac 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -87,6 +87,7 @@ Document::Document() { eolMode = SC_EOL_LF; #endif dbcsCodePage = 0; + lineEndBitSet = SC_LINE_END_TYPE_DEFAULT; stylingBits = 5; stylingBitsMask = 0x1F; stylingMask = 0; @@ -157,12 +158,29 @@ bool Document::SetDBCSCodePage(int dbcsCodePage_) { if (dbcsCodePage != dbcsCodePage_) { dbcsCodePage = dbcsCodePage_; SetCaseFolder(NULL); + cb.SetLineEndTypes(lineEndBitSet & LineEndTypesSupported()); return true; } else { return false; } } +bool Document::SetLineEndTypesAllowed(int lineEndBitSet_) { + if (lineEndBitSet != lineEndBitSet_) { + lineEndBitSet = lineEndBitSet_; + int lineEndBitSetActive = lineEndBitSet & LineEndTypesSupported(); + if (lineEndBitSetActive != cb.GetLineEndTypes()) { + ModifiedAt(0); + cb.SetLineEndTypes(lineEndBitSetActive); + return true; + } else { + return false; + } + } else { + return false; + } +} + void Document::InsertLine(int line) { for (int j=0; j<ldSize; j++) { if (perLineData[j]) @@ -267,7 +285,21 @@ int SCI_METHOD Document::LineEnd(int line) const { if (line == LinesTotal() - 1) { return LineStart(line + 1); } else { - int position = LineStart(line + 1) - 1; + int position = LineStart(line + 1); + if (SC_CP_UTF8 == dbcsCodePage) { + unsigned char bytes[] = { + static_cast<unsigned char>(cb.CharAt(position-3)), + static_cast<unsigned char>(cb.CharAt(position-2)), + static_cast<unsigned char>(cb.CharAt(position-1)), + }; + if (UTF8IsSeparator(bytes)) { + return position - UTF8SeparatorLength; + } + if (UTF8IsNEL(bytes+1)) { + return position - UTF8NELLength; + } + } + position--; // Back over CR or LF // When line terminator is CR+LF, may need to go back one more if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) { position--; |