diff options
author | nyamatongwe <unknown> | 2013-01-19 12:33:20 +1100 |
---|---|---|
committer | nyamatongwe <unknown> | 2013-01-19 12:33:20 +1100 |
commit | 5d17740fdedcea321a23ffd3350aa7adbf4c2329 (patch) | |
tree | 1512465a2bbf066e96eb1ae2d10fdf3fc7dbd42b /lexlib/LexAccessor.h | |
parent | f46c96ecb682ad736453f78f6709fca6c6911886 (diff) | |
download | scintilla-mirror-5d17740fdedcea321a23ffd3350aa7adbf4c2329.tar.gz |
Implement generic support for Unicode line ends and sub styles in lexer support classes.
Diffstat (limited to 'lexlib/LexAccessor.h')
-rw-r--r-- | lexlib/LexAccessor.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lexlib/LexAccessor.h b/lexlib/LexAccessor.h index 6458525cc..59ae11346 100644 --- a/lexlib/LexAccessor.h +++ b/lexlib/LexAccessor.h @@ -12,6 +12,8 @@ namespace Scintilla { #endif +enum EncodingType { enc8bit, encUnicode, encDBCS }; + class LexAccessor { private: IDocument *pAccess; @@ -25,7 +27,7 @@ private: int startPos; int endPos; int codePage; - enum { enc8bit, encUnicode, encDBCS } encodingType; + enum EncodingType encodingType; int lenDoc; int mask; char styleBuf[bufferSize]; @@ -91,7 +93,9 @@ public: bool IsLeadByte(char ch) { return pAccess->IsDBCSLeadByte(ch); } - + EncodingType Encoding() const { + return encodingType; + } bool Match(int pos, const char *s) { for (int i=0; *s; i++) { if (*s != SafeGetCharAt(pos+i)) @@ -109,6 +113,19 @@ public: int LineStart(int line) { return pAccess->LineStart(line); } + int LineEnd(int line) { + if (documentVersion >= dvLineEnd) { + return (static_cast<IDocumentWithLineEnd *>(pAccess))->LineEnd(line); + } else { + // Old interface means only '\r', '\n' and '\r\n' line ends. + int startNext = pAccess->LineStart(line+1); + char chLineEnd = SafeGetCharAt(startNext-1); + if (chLineEnd == '\n' && (SafeGetCharAt(startNext-2) == '\r')) + return startNext - 2; + else + return startNext - 1; + } + } int LevelAt(int line) { return pAccess->GetLevel(line); } |