aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2005-08-05 10:51:50 +0000
committernyamatongwe <devnull@localhost>2005-08-05 10:51:50 +0000
commit37d0528e8a9bfe8ff6b3137b2460a19e7aac6238 (patch)
tree39370d1853946fb3b8a32edfe8179d25f35b1cd5 /src
parent08dd6472641a8569e8418f603f403d5fd7588463 (diff)
downloadscintilla-mirror-37d0528e8a9bfe8ff6b3137b2460a19e7aac6238.tar.gz
Patch from Philippe to fold nested comments, nested strings and repeat
until.
Diffstat (limited to 'src')
-rw-r--r--src/LexLua.cxx37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/LexLua.cxx b/src/LexLua.cxx
index 2ead7c09d..98670cc1a 100644
--- a/src/LexLua.cxx
+++ b/src/LexLua.cxx
@@ -22,15 +22,18 @@
#include "Scintilla.h"
#include "SciLexer.h"
-static inline bool IsAWordChar(const int ch) {
- return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.');
+// Extended to accept accented characters
+static inline bool IsAWordChar(int ch) {
+ return ch >= 0x80 ||
+ (isalnum(ch) || ch == '.' || ch == '_');
}
-static inline bool IsAWordStart(const int ch) {
- return (ch < 0x80) && (isalnum(ch) || ch == '_');
+static inline bool IsAWordStart(int ch) {
+ return ch >= 0x80 ||
+ (isalpha(ch) || ch == '_');
}
-static inline bool IsANumberChar(const int ch) {
+static inline bool IsANumberChar(int ch) {
// Not exactly following number definition (several dots are seen as OK, etc.)
// but probably enough in most cases.
return (ch < 0x80) &&
@@ -83,7 +86,7 @@ static void ColouriseLuaDoc(
}
// Do not leak onto next line
- if (initStyle == SCE_LUA_STRINGEOL || initStyle == SCE_LUA_COMMENTLINE) {
+ if (initStyle == SCE_LUA_STRINGEOL || initStyle == SCE_LUA_COMMENTLINE || initStyle == SCE_LUA_PREPROCESSOR) {
initStyle = SCE_LUA_DEFAULT;
}
@@ -161,11 +164,11 @@ static void ColouriseLuaDoc(
}
sc.SetState(SCE_LUA_DEFAULT);
}
- } else if (sc.state == SCE_LUA_COMMENTLINE ) {
+ } else if (sc.state == SCE_LUA_COMMENTLINE) {
if (sc.atLineEnd) {
sc.ForwardSetState(SCE_LUA_DEFAULT);
}
- } else if (sc.state == SCE_LUA_PREPROCESSOR ) {
+ } else if (sc.state == SCE_LUA_PREPROCESSOR) {
if (sc.atLineEnd) {
sc.ForwardSetState(SCE_LUA_DEFAULT);
}
@@ -266,7 +269,7 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (style == SCE_LUA_WORD) {
- if (ch == 'i' || ch == 'd' || ch == 'f' || ch == 'e') {
+ if (ch == 'i' || ch == 'd' || ch == 'f' || ch == 'e' || ch == 'r' || ch == 'u') {
for (unsigned int j = 0; j < 8; j++) {
if (!iswordchar(styler[i + j])) {
break;
@@ -275,10 +278,10 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
s[j + 1] = '\0';
}
- if ((strcmp(s, "if") == 0) || (strcmp(s, "do") == 0) || (strcmp(s, "function") == 0)) {
+ if ((strcmp(s, "if") == 0) || (strcmp(s, "do") == 0) || (strcmp(s, "function") == 0) || (strcmp(s, "repeat") == 0)) {
levelCurrent++;
}
- if ((strcmp(s, "end") == 0) || (strcmp(s, "elseif") == 0)) {
+ if ((strcmp(s, "end") == 0) || (strcmp(s, "elseif") == 0) || (strcmp(s, "until") == 0)) {
levelCurrent--;
}
}
@@ -288,6 +291,12 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
} else if (ch == '}' || ch == ')') {
levelCurrent--;
}
+ } else if (style == SCE_LUA_LITERALSTRING || style == SCE_LUA_COMMENT) {
+ if (ch == '[') {
+ levelCurrent++;
+ } else if (ch == ']') {
+ levelCurrent--;
+ }
}
if (atEOL) {
@@ -320,8 +329,10 @@ static const char * const luaWordListDesc[] = {
"Basic functions",
"String, (table) & math functions",
"(coroutines), I/O & system facilities",
- "XXX",
- "XXX",
+ "user1",
+ "user2",
+ "user3",
+ "user4",
0
};