aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-03-06 11:18:50 +1100
committerNeil <nyamatongwe@gmail.com>2025-03-06 11:18:50 +1100
commit102fa1d501808187235f93670591d5b9d1253778 (patch)
tree9b66d840ad8ac1ed8580743afa5673b8e335ef82 /src/Document.cxx
parent00838f369d7ca189b498f70c8c446ccc64cc0e2f (diff)
downloadscintilla-mirror-102fa1d501808187235f93670591d5b9d1253778.tar.gz
Move static functions and variables into unnamed namespace and use constexpr.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx53
1 files changed, 30 insertions, 23 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);