diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 53 | ||||
-rw-r--r-- | src/Editor.cxx | 32 |
2 files changed, 48 insertions, 37 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index f211f0a7c..05f80640c 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -620,11 +620,14 @@ void Document::ClearLevels() { Levels()->ClearLevels(); } -static bool IsSubordinate(FoldLevel levelStart, FoldLevel levelTry) noexcept { +namespace { + +constexpr bool IsSubordinate(FoldLevel levelStart, FoldLevel levelTry) noexcept { if (LevelIsWhitespace(levelTry)) return true; - else - return LevelNumber(levelStart) < LevelNumber(levelTry); + return LevelNumber(levelStart) < LevelNumber(levelTry); +} + } Sci::Line Document::GetLastChild(Sci::Line lineParent, std::optional<FoldLevel> level, Sci::Line lastLine) { @@ -1280,6 +1283,25 @@ CharacterExtracted LastCharacter(std::string_view text) noexcept { static_cast<unsigned int>(utf8status & UTF8MaskWidth) }; } +constexpr Sci::Position NextTab(Sci::Position pos, Sci::Position tabSize) noexcept { + return ((pos / tabSize) + 1) * tabSize; +} + +std::string CreateIndentation(Sci::Position indent, int tabSize, bool insertSpaces) { + std::string indentation; + if (!insertSpaces) { + while (indent >= tabSize) { + indentation += '\t'; + indent -= tabSize; + } + } + while (indent > 0) { + indentation += ' '; + indent--; + } + return indentation; +} + } bool Scintilla::Internal::DiscardLastCombinedCharacter(std::string_view &text) noexcept { @@ -1708,25 +1730,6 @@ void Document::DelCharBack(Sci::Position pos) { } } -static constexpr Sci::Position NextTab(Sci::Position pos, Sci::Position tabSize) noexcept { - return ((pos / tabSize) + 1) * tabSize; -} - -static std::string CreateIndentation(Sci::Position indent, int tabSize, bool insertSpaces) { - std::string indentation; - if (!insertSpaces) { - while (indent >= tabSize) { - indentation += '\t'; - indent -= tabSize; - } - } - while (indent > 0) { - indentation += ' '; - indent--; - } - return indentation; -} - int SCI_METHOD Document::GetLineIndentation(Sci_Position line) { int indent = 0; if ((line >= 0) && (line < LinesTotal())) { @@ -2981,7 +2984,9 @@ Sci::Position Document::ExtendStyleRange(Sci::Position pos, int delta, bool sing return pos; } -static char BraceOpposite(char ch) noexcept { +namespace { + +constexpr char BraceOpposite(char ch) noexcept { switch (ch) { case '(': return ')'; @@ -3004,6 +3009,8 @@ static char BraceOpposite(char ch) noexcept { } } +} + // TODO: should be able to extend styled region to find matching brace Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxReStyle*/, Sci::Position startPos, bool useStartPos) noexcept { const unsigned char chBrace = CharAt(position); diff --git a/src/Editor.cxx b/src/Editor.cxx index a696cb7e0..1557ce75e 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -106,15 +106,7 @@ constexpr bool IsLastStep(const DocModification &mh) noexcept { && ((mh.modificationType & finalMask) == finalMask); } -} - -Timer::Timer() noexcept : - ticking(false), ticksToWait(0), tickerID{} {} - -Idler::Idler() noexcept : - state(false), idlerID(nullptr) {} - -static constexpr bool IsAllSpacesOrTabs(std::string_view sv) noexcept { +constexpr bool IsAllSpacesOrTabs(std::string_view sv) noexcept { for (const char ch : sv) { // This is safe because IsSpaceOrTab() will return false for null terminators if (!IsSpaceOrTab(ch)) @@ -123,6 +115,14 @@ static constexpr bool IsAllSpacesOrTabs(std::string_view sv) noexcept { return true; } +} + +Timer::Timer() noexcept : + ticking(false), ticksToWait(0), tickerID{} {} + +Idler::Idler() noexcept : + state(false), idlerID(nullptr) {} + Editor::Editor() : durationWrapOneByte(0.000001, 0.00000001, 0.00001) { ctrlID = 0; @@ -4402,7 +4402,9 @@ void Editor::GoToLine(Sci::Line lineNo) { EnsureCaretVisible(); } -static bool Close(Point pt1, Point pt2, Point threshold) noexcept { +namespace { + +bool Close(Point pt1, Point pt2, Point threshold) noexcept { const Point ptDifference = pt2 - pt1; if (std::abs(ptDifference.x) > threshold.x) return false; @@ -4411,6 +4413,12 @@ static bool Close(Point pt1, Point pt2, Point threshold) noexcept { return true; } +constexpr bool AllowVirtualSpace(VirtualSpace virtualSpaceOptions, bool rectangular) noexcept { + return FlagSet(virtualSpaceOptions, (rectangular ? VirtualSpace::RectangularSelection : VirtualSpace::UserAccessible)); +} + +} + std::string Editor::RangeText(Sci::Position start, Sci::Position end) const { if (start < end) { const Sci::Position len = end - start; @@ -4756,10 +4764,6 @@ void Editor::MouseLeave() { } } -static constexpr bool AllowVirtualSpace(VirtualSpace virtualSpaceOptions, bool rectangular) noexcept { - return FlagSet(virtualSpaceOptions, (rectangular ? VirtualSpace::RectangularSelection : VirtualSpace::UserAccessible)); -} - void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modifiers) { SetHoverIndicatorPoint(pt); //Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop); |