aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/Accessor.h15
-rw-r--r--include/KeyWords.h37
2 files changed, 49 insertions, 3 deletions
diff --git a/include/Accessor.h b/include/Accessor.h
index e31a8de6d..031ad7a91 100644
--- a/include/Accessor.h
+++ b/include/Accessor.h
@@ -3,6 +3,8 @@
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
+
class Accessor {
protected:
// bufferSize is a trade off between time taken to copy the characters and SendMessage overhead
@@ -15,12 +17,15 @@ protected:
int endPos;
int lenDoc;
int offset; // Optional but including an offset makes GCC generate better code
+ int codePage;
+ bool InternalIsLeadByte(char ch);
void Fill(int position);
public:
Accessor(WindowID id_, PropSet &props_, int offset_=0) :
id(id_), props(props_), startPos(0x7FFFFFFF), endPos(0),
- lenDoc(-1), offset(offset_) {
+ lenDoc(-1), offset(offset_), codePage(0) {
}
+ void SetCodePage(int codePage_) { codePage = codePage_; }
char operator[](int position) {
position += offset;
if (position < startPos || position >= endPos) {
@@ -40,6 +45,9 @@ public:
}
return buf[position - startPos];
}
+ bool IsLeadByte(char ch) {
+ return codePage && InternalIsLeadByte(ch);
+ }
char StyleAt(int position);
int GetLine(int position);
int LineStart(int line);
@@ -54,6 +62,10 @@ public:
PropSet &GetPropSet() { return props; }
};
+class StylingContext;
+
+typedef bool (*PFNIsCommentLeader)(StylingContext &styler, int pos, int len);
+
class StylingContext : public Accessor {
char styleBuf[bufferSize];
int validLen;
@@ -71,5 +83,6 @@ public:
int GetLine(int position);
void SetLevel(int line, int level);
void Flush();
+ int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
};
diff --git a/include/KeyWords.h b/include/KeyWords.h
index 2cc03b788..1b42ecdd9 100644
--- a/include/KeyWords.h
+++ b/include/KeyWords.h
@@ -3,6 +3,39 @@
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
-void ColouriseDoc(int codePage, int startPos, int lengthDoc, int initStyle,
- int language, WordList *keywordlists[], StylingContext &styler);
+typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
+ WordList *keywordlists[], StylingContext &styler);
+
+class LexerModule {
+ static LexerModule *base;
+ LexerModule *next;
+ int language;
+ LexerFunction fn;
+public:
+ LexerModule(int language_, LexerFunction fn_);
+ static void Colourise(unsigned int startPos, int lengthDoc, int initStyle,
+ int language, WordList *keywordlists[], StylingContext &styler);
+};
+
+inline bool iswordchar(char ch) {
+ return isalnum(ch) || ch == '.' || ch == '_';
+}
+
+inline bool iswordstart(char ch) {
+ return isalnum(ch) || ch == '_';
+}
+
+inline bool isoperator(char ch) {
+ if (isalnum(ch))
+ return false;
+ // '.' left out as it is used to make up numbers
+ if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
+ ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
+ ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
+ ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
+ ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
+ ch == '?' || ch == '!' || ch == '.' || ch == '~')
+ return true;
+ return false;
+}