diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/EditView.cxx | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 4 | ||||
-rw-r--r-- | src/PositionCache.cxx | 18 | ||||
-rw-r--r-- | src/PositionCache.h | 20 |
4 files changed, 23 insertions, 21 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index b3b107cff..c5e3a3726 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -179,7 +179,7 @@ EditView::EditView() { additionalCaretsBlink = true; additionalCaretsVisible = true; imeCaretBlockOverride = false; - llc.SetLevel(LineLayoutCache::llcCaret); + llc.SetLevel(LineLayoutCache::Cache::caret); posCache.SetSize(0x400); tabArrowHeight = 4; customDrawTabArrow = nullptr; diff --git a/src/Editor.cxx b/src/Editor.cxx index dcaa6fc6b..bcfd4c82a 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6754,11 +6754,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapIndentMode; case SCI_SETLAYOUTCACHE: - view.llc.SetLevel(static_cast<int>(wParam)); + view.llc.SetLevel(static_cast<LineLayoutCache::Cache>(wParam)); break; case SCI_GETLAYOUTCACHE: - return view.llc.GetLevel(); + return static_cast<sptr_t>(view.llc.GetLevel()); case SCI_SETPOSITIONCACHE: view.posCache.SetSize(wParam); diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index c9b886119..7516c82ec 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -357,7 +357,7 @@ XYPOSITION ScreenLine::TabPositionAfter(XYPOSITION xPosition) const { } LineLayoutCache::LineLayoutCache() : - level(0), + level(Cache::none), allInvalidated(false), styleClock(-1), useCount(0) { Allocate(0); } @@ -375,11 +375,11 @@ void LineLayoutCache::Allocate(size_t length_) { void LineLayoutCache::AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc) { PLATFORM_ASSERT(useCount == 0); size_t lengthForLevel = 0; - if (level == llcCaret) { + if (level == Cache::caret) { lengthForLevel = 1; - } else if (level == llcPage) { + } else if (level == Cache::page) { lengthForLevel = linesOnScreen + 1; - } else if (level == llcDocument) { + } else if (level == Cache::document) { lengthForLevel = linesInDoc; } if (lengthForLevel > cache.size()) { @@ -414,9 +414,9 @@ void LineLayoutCache::Invalidate(LineLayout::ValidLevel validity_) noexcept { } } -void LineLayoutCache::SetLevel(int level_) noexcept { +void LineLayoutCache::SetLevel(Cache level_) noexcept { allInvalidated = false; - if ((level_ != -1) && (level != level_)) { + if ((static_cast<int>(level_) != -1) && (level != level_)) { level = level_; Deallocate(); } @@ -432,15 +432,15 @@ LineLayout *LineLayoutCache::Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, allInvalidated = false; Sci::Position pos = -1; LineLayout *ret = nullptr; - if (level == llcCaret) { + if (level == Cache::caret) { pos = 0; - } else if (level == llcPage) { + } else if (level == Cache::page) { if (lineNumber == lineCaret) { pos = 0; } else if (cache.size() > 1) { pos = 1 + (lineNumber % (cache.size() - 1)); } - } else if (level == llcDocument) { + } else if (level == Cache::document) { pos = lineNumber; } if (pos >= 0) { diff --git a/src/PositionCache.h b/src/PositionCache.h index 5a3ec9bfd..e86b2bd51 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -149,7 +149,15 @@ struct ScreenLine : public IScreenLine { /** */ class LineLayoutCache { - int level; +public: + enum class Cache { + none = SC_CACHE_NONE, + caret = SC_CACHE_CARET, + page = SC_CACHE_PAGE, + document = SC_CACHE_DOCUMENT + }; +private: + Cache level; std::vector<std::unique_ptr<LineLayout>>cache; bool allInvalidated; int styleClock; @@ -165,15 +173,9 @@ public: void operator=(LineLayoutCache &&) = delete; virtual ~LineLayoutCache(); void Deallocate() noexcept; - enum { - llcNone=SC_CACHE_NONE, - llcCaret=SC_CACHE_CARET, - llcPage=SC_CACHE_PAGE, - llcDocument=SC_CACHE_DOCUMENT - }; void Invalidate(LineLayout::ValidLevel validity_) noexcept; - void SetLevel(int level_) noexcept; - int GetLevel() const noexcept { return level; } + void SetLevel(Cache level_) noexcept; + Cache GetLevel() const noexcept { return level; } LineLayout *Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_, Sci::Line linesOnScreen, Sci::Line linesInDoc); void Dispose(LineLayout *ll) noexcept; |