aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2013-01-19 11:17:27 +1100
committernyamatongwe <unknown>2013-01-19 11:17:27 +1100
commitf0cd733f9f71a76b641546a2401636d7f8f3c1ed (patch)
treeb1dc2ba5622526a957dd5abe2691e4d6f8e6daae
parent7d3a087d2e149d95e1e267fd6191dd0312fe3c0a (diff)
downloadscintilla-mirror-f0cd733f9f71a76b641546a2401636d7f8f3c1ed.tar.gz
To allow for new line end sequences implement IsPositionInLineEnd on the
document and use it instead of checks for particular byte values. Use equivalent checks against numCharsBeforeEOL in other contexts. When line ends visible, display byte value blobs for non-ASCII line ends.
-rw-r--r--src/Document.cxx4
-rw-r--r--src/Document.h1
-rw-r--r--src/Editor.cxx20
3 files changed, 19 insertions, 6 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 500259d8d..2036f383c 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -295,6 +295,10 @@ bool Document::IsLineEndPosition(int position) const {
return LineEnd(LineFromPosition(position)) == position;
}
+bool Document::IsPositionInLineEnd(int position) const {
+ return position >= LineEnd(LineFromPosition(position));
+}
+
int Document::VCHomePosition(int position) const {
int line = LineFromPosition(position);
int startPosition = LineStart(line);
diff --git a/src/Document.h b/src/Document.h
index 2830d626e..592d2ecb9 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -343,6 +343,7 @@ public:
int SCI_METHOD LineEnd(int line) const;
int LineEndPosition(int position) const;
bool IsLineEndPosition(int position) const;
+ bool IsPositionInLineEnd(int position) const;
int VCHomePosition(int position) const;
int SCI_METHOD SetLevel(int line, int level);
diff --git a/src/Editor.cxx b/src/Editor.cxx
index f0a4f44f2..e4ae6060e 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1606,7 +1606,7 @@ void Editor::LinesJoin() {
UndoGroup ug(pdoc);
bool prevNonWS = true;
for (int pos = targetStart; pos < targetEnd; pos++) {
- if (IsEOLChar(pdoc->CharAt(pos))) {
+ if (pdoc->IsPositionInLineEnd(pos)) {
targetEnd -= pdoc->LenChar(pos);
pdoc->DelChar(pos);
if (prevNonWS) {
@@ -2193,7 +2193,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
bool isBadUTF = isBadUTFNext;
isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars + charInLine + 1, numCharsInLine - charInLine - 1, trailBytes);
if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) ||
- isControl || isControlNext || isBadUTF || isBadUTFNext) {
+ isControl || isControlNext || isBadUTF || isBadUTFNext || ((charInLine+1) >= numCharsBeforeEOL)) {
ll->positions[startseg] = 0;
if (vstyle.styles[ll->styles[charInLine]].visible) {
if (isControl) {
@@ -2213,7 +2213,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
ll->positions + startseg + 1);
}
lastSegItalics = false;
- } else if (isBadUTF) {
+ } else if ((isBadUTF) || (charInLine >= numCharsBeforeEOL)) {
char hexits[4];
sprintf(hexits, "x%2X", ll->chars[charInLine] & 0xff);
ll->positions[charInLine + 1] =
@@ -2504,7 +2504,15 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
rcSegment.left = xStart + ll->positions[eolPos] - subLineStart + virtualSpace;
rcSegment.right = xStart + ll->positions[eolPos+1] - subLineStart + virtualSpace;
blobsWidth += rcSegment.Width();
- const char *ctrlChar = ControlCharacterString(ll->chars[eolPos]);
+ char hexits[4];
+ const char *ctrlChar;
+ unsigned char chEOL = ll->chars[eolPos];
+ if (UTF8IsAscii(chEOL)) {
+ ctrlChar = ControlCharacterString(chEOL);
+ } else {
+ sprintf(hexits, "x%2X", chEOL);
+ ctrlChar = hexits;
+ }
int styleMain = ll->styles[eolPos];
ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, eolInSelection, false, styleMain, eolPos, ll);
ColourDesired textFore = vsDraw.styles[styleMain].fore;
@@ -3995,7 +4003,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
}
} else if (inOverstrike) {
if (positionInsert < pdoc->Length()) {
- if (!IsEOLChar(pdoc->CharAt(positionInsert))) {
+ if (!pdoc->IsPositionInLineEnd(positionInsert)) {
pdoc->DelChar(positionInsert);
currentSel->ClearVirtualSpace();
}
@@ -4240,7 +4248,7 @@ void Editor::Clear() {
else
sel.Range(r) = SelectionPosition(InsertSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace()));
}
- if ((sel.Count() == 1) || !IsEOLChar(pdoc->CharAt(sel.Range(r).caret.Position()))) {
+ if ((sel.Count() == 1) || !pdoc->IsPositionInLineEnd(sel.Range(r).caret.Position())) {
pdoc->DelChar(sel.Range(r).caret.Position());
sel.Range(r).ClearVirtualSpace();
} // else multiple selection so don't eat line ends