diff options
-rw-r--r-- | src/DocumentAccessor.cxx | 9 | ||||
-rw-r--r-- | src/DocumentAccessor.h | 1 | ||||
-rw-r--r-- | src/LexCPP.cxx | 17 | ||||
-rw-r--r-- | src/StyleContext.h | 4 | ||||
-rw-r--r-- | src/WindowAccessor.cxx | 9 |
5 files changed, 25 insertions, 15 deletions
diff --git a/src/DocumentAccessor.cxx b/src/DocumentAccessor.cxx index f115f1930..595edf8ba 100644 --- a/src/DocumentAccessor.cxx +++ b/src/DocumentAccessor.cxx @@ -48,6 +48,15 @@ void DocumentAccessor::Fill(int position) { buf[endPos-startPos] = '\0'; } +bool DocumentAccessor::Match(int pos, const char *s) { + for (int i=0; *s; i++) { + if (*s != SafeGetCharAt(pos+i)) + return false; + s++; + } + return true; +} + char DocumentAccessor::StyleAt(int position) { return pdoc->StyleAt(position); } diff --git a/src/DocumentAccessor.h b/src/DocumentAccessor.h index 5b68dd15c..dc591d13e 100644 --- a/src/DocumentAccessor.h +++ b/src/DocumentAccessor.h @@ -38,6 +38,7 @@ public: startSeg(0), startPosStyling(0) { } ~DocumentAccessor(); + bool Match(int pos, const char *s); char StyleAt(int position); int GetLine(int position); int LineStart(int line); diff --git a/src/LexCPP.cxx b/src/LexCPP.cxx index d625634ed..85dcd42e8 100644 --- a/src/LexCPP.cxx +++ b/src/LexCPP.cxx @@ -32,10 +32,6 @@ static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } -static inline bool IsASpaceOrTab(const int ch) { - return (ch == ' ') || (ch == '\t'); -} - static inline bool IsADoxygenChar(const int ch) { return (islower(ch) || ch == '$' || ch == '@' || ch == '\\' || ch == '&' || ch == '<' || @@ -274,15 +270,6 @@ static bool IsStreamCommentStyle(int style) { style == SCE_C_COMMENTDOCKEYWORDERROR; } -static bool MatchString(Accessor &styler, int pos, const char *s) { - for (int i=0; *s; i++) { - if (*s != styler.SafeGetCharAt(pos+i)) - return false; - s++; - } - return true; -} - static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; @@ -326,9 +313,9 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordLis while ((j<endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { j++; } - if (MatchString(styler, j, "region")) { + if (styler.Match(j, "region")) { levelCurrent++; - } else if (MatchString(styler, j, "endregion")) { + } else if (styler.Match(j, "endregion")) { levelCurrent--; } } diff --git a/src/StyleContext.h b/src/StyleContext.h index 9e803c4a7..4c9352916 100644 --- a/src/StyleContext.h +++ b/src/StyleContext.h @@ -144,6 +144,10 @@ inline bool IsASpace(unsigned int ch) { return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); } +inline bool IsASpaceOrTab(unsigned int ch) { + return (ch == ' ') || (ch == '\t'); +} + inline bool IsADigit(unsigned int ch) { return (ch >= '0') && (ch <= '9'); } diff --git a/src/WindowAccessor.cxx b/src/WindowAccessor.cxx index e02bf90e4..e980b9a77 100644 --- a/src/WindowAccessor.cxx +++ b/src/WindowAccessor.cxx @@ -45,6 +45,15 @@ void WindowAccessor::Fill(int position) { Platform::SendScintilla(id, SCI_GETTEXTRANGE, 0, reinterpret_cast<long>(&tr)); } +bool WindowAccessor::Match(int pos, const char *s) { + for (int i=0; *s; i++) { + if (*s != SafeGetCharAt(pos+i)) + return false; + s++; + } + return true; +} + char WindowAccessor::StyleAt(int position) { return static_cast<char>(Platform::SendScintilla( id, SCI_GETSTYLEAT, position, 0)); |