diff options
| author | Neil <nyamatongwe@gmail.com> | 2020-07-16 08:04:11 +1000 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2020-07-16 08:04:11 +1000 |
| commit | 500d0c61325b097df66f6a8f1981e71bf30ff139 (patch) | |
| tree | 47ae4426c33bce753d7a89c6b7e1806dfab3cef9 | |
| parent | 4fee1c0972ef24589e6d872b5cf4ad91f192d8d8 (diff) | |
| download | scintilla-mirror-500d0c61325b097df66f6a8f1981e71bf30ff139.tar.gz | |
Backport: Make EncodingFamily an enum class for more type safety.
Backport of changeset 8408:e89f22691610.
| -rw-r--r-- | src/Document.cxx | 6 | ||||
| -rw-r--r-- | src/Document.h | 2 | ||||
| -rw-r--r-- | src/PositionCache.cxx | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index eb8d764a3..8deec96d3 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1178,11 +1178,11 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const EncodingFamily Document::CodePageFamily() const noexcept { if (SC_CP_UTF8 == dbcsCodePage) - return efUnicode; + return EncodingFamily::unicode; else if (dbcsCodePage) - return efDBCS; + return EncodingFamily::dbcs; else - return efEightBit; + return EncodingFamily::eightBit; } void Document::ModifiedAt(Sci::Position pos) noexcept { diff --git a/src/Document.h b/src/Document.h index 57dcd6e36..a31424739 100644 --- a/src/Document.h +++ b/src/Document.h @@ -18,7 +18,7 @@ class LineLevels; class LineState; class LineAnnotation; -enum EncodingFamily { efEightBit, efUnicode, efDBCS }; +enum class EncodingFamily { eightBit, unicode, dbcs }; /** * The range class represents a range of text in a document. diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 5b9c2ddd4..06e3586f2 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -505,10 +505,10 @@ TextSegment BreakFinder::Next() { const int prev = nextBreak; while (nextBreak < lineRange.end) { int charWidth = 1; - if (encodingFamily == efUnicode) + if (encodingFamily == EncodingFamily::unicode) charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(&ll->chars[nextBreak]), static_cast<int>(lineRange.end - nextBreak)); - else if (encodingFamily == efDBCS) + else if (encodingFamily == EncodingFamily::dbcs) charWidth = pdoc->DBCSDrawBytes( &ll->chars[nextBreak], static_cast<int>(lineRange.end - nextBreak)); const Representation *repr = preprs->RepresentationFromCharacter(&ll->chars[nextBreak], charWidth); |
