diff options
author | nyamatongwe <devnull@localhost> | 2013-01-19 11:17:27 +1100 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2013-01-19 11:17:27 +1100 |
commit | 46ff1fe3d148b9d131788be6b4d7da8daa65189c (patch) | |
tree | 345490577d8f395312d6fce1d8925ce21cdd215a /src/Editor.cxx | |
parent | 5a13b76c4ba92e4e47cac86d8d7d2617c60aa856 (diff) | |
download | scintilla-mirror-46ff1fe3d148b9d131788be6b4d7da8daa65189c.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.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 20 |
1 files changed, 14 insertions, 6 deletions
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 |